[Pkg-mono-svn-commits] rev 2363 - mono/trunk/debian
D. Moonfire
dmoonfire-guest at costa.debian.org
Fri Mar 24 20:52:11 UTC 2006
Author: dmoonfire-guest
Date: 2006-03-24 20:52:11 +0000 (Fri, 24 Mar 2006)
New Revision: 2363
Added:
mono/trunk/debian/GetAssemblyName.cs
mono/trunk/debian/mono.runtime-script
Log:
These are the two proposed files for the late GAC install script
and a replacement for the monop process (which lets it be stored in mono-gac
which is where this script belongs).
Added: mono/trunk/debian/GetAssemblyName.cs
===================================================================
--- mono/trunk/debian/GetAssemblyName.cs 2006-03-24 20:48:35 UTC (rev 2362)
+++ mono/trunk/debian/GetAssemblyName.cs 2006-03-24 20:52:11 UTC (rev 2363)
@@ -0,0 +1,14 @@
+using System;
+using System.Reflection;
+
+public class GetAssemblyName
+{
+ public static void Main(string [] args)
+ {
+ if (args.Length == 0)
+ throw new Exception("You must supply an assembly name");
+
+ Assembly assembly = Assembly.LoadFile(args[0]);
+ Console.WriteLine("{0}", assembly.FullName);
+ }
+}
Added: mono/trunk/debian/mono.runtime-script
===================================================================
--- mono/trunk/debian/mono.runtime-script 2006-03-24 20:48:35 UTC (rev 2362)
+++ mono/trunk/debian/mono.runtime-script 2006-03-24 20:52:11 UTC (rev 2363)
@@ -0,0 +1,182 @@
+#!/usr/bin/perl
+
+#
+# Setup
+#
+
+# Directives
+use strict;
+use warnings;
+
+# Modules
+use File::Basename;
+
+# Figure out the mode
+my $mode = shift @ARGV;
+
+if (!defined $mode)
+{
+ print STDERR "E: You must supply a mode\n";
+ print STDERR "E: Use: install, remove, or name\n";
+ exit 1;
+}
+
+# Name is simply
+if ($mode eq "name")
+{
+ print "Mono\n";
+ exit 0;
+}
+
+# This program gets the name of a file (ending in .installcligac) and
+# a list of assemblies to install, as full paths. The ones given are
+# the only ones that passed the white/blacklisting.
+
+# Get the base file
+my $basename = shift @ARGV;
+my $cligac = "/usr/lib/cli-common/packages.d/$basename.installcligac";
+
+if (! -f $cligac)
+{
+ print STDERR "E: File does not exist: $cligac\n";
+ exit 1;
+}
+
+# Get the base directory
+my $basedir = "/usr/lib/cli-common/packages.d/";
+
+# Removing is also simple
+if ($mode eq "remove")
+{
+ # Get the uninstall file
+ my $uninstall = "$basedir/$basename.mono";
+
+ if (-f $uninstall)
+ {
+ # Go through the file
+ open UNINSTALL, "<$uninstall" or
+ die "E: Cannot open uninstall file ($!)";
+
+ while (<UNINSTALL>)
+ {
+ # Clean up the line and get the base directory
+ chomp;
+ my $basedir = dirname($_);
+ system("rm -f $_/*");
+ system("rmdir $_");
+ system("rmdir $basedir");
+ }
+
+ close UNINSTALL;
+
+ # Unlike the file
+ unlink($uninstall);
+ }
+
+ # We are good
+ exit 0;
+}
+
+# The only thing left should be "install"
+if ($mode ne "install")
+{
+ print STDERR "E: Unknown mode: $mode\n";
+ print STDERR "E: Use: install, remove, or name\n";
+ exit 1;
+}
+
+
+# Open up our uninstall file
+open UNINSTALL, ">$basedir/$basename.mono"
+ or die "E: Cannot open uninstall: $basedir/$basename.mono";
+
+# Go through the file
+open CLIGAC, "<$cligac" or die "E: Cannot open: $cligac ($!)";
+
+while (@ARGV)
+{
+ # Get the assembly name
+ my $dll = shift @ARGV;
+
+ # Make sure it is there
+ if (! -f $dll)
+ {
+ print STDERR "E: Assembly does not exist: $dll\n";
+ next;
+ }
+
+ # Figure out the mono's precise name
+ my $fullname = get_full_name($dll);
+
+ # Write out the uninstall file
+ print UNINSTALL "$fullname\n";
+
+ # Install the file. We use the "../../../.." to make it a
+ # relative path to this program (since gacutil doesn't like
+ # absolute paths). There isn't a problem of doing too many
+ # since we typically run from the root context.
+ my $cmd = "(cd / && /usr/bin/gacutil /i ./$dll)";
+ print " ";
+ system($cmd);
+}
+
+close CLIGAC;
+close UNINSTALL;
+
+# Finish up successfully
+exit 0;
+
+# Get the name of the assembly in a manner suitable for uninstall
+# using gacutil.
+sub get_full_name
+{
+ # Get the name
+ my $dll = shift;
+
+ # Open a pipe to monop
+ my $cmd = "/usr/bin/monop -r:$dll";
+ open PIPE, "$cmd |" or die "E: Cannot open pipe: monop $dll";
+
+ # Go through the file and get the last four lines when we find
+ # PublicKey (which is the end of the block.
+ my @p = ();
+
+ while (<PIPE>)
+ {
+ # Add to the list
+ chomp;
+ push @p, $_;
+
+ # Get rid of elements to keep only the last four lines
+ shift @p while (@p > 4);
+
+ # Stop if we have the publick key
+ last if /PublicKey/;
+ }
+
+ # Full version
+ # return join(",", @p);
+
+ # Clean up the path and build the mono-specific directory
+ my %hash = ();
+ $hash{"Assembly"} = shift @p;
+
+ foreach my $p (@p)
+ {
+ if ($p =~ /^(\w+)=(.*)$/)
+ {
+ $hash{$1} = $2;
+ }
+ else
+ {
+ print "E: Unknown line: $p\n";
+ exit 1;
+ }
+ }
+
+ # Figure out the path
+ # /usr/lib/mono/gac/log4net/1.2.9.0__a5715cc6d5c3540b
+ return "/usr/lib/mono/gac/"
+ . "$hash{Assembly}/$hash{Version}"
+ . "__$hash{PublicKeyToken}/";
+}
More information about the Pkg-mono-svn-commits
mailing list