]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2002-11-17 16:04:16 by cjwatson]
authorcjwatson <>
Mon, 18 Nov 2002 00:04:16 +0000 (16:04 -0800)
committercjwatson <>
Mon, 18 Nov 2002 00:04:16 +0000 (16:04 -0800)
Add db to db-h migration tool.

migrate/debbugs-dbhash [new file with mode: 0755]
migrate/debbugs-dbhash.8 [new file with mode: 0644]

diff --git a/migrate/debbugs-dbhash b/migrate/debbugs-dbhash
new file mode 100755 (executable)
index 0000000..486688d
--- /dev/null
@@ -0,0 +1,42 @@
+#! /usr/bin/perl -w
+# Migrate an old-style database to the new hashed (db-h) form.
+
+use strict;
+use File::Copy;
+
+if (@ARGV != 2) {
+    print <<EOF;
+Usage: $0 old-db-directory new-db-directory
+
+debbugs-dbhash converts an old-style flat debbugs database into a
+new-style hashed-directory debbugs database.
+
+The old database is simply copied, and otherwise left untouched.
+The directory given for the new database must not already exist.
+
+EOF
+    exit 0;
+}
+
+my ($db, $dbh) = @ARGV[0, 1];
+opendir DB, $db or die "Can't opendir $db: $!";
+mkdir $dbh or die "Can't mkdir $dbh: $!";
+for my $i (0 .. 99) {
+    my $dir = sprintf '%s/%02d', $dbh, $i;
+    mkdir $dir or die "Can't mkdir $dir: $!";
+}
+
+while (defined(my $file = readdir DB)) {
+    next if $file =~ /^\.\.?$/;
+    my $oldfile = "$db/$file";
+    my $newfile;
+    if ($file =~ /(\d*)(\d\d)\.(.*)/) {
+       $newfile = "$dbh/$2/$1$2.$3";
+    } else {
+       warn "Not hashing $file.\n";
+       $newfile = "$dbh/$file";
+    }
+    copy $oldfile, $newfile or warn "Can't copy $oldfile to $newfile: $!";
+}
+
+closedir DB;
diff --git a/migrate/debbugs-dbhash.8 b/migrate/debbugs-dbhash.8
new file mode 100644 (file)
index 0000000..efabdb8
--- /dev/null
@@ -0,0 +1,35 @@
+.TH DEBBUGS\-DBHASH 8
+.SH NAME
+debbugs\-dbhash \- migrate a debbugs database to hashed format
+.SH SYNOPSIS
+.B debbugs\-dbhash
+.I old-db-directory
+.I new-db-directory
+.SH DESCRIPTION
+.B debbugs\-dbhash
+converts an old-style flat debbugs database into a new-style
+hashed-directory debbugs database, for use with debbugs 2.4 and
+above.
+.PP
+The old database is simply copied, and otherwise left untouched.
+The directory given for the new database must not already exist.
+.PP
+In the hashed format, files with names of the form
+.I 1023.log
+are now stored as
+.I 23/1023.log
+instead.
+This improves performance on many filesystems for debbugs
+installations with large numbers of bug reports.
+.SH WARNINGS
+.B debbugs\-dbhash
+will print a warning message for each file whose name is of a form
+that cannot be hashed as above.
+Typical debbugs installations will have a few of these, usually
+index files and the like.
+.SH AUTHORS
+Adam Heath is primarily responsible for the hashed directory support
+in debbugs.
+Colin Watson wrote
+.B debbugs\-dbhash
+and this man page.