Code Search for Developers
 
 
  

Db.pm from GreenSocs at Krugle


Show Db.pm syntax highlighted

#!/usr/bin/perl -w

=head1 NAME

Debconf::Db - debconf databases

=cut

package Debconf::Db;
use strict;
use Debconf::Log qw{:all};
use Debconf::Config;
use Debconf::DbDriver;
our $config;
our $templates;

=head1 DESCRIPTION

This class makes available a $Debconf::Db::config, which is the root db
driver for storing state, and a $Debconf::Db::templates, which is the root
db driver for storing template data.

Requests can be sent directly to the db's by things like 
$Debconf::Db::config->setfield(...)

=head1 CLASS METHODS

=item load

Loads up the database drivers.

If a hash of parameters are passed, those parameters are used as the defaults
for *every* database driver that is loaded up. Practically, setting 
(readonly => "true") is the only use of this.

=cut

sub load {
	my $class=shift;

	Debconf::Config->load('', @_); # load default config file
	$config=Debconf::DbDriver->driver(Debconf::Config->config);
	if (not ref $config) {
		die "Configuration database \"".Debconf::Config->config.
			"\" was not initialized.\n";
	}
	$templates=Debconf::DbDriver->driver(Debconf::Config->templates);
	if (not ref $templates) {
		die "Template database \"".Debconf::Templates->templates.
			"\" was not initialized.\n";
	}
}

=item makedriver

Set up a driver. Pass it all the fields the driver needs, and one more
field, called "driver" that specifies the type of driver to make.

=cut

sub makedriver {
	my $class=shift;
	my %config=@_;

	my $type=$config{driver} or die "driver type not specified (perhaps you need to re-read debconf.conf(5))";

	# Make sure that the class is loaded..
	if (! UNIVERSAL::can("Debconf::DbDriver::$type", 'new')) {
		eval qq{use Debconf::DbDriver::$type};
		die $@ if $@;
	}
	delete $config{driver}; # not a field for the object
	
	# Make object, and pass in the config, and we're done with it.
	debug db => "making DbDriver of type $type";
	"Debconf::DbDriver::$type"->new(%config);
}

=item save

Save the databases, and shutdown the drivers.

=cut

sub save {
	$config->shutdown if $config;
	# FIXME: if debconf is killed right here, the db is inconsistent.
	$templates->shutdown if $templates;
	$config='';
	$templates='';
}

=head1 AUTHOR

Joey Hess <joeyh@debian.org>

=cut

1




See more files for this project here

GreenSocs

To develop SystemC infrustructure, basic IP, patches and add on library code for eventual standerdization.\r\nThe GreenSocs project is made up of a number of contributions (sub projects). Please visit www.greensocs.com for more information.

Project homepage: http://sourceforge.net/projects/greensocs
Programming language(s): C,C++,Java,Perl,XML
License: other

  Client/
    ConfModule.pm
    ConfModule.stub
  DbDriver/
    Backup.pm
    Cache.pm
    Copy.pm
    Debug.pm
    DirTree.pm
    Directory.pm
    File.pm
    LDAP.pm
    PackageDir.pm
    Pipe.pm
    Stack.pm
  Element/
    Dialog/
      Boolean.pm
      Multiselect.pm
      Note.pm
      Password.pm
      Select.pm
      String.pm
      Text.pm
    Editor/
      Boolean.pm
      Multiselect.pm
      Note.pm
      Password.pm
      Select.pm
      String.pm
      Text.pm
    Gnome/
      Boolean.pm
      Multiselect.pm
      Note.pm
      Password.pm
      Select.pm
      String.pm
      Text.pm
    Kde/
      Boolean.pm
      Multiselect.pm
      Note.pm
      Password.pm
      Select.pm
      String.pm
      Text.pm
    Noninteractive/
      Note.pm
      Select.pm
    Teletype/
      Boolean.pm
      Multiselect.pm
      Note.pm
      Password.pm
      Select.pm
      String.pm
      Text.pm
    Web/
      Boolean.pm
      Multiselect.pm
      Note.pm
      Password.pm
      Select.pm
      String.pm
      Text.pm
    Gnome.pm
    Kde.pm
    Multiselect.pm
    Noninteractive.pm
    Select.pm
  Format/
    822.pm
  FrontEnd/
    Kde/
    Dialog.pm
    Editor.pm
    Gnome.pm
    Kde.pm
    Noninteractive.pm
    Passthrough.pm
    Readline.pm
    ScreenSize.pm
    Teletype.pm
    Text.pm
    Web.pm
  Template/
    Transient.pm
  AutoSelect.pm
  Base.pm
  ConfModule.pm
  Config.pm
  Db.pm
  DbDriver.pm
  Element.pm
  Encoding.pm
  Format.pm
  FrontEnd.pm
  Gettext.pm
  Iterator.pm
  Log.pm
  Priority.pm
  Question.pm
  Template.pm
  TmpFile.pm