[Pkg-cli-common-commits] [cli-common] 01/01: Add dh_installcliframework

Christopher Halse Rogers raof-guest at alioth.debian.org
Mon Oct 28 23:20:39 UTC 2013


This is an automated email from the git hooks/post-receive script.

raof-guest pushed a commit to branch dh_installcliframework
in repository cli-common.

commit ebd443ad4f0261f899b5eed9f210ad2294c573a9
Author: Christopher James Halse Rogers <raof at ubuntu.com>
Date:   Fri Oct 18 17:15:07 2013 +1100

    Add dh_installcliframework
    
    This is infrastructure for installing 3rd party framework libraries, such as
    FSharp.Core, in the framework directories where the compilers can find them
    without explicit references.
    
    Obviously developed for F#, but should be useful for any subsequent languages
    built for the CLR.
---
 cli.pm                        |    1 +
 debian/cli-common-dev.install |    4 +
 debian/cli-common.install     |    2 +
 debian/rules                  |    2 +-
 dh_clideps                    |    9 ++-
 dh_installcliframework        |  168 +++++++++++++++++++++++++++++++++++++++++
 framework-package-install     |   94 +++++++++++++++++++++++
 framework-package-remove      |   13 ++++
 postinst-cliframework         |    3 +
 prerm-cliframework            |    3 +
 10 files changed, 297 insertions(+), 2 deletions(-)

diff --git a/cli.pm b/cli.pm
index cda5bfe..57cb3c9 100644
--- a/cli.pm
+++ b/cli.pm
@@ -13,6 +13,7 @@ insert_before("dh_installdeb", "dh_clistrip");
 insert_before("dh_installdeb", "dh_cligacpolicy");
 insert_before("dh_installdeb", "dh_makeclilibs");
 insert_before("dh_installdeb", "dh_installcligac");
+insert_before("dh_installdeb", "dh_installcliframework");
 insert_before("dh_installdeb", "dh_clideps");
 
 1;
diff --git a/debian/cli-common-dev.install b/debian/cli-common-dev.install
index 32a8a40..b3626d2 100644
--- a/debian/cli-common-dev.install
+++ b/debian/cli-common-dev.install
@@ -15,6 +15,10 @@ dh_installcligac	/usr/bin/
 postinst-cligac		/usr/share/debhelper/autoscripts/
 prerm-cligac		/usr/share/debhelper/autoscripts/
 
+dh_installcliframework	/usr/bin/
+postinst-cliframework	/usr/share/debhelper/autoscripts/
+prerm-cliframework	/usr/share/debhelper/autoscripts/
+
 dh_cligacpolicy		/usr/bin/
 postinst-cligacpolicy	/usr/share/debhelper/autoscripts/
 postrm-cligacpolicy     /usr/share/debhelper/autoscripts/
diff --git a/debian/cli-common.install b/debian/cli-common.install
index 3d99369..cafd899 100644
--- a/debian/cli-common.install
+++ b/debian/cli-common.install
@@ -4,3 +4,5 @@ gac-package-install	/usr/share/cli-common/
 gac-package-remove	/usr/share/cli-common/
 policy-install          /usr/share/cli-common/
 policy-remove           /usr/share/cli-common/
+framework-package-install	/usr/share/cli-common/
+framework-package-remove	/usr/share/cli-common/
diff --git a/debian/rules b/debian/rules
index 2e5c227..98c0a00 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,7 +11,7 @@ build-stamp:
 	debiandoc2text cli-policy.sgml
 	debiandoc2html cli-policy.sgml
 	debiandoc2pdf cli-policy.sgml
-	for x in dh_clideps dh_makeclilibs dh_installcligac dh_clifixperms dh_clistrip dh_cligacpolicy; \
+	for x in dh_clideps dh_makeclilibs dh_installcligac dh_clifixperms dh_clistrip dh_cligacpolicy dh_installcliframework; \
 	  do chmod +x $$x; pod2man -c "Debhelper for CLI (Common Language Infrastructure)" $$x > $$x.1; done
 	touch build-stamp
 
diff --git a/dh_clideps b/dh_clideps
index e71c506..bae5a62 100755
--- a/dh_clideps
+++ b/dh_clideps
@@ -358,7 +358,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
   }
   
   my $dh_ref = "";
-  if (-f "$tmp/usr/share/cli-common/packages.d/$package.installcligac") {
+  my $cli_common_dir = "$tmp/usr/share/cli-common/packages.d/";
+  if (-f ($cli_common_dir . "$package.installcligac")) {
     # this package uses late GAC install, thus we need cli-common at package install time
     if (-f "debian/cligacpolicy" || -f "debian/$package.cligacpolicy") {
       # if this package uses dh_cligacpolicy then we need 0.5.4 for the policy-remove script in .postrm
@@ -369,6 +370,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
       $dh_ref = "cli-common (>= 0.5.1), ";
     }
   }
+  if (-f ($cli_common_dir . "$package.installcliframework")) {
+    # This package uses framework install, added in 0.9...
+    $dh_ref = "cli-common (>= 0.9), ";
+    # ...and the framework helper was only added to mono-gac in 3.2.1+dfsg-2
+    $vm_ref .= "mono-gac (>= 3.2.1+dfsg-2~), ";
+  }
   $vm_ref .= $dh_ref;
   
     #$deps .= join(", ", "",
diff --git a/dh_installcliframework b/dh_installcliframework
new file mode 100755
index 0000000..2ccd22d
--- /dev/null
+++ b/dh_installcliframework
@@ -0,0 +1,168 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_installcliframework - install development links into framework paths
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_installcliframework> [S<I<debhelper options>>] [B<-n>]
+
+=head1 DESCRIPTION
+
+dh_installcliframework is a debhelper program that is responsible for
+installing assemblies and related files used by the Debian cli-common
+package into the framework paths.
+
+This is useful for third-party languages, such as F#, that add an automatic
+reference a core library in the same way that B<mcs> adds an automatic
+reference to B<mscorlib>.
+
+The format of a C<installcliframework> file is line based, treating any line
+starting with '#' as a comment. The first component of each line specifies the
+framework version to install to, multiplied by 10 to get an integer. The second
+component is the full path of the file to install into the framework path.
+
+dh_installcliframework only installs links for compile-time assembly resolution;
+it does B<not> provide any support for runtime assembly resolution, which is
+the responsibility of the GAC. Any assembly reference installed by
+dh_installcliframework will also need to be installed into the GAC. See
+L<dh_installcligac(1)> for how to do this.
+
+Note that, unlike the GAC, there is no mechanism for multiple versions of the
+same assembly to be installed into the framework paths. This means that it is
+usually incorrect for a package to call both dh_installcligac and 
+dh_installcliframework.
+
+If the files installed by dh_installcliframework are provided by binary
+packages built from the same source package then appropriate dependencies
+are generated into the C<cli:Depends> field.
+
+It also automatically generates the postinst and prerm commands needed
+to late install the assemblies. See L<dh_installdeb(1)> for an
+explanation of how this works.
+
+This is based on L<dh_installemacsen(1)> in the emacsen-common package.
+
+=head1 EXAMPLE
+
+=over 4
+
+ # Example debian/pkgfoo.installcliframework file
+ # This is a comment.
+ # Blank lines are ignored:
+ 
+ # This assembly is installed into the .NET 4.0 framework path
+ # (usually /usr/lib/mono/4.0/):
+ 40 /usr/lib/cli/pkgfoo/Foo.dll
+ 
+ # This assembly is installed into the .NET 3.5 framework path:
+ 35 /usr/lib/cli/pkgfoo/Bar.dll
+ 
+ # You can also install ancilliary files, if needed:
+ 40 /usr/lib/cli/pkgfoo/Foo.dll.optdata
+ 
+ # It is valid to install the same file for different framework versions:
+ 40 /usr/lib/cli/pkgfoo/Baz.dll
+ 45 /usr/lib/cli/pkgfoo/Baz.dll
+
+=back
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-n>, B<--noscripts>
+
+Do not modify postinst/prerm scripts.
+
+=back
+
+=head1 NOTES
+
+Note that this command is not idempotent. "dh_clean -k" should be called
+between invocations of this command. Otherwise, it may cause multiple
+instances of the same text to be added to maintainer scripts.
+
+=cut
+
+init();
+
+my @allpackages = getpackages();
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+    my $tmp = tmpdir($package);
+    
+    my $cliframework = pkgfile($package, "installcliframework");
+    
+    if ($cliframework ne '') {
+	# sanity check: do all files listed in the installcliframework file exist?
+	open CLIFRAMEWORK, "<$cliframework" or
+	    die "E: Can't open $cliframework\n";
+	my $pkgref;
+	while (<CLIFRAMEWORK>)
+	{
+	    chomp;
+	    s/^\s+//;
+	    s/\s+$//;
+	    next if /^\#/;
+	    next if /^\s*$/;
+	    
+	    # Split on the space
+	    my @p = split(/\s+/);
+	    
+	    # Framework version is first...
+	    my $framework = shift @p;
+	    # ...then the file to install
+	    my $file = shift @p;
+	    
+	    if (! -f "$tmp$file") {
+		# Search through the other packages for our file
+		foreach my $binary_package (@allpackages) {
+		    verbose_print("Checking $binary_package for $file");
+		    if( -f (tmpdir($binary_package) . $file)) {
+			verbose_print("Found framework reference in $binary_package");
+			$pkgref = $binary_package . " (= \${binary:Version})";
+			verbose_print("pkgref is $pkgref");
+			addsubstvar($package, "cli:Depends", $binary_package, "(= \${binary:Version})");
+			last;
+		    }
+		}
+		
+		if (! defined($pkgref)) {
+		    die "E: Can't find file $file in any binary package!\n";
+		}
+	    }
+	}
+	close CLIFRAMEWORK;
+	
+	if (! -d "$tmp/usr/share/cli-common/packages.d") {
+	    doit("install","-d","$tmp/usr/share/cli-common/packages.d");
+	}
+	doit("install", "-m0644", $cliframework, "$tmp/usr/share/cli-common/packages.d/$package.installcliframework");
+	
+	if (! $dh{NOSCRIPTS}) {
+	    autoscript($package, "postinst", "postinst-cliframework",
+		       "s/#PACKAGE#/$package/");
+	    autoscript($package, "prerm", "prerm-cliframework",
+		       "s/#PACKAGE#/$package/");
+	}
+    }
+}
+
+=head1 SEE ALSO
+
+L<debhelper(7)>
+
+This program is a part of cli-common-dev.
+
+=head1 AUTHOR
+
+Christopher James Halse Rogers <raof at ubuntu.com>
+
+=cut
diff --git a/framework-package-install b/framework-package-install
new file mode 100755
index 0000000..aaf7dc6
--- /dev/null
+++ b/framework-package-install
@@ -0,0 +1,94 @@
+#!/usr/bin/perl
+
+#
+# Setup
+#
+
+# Directives
+use strict;
+use warnings;
+
+# Modules
+use File::Basename;
+
+# This script gets the name of the package as the first parameter.  It
+# parses the file given, then installs them as appropriate.
+# If there is a second parameter, this is the only CLR installed.
+
+#
+# Handle the input file
+#
+
+# Get the package
+my $pkg = $ARGV[0];
+my $use_clr = $ARGV[1];
+my $full = "/usr/share/cli-common/packages.d/$pkg";
+
+# Make sure it exists
+if ( ! -f "$full.installcliframework" )
+{
+    print STDERR "! $full.installcliframework doesn't exist!\n";
+    exit 1;
+}
+
+# Parse the file
+unless (open INPUT, "<$full.installcliframework")
+{
+    print STDERR "! Cannot open $full.installcliframework ($!)\n";
+    exit 2;
+}
+
+my @files = ();
+
+while (<INPUT>)
+{
+    # Clean up the line and ignore blanks and comments
+    chomp;
+    s/^\s+//;
+    s/\s+$//;
+    next if /^\#/;
+    next if /^\s*$/;
+
+    # Split on the space
+    my @p = split(/\s+/);
+
+    # Framework version is first...
+    my $framework = shift @p;
+    # ...then the file to install
+    my $file = shift @p;
+
+    if (! -f $file)
+    {
+	print STDERR "! Assembly $file does not exist\n";
+	exit 3;
+    }
+
+    push @files, $framework;
+    push @files, $file;
+}
+
+# Go through the installation targets
+foreach my $clr (glob("/usr/share/cli-common/runtimes.d/*"))
+{
+    # Ignore temporary files
+    next if $clr =~ /~$/;
+    next if $clr =~ /^\./;
+
+    # Get the "name"
+    my $name = basename($clr);
+
+    # Get the formal name
+    my $formal = `$clr name`;
+    $formal = $name if !defined $formal || $formal =~ /^\s*$/;
+    chomp($formal);
+
+    # Only use the one CLR if given
+    next if (defined $use_clr && $name ne $use_clr);
+
+    # Install them
+    my $t = (scalar(@files) / 2) . " assemblies";
+    $t = "1 assembly" if (@files == 2);
+	
+    print STDOUT "* Installing $t from $pkg into $formal framework paths\n";
+    system($clr, "install-framework", $pkg, @files) == 0 or die "E: Installation of $pkg with $clr failed\n";
+}
diff --git a/framework-package-remove b/framework-package-remove
new file mode 100755
index 0000000..5ac1ca5
--- /dev/null
+++ b/framework-package-remove
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+for file in /usr/share/cli-common/runtimes.d/*
+  do	
+  if [ -x $file ]; then
+      # Figure out the formal name
+      F="$($file name)"
+
+      # Remove it
+      echo "Removing $1 from $F"
+      $file remove-framework $1
+  fi
+done
diff --git a/postinst-cliframework b/postinst-cliframework
new file mode 100644
index 0000000..5a1d327
--- /dev/null
+++ b/postinst-cliframework
@@ -0,0 +1,3 @@
+if [ "$1" = "configure" ] && [ -x /usr/share/cli-common/framework-package-install ]; then
+	/usr/share/cli-common/framework-package-install #PACKAGE#
+fi
diff --git a/prerm-cliframework b/prerm-cliframework
new file mode 100644
index 0000000..2e77841
--- /dev/null
+++ b/prerm-cliframework
@@ -0,0 +1,3 @@
+if [ "$1" = "remove" ] || [ "$1" = "upgrade" ] && [ -x /usr/share/cli-common/framework-package-remove ]; then
+	/usr/share/cli-common/framework-package-remove #PACKAGE#
+fi

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-cli-common/packages/cli-common.git



More information about the Pkg-cli-common-commits mailing list