teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.4.2.2-osgideps.patch

Panu Matilainen 6a747f
changeset:   6184:9de21aa6bd62
Panu Matilainen 6a747f
tag:         tip
Panu Matilainen 6a747f
user:        Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen 6a747f
date:        Thu Sep 06 08:19:03 2007 +0300
Panu Matilainen 6a747f
files:       scripts/Makefile.am scripts/osgideps.pl
Panu Matilainen 6a747f
description:
Panu Matilainen 6a747f
Add OSGi dependency extractor script from Kyu Lee
Panu Matilainen 6a747f
(transplanted from 838c8ccfcf2619369e76bdca375721e049052dc8)
Panu Matilainen 6a747f
Panu Matilainen 6a747f
Panu Matilainen 6a747f
diff -r 358dd9d838a6 -r 9de21aa6bd62 scripts/Makefile.am
Panu Matilainen 6a747f
--- a/scripts/Makefile.am	Thu Oct 11 14:14:00 2007 +0300
Panu Matilainen 6a747f
+++ b/scripts/Makefile.am	Thu Sep 06 08:19:03 2007 +0300
Panu Matilainen 6a747f
@@ -21,7 +21,7 @@ EXTRA_DIST = \
Panu Matilainen 6a747f
 	sql.prov sql.req tcl.req tgpg trpm u_pkg.sh \
Panu Matilainen 6a747f
 	vpkg-provides.sh vpkg-provides2.sh \
Panu Matilainen 6a747f
 	macros.perl* macros.python* \
Panu Matilainen 6a747f
-	macros.php* find-*.php find-php-* mono-find*
Panu Matilainen 6a747f
+	macros.php* find-*.php find-php-* mono-find* osgideps.pl
Panu Matilainen 6a747f
 
Panu Matilainen 6a747f
 installprefix = $(DESTDIR)
Panu Matilainen 6a747f
 
Panu Matilainen 6a747f
@@ -38,7 +38,7 @@ config_SCRIPTS = \
Panu Matilainen 6a747f
 	cpanflute cpanflute2 Specfile.pm find-provides.perl \
Panu Matilainen 6a747f
 	find-requires.perl freshen.sh get_magic.pl getpo.sh http.req \
Panu Matilainen 6a747f
 	magic.prov magic.req perldeps.pl perl.prov perl.req pythondeps.sh \
Panu Matilainen 6a747f
-	mono-find-requires mono-find-provides \
Panu Matilainen 6a747f
+	mono-find-requires mono-find-provides osgideps.pl \
Panu Matilainen 6a747f
 	rpmdb_loadcvt rpmdiff rpmdiff.cgi \
Panu Matilainen 6a747f
 	rpm.daily rpm.log rpm.xinetd rpm2cpio.sh \
Panu Matilainen 6a747f
 	sql.prov sql.req tcl.req tgpg trpm u_pkg.sh \
Panu Matilainen 6a747f
diff -r 358dd9d838a6 -r 9de21aa6bd62 scripts/osgideps.pl
Panu Matilainen 6a747f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
Panu Matilainen 6a747f
+++ b/scripts/osgideps.pl	Thu Sep 06 08:19:03 2007 +0300
Panu Matilainen 6a747f
@@ -0,0 +1,161 @@
Panu Matilainen 6a747f
+#!/usr/bin/perl
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+use Cwd;
Panu Matilainen 6a747f
+use Getopt::Long;
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+$cdir = getcwd();
Panu Matilainen 6a747f
+$TEMPDIR="/tmp";
Panu Matilainen 6a747f
+$MANIFEST_NAME="META-INF/MANIFEST.MF";
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+# prepare temporary directory
Panu Matilainen 6a747f
+if (! (-d $TEMPDIR)) {
Panu Matilainen 6a747f
+        if (($_ = `mkdir $TEMPDIR`) != 0) {exit 1;}
Panu Matilainen 6a747f
+        elsif (! (-w $TEMPDIR) && (-x $TEMPDIR)) {exit 1;}
Panu Matilainen 6a747f
+}
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+# parse options
Panu Matilainen 6a747f
+my ($show_provides, $show_requires);
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+my $result = GetOptions("provides" => \$show_provides,
Panu Matilainen 6a747f
+			"requires" => \$show_requires);
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+exit(1) if (not $result);
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+@allfiles = <STDIN>;
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+if ($show_provides) {
Panu Matilainen 6a747f
+	do_provides(@allfiles);
Panu Matilainen 6a747f
+}
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+if ($show_requires) {
Panu Matilainen 6a747f
+	do_requires(@allfiles);
Panu Matilainen 6a747f
+}
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+exit(0);
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+sub do_provides {
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+foreach $jar (@_) {
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+next if -f $jar && -r $jar;
Panu Matilainen 6a747f
+ $jar =~ s/[^[:print:]]//g;
Panu Matilainen 6a747f
+        # if this jar contains MANIFEST.MF file
Panu Matilainen 6a747f
+        if (`jar tf $jar | grep -e \^$MANIFEST_NAME` eq "$MANIFEST_NAME\n") {
Panu Matilainen 6a747f
+                # extract MANIFEST.MF file from jar to temporary directory
Panu Matilainen 6a747f
+                chdir $TEMPDIR;
Panu Matilainen 6a747f
+                `jar xf $cdir/$jar $MANIFEST_NAME`;
Panu Matilainen 6a747f
+                open(MANIFEST, "$MANIFEST_NAME");
Panu Matilainen 6a747f
+                my $bundleName = "";
Panu Matilainen 6a747f
+                my $bundleVersion = "";
Panu Matilainen 6a747f
+                # parse bundle name and version
Panu Matilainen 6a747f
+                while(<MANIFEST>) {
Panu Matilainen 6a747f
+                        # get rid of non-print chars (some manifest files contain weird chars
Panu Matilainen 6a747f
+                        s/[^[:print]]//g;
Panu Matilainen 6a747f
+                        if (m/(^Bundle-SymbolicName: )((\w|\.)+)(\;*)(.*\n)/) {
Panu Matilainen 6a747f
+                                $bundleName = $2;
Panu Matilainen 6a747f
+                        }
Panu Matilainen 6a747f
+                        if (m/(^Bundle-Version: )(.*)/) {
Panu Matilainen 6a747f
+                                $bundleVersion = $2;
Panu Matilainen 6a747f
+                        }
Panu Matilainen 6a747f
+                }
Panu Matilainen 6a747f
+                # skip this jar if no bundle name exists
Panu Matilainen 6a747f
+                if (! $bundleName eq "") {
Panu Matilainen 6a747f
+                        if (! $bundleVersion eq "") {
Panu Matilainen 6a747f
+                                print "osgi(".$bundleName.") = ".$bundleVersion."\n";
Panu Matilainen 6a747f
+                        } else {
Panu Matilainen 6a747f
+                                print "osgi(".$bundleName.")\n";
Panu Matilainen 6a747f
+                        }
Panu Matilainen 6a747f
+                }
Panu Matilainen 6a747f
+                chdir $cdir;
Panu Matilainen 6a747f
+        }
Panu Matilainen 6a747f
+	
Panu Matilainen 6a747f
+}
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+}
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+sub do_requires {
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+foreach $jar (@_) {
Panu Matilainen 6a747f
+next if -f $jar && -r $jar;
Panu Matilainen 6a747f
+$jar =~ s/[^[:print:]]//g;
Panu Matilainen 6a747f
+        if (`jar tf $jar | grep -e \^$MANIFEST_NAME` eq "$MANIFEST_NAME\n") {
Panu Matilainen 6a747f
+                chdir $TEMPDIR;
Panu Matilainen 6a747f
+                `jar xf $cdir/$jar $MANIFEST_NAME`;
Panu Matilainen 6a747f
+                open(MANIFEST, "$MANIFEST_NAME") or die;
Panu Matilainen 6a747f
+                my %reqcomp = ();
Panu Matilainen 6a747f
+                while(<MANIFEST>) {
Panu Matilainen 6a747f
+                        if (m/(^(Require-Bundle|Import-Package): )(.*)$/) {
Panu Matilainen 6a747f
+                                my $reqlist = "$3"."\n";
Panu Matilainen 6a747f
+                                while(<MANIFEST>) {
Panu Matilainen 6a747f
+                                        if (m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/) {
Panu Matilainen 6a747f
+                                                $len = length $_;
Panu Matilainen 6a747f
+                                                seek MANIFEST, $len*-1 , 1;
Panu Matilainen 6a747f
+                                                last;
Panu Matilainen 6a747f
+                                        }
Panu Matilainen 6a747f
+                                        $reqlist.="$_";
Panu Matilainen 6a747f
+                                }
Panu Matilainen 6a747f
+                                push @requirelist,  parseReqString($reqlist);
Panu Matilainen 6a747f
+                        }
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+                }
Panu Matilainen 6a747f
+                chdir $cdir;
Panu Matilainen 6a747f
+	}
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+}
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+$list = "";
Panu Matilainen 6a747f
+for $require (@requirelist) {
Panu Matilainen 6a747f
+        $list .= "osgi(".$require->{NAME}.")".$require->{VERSION}."\n";
Panu Matilainen 6a747f
+}
Panu Matilainen 6a747f
+#$abc = `echo \"$list\"|grep -e \^osgi\\(.*\\)| sort|uniq`;
Panu Matilainen 6a747f
+print $list;
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+}
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+sub parseReqString {
Panu Matilainen 6a747f
+        my $reqstr = $_[0];
Panu Matilainen 6a747f
+        my @return;
Panu Matilainen 6a747f
+        $reqstr =~ s/ //g;
Panu Matilainen 6a747f
+        $reqstr =~ s/\n//g;
Panu Matilainen 6a747f
+        $reqstr =~ s/[^[:print:]]//g;
Panu Matilainen 6a747f
+        $reqstr =~ s/("[[:alnum:]|\-|\_|\.|\(|\)|\[|\]]+)(,)([[:alnum:]|\-|\_|\.|\(|\)|\[|\]]+")/$1 $3/g;
Panu Matilainen 6a747f
+        @reqcomp = split /,/g, $reqstr;
Panu Matilainen 6a747f
+        foreach $reqelement (@reqcomp) {
Panu Matilainen 6a747f
+                @reqelementfrmnt = split /;/g, $reqelement;
Panu Matilainen 6a747f
+                $name="";
Panu Matilainen 6a747f
+                $version="";
Panu Matilainen 6a747f
+                $name = $reqelementfrmnt[0];
Panu Matilainen 6a747f
+                for $i (1 .. $#reqelementfrmnt) {
Panu Matilainen 6a747f
+                        if ($reqelementfrmnt[$i] =~ m/(^(bundle-|)version=")(.*)(")/){
Panu Matilainen 6a747f
+                                $version = $3;
Panu Matilainen 6a747f
+                                last;
Panu Matilainen 6a747f
+                        }
Panu Matilainen 6a747f
+                }
Panu Matilainen 6a747f
+                $version = parseVersion($version);
Panu Matilainen 6a747f
+                push @return, { NAME=>"$name", VERSION=>"$version"};
Panu Matilainen 6a747f
+        }
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+        return @return;
Panu Matilainen 6a747f
+}
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f
+sub parseVersion {
Panu Matilainen 6a747f
+        my $ver = $_[0];
Panu Matilainen 6a747f
+        if ($ver eq "") { return "";}
Panu Matilainen 6a747f
+        if ($ver =~ m/(^[\[|\(])(.+)\ (.+)([\]|\)]$)/) {
Panu Matilainen 6a747f
+                ($1 eq "\[") ? return " <= $2" : return " < $2";
Panu Matilainen 6a747f
+        } else {
Panu Matilainen 6a747f
+                return " = $ver";
Panu Matilainen 6a747f
+        }
Panu Matilainen 6a747f
+        return $ver;
Panu Matilainen 6a747f
+}
Panu Matilainen 6a747f
+
Panu Matilainen 6a747f