On Fri, 21 Jun 2013 11:24:50 +0200
Nico Gryzan <nico.gry...@cs.tu-dortmund.de> wrote:

> 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]).

I had fotgotten a "/" inside this patch - sorry for double-posting.
Btw the "empty section" represents the old location, as the string will be 
concatenated to ".../$dist<empty-string>/Contents-...".

-- 
Nico Gryzan <nico.gry...@cs.tu-dortmund.de>
--- debmirror.sid	2013-06-14 13:36:04.000000000 +0200
+++ debmirror.sid.modified	2013-06-21 14:16:58.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
     }
   }
 }

Reply via email to