[Pkg-cli-common-commits] [cli-common] 01/01: Add dh_installcliframework
Christopher Halse Rogers
raof-guest at moszumanska.debian.org
Mon Dec 16 04:05:55 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 b3b0310338b70a706fb218fe1a931cd0eba9e8e7
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 | 4 +
debian/rules | 2 +-
dh_installcliframework | 168 ++++++++++++++++++++++++++++++++++++++++++
framework-install | 16 ++++
framework-package-install | 115 +++++++++++++++++++++++++++++
framework-package-remove | 33 +++++++++
framework-remove | 18 +++++
postinst-cliframework | 3 +
prerm-cliframework | 3 +
11 files changed, 366 insertions(+), 1 deletion(-)
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..59526d1 100644
--- a/debian/cli-common.install
+++ b/debian/cli-common.install
@@ -4,3 +4,7 @@ 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-install /usr/share/cli-common/
+framework-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_installcliframework b/dh_installcliframework
new file mode 100755
index 0000000..db64b86
--- /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-install b/framework-install
new file mode 100755
index 0000000..603a1a0
--- /dev/null
+++ b/framework-install
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Make sure the GAC file exists
+if [ ! -x /usr/share/cli-common/runtimes.d/$1 ]; then
+ echo ! Cannot install framework $1
+ exit 1
+fi
+
+for file in /usr/share/cli-common/packages.d/*.installcliframework
+do
+ if [ -f $file ]; then
+ /usr/share/cli-common/framework-package-install \
+ $(basename $file .installcliframework) \
+ $1
+ fi
+done
diff --git a/framework-package-install b/framework-package-install
new file mode 100755
index 0000000..6d61d84
--- /dev/null
+++ b/framework-package-install
@@ -0,0 +1,115 @@
+#!/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);
+
+ if (! check_framework_install_supported($clr))
+ {
+ print STDOUT "* Skipping $formal; no support for framework install\n";
+ next;
+ }
+
+ # 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";
+}
+
+sub check_framework_install_supported
+{
+ my $clr = shift;
+
+ open PIPE, "$clr 2>&1 |" or die "E: Cannot query $clr capabilities";
+ while (<PIPE>)
+ {
+ if (/install-framework/)
+ {
+ return 1;
+ }
+ }
+ return 0;
+}
diff --git a/framework-package-remove b/framework-package-remove
new file mode 100755
index 0000000..049bb4b
--- /dev/null
+++ b/framework-package-remove
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+function supports_framework_remove ()
+{
+ echo Checking $1
+ if [ -x $1 ]; then
+ if $1 2>&1 | grep "remove-framework" > /dev/null; then
+ echo supported
+ return 0
+ fi
+ fi
+ echo unsupported
+ return 1
+}
+
+# If there is a second argument, it's the only runtime to remove
+if [ -n "$2" ]; then
+ RUNTIMES=/usr/share/cli-common/runtimes.d/$2
+else
+ RUNTIMES=/usr/share/cli-common/runtimes.d/*
+fi
+
+for file in $RUNTIMES
+ do
+ if supports_framework_remove $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/framework-remove b/framework-remove
new file mode 100755
index 0000000..afac0f5
--- /dev/null
+++ b/framework-remove
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+if [ ! -x /usr/share/cli-common/runtimes.d/$1 ]; then
+ echo ! Cannot remove framework $1
+ exit 1
+fi
+
+echo "* Removing packages from $1's framework paths"
+
+for file in /usr/share/cli-common/packages.d/*.installcliframework
+do
+ if [ -f $file ]; then
+ /usr/share/cli-common/framework-package-remove \
+ $(basename $file .installcliframework) \
+ $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