rpm/rpm-4.4.2.2-osgideps.patch

198 lines
6.1 KiB
Diff
Raw Normal View History

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