[Python-modules-commits] r17779 - in packages/sphinx/trunk/debian (7 files)

jwilk at users.alioth.debian.org jwilk at users.alioth.debian.org
Sat Jul 9 19:56:35 UTC 2011


    Date: Saturday, July 9, 2011 @ 19:56:34
  Author: jwilk
Revision: 17779

Move dh_sphinxdoc stuff into a separate directory.

Added:
  packages/sphinx/trunk/debian/dh-sphinxdoc/
  packages/sphinx/trunk/debian/dh-sphinxdoc/dh_sphinxdoc
    (from rev 17773, packages/sphinx/trunk/debian/dh_sphinxdoc)
  packages/sphinx/trunk/debian/dh-sphinxdoc/sphinxdoc.pm
    (from rev 17743, packages/sphinx/trunk/debian/sphinxdoc.pm)
Modified:
  packages/sphinx/trunk/debian/python-sphinx.install
  packages/sphinx/trunk/debian/rules
Deleted:
  packages/sphinx/trunk/debian/dh_sphinxdoc
  packages/sphinx/trunk/debian/sphinxdoc.pm

Copied: packages/sphinx/trunk/debian/dh-sphinxdoc/dh_sphinxdoc (from rev 17773, packages/sphinx/trunk/debian/dh_sphinxdoc)
===================================================================
--- packages/sphinx/trunk/debian/dh-sphinxdoc/dh_sphinxdoc	                        (rev 0)
+++ packages/sphinx/trunk/debian/dh-sphinxdoc/dh_sphinxdoc	2011-07-09 19:56:34 UTC (rev 17779)
@@ -0,0 +1,275 @@
+#!/usr/bin/perl
+
+# Copyright © 2011 Jakub Wilk <jwilk at debian.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use warnings;
+
+use Digest::MD5;
+use File::Find;
+use Debian::Debhelper::Dh_Lib;
+
+my %packaged_js = ();
+
+sub md5($)
+{
+    my ($filename) = @_;
+    my $md5 = Digest::MD5->new;
+    open(F, '<', $filename) or error("cannot open $filename");
+    $md5->addfile(*F);
+    close(F);
+    return $md5->digest;
+}
+
+sub load_packaged_js()
+{
+    my $root = tmpdir('libjs-sphinxdoc');    
+    $root = '' unless -d $root;
+    find({
+        wanted => sub {
+            my $js = $_;
+            my ($version, $name) = m{([0-9.]+)/(\w+[.]js)$} or return;
+            my $md5;
+            if (-l $js)
+            {
+                my $js_target = readlink($js);
+                unless ($js_target =~ m{^/})
+                {
+                    $js_target = "$js/../$js_target";
+                    while ($js_target =~ s{[^./][^/]+/[.][.]/}{}) {};
+                }
+                $md5 = md5($js_target);
+            }
+            else
+            {
+                $js =~ s{^\Q$root\E}{} unless -f $js;
+                $md5 = md5($js);
+            }
+            $js =~ s{^\Q$root\E}{};
+            my $data = [$js, "libjs-sphinxdoc (>= $version)"];
+            $packaged_js{$md5} = $data;
+            $packaged_js{$name} = $data;
+        },
+        no_chdir => 1
+    }, "$root/usr/share/javascript/sphinxdoc/");
+}
+
+sub looks_like_sphinx_doc($)
+{
+    my ($path) = @_;
+    return 0 unless -f "$path/searchindex.js";
+    return 0 unless -f "$path/search.html";
+    return 1;
+}
+
+sub sanity_check($)
+{
+    local $/;
+    my ($path) = @_;
+    my $indexfn = "$path/searchindex.js";
+    open(F, '<', $indexfn) or error("cannot open $indexfn");
+    my $index = <F>;
+    close(F);
+    $index =~ m{^Search[.]setIndex[(].*?filenames:\["(.*?)"\].*[)]$} or error("$indexfn doesn't look like a Sphinx search index");
+    $index = $1;
+    my $searchfn = "$path/search.html";
+    open(F, '<', $searchfn) or error("cannot open $searchfn");
+    my $search = <F>;
+    close F;
+    my %js = ();
+    grep { $js{$_} = 1 unless excludefile($_); } $search =~ m{<script type="text/javascript" src="([^"]++)"></script>}g;
+    my $loads_searchindex = $search =~ m/\QjQuery(function() { Search.loadIndex("searchindex.js"); });\E/;
+    my ($has_source) = $search =~ m{HAS_SOURCE:\s*(true|false)};
+    my ($url_root) = $search =~ m{URL_ROOT:\s*'([^']*)'};
+    (%js and $loads_searchindex and defined $has_source and defined $url_root) or error("$searchfn doesn't look like a Sphinx search page");
+    $url_root =~ m{^([a-z]+:/)?/} and error("URL_ROOT in $searchfn is not relative");
+    for my $js (keys(%js))
+    {
+        -f "$path/$js" or -l "$path/$js" or error("$path/$js is missing");
+    }
+    for my $page (split(/","/, $index))
+    {
+        -f "$path/$page.html"
+            or excludefile("$page.html")
+            or error("$path/$page.html is missing");
+        -f "$path/_sources/$page.txt"
+            or excludefile("_sources/$page.txt")
+            or error("$path/_sources/$page.txt is missing")
+            if $has_source;
+    }
+    if (opendir(D, "$path/_static/"))
+    {
+        grep {
+            $js{"_static/$_"} = 1
+                if /[.]js$/ and not excludefile("_static/$_"); 
+        } readdir(D);
+        closedir(D);
+    }
+    return keys(%js);
+}
+
+sub unknown_javascript($)
+{
+    my ($js) = @_;
+    my $message = "unknown JavaScript code: $js";
+    $js =~ s{.*/}{};
+    my $basic = grep { $_ eq $js } qw(searchtools.js doctools.js jquery.js underscore.js);
+    if ($basic)
+    {
+        error($message);
+    }
+    else
+    {
+        warning($message);
+    }
+}
+
+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)
+    {
+        my $id = '';
+        if (-l "$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");
+            $deps{$dependency} = 1;
+        }
+        else
+        {
+            unknown_javascript("$path/$js");
+        }
+    }
+    return keys %deps;
+}
+
+sub drop_cruft($)
+{
+    my ($path) = @_;
+    unless (excludefile('.doctrees'))
+    {
+        my $doctrees = "$path/.doctrees/";
+        doit('rm', '-rf', $doctrees) if -d $doctrees;
+    }
+    unless (excludefile('.buildinfo'))
+    {
+        my $buildinfo = "$path/.buildinfo";
+        doit('rm', '-f', $buildinfo) if -f $buildinfo;
+    }
+}
+ 
+sub fix_sphinx_doc($$)
+{
+    my ($package, $path) = @_;
+    return 0 if not looks_like_sphinx_doc($path);
+    my @js = sanity_check($path);
+    my @deps = fix_symlinks($path, @js);
+    drop_cruft($path);
+    map { addsubstvar($package, "sphinxdoc:Depends", $_) } @deps;
+    return 1;
+}
+
+init();
+
+load_packaged_js();
+
+my @paths = @ARGV;
+ at paths = (undef) unless @paths;
+
+foreach my $path (@paths)
+{
+    my $done = 0;
+    foreach my $package (@{$dh{DOPACKAGES}})
+    {
+        my $pkgpath = tmpdir($package);
+        if (defined $path)
+        {
+            next if -l $path;
+            $pkgpath .= "/$path";
+            $done += fix_sphinx_doc($package, $pkgpath);
+        }
+        else
+        {
+            $pkgpath .= '/usr/share/doc/';
+            next unless -d $pkgpath;
+            find({
+                wanted => sub {
+                    return unless -d;
+                    return if -l;
+                    return if excludefile($_);
+                    $done += fix_sphinx_doc($package, $_);
+                },
+                no_chdir => 1
+            }, $pkgpath);
+        }
+    }
+    if ($done == 0)
+    {
+        my $message = 'Sphinx documentation not found';
+        $message .= " at $path" if defined $path;
+        error($message);
+    }
+}
+
+# vim:ts=4 sw=4 et

Copied: packages/sphinx/trunk/debian/dh-sphinxdoc/sphinxdoc.pm (from rev 17743, packages/sphinx/trunk/debian/sphinxdoc.pm)
===================================================================
--- packages/sphinx/trunk/debian/dh-sphinxdoc/sphinxdoc.pm	                        (rev 0)
+++ packages/sphinx/trunk/debian/dh-sphinxdoc/sphinxdoc.pm	2011-07-09 19:56:34 UTC (rev 17779)
@@ -0,0 +1,8 @@
+use warnings;
+use strict;
+
+use Debian::Debhelper::Dh_Lib;
+
+insert_after('dh_installdocs', 'dh_sphinxdoc');
+
+1;

Deleted: packages/sphinx/trunk/debian/dh_sphinxdoc
===================================================================
--- packages/sphinx/trunk/debian/dh_sphinxdoc	2011-07-09 19:55:10 UTC (rev 17778)
+++ packages/sphinx/trunk/debian/dh_sphinxdoc	2011-07-09 19:56:34 UTC (rev 17779)
@@ -1,275 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright © 2011 Jakub Wilk <jwilk at debian.org>
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-use warnings;
-
-use Digest::MD5;
-use File::Find;
-use Debian::Debhelper::Dh_Lib;
-
-my %packaged_js = ();
-
-sub md5($)
-{
-    my ($filename) = @_;
-    my $md5 = Digest::MD5->new;
-    open(F, '<', $filename) or error("cannot open $filename");
-    $md5->addfile(*F);
-    close(F);
-    return $md5->digest;
-}
-
-sub load_packaged_js()
-{
-    my $root = tmpdir('libjs-sphinxdoc');    
-    $root = '' unless -d $root;
-    find({
-        wanted => sub {
-            my $js = $_;
-            my ($version, $name) = m{([0-9.]+)/(\w+[.]js)$} or return;
-            my $md5;
-            if (-l $js)
-            {
-                my $js_target = readlink($js);
-                unless ($js_target =~ m{^/})
-                {
-                    $js_target = "$js/../$js_target";
-                    while ($js_target =~ s{[^./][^/]+/[.][.]/}{}) {};
-                }
-                $md5 = md5($js_target);
-            }
-            else
-            {
-                $js =~ s{^\Q$root\E}{} unless -f $js;
-                $md5 = md5($js);
-            }
-            $js =~ s{^\Q$root\E}{};
-            my $data = [$js, "libjs-sphinxdoc (>= $version)"];
-            $packaged_js{$md5} = $data;
-            $packaged_js{$name} = $data;
-        },
-        no_chdir => 1
-    }, "$root/usr/share/javascript/sphinxdoc/");
-}
-
-sub looks_like_sphinx_doc($)
-{
-    my ($path) = @_;
-    return 0 unless -f "$path/searchindex.js";
-    return 0 unless -f "$path/search.html";
-    return 1;
-}
-
-sub sanity_check($)
-{
-    local $/;
-    my ($path) = @_;
-    my $indexfn = "$path/searchindex.js";
-    open(F, '<', $indexfn) or error("cannot open $indexfn");
-    my $index = <F>;
-    close(F);
-    $index =~ m{^Search[.]setIndex[(].*?filenames:\["(.*?)"\].*[)]$} or error("$indexfn doesn't look like a Sphinx search index");
-    $index = $1;
-    my $searchfn = "$path/search.html";
-    open(F, '<', $searchfn) or error("cannot open $searchfn");
-    my $search = <F>;
-    close F;
-    my %js = ();
-    grep { $js{$_} = 1 unless excludefile($_); } $search =~ m{<script type="text/javascript" src="([^"]++)"></script>}g;
-    my $loads_searchindex = $search =~ m/\QjQuery(function() { Search.loadIndex("searchindex.js"); });\E/;
-    my ($has_source) = $search =~ m{HAS_SOURCE:\s*(true|false)};
-    my ($url_root) = $search =~ m{URL_ROOT:\s*'([^']*)'};
-    (%js and $loads_searchindex and defined $has_source and defined $url_root) or error("$searchfn doesn't look like a Sphinx search page");
-    $url_root =~ m{^([a-z]+:/)?/} and error("URL_ROOT in $searchfn is not relative");
-    for my $js (keys(%js))
-    {
-        -f "$path/$js" or -l "$path/$js" or error("$path/$js is missing");
-    }
-    for my $page (split(/","/, $index))
-    {
-        -f "$path/$page.html"
-            or excludefile("$page.html")
-            or error("$path/$page.html is missing");
-        -f "$path/_sources/$page.txt"
-            or excludefile("_sources/$page.txt")
-            or error("$path/_sources/$page.txt is missing")
-            if $has_source;
-    }
-    if (opendir(D, "$path/_static/"))
-    {
-        grep {
-            $js{"_static/$_"} = 1
-                if /[.]js$/ and not excludefile("_static/$_"); 
-        } readdir(D);
-        closedir(D);
-    }
-    return keys(%js);
-}
-
-sub unknown_javascript($)
-{
-    my ($js) = @_;
-    my $message = "unknown JavaScript code: $js";
-    $js =~ s{.*/}{};
-    my $basic = grep { $_ eq $js } qw(searchtools.js doctools.js jquery.js underscore.js);
-    if ($basic)
-    {
-        error($message);
-    }
-    else
-    {
-        warning($message);
-    }
-}
-
-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)
-    {
-        my $id = '';
-        if (-l "$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");
-            $deps{$dependency} = 1;
-        }
-        else
-        {
-            unknown_javascript("$path/$js");
-        }
-    }
-    return keys %deps;
-}
-
-sub drop_cruft($)
-{
-    my ($path) = @_;
-    unless (excludefile('.doctrees'))
-    {
-        my $doctrees = "$path/.doctrees/";
-        doit('rm', '-rf', $doctrees) if -d $doctrees;
-    }
-    unless (excludefile('.buildinfo'))
-    {
-        my $buildinfo = "$path/.buildinfo";
-        doit('rm', '-f', $buildinfo) if -f $buildinfo;
-    }
-}
- 
-sub fix_sphinx_doc($$)
-{
-    my ($package, $path) = @_;
-    return 0 if not looks_like_sphinx_doc($path);
-    my @js = sanity_check($path);
-    my @deps = fix_symlinks($path, @js);
-    drop_cruft($path);
-    map { addsubstvar($package, "sphinxdoc:Depends", $_) } @deps;
-    return 1;
-}
-
-init();
-
-load_packaged_js();
-
-my @paths = @ARGV;
- at paths = (undef) unless @paths;
-
-foreach my $path (@paths)
-{
-    my $done = 0;
-    foreach my $package (@{$dh{DOPACKAGES}})
-    {
-        my $pkgpath = tmpdir($package);
-        if (defined $path)
-        {
-            next if -l $path;
-            $pkgpath .= "/$path";
-            $done += fix_sphinx_doc($package, $pkgpath);
-        }
-        else
-        {
-            $pkgpath .= '/usr/share/doc/';
-            next unless -d $pkgpath;
-            find({
-                wanted => sub {
-                    return unless -d;
-                    return if -l;
-                    return if excludefile($_);
-                    $done += fix_sphinx_doc($package, $_);
-                },
-                no_chdir => 1
-            }, $pkgpath);
-        }
-    }
-    if ($done == 0)
-    {
-        my $message = 'Sphinx documentation not found';
-        $message .= " at $path" if defined $path;
-        error($message);
-    }
-}
-
-# vim:ts=4 sw=4 et

Modified: packages/sphinx/trunk/debian/python-sphinx.install
===================================================================
--- packages/sphinx/trunk/debian/python-sphinx.install	2011-07-09 19:55:10 UTC (rev 17778)
+++ packages/sphinx/trunk/debian/python-sphinx.install	2011-07-09 19:56:34 UTC (rev 17779)
@@ -1,3 +1,3 @@
-debian/sphinxdoc.pm /usr/share/perl5/Debian/Debhelper/Sequence/
-debian/dh_sphinxdoc /usr/bin/
+debian/dh-sphinxdoc/sphinxdoc.pm /usr/share/perl5/Debian/Debhelper/Sequence/
+debian/dh-sphinxdoc/dh_sphinxdoc /usr/bin/
 

Modified: packages/sphinx/trunk/debian/rules
===================================================================
--- packages/sphinx/trunk/debian/rules	2011-07-09 19:55:10 UTC (rev 17778)
+++ packages/sphinx/trunk/debian/rules	2011-07-09 19:56:34 UTC (rev 17779)
@@ -81,7 +81,7 @@
 	dh_installchangelogs CHANGES
 	dh_installdocs
 	dh_install
-	./debian/dh_sphinxdoc /usr/share/doc/python-sphinx/html/
+	./debian/dh-sphinxdoc/dh_sphinxdoc /usr/share/doc/python-sphinx/html/
 	dh_installexamples
 	dh_installman
 	dh_pysupport

Deleted: packages/sphinx/trunk/debian/sphinxdoc.pm
===================================================================
--- packages/sphinx/trunk/debian/sphinxdoc.pm	2011-07-09 19:55:10 UTC (rev 17778)
+++ packages/sphinx/trunk/debian/sphinxdoc.pm	2011-07-09 19:56:34 UTC (rev 17779)
@@ -1,8 +0,0 @@
-use warnings;
-use strict;
-
-use Debian::Debhelper::Dh_Lib;
-
-insert_after('dh_installdocs', 'dh_sphinxdoc');
-
-1;




More information about the Python-modules-commits mailing list