Package: debmirror Version: 20060907 Severity: normal Tags: patch Hello Goswin,
Attached is a rough patch to allow more fine grained mirroring than is currently possible. The gist of the patch logic is that as arch/dist/section tuples are parsed, on duplicate option or end of line, defaults are filled in. the data structure is stored as nested hashes instead of arrays, so that it becomes possible to request something like: $VAR1 = { 'sid' => { 'amd64' => { 'non-free' => 1, 'contrib' => 1, 'main' => 1 }, 'i386' => { 'contrib' => 1, 'main/debian-installer' => 1, 'main' => 1 } }, 'etch' => { 'mips' => { 'non-free' => 1, 'contrib' => 1, 'main/debian-installer' => 1, 'main' => 1 } }, 'sarge' => { 'powerpc' => { 'non-free' => 1, 'contrib' => 1, 'main' => 1 }, 'sparc' => { 'non-free' => 1, 'contrib' => 1, 'main/debian-installer' => 1, 'main' => 1 } } }; (Data::Dumper output from a debug run) As you can see, it allows more fine grained mirroring than is currently possible. I would appreciate if you could apply this patch or something like it. I have not chased all the corner cases yet, so I can't say with absolute confidence it introduces no regressions, but it seems sane from the tests I've run so far. Thanks, -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.17-2-686 Locale: LANG=en_US.UTF8, LC_CTYPE=en_US.UTF8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF8) Versions of packages debmirror depends on: ii bzip2 1.0.3-6 high-quality block-sorting file co ii libcompress-zlib-perl 1.42-1 Perl module for creation and manip ii liblockfile-simple-perl 0.2.5-7 Simple advisory file locking ii libnet-perl 1:1.19-3 Implementation of Internet protoco ii libwww-perl 5.805-1 WWW client/server library for Perl ii perl [libdigest-md5-perl] 5.8.8-6.1 Larry Wall's Practical Extraction ii perl-modules [libnet-perl] 5.8.8-6.1 Core Perl modules ii rsync 2.6.8-2 fast remote file copy program (lik Versions of packages debmirror recommends: ii gnupg 1.4.5-1 GNU privacy guard - a free PGP rep ii patch 2.5.9-4 Apply a diff file to an original -- no debconf information -- ----------------------------------------------------------------- | ,''`. Stephen Gran | | : :' : [EMAIL PROTECTED] | | `. `' Debian user, admin, and developer | | `- http://www.debian.org | -----------------------------------------------------------------
--- /usr/bin/debmirror 2006-09-08 20:03:49.000000000 +0100 +++ debmirror 2006-09-16 00:19:41.000000000 +0100 @@ -376,7 +376,8 @@ # Yeah, I use too many global variables in this program. our ($debug, $progress, $verbose, $passive, $skippackages, $getcontents); our ($ua, $proxy); -our (@dists, @sections, @arches, @extra_dirs, @ignores, @excludes, @includes); +my %data; +our (@dist, @section, @arch, @extra_dirs, @ignores, @excludes, @includes); our (@excludes_deb_section, @limit_priority); our $check_md5sums = 0; our $check_downloads = 0; @@ -429,9 +430,9 @@ 'user|u=s' => \$user, 'passwd=s' => \$passwd, 'root|r=s' => \$remoteroot, - 'dist|d=s' => [EMAIL PROTECTED], - 'section|s=s' => [EMAIL PROTECTED], - 'arch|a=s' => [EMAIL PROTECTED], + 'dist|d=s' => \&add_bits, + 'section|s=s' => \&add_bits, + 'arch|a=s' => \&add_bits, 'adddir=s' => [EMAIL PROTECTED], 'cleanup' => \$cleanup, 'postcleanup' => \$post_cleanup, @@ -463,13 +464,38 @@ # Post-process arrays. Allow commas to seperate values the user entered. # If the user entered nothing, provide defaults. [EMAIL PROTECTED](/,/,join(',',@dists)); [EMAIL PROTECTED](sid) unless @dists; [EMAIL PROTECTED](/,/,join(',',@sections)); [EMAIL PROTECTED](main contrib non-free main/debian-installer) unless @sections; [EMAIL PROTECTED](/,/,join(',',@arches)); [EMAIL PROTECTED](i386) unless @arches; [EMAIL PROTECTED]() if (join(',',@arches) eq "none"); + +if ([EMAIL PROTECTED] || [EMAIL PROTECTED] || [EMAIL PROTECTED]) { + @dist = qw(sid) unless @dist; + @section = qw(main contrib non-free main/debian-installer) unless @section; + @arch = qw(i386) unless @arch; +} + [EMAIL PROTECTED]() if (join(',',@arch) eq "none"); + +&add_data; + +my (@arches, @dists, @sections); + +my (%sections, %arches); + +foreach my $dist (keys %data) { + foreach my $arch (keys %{$data{$dist}}) { + $arches{$arch}++; + foreach my $section (keys %{$data{$dist}{$arch}}) { + $sections{$section}++; + } + } +} + + [EMAIL PROTECTED] = keys %data; [EMAIL PROTECTED] = keys %arches; [EMAIL PROTECTED] = keys %sections; + +undef(%arches); +undef(%sections); + $cleanup=0 if ($no_cleanup); $post_cleanup=0 if ($no_cleanup); $post_cleanup=0 if ($cleanup); @@ -596,7 +622,7 @@ # Get Release files without caching for http $ua->default_header( "Cache-Control" => "max-age=0" ) if ($ua); my (%file_lists_md5, %file_lists_size); -foreach my $dist (@dists) { +foreach my $dist (keys %data) { make_dir ("dists/$dist"); make_dir ("$tempdir/dists/$dist"); remote_get("dists/$dist/Release"); @@ -669,16 +695,18 @@ my $name=shift; $bytes_to_get += $file_lists_size{"$tempdir/$name"} if (exists $file_lists_size{"$tempdir/$name"}); } -foreach my $dist (@dists) { - foreach my $section (@sections) { - foreach my $arch (@arches) { +foreach my $dist (keys %data) { + foreach my $arch (keys %{$data{$dist}}) { + foreach my $section (keys %{$data{$dist}{$arch}}) { add_bytes("dists/$dist/$section/binary-$arch/Packages"); add_bytes("dists/$dist/$section/binary-$arch/Packages.gz"); add_bytes("dists/$dist/$section/binary-$arch/Packages.bz2"); add_bytes("dists/$dist/$section/binary-$arch/Release"); add_bytes("dists/$dist/$section/binary-$arch/Packages.diff/Index") unless ($pdiff_mode eq "none"); } - if ($do_source) { + } + if ($do_source) { + foreach my $section (@sections) { add_bytes("dists/$dist/$section/source/Sources"); add_bytes("dists/$dist/$section/source/Sources.gz"); add_bytes("dists/$dist/$section/source/Sources.bz2"); @@ -701,8 +729,8 @@ } } if ($getcontents) { - foreach my $dist (@dists) { - foreach my $arch (@arches) { + foreach my $dist (keys %data) { + foreach my $arch (keys %{$data{$dist}}) { next if $dist=~/experimental/; next if $dist=~/.*-proposed-updates/; next if $arch=~/source/; @@ -715,17 +743,19 @@ say("Get Packages and Sources files and other miscellany."); # Get Packages and Sources files and other miscellany. my (@package_files, @source_files); -foreach my $dist (@dists) { - foreach my $section (@sections) { - # no d-i in woody - next if ($section =~ /debian-installer/ && $dist eq "woody"); - next if ($section =~ /debian-installer/ && $dist eq "experimental"); - next if ($section =~ /debian-installer/ && $dist =~ /.*-proposed-updates/); - next if ($section =~ /debian-installer/ && $dist =~ /.*breezy-updates/ ); - next if ($section =~ /debian-installer/ && $dist eq "breezy-security" ); - foreach my $arch (@arches) { +foreach my $dist (keys %data) { + foreach my $arch (keys %{$data{$dist}}) { + foreach my $section (keys %{$data{$dist}{$arch}}) { + # no d-i in woody + next if ($section =~ /debian-installer/ && $dist eq "woody"); + next if ($section =~ /debian-installer/ && $dist eq "experimental"); + next if ($section =~ /debian-installer/ && $dist =~ /.*-proposed-updates/); + next if ($section =~ /debian-installer/ && $dist =~ /.*breezy-updates/ ); + next if ($section =~ /debian-installer/ && $dist eq "breezy-security" ); get_index("dists/$dist/$section/binary-$arch", "Packages"); } + } + foreach my $section (@sections) { get_index("dists/$dist/$section/source", "Sources") if ($do_source); } } @@ -755,8 +785,8 @@ if ($getcontents) { say("Get Contents files."); - foreach my $dist (@dists) { - foreach my $arch (@arches) { + foreach my $dist (keys %data) { + foreach my $arch (keys %{$data{$dist}}) { next if $dist=~/experimental/; next if $dist=~/.*-proposed-updates/; next if $arch=~/source/; @@ -1598,6 +1628,60 @@ print $0.': '.join(' ', @_)."\n" if $debug; } +sub make_array { + my @array = @_; + return split(/,/,join(',',@array)); +} + +sub add_bits { + my %args = @_; + if ($args{'dist'}) { + if (@dist) { + @arch = qw(i386) unless @arch; + @section = qw(main contrib non-free main/debian-installer) unless @section; + &add_data; + } + @dist = $args{'dist'}; + return; + } elsif ($args{'section'}) { + if (@section) { + @arch = qw(i386) unless @arch; + @dist = qw(sid) unless @dist; + &add_data; + } + @section = $args{'section'}; + return; + } elsif ($args{'arch'}) { + if (@arch) { + @section = qw(main contrib non-free main/debian-installer) unless @section; + @dist = qw(sid) unless @dist; + &add_data; + } + @arch = $args{'arch'}; + return; + } else { + die "HTF did I get here?\n"; + } +} + +sub add_data { + if (@arch && @dist && @section) { + @arch = make_array(@arch); + @dist = make_array(@dist); + @section = make_array(@section); + for my $dist (@dist) { + for my $arch (@arch) { + for my $section (@section) { + $data{$dist}{$arch}{$section} = 1; + } + } + } + @arch = (); + @dist = (); + @section = (); + } +} + =head1 COPYRIGHT This program is copyright 2001 by Joey Hess <[EMAIL PROTECTED]>, under
signature.asc
Description: Digital signature