> This seems to need to be tested, You're right, it needs to be tested. It works for our local squeeze, sid, jessie and wheezy mirror, but this mirror runs without diffs or snapshots. So the main functionality is tested as repositories with the old and the new location are mirrored correctly. The patched version will not mirror Ubuntu Contents-*.gz (just like the unpatched debmirror script) since Ubuntu does not list them in the Release-file.
> but first it seems like it could avoid > adding a lot of code that is almost entirely the same as code that's > already there.. I've attached an improved version with lesser code-duplication. The main functionality stays the same, but it uses a temporary array with an additional empty section and is tested for the above-mentioned cases (contents in old AND new location [wheezy], contents in old location [squeeze], contents in new location [jessie]). -- Nico Gryzan <nico.gry...@cs.tu-dortmund.de>
--- debmirror.sid 2013-06-14 13:36:04.000000000 +0200 +++ debmirror.sid.modified 2013-06-21 11:20:41.000000000 +0200 @@ -1104,13 +1104,23 @@ next if $dist=~/experimental/; next if $dist=~/.*-proposed-updates/; next if $arch=~/source/; - if ($diff_mode ne "none") { - if (!update_contents("dists/$dist", "Contents-$arch")) { - add_bytes("dists/$dist/Contents-$arch.gz"); - } - } elsif (!check_lists("$tempdir/dists/$dist/Contents-$arch.gz")) { - add_bytes("dists/$dist/Contents-$arch.gz"); + +#EDIT: In Debian Wheezy, the Contents-*.gz moved to '/dists/$dist/$sect/'. The following changes take account +# of the new location, but also respect the old location for backwards compatibility + push my @sects, @sections, ""; + foreach my $sect (@sects) { + if ($sect ne "") {$sect = "/$sect";} + if (exists $file_lists{"$tempdir/dists/$dist${sect}Contents-$arch.gz"}) { + if ($diff_mode ne "none") { + if (!update_contents("dists/$dist$sect", "Contents-$arch")) { + add_bytes("dists/$dist$sect/Contents-$arch.gz"); + } + } elsif (!check_lists("$tempdir/dists/$dist$sect/Contents-$arch.gz")) { + add_bytes("dists/$dist$sect/Contents-$arch.gz"); + } + } } +#END-EDIT } } } @@ -1962,10 +1972,20 @@ sub link_contents_into_snapshot { my ($dist,$mirrordir,$arch,$tempdir) = @_; my $next = get_next_snapshot($dist); - unlink("$mirrordir/dists/$dist/$next/Contents-$arch.gz"); - link("$tempdir/dists/$dist/Contents-$arch.gz", - "$mirrordir/dists/$dist/$next/Contents-$arch.gz") - or die "Error while linking $tempdir/dists/$dist/Contents-$arch.gz: $!\n"; +#EDIT: new contents location, see first #EDIT. +# TODO: The following changes have not been tested yet. Please test them +# before using in a production environment. + push my @sects, @sections, ""; + foreach my $sect (@sects) { + if ($sect ne "") {$sect = "/$sect";} + if (exists $file_lists{"$tempdir/dists/$dist$sect/Contents-$arch.gz"}) { + unlink("$mirrordir/dists/$dist/$next$sect/Contents-$arch.gz"); + link("$tempdir/dists/$dist$sect/Contents-$arch.gz", + "$mirrordir/dists/$dist/$next$sect/Contents-$arch.gz") + or die "Error while linking $tempdir/dists/$dist$sect/Contents-$arch.gz: $!\n"; + } + } +#END_EDIT } sub link_translation_into_snapshot { @@ -2313,18 +2333,26 @@ next if $dist=~/experimental/; next if $dist=~/.*-proposed-updates/; next if $arch=~/source/; - if (!check_lists("$tempdir/dists/$dist/Contents-$arch.gz")) { - if ($first) { - say("Get Contents files."); - $first = 0; - } - remote_get("dists/$dist/Contents-$arch.gz"); - } - $files{"dists/$dist/Contents-$arch.gz"}=1; - $files{$tempdir."/"."dists/$dist/Contents-$arch.gz"}=1; - if ($debmarshal) { - link_contents_into_snapshot($dist,$mirrordir,$arch,$tempdir); +#EDIT: new contents-location, see first #EDIT. + push my @sects, @sections, ""; + foreach my $sect (@sects) { + if ($sect ne "") {$sect = "/$sect";} + if (exists $file_lists{"$tempdir/dists/$dist$sect/Contents-$arch.gz"}) { + if (!check_lists("$tempdir/dists/$dist$sect/Contents-$arch.gz")) { + if ($first) { + say("Get Contents files."); + $first = 0; + } + remote_get("dists/$dist$sect/Contents-$arch.gz"); + } + $files{"dists/$dist$sect/Contents-$arch.gz"}=1; + $files{$tempdir."/"."dists/$dist$sect/Contents-$arch.gz"}=1; + if ($debmarshal) { + link_contents_into_snapshot($dist,$mirrordir,$arch,$tempdir); + } + } } +#END_EDIT } } }