[Pkg-mono-svn-commits] rev 3721 - monodoc/trunk/debian

David Paleino hanska-guest at alioth.debian.org
Sat Oct 11 16:25:49 UTC 2008


Author: hanska-guest
Date: 2008-10-11 16:25:49 +0000 (Sat, 11 Oct 2008)
New Revision: 3721

Added:
   monodoc/trunk/debian/update-monodoc
Modified:
   monodoc/trunk/debian/changelog
   monodoc/trunk/debian/control
   monodoc/trunk/debian/monodoc-base.dirs
   monodoc/trunk/debian/monodoc-base.install
   monodoc/trunk/debian/monodoc-base.manpages
   monodoc/trunk/debian/rules
Log:
  + update-monodoc
    - debian/control updated: needed dependency on libxml-libxml-perl on
      monodoc-base
    - debian/rules updated
    - debian/monodoc-base.manpages updated
    - debian/monodoc-base.dirs updated
    - debian/monodoc-base.install updated
    - debian/update-monodoc added

Modified: monodoc/trunk/debian/changelog
===================================================================
--- monodoc/trunk/debian/changelog	2008-10-11 16:14:32 UTC (rev 3720)
+++ monodoc/trunk/debian/changelog	2008-10-11 16:25:49 UTC (rev 3721)
@@ -15,8 +15,16 @@
       - debian/postinst-monodoc added
       - debian/postrm-monodoc added
       - debian/rules updated
+    + update-monodoc
+      - debian/control updated: needed dependency on libxml-libxml-perl on
+        monodoc-base
+      - debian/rules updated
+      - debian/monodoc-base.manpages updated
+      - debian/monodoc-base.dirs updated
+      - debian/monodoc-base.install updated
+      - debian/update-monodoc added
 
- -- David Paleino <d.paleino at gmail.com>  Sat, 11 Oct 2008 17:54:24 +0200
+ -- David Paleino <d.paleino at gmail.com>  Sat, 11 Oct 2008 18:24:39 +0200
 
 monodoc (1.9-2) unstable; urgency=low
 

Modified: monodoc/trunk/debian/control
===================================================================
--- monodoc/trunk/debian/control	2008-10-11 16:14:32 UTC (rev 3720)
+++ monodoc/trunk/debian/control	2008-10-11 16:25:49 UTC (rev 3721)
@@ -31,7 +31,7 @@
 
 Package: monodoc-base
 Architecture: all
-Depends: ${cli:Depends}
+Depends: ${cli:Depends}, libxml-libxml-perl
 Description: shared MonoDoc binaries
  The MonoDoc Project is the documentation framework of the Mono project which
  provides detailed API documentation for all Mono components and the Mono CLI

Modified: monodoc/trunk/debian/monodoc-base.dirs
===================================================================
--- monodoc/trunk/debian/monodoc-base.dirs	2008-10-11 16:14:32 UTC (rev 3720)
+++ monodoc/trunk/debian/monodoc-base.dirs	2008-10-11 16:25:49 UTC (rev 3721)
@@ -1,2 +1,3 @@
 usr/bin/
+usr/sbin/
 usr/share/debhelper/autoscripts/

Modified: monodoc/trunk/debian/monodoc-base.install
===================================================================
--- monodoc/trunk/debian/monodoc-base.install	2008-10-11 16:14:32 UTC (rev 3720)
+++ monodoc/trunk/debian/monodoc-base.install	2008-10-11 16:25:49 UTC (rev 3721)
@@ -8,3 +8,5 @@
 debian/dh_installmonodoc	usr/bin/
 debian/postinst-monodoc		usr/share/debhelper/autoscripts/
 debian/postrm-monodoc		usr/share/debhelper/autoscripts/
+
+debian/update-monodoc		usr/sbin/

Modified: monodoc/trunk/debian/monodoc-base.manpages
===================================================================
--- monodoc/trunk/debian/monodoc-base.manpages	2008-10-11 16:14:32 UTC (rev 3720)
+++ monodoc/trunk/debian/monodoc-base.manpages	2008-10-11 16:25:49 UTC (rev 3721)
@@ -1,3 +1,4 @@
 debian/man/mod.1
 debian/man/monodoc.1
 debian/man/dh_installmonodoc.1
+debian/man/update-monodoc.1

Modified: monodoc/trunk/debian/rules
===================================================================
--- monodoc/trunk/debian/rules	2008-10-11 16:14:32 UTC (rev 3720)
+++ monodoc/trunk/debian/rules	2008-10-11 16:25:49 UTC (rev 3721)
@@ -11,9 +11,10 @@
 	./configure --prefix=/usr
 	$(MAKE)
 	
-	# Generate the manpage
-	chmod +x debian/dh_installmonodoc;
-	pod2man -c "Debhelper for Monodoc" debian/dh_installmonodoc > debian/man/dh_installmonodoc.1
+	# Generate the manpages
+	for x in dh_installmonodoc update-monodoc; \
+	  do chmod +x $$x; pod2man -c "Debhelper for Monodoc" debian/$$x > debian/man/$$x.1; \
+	done
 
 	touch build-stamp
 
@@ -26,7 +27,7 @@
 	    tools/monodocer1.exe.mdb tools/monodocs2html.exe \
 	    tools/monodocs2html.exe.mdb tools/monodocs2slashdoc.exe \
 	    tools/monodocs2slashdoc.exe.mdb
-	rm -f debian/dh_installmonodoc.1
+	rm -f debian/dh_installmonodoc.1 debian/update-monodoc.1
 	[ ! -f Makefile ] || $(MAKE) clean
 	rm -f build-stamp
 	rm -rf $$MONO_SHARED_DIR/.wapi

Added: monodoc/trunk/debian/update-monodoc
===================================================================
--- monodoc/trunk/debian/update-monodoc	                        (rev 0)
+++ monodoc/trunk/debian/update-monodoc	2008-10-11 16:25:49 UTC (rev 3721)
@@ -0,0 +1,218 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+update-monodoc - updates monodoc.xml global documentation registry
+
+=cut
+
+use strict;
+use File::Temp qw/ tempfile /;
+use File::Basename;
+use XML::LibXML;
+
+=head1 SYNOPSIS
+
+B<update-monodoc> [B<-n>]
+
+=head1 DESCRIPTION
+
+B<update-monodoc> is a program taht handles the update of monodoc documentation database.
+It looks for files in /usr/share/monodoc/manuals.d/, and adds the corresponding nodes to
+/usr/lib/monodoc/monodoc.xml. This program is usually called on documentation postinst/postrm,
+or on monodoc postinst/postrm.
+
+=cut
+
+my $monodoc = "/usr/lib/monodoc/monodoc.xml";
+my $manuals = "/usr/share/monodoc/manuals.d";
+
+# Create the XML
+my $dom = XML::LibXML::Document->createDocument("1.0");
+
+# Add the root element
+# <node label="Mono Documentation" name="root:">
+my $root = XML::LibXML::Element->new("node");
+$root->setAttribute("label", "Mono Documentation");
+$root->setAttribute("name", "root:");
+$dom->setDocumentElement($root);
+
+my $parser = new XML::LibXML;
+
+# This is for non-existing parents
+my @dummy_parents;
+
+foreach my $file (glob("${manuals}/*")) {
+	my %info = get_info($file);
+	update_tree(%info);
+}
+
+# TODO: we should check for "second level childs". Any easy way to do
+# it? --David
+
+sub get_info {
+	my $file = $_[0];
+	my $line;
+	my ($parent, $name, $label);
+	my %res;
+	
+	open REGISTRY, "<$file" or
+		die "E: Cannot open $file for reading!\n";
+	while (<REGISTRY>) {
+		my $line = $_;
+		our ($name, $label, $parent);
+		
+		# This is just in case someone edited them manually... :)
+		$line =~ s/^\s*#.*//;
+		$line =~ s/^\s+//;
+		$line =~ s/\s+$//;
+		next unless length($line);
+		
+		# Same checks as dh_installmonodoc
+		($name, $label, $parent) = split(/ /, $line, 3);
+		
+		# Handle " and ' without inner spaces
+		if ($label =~ /([\"\']).*\1/) {
+			$label =~ s/$1//g;
+		}
+		# The label usually has spaces, handle " and ' correctly.
+		elsif ($label =~ /([\"\']).*/) {
+			my $sep = $1;
+			my $tmp = $parent if $parent;
+			$tmp =~ s/(.*)[\"\'] [^\"\']*/$1/g;
+			$label = "$label ".$tmp;
+			$label =~ s/["']//g;
+			$parent =~ s/${tmp}${sep}\s*//;
+			$parent = "" if ($parent eq $tmp);
+		}
+		
+		# We don't check everything again, that's maintainers duty.
+		# TODO: is this correct? Or should we check everything again?
+		# If we should check everything again, a separate Perl Module (.pm)
+		# might be needed, to avoid code duplication. --David
+		
+		# Let's set defaults for optional parameters
+		$parent = "various" if !$parent;
+		
+		$res{"parent"} = $parent;
+		$res{"name"} = $name;
+		$res{"label"} = $label;
+	}
+	close REGISTRY;
+	
+	return %res;
+}
+
+sub update_tree {
+	my %info = @_;
+	my $name = $info{"name"};
+	my $parent = $info{"parent"};
+	my $label = $info{"label"};
+
+	my @nodelist = $dom->getElementsByTagName("node");
+
+	my $res = $dom->findnodes("//node");
+
+	my $parent_found = 0;
+	
+	my $child = XML::LibXML::Element->new("node");
+	$child->setAttribute("label", $label);
+	$child->setAttribute("name", $name);
+			
+	foreach my $element ($res->get_nodelist) {		
+		my $el_name = $element->getAttribute("name");
+		if ($el_name eq $parent) {
+			$parent_found = 1;
+#			print "Adding «$label» ($name) to $parent.\n";
+			$element->appendChild($child);
+			return;
+		} else {
+			next;
+		}
+		
+		# If the element is already here, probably it's a "dummy parent".
+		if ($el_name eq $name) {
+			$element->setAttribute("label", $label);
+			next;
+		}
+	}
+	
+	# We didn't find a parent node, create a dummy one.
+	if (!$parent_found) {
+		my $dummy_parent = XML::LibXML::Element->new("node");
+		$dummy_parent->setAttribute("label", "dummy-$parent");
+		$dummy_parent->setAttribute("name", "$parent");
+		$dummy_parent->appendChild($child);
+		$root->appendChild($dummy_parent);
+		push(@dummy_parents, $parent);
+	}
+}
+
+# Check for dummy parents hanging around -- move children to Various,
+# if a parent wasn't added before.
+foreach my $nodename (@dummy_parents) {
+	my $found = 0;
+	my $dummy;
+	
+	# Grab the node
+	foreach my $element ($dom->findnodes("//node")->get_nodelist) {
+#		print $element->getAttribute("label")."\n";
+		if (($element->getAttribute("name") eq $nodename) and
+		    ($element->getAttribute("label") eq "dummy-$nodename")) {
+			$dummy = $element;
+		}
+	}
+	
+	# Look for the "real" parent
+	foreach my $element ($dom->findnodes("//node")->get_nodelist) {
+		if (($element->getAttribute("name") eq $nodename) and
+		    ($element->getAttribute("label") ne "dummy-$nodename")) {
+			$found = 1;
+			foreach my $child ($dummy->childNodes) {
+				$element->appendChild($child);
+			}
+		}
+	}
+	
+	# The parent node wasn't added in the previous cycle, move everything
+	# under "Various".
+	if (!$found) {
+		# TODO: do this in a more efficient way.
+		foreach my $element ($dom->findnodes("//node")->get_nodelist) {
+			if ($element->getAttribute("name") eq "various") {
+				foreach my $child ($dummy->childNodes) {
+					$element->appendChild($child);
+				}
+			}
+		}
+	}
+	
+	# Remove the node.
+	$dummy->unbindNode();
+}
+
+# Use a temporary file to write the XML, just to be sure we don't
+# fail writing the monodoc.xml in the middle because of something
+# else (most notably: power failure?)
+my ($fh, $filename) = tempfile("/tmp/".basename($0).".XXXX", UNLINK => 1);
+print $fh $dom->toString(2);
+close $fh;
+
+system("mv $filename $monodoc");
+
+print "Regenerating Monodoc search index... ";
+system("monodoc --make-index 2>&1 >/dev/null");
+print "done.\n";
+
+
+=head1 SEE ALSO
+
+L<dh_installmonodoc(1)>
+
+This program is a part of monodoc-base.
+
+=head1 AUTHOR
+
+David Paleino <d.paleino at gmail.com>
+
+=cut


Property changes on: monodoc/trunk/debian/update-monodoc
___________________________________________________________________
Name: svn:executable
   + *




More information about the Pkg-mono-svn-commits mailing list