Hi,

I've run into this a few weeks ago already and made a patch.  The underlying
problem is that the "i18n/" directory is not created before the debmarshal
code tries to create links there.

I originally patched 2.12 but have now improved and adapted the patch for 2.13.

--Frank
>From 8b8ea44d43e1738d23785386d23e891558d1a76d Mon Sep 17 00:00:00 2001
From: Frank Luithle <frank.luit...@barco.com>
Date: Fri, 1 Jun 2012 14:44:55 +0200
Subject: [PATCH] Do not crash on i18n/Index with --debmarshal

The "i18n" subdirectory does not exist in the snapshot directory, so the call to
"link()" fails on the files below ".../i18n/".

In the past, this bug did not surface unless the "--i18n" option was also given.
With debmirror 2.12, "--i18n" is partly implied, so the crash happens
regardless.

With this patch, the target directory is guaranteed to exist before attepting to
link.

Also, "link_index_into_snapshot()" has been removed since it is not called
anywhere as of version 2.13.
---
 debmirror |   20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/debmirror b/debmirror
index 12ca9fb..0cca088 100755
--- a/debmirror
+++ b/debmirror
@@ -532,6 +532,7 @@ use Cwd;
 use Storable qw(nstore retrieve);
 use Getopt::Long;
 use File::Temp qw/ tempfile /;
+use File::Path qw(make_path);
 use LockFile::Simple;
 use Compress::Zlib;
 use Digest::MD5;
@@ -1870,24 +1871,15 @@ sub link_contents_into_snapshot {
     or die "Error while linking $tempdir/dists/$dist/Contents-$arch.gz: $!\n";
 }
 
-sub link_index_into_snapshot {
-  my ($dist,$mirrordir,$distpath,$subdir,$tempdir) = @_;
-  my $next = get_next_snapshot($dist);
-  say("linking $mirrordir/dists/$dist/$next/$distpath/Index");
-  unlink("$mirrordir/dists/$dist/$next/$distpath/Index");
-  link("$tempdir/$subdir/Index",
-       "$mirrordir/dists/$dist/$next/$distpath/Index")
-    or die "Error while linking $tempdir/$subdir/Index: $!\n";
-}
-
 sub link_translation_into_snapshot {
   my ($file,$dist,$distpath,$filename,$mirrordir,$tempdir) = @_;
   my $next = get_next_snapshot($dist);
+  my $target_path = "$mirrordir/dists/$dist/$next/$distpath";
   say("linking $file");
-  unlink("$mirrordir/dists/$dist/$next/$distpath/$filename");
-  link("$tempdir/$file",
-       "$mirrordir/dists/$dist/$next/$distpath/$filename")
-    or die "Erorr while linking $tempdir/$file: $!";
+  unlink("$target_path/$filename");
+  make_path($target_path);
+  link("$tempdir/$file", "$target_path/$filename")
+    or die "Error while linking $tempdir/$file: $!";
 }
 
 sub get_release {
-- 
1.7.10

Reply via email to