/usr/sbin/debbugs-upgradestatus is in debbugs 2.6.0.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | #! /usr/bin/perl -w
# Migrate from .status format version 1 to version 2. The new format uses
# RFC822-style name/value pairs to allow new fields to be added more easily.
use vars qw($gSpoolDir);
my $config_path = '/etc/debbugs';
my $lib_path = '/usr/lib/debbugs';
require "$config_path/config";
require "$lib_path/errorlib";
if (@ARGV < 1 or $ARGV[0] !~ /^(?:db-h|archive)$/) {
print <<EOF;
Usage: $0 db-h|archive (relative to $gSpoolDir)
debbugs-upgradestatus converts a debbugs database in-place to use version 2
of the bug status file format. Version 1 metadata files were stored in
.status files; version 2 metadata files are written to .summary files.
EOF
exit 0;
}
chdir $gSpoolDir or die "Can't chdir to $gSpoolDir: $!";
my $archive = $ARGV[0];
my $db = getlocationpath($archive);
opendir DB, $db or die "Can't opendir $db: $!";
my @files;
for (my $subdir = 0; $subdir < 100; ++$subdir) {
my $path = sprintf "$archive/%.2d", $subdir;
opendir DIR, $path or next;
my @list = grep /^\d+\.status$/, readdir DIR;
closedir DIR;
grep s/\.status$//, @list;
push @files, @list;
}
closedir DB;
@files = sort { $a <=> $b } @files;
my @v1fields = qw(originator date subject msgid package
keywords done forwarded mergedwith severity);
sub v1readbug {
my ($lref, $location) = @_;
my $status = getbugcomponent($lref, 'status', $location);
return undef unless defined $status;
if (!open(S,$status)) { return undef; }
my %data;
my @lines;
local $_;
while (<S>) {
chomp;
push @lines, $_;
}
for my $field (@v1fields) {
if (@lines) {
$data{$field} = shift @lines;
} else {
$data{$field} = '';
}
}
close(S);
$data{severity} = 'normal' if $data{severity} eq '';
return \%data;
}
my $success = 0;
my $failure = 0;
for my $ref (@files) {
filelock("lock/$ref") unless $ENV{NO_LOCKING};
my $data = v1readbug($ref, $archive);
if (defined $data) {
if ($ENV{NO_LOCKING}) {
writebug($ref, $data, $archive, 2, 'disable bughook');
} else {
unlockwritebug($ref, $data, $archive, 2, 'disable bughook');
}
# Test new .summary file
my $newdata = readbug($ref, $archive);
my %jointkeys = map { $_ => 1 } (keys %$data), (keys %$newdata);
for my $key (keys %jointkeys) {
unless (exists $data->{$key}) {
die "BUG: $ref: key '$key' in .summary but not .status!\n";
}
unless (exists $newdata->{$key}) {
die "BUG: $ref: key '$key' in .status but not .summary!\n";
}
if ($data->{$key} ne $newdata->{$key}) {
die "BUG: $ref: key '$key' different in " .
".status and .summary\n" .
" .status has '$data->{$key}';\n" .
" .summary has '$newdata->{$key}'!\n";
}
}
++$success;
} else {
unfilelock() unless $ENV{NO_LOCKING};
++$failure;
}
}
print "$success bugs converted successfully.\n" if $success;
print "Failed to convert $failure bugs.\n" if $failure;
exit !($success && !$failure);
|