[Python-modules-commits] r17765 - in packages/sphinx/trunk/debian (dh_sphinxdoc)

jwilk at users.alioth.debian.org jwilk at users.alioth.debian.org
Sat Jul 9 11:29:06 UTC 2011


    Date: Saturday, July 9, 2011 @ 11:29:05
  Author: jwilk
Revision: 17765

dh_sphinxdoc: if necessary, identify 3rd party JavaScript libraries by name rather than contents; make symlinks Policy 10.5 compliant.

Modified:
  packages/sphinx/trunk/debian/dh_sphinxdoc

Modified: packages/sphinx/trunk/debian/dh_sphinxdoc
===================================================================
--- packages/sphinx/trunk/debian/dh_sphinxdoc	2011-07-09 04:51:21 UTC (rev 17764)
+++ packages/sphinx/trunk/debian/dh_sphinxdoc	2011-07-09 11:29:05 UTC (rev 17765)
@@ -69,7 +69,9 @@
                 $md5 = md5($js);
             }
             $js =~ s{^\Q$root\E}{};
-            $packaged_js{$md5} = [$js, "libjs-sphinxdoc (>= $version)"];
+            my $data = [$js, "libjs-sphinxdoc (>= $version)"];
+            $packaged_js{$md5} = $data;
+            $packaged_js{$name} = $data;
         },
         no_chdir => 1
     }, "$root/usr/share/javascript/sphinxdoc/");
@@ -145,19 +147,53 @@
     }
 }
 
+sub ln_sf($$)
+{
+    my ($orig_target, $orig_source) = my ($target, $source) = @_;
+    $source =~ s{^debian/[^/]++/+}{} or die;
+    $target =~ s{^/++}{} or die;
+    my @source = split(m{/++}, $source);
+    my @target = split(m{/++}, $target);
+    @source > 0 and @target > 0 or die;
+    if ($source[0] eq $target[0])
+    {
+        # Make the symlink relative, as per Policy 10.5.
+        while (@source > 0 and @target > 0 and $source[0] eq $target[0])
+        {
+            shift @source;
+            shift @target;
+        }
+        $target = ('../' x $#source) . join('/', @target);
+    }
+    else
+    {
+        # Keep the symlink absolute, as per Policy 10.5.
+        $target = $orig_target;
+    }
+    doit('ln', '-sf', $target, $orig_source);
+}
+
 sub fix_symlinks($@)
 {
     my @deps = ();
     my ($path, @js) = @_;
     for my $js (@js)
     {
-        next if -l "$path/$js" and readlink("$path/$js") =~ m{/sphinxdoc/};
-        -f "$path/$js" or unknown_javascript("$path/$js");
-        my $md5 = md5("$path/$js");
-        if (exists $packaged_js{$md5})
+        my $id = '';
+        if (-l "$path/$js")
         {
-            my ($target, $dependency) = @{$packaged_js{$md5}};
-            doit('ln', '-sf', "$target", "$path/$js");
+            my $symlink_target = readlink("$path/$js");
+            $symlink_target =~ m{/sphinxdoc/} and next;
+            $symlink_target =~ m{/javascript/\w+/(\w+)([.](min|lite|pack))?[.]js$} and $id = "$1.js";
+        }
+        elsif (-f "$path/$js")
+        {
+            $id = md5("$path/$js");
+        }
+        if (exists $packaged_js{$id})
+        {
+            my ($target, $dependency) = @{$packaged_js{$id}};
+            ln_sf($target, "$path/$js");
             push @deps, $dependency;
         }
         else




More information about the Python-modules-commits mailing list