On Sun, Jul 23, 2006 at 10:34:26PM +0200, Eduard Bloch wrote:
> I was going to setup a new chroot and this time I decided to look for a
> better way than "cp" to get the database over to the new location. So I
> found the debconf-copydb utility which seems to do the job. After RTFM I
> tried:
> 
> debconf-copydb /var/cache/debconf/config.dat var/cache/debconf/config.dat
> /usr/bin/debconf-copydb: source database, "/var/cache/debconf/config.dat" 
> does not exist
> 
> Uhm, what am I doing wrong? The database file does exist and I think it
> is exactly what the manpage talks about. So either there is a program
> bug (as demonstrated) or a documentation problem, or both ("does not
> exist" is not correct after all).

As it stands it's a documentation problem, but it might be possible to
educate debconf to do the right thing in this case anyway.

debconf-copydb (and all other places in debconf's command-line interface
that accept a database as a parameter) want a database name, not a file
name. Database names are configured in /etc/debconf.conf (etc.) or by
--config parameters. So something like the following would work:

  debconf-copydb olddb newdb \
    --config=Name:olddb --config=Driver:File \
    --config=Filename:/var/cache/debconf/config.dat \
    --config=Name:newdb --config=Driver:File \
    --config=Filename:var/cache/debconf/config.dat

You could abbreviate this by noticing that /var/cache/debconf/config.dat
is already configured in /etc/debconf.conf, so you can just copy the
'config' database without needing to configure it explicitly. In fact,
there's an example quite similar to this in the debconf-copydb(1) man
page. Note that you need to copy the config and passwords databases
separately, or else do more elaborate configuration on the target
databases to make them accept/reject passwords as appropriate.

(cp is a perfectly good way to copy debconf databases, by the way, if
you're already referring to them as files anyway. If you're referring to
them using database names with more elaborate configuration, then
debconf-copydb is certainly useful, but the above doesn't really add any
value over plain cp.)


All that said, it might be possible to make debconf transparently do
something approaching the right thing here. Joey, what do you think of
doing something like this?

Index: Debconf/DbDriver.pm
===================================================================
--- Debconf/DbDriver.pm (revision 2088)
+++ Debconf/DbDriver.pm (working copy)
@@ -177,6 +177,17 @@
        my $this=shift;
        my $name=shift;
        
+       if (not exists $drivers{$name} and -e $name) {
+               # Transparently turn filenames into database drivers if
+               # possible.
+               my %config = (
+                       name => $name,
+                       driver => 'File',
+                       filename => $name,
+               );
+               Debconf::Db->makedriver(%config);
+       }
+
        return $drivers{$name};
 }
 

Cheers,

-- 
Colin Watson                                       [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to