|
Panu Matilainen |
e91c67 |
commit 7417cd283a3641ee62b282ae36c5d2d7df349d04
|
|
Panu Matilainen |
e91c67 |
Author: Panu Matilainen <pmatilai@redhat.com>
|
|
Panu Matilainen |
e91c67 |
Date: Thu Jun 18 13:06:42 2009 +0300
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
Pile of OSGi dependency generator fixes from Alphonse Van Assche (ticket #39)
|
|
Panu Matilainen |
e91c67 |
- use Temp perl module to provide temp dir
|
|
Panu Matilainen |
e91c67 |
- re-enable deps solving in Require-Bundle, Import-Package, Export-Package
|
|
Panu Matilainen |
e91c67 |
OSGI properties
|
|
Panu Matilainen |
e91c67 |
- remove uses bundle of Export-Package OSGI property
|
|
Panu Matilainen |
e91c67 |
- use RPM '>=' as version operator to match OSGI '='
|
|
Panu Matilainen |
e91c67 |
- remove all .0 at the end of the version string
|
|
Panu Matilainen |
e91c67 |
- typo fixes
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
diff --git a/scripts/osgideps.pl b/scripts/osgideps.pl
|
|
Panu Matilainen |
e91c67 |
index 7b02016..971dade 100644
|
|
Panu Matilainen |
e91c67 |
--- a/scripts/osgideps.pl
|
|
Panu Matilainen |
e91c67 |
+++ b/scripts/osgideps.pl
|
|
Panu Matilainen |
e91c67 |
@@ -1,203 +1,357 @@
|
|
Panu Matilainen |
e91c67 |
#!/usr/bin/perl
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
+#
|
|
Panu Matilainen |
e91c67 |
+# osgideps.pl -- Analyze dependencies of OSGi bundles.
|
|
Panu Matilainen |
e91c67 |
+#
|
|
Panu Matilainen |
e91c67 |
+# Kyu Lee
|
|
Panu Matilainen |
e91c67 |
+# Alphonse Van Assche <alcapcom@fedoraproject.org>
|
|
Panu Matilainen |
e91c67 |
+#
|
|
Panu Matilainen |
e91c67 |
+# $Id: osgideps.pl,v 1.0 2009/06/08 12:12:12 mej Exp $
|
|
Panu Matilainen |
e91c67 |
+#
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
use Cwd;
|
|
Panu Matilainen |
e91c67 |
use Getopt::Long;
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
+use File::Temp qw/ tempdir /;
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
$cdir = getcwd();
|
|
Panu Matilainen |
e91c67 |
-$TEMPDIR="/tmp";
|
|
Panu Matilainen |
e91c67 |
-$MANIFEST_NAME="META-INF/MANIFEST.MF";
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
+$TEMPDIR = tempdir( CLEANUP => 1 );
|
|
Panu Matilainen |
e91c67 |
+$MANIFEST_NAME = "META-INF/MANIFEST.MF";
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
# prepare temporary directory
|
|
Panu Matilainen |
e91c67 |
-if (! (-d $TEMPDIR)) {
|
|
Panu Matilainen |
e91c67 |
- if (($_ = `mkdir $TEMPDIR`) != 0) {exit 1;}
|
|
Panu Matilainen |
e91c67 |
- elsif (! (-w $TEMPDIR) && (-x $TEMPDIR)) {exit 1;}
|
|
Panu Matilainen |
e91c67 |
+if ( !( -d $TEMPDIR ) ) {
|
|
Panu Matilainen |
e91c67 |
+ if ( ( $_ = `mkdir $TEMPDIR` ) != 0 ) { exit 1; }
|
|
Panu Matilainen |
e91c67 |
+ elsif ( !( -w $TEMPDIR ) && ( -x $TEMPDIR ) ) { exit 1; }
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
# parse options
|
|
Panu Matilainen |
e91c67 |
-my ($show_provides, $show_requires);
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
-my $result = GetOptions("provides" => \$show_provides,
|
|
Panu Matilainen |
e91c67 |
- "requires" => \$show_requires);
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
-exit(1) if (not $result);
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
+my ( $show_provides, $show_requires, $show_system_bundles, $debug );
|
|
Panu Matilainen |
e91c67 |
+my $result = GetOptions(
|
|
Panu Matilainen |
e91c67 |
+ "provides" => \$show_provides,
|
|
Panu Matilainen |
e91c67 |
+ "requires" => \$show_requires,
|
|
Panu Matilainen |
e91c67 |
+ "system" => \$show_system_bundles,
|
|
Panu Matilainen |
e91c67 |
+ "debug" => \$debug
|
|
Panu Matilainen |
e91c67 |
+);
|
|
Panu Matilainen |
e91c67 |
+exit(1) if ( not $result );
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
+# run selected function
|
|
Panu Matilainen |
e91c67 |
@allfiles = <STDIN>;
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
if ($show_provides) {
|
|
Panu Matilainen |
e91c67 |
- do_provides(@allfiles);
|
|
Panu Matilainen |
e91c67 |
+ getProvides(@allfiles);
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
if ($show_requires) {
|
|
Panu Matilainen |
e91c67 |
- do_requires(@allfiles);
|
|
Panu Matilainen |
e91c67 |
+ getRequires(@allfiles);
|
|
Panu Matilainen |
e91c67 |
+}
|
|
Panu Matilainen |
e91c67 |
+if ($show_system_bundles) {
|
|
Panu Matilainen |
e91c67 |
+ getSystemBundles(@allfiles);
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
exit(0);
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
-sub do_provides {
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
-foreach $file (@_) {
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
- next if -f $file && -r $file && !-l $file;
|
|
Panu Matilainen |
e91c67 |
- $file =~ s/[^[:print:]]//g;
|
|
Panu Matilainen |
e91c67 |
- if ($file =~ m/$MANIFEST_NAME$/ || $file =~ m/\.jar$/ ) {
|
|
Panu Matilainen |
e91c67 |
- if ($file =~ m/\.jar$/) {
|
|
Panu Matilainen |
e91c67 |
- # if this jar contains MANIFEST.MF file
|
|
Panu Matilainen |
e91c67 |
- if (`jar tf $file | grep -e \^$MANIFEST_NAME` eq "$MANIFEST_NAME\n") {
|
|
Panu Matilainen |
e91c67 |
- # extract MANIFEST.MF file from jar to temporary directory
|
|
Panu Matilainen |
e91c67 |
- chdir $TEMPDIR;
|
|
Panu Matilainen |
e91c67 |
- `jar xf $file $MANIFEST_NAME`;
|
|
Panu Matilainen |
e91c67 |
- open(MANIFEST, "$MANIFEST_NAME");
|
|
Panu Matilainen |
e91c67 |
- chdir $cdir;
|
|
Panu Matilainen |
e91c67 |
+# this function print provides of OSGi aware files
|
|
Panu Matilainen |
e91c67 |
+sub getProvides {
|
|
Panu Matilainen |
e91c67 |
+ foreach $file (@_) {
|
|
Panu Matilainen |
e91c67 |
+ chomp($file);
|
|
Panu Matilainen |
e91c67 |
+ # we don't follow symlinks for provides
|
|
Panu Matilainen |
e91c67 |
+ next if -f $file && -r $file && -l $file;
|
|
Panu Matilainen |
e91c67 |
+ $file =~ s/[^[:print:]]//g;
|
|
Panu Matilainen |
e91c67 |
+ if ( $file =~ m/$MANIFEST_NAME$/ || $file =~ m/\.jar$/ ) {
|
|
Panu Matilainen |
e91c67 |
+ if ( $file =~ m/\.jar$/ ) {
|
|
Panu Matilainen |
e91c67 |
+ if ( `jar tf $file | grep -e \^$MANIFEST_NAME` eq "$MANIFEST_NAME\n" ) {
|
|
Panu Matilainen |
e91c67 |
+ # extract MANIFEST.MF file from jar to temporary directory
|
|
Panu Matilainen |
e91c67 |
+ chdir $TEMPDIR;
|
|
Panu Matilainen |
e91c67 |
+ `jar xf $file $MANIFEST_NAME`;
|
|
Panu Matilainen |
e91c67 |
+ open( MANIFEST, "$MANIFEST_NAME" );
|
|
Panu Matilainen |
e91c67 |
+ chdir $cdir;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ } else {
|
|
Panu Matilainen |
e91c67 |
+ open( MANIFEST, "$file" );
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
- } else {
|
|
Panu Matilainen |
e91c67 |
- open(MANIFEST, "$file");
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- my $bundleName = "";
|
|
Panu Matilainen |
e91c67 |
- my $version = "";
|
|
Panu Matilainen |
e91c67 |
- # parse bundle name and version
|
|
Panu Matilainen |
e91c67 |
- while(<MANIFEST>) {
|
|
Panu Matilainen |
e91c67 |
- # get rid of non-print chars (some manifest files contain weird chars)
|
|
Panu Matilainen |
e91c67 |
- s/[^[:print]]//g;
|
|
Panu Matilainen |
e91c67 |
- if (m/(^Bundle-SymbolicName: )((\w|\.)+)(\;*)(.*\n)/) {
|
|
Panu Matilainen |
e91c67 |
- $bundleName = $2;
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- if (m/(^Bundle-Version: )(.*)/) {
|
|
Panu Matilainen |
e91c67 |
- $version = $2;
|
|
Panu Matilainen |
e91c67 |
- $version = fixVersion($version);
|
|
Panu Matilainen |
e91c67 |
+ my $bundleName = "";
|
|
Panu Matilainen |
e91c67 |
+ my $version = "";
|
|
Panu Matilainen |
e91c67 |
+ # parse Bundle-SymbolicName, Bundle-Version and Export-Package attributes
|
|
Panu Matilainen |
e91c67 |
+ while (<MANIFEST>) {
|
|
Panu Matilainen |
e91c67 |
+ # get rid of non-print chars (some manifest files contain weird chars)
|
|
Panu Matilainen |
e91c67 |
+ s/[^[:print]]//g;
|
|
Panu Matilainen |
e91c67 |
+ if ( m/(^(Bundle-SymbolicName): )(.*)$/ ) {
|
|
Panu Matilainen |
e91c67 |
+ $bundleName = "$3" . "\n";
|
|
Panu Matilainen |
e91c67 |
+ while (<MANIFEST>) {
|
|
Panu Matilainen |
e91c67 |
+ if ( m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) {
|
|
Panu Matilainen |
e91c67 |
+ $len = length $_;
|
|
Panu Matilainen |
e91c67 |
+ seek MANIFEST, $len * -1, 1;
|
|
Panu Matilainen |
e91c67 |
+ last;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ $bundleName .= "$_";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ $bundleName =~ s/\s+//g;
|
|
Panu Matilainen |
e91c67 |
+ $bundleName =~ s/;.*//g;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ if ( m/(^Bundle-Version: )(.*)/ ) {
|
|
Panu Matilainen |
e91c67 |
+ $version = $2;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ if ( m/(^(Export-Package): )(.*)$/ ) {
|
|
Panu Matilainen |
e91c67 |
+ my $bunlist = "$3" . "\n";
|
|
Panu Matilainen |
e91c67 |
+ while (<MANIFEST>) {
|
|
Panu Matilainen |
e91c67 |
+ if ( m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) {
|
|
Panu Matilainen |
e91c67 |
+ $len = length $_;
|
|
Panu Matilainen |
e91c67 |
+ seek MANIFEST, $len * -1, 1;
|
|
Panu Matilainen |
e91c67 |
+ last;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ $bunlist .= "$_";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ push @bundlelist, parsePkgString($bunlist, $file);
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
- if (m/(^(Export-Package): )(.*)$/) {
|
|
Panu Matilainen |
e91c67 |
- my $bunlist = "$3"."\n";
|
|
Panu Matilainen |
e91c67 |
- while(<MANIFEST>) {
|
|
Panu Matilainen |
e91c67 |
- if (m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/) {
|
|
Panu Matilainen |
e91c67 |
- $len = length $_;
|
|
Panu Matilainen |
e91c67 |
- seek MANIFEST, $len*-1 , 1;
|
|
Panu Matilainen |
e91c67 |
- last;
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- $bunlist.="$_";
|
|
Panu Matilainen |
e91c67 |
+
|
|
Panu Matilainen |
e91c67 |
+ # skip this jar if no bundle name exists
|
|
Panu Matilainen |
e91c67 |
+ if ( !$bundleName eq "" ) {
|
|
Panu Matilainen |
e91c67 |
+ if ( !$version eq "" ) {
|
|
Panu Matilainen |
e91c67 |
+ $version = parseVersion($version);
|
|
Panu Matilainen |
e91c67 |
+ push @bundlelist, { FILE => "$file", NAME => "$bundleName", VERSION => "$version" };
|
|
Panu Matilainen |
e91c67 |
+ } else {
|
|
Panu Matilainen |
e91c67 |
+ push @bundlelist, { FILE => "$file", NAME => "$bundleName", VERSION => "" };
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
- push @bundlelist, parsePkgString($bunlist);
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- # skip this jar if no bundle name exists
|
|
Panu Matilainen |
e91c67 |
- if (! $bundleName eq "") {
|
|
Panu Matilainen |
e91c67 |
- if (! $version eq "") {
|
|
Panu Matilainen |
e91c67 |
- print "osgi(".$bundleName.") = ".$version."\n";
|
|
Panu Matilainen |
e91c67 |
- } else {
|
|
Panu Matilainen |
e91c67 |
- print "osgi(".$bundleName.")\n";
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
-}
|
|
Panu Matilainen |
e91c67 |
-$list = "";
|
|
Panu Matilainen |
e91c67 |
-for $bundle (@bundlelist) {
|
|
Panu Matilainen |
e91c67 |
- $list .= "osgi(".$bundle->{NAME}.")".$bundle->{VERSION}."\n";
|
|
Panu Matilainen |
e91c67 |
-}
|
|
Panu Matilainen |
e91c67 |
-# For now we dont take Require-Bundle AND Import-Package in account
|
|
Panu Matilainen |
e91c67 |
-#print $list;
|
|
Panu Matilainen |
e91c67 |
+ if ( !$debug ) { @bundlelist = prepareOSGiBundlesList(@bundlelist); }
|
|
Panu Matilainen |
e91c67 |
+ $list = "";
|
|
Panu Matilainen |
e91c67 |
+ for $bundle (@bundlelist) {
|
|
Panu Matilainen |
e91c67 |
+ if ( !$debug ) {
|
|
Panu Matilainen |
e91c67 |
+ $list .= "osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n";
|
|
Panu Matilainen |
e91c67 |
+ } else {
|
|
Panu Matilainen |
e91c67 |
+ $list .= $bundle->{FILE} . " osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ print $list;
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
-sub do_requires {
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
+# this function print requires of OSGi aware files
|
|
Panu Matilainen |
e91c67 |
+sub getRequires {
|
|
Panu Matilainen |
e91c67 |
foreach $file (@_) {
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
- next if -f $file && -r $file;
|
|
Panu Matilainen |
e91c67 |
+ next if (-f $file && -r $file);
|
|
Panu Matilainen |
e91c67 |
+ # we explicitly requires symlinked jars
|
|
Panu Matilainen |
e91c67 |
+ if (-l $file) {
|
|
Panu Matilainen |
e91c67 |
+ $file = readlink $file;
|
|
Panu Matilainen |
e91c67 |
+ if ( !$file eq "" ) {
|
|
Panu Matilainen |
e91c67 |
+ print "$file" . "\n";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ next;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
$file =~ s/[^[:print:]]//g;
|
|
Panu Matilainen |
e91c67 |
- if ($file =~ m/$MANIFEST_NAME$/ || $file =~ m/\.jar$/ ) {
|
|
Panu Matilainen |
e91c67 |
- if ($file =~ m/\.jar$/) {
|
|
Panu Matilainen |
e91c67 |
- # if this jar contains MANIFEST.MF file
|
|
Panu Matilainen |
e91c67 |
- if (`jar tf $file | grep -e \^$MANIFEST_NAME` eq "$MANIFEST_NAME\n") {
|
|
Panu Matilainen |
e91c67 |
+ if ( $file =~ m/$MANIFEST_NAME$/ || $file =~ m/\.jar$/ ) {
|
|
Panu Matilainen |
e91c67 |
+ if ( $file =~ m/\.jar$/ ) {
|
|
Panu Matilainen |
e91c67 |
+ if ( `jar tf $file | grep -e \^$MANIFEST_NAME` eq "$MANIFEST_NAME\n" ) {
|
|
Panu Matilainen |
e91c67 |
# extract MANIFEST.MF file from jar to temporary directory
|
|
Panu Matilainen |
e91c67 |
- chdir $TEMPDIR;
|
|
Panu Matilainen |
e91c67 |
- `jar xf $file $MANIFEST_NAME`;
|
|
Panu Matilainen |
e91c67 |
- open(MANIFEST, "$MANIFEST_NAME");
|
|
Panu Matilainen |
e91c67 |
+ chdir $TEMPDIR;
|
|
Panu Matilainen |
e91c67 |
+ `jar xf $file $MANIFEST_NAME`;
|
|
Panu Matilainen |
e91c67 |
+ open( MANIFEST, "$MANIFEST_NAME" );
|
|
Panu Matilainen |
e91c67 |
chdir $cdir;
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
- } else {
|
|
Panu Matilainen |
e91c67 |
- open(MANIFEST, "$file");
|
|
Panu Matilainen |
e91c67 |
+ } else {
|
|
Panu Matilainen |
e91c67 |
+ open( MANIFEST, "$file" );
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ while (<MANIFEST>) {
|
|
Panu Matilainen |
e91c67 |
+ if ( m/(^(Require-Bundle|Import-Package): )(.*)$/ ) {
|
|
Panu Matilainen |
e91c67 |
+ my $bunlist = "$3" . "\n";
|
|
Panu Matilainen |
e91c67 |
+ while (<MANIFEST>) {
|
|
Panu Matilainen |
e91c67 |
+ if (m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) {
|
|
Panu Matilainen |
e91c67 |
+ $len = length $_;
|
|
Panu Matilainen |
e91c67 |
+ seek MANIFEST, $len * -1, 1;
|
|
Panu Matilainen |
e91c67 |
+ last;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ $bunlist .= "$_";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ push @bundlelist, parsePkgString($bunlist, $file);
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ # we also explicitly require symlinked jars define by
|
|
Panu Matilainen |
e91c67 |
+ # Bundle-ClassPath attribut
|
|
Panu Matilainen |
e91c67 |
+ if ( m/(^(Bundle-ClassPath): )(.*)$/ ) {
|
|
Panu Matilainen |
e91c67 |
+ $bunclp = "$3" . "\n";
|
|
Panu Matilainen |
e91c67 |
+ while (<MANIFEST>) {
|
|
Panu Matilainen |
e91c67 |
+ if ( m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) {
|
|
Panu Matilainen |
e91c67 |
+ $len = length $_;
|
|
Panu Matilainen |
e91c67 |
+ seek MANIFEST, $len * -1, 1;
|
|
Panu Matilainen |
e91c67 |
+ last;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ $bunclp .= "$_";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ $bunclp =~ s/\ //g;
|
|
Panu Matilainen |
e91c67 |
+ $bunclp =~ s/\n//g;
|
|
Panu Matilainen |
e91c67 |
+ $bunclp =~ s/[^[:print:]]//g;
|
|
Panu Matilainen |
e91c67 |
+ $dir = `dirname $file`;
|
|
Panu Matilainen |
e91c67 |
+ $dir =~ s/\n//g;
|
|
Panu Matilainen |
e91c67 |
+ @jars = split /,/, $bunclp;
|
|
Panu Matilainen |
e91c67 |
+ for $jarfile (@jars) {
|
|
Panu Matilainen |
e91c67 |
+ $jarfile = "$dir\/\.\.\/$jarfile";
|
|
Panu Matilainen |
e91c67 |
+ $jarfile = readlink $jarfile;
|
|
Panu Matilainen |
e91c67 |
+ if ( !$jarfile eq "" ) {
|
|
Panu Matilainen |
e91c67 |
+ print "$jarfile" . "\n";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
- my %reqcomp = ();
|
|
Panu Matilainen |
e91c67 |
- while(<MANIFEST>) {
|
|
Panu Matilainen |
e91c67 |
- if (m/(^(Require-Bundle|Import-Package): )(.*)$/) {
|
|
Panu Matilainen |
e91c67 |
- my $bunlist = "$3"."\n";
|
|
Panu Matilainen |
e91c67 |
- while(<MANIFEST>) {
|
|
Panu Matilainen |
e91c67 |
- if (m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/) {
|
|
Panu Matilainen |
e91c67 |
- $len = length $_;
|
|
Panu Matilainen |
e91c67 |
- seek MANIFEST, $len*-1 , 1;
|
|
Panu Matilainen |
e91c67 |
- last;
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- $bunlist.="$_";
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- push @bundlelist, parsePkgString($bunlist);
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
+ if ( !$debug ) { @bundlelist = prepareOSGiBundlesList(@bundlelist); }
|
|
Panu Matilainen |
e91c67 |
+ $list = "";
|
|
Panu Matilainen |
e91c67 |
+ for $bundle (@bundlelist) {
|
|
Panu Matilainen |
e91c67 |
+ # replace '=' by '>=' because qualifiers are set on provides
|
|
Panu Matilainen |
e91c67 |
+ # but not on requires.
|
|
Panu Matilainen |
e91c67 |
+ $bundle->{VERSION} =~ s/\ =/\ >=/g;
|
|
Panu Matilainen |
e91c67 |
+ if ( !$debug ) {
|
|
Panu Matilainen |
e91c67 |
+ $list .= "osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n";
|
|
Panu Matilainen |
e91c67 |
+ } else {
|
|
Panu Matilainen |
e91c67 |
+ $list .= $bundle->{FILE} . " osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ print $list;
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
-$list = "";
|
|
Panu Matilainen |
e91c67 |
-for $bundle (@bundlelist) {
|
|
Panu Matilainen |
e91c67 |
- $list .= "osgi(".$bundle->{NAME}.")".$bundle->{VERSION}."\n";
|
|
Panu Matilainen |
e91c67 |
-}
|
|
Panu Matilainen |
e91c67 |
-# For now we dont take Require-Bundle AND Import-Package in account
|
|
Panu Matilainen |
e91c67 |
-#print $list;
|
|
Panu Matilainen |
e91c67 |
+# this function print system bundles of OSGi profile files.
|
|
Panu Matilainen |
e91c67 |
+sub getSystemBundles {
|
|
Panu Matilainen |
e91c67 |
+ foreach $file (@_) {
|
|
Panu Matilainen |
e91c67 |
+ if ( -r $file && -r $file ) {
|
|
Panu Matilainen |
e91c67 |
+ print "'$file' file not found or cannot be read!";
|
|
Panu Matilainen |
e91c67 |
+ next;
|
|
Panu Matilainen |
e91c67 |
+ } else {
|
|
Panu Matilainen |
e91c67 |
+ open( PROFILE, "$file" );
|
|
Panu Matilainen |
e91c67 |
+ while (<PROFILE>) {
|
|
Panu Matilainen |
e91c67 |
+ if ( $file =~ m/\.profile$/ ) {
|
|
Panu Matilainen |
e91c67 |
+ if (m/(^(org\.osgi\.framework\.system\.packages)[=|\ ]+)(.*)$/) {
|
|
Panu Matilainen |
e91c67 |
+ $syspkgs = "$3" . "\n";
|
|
Panu Matilainen |
e91c67 |
+ while (<PROFILE>) {
|
|
Panu Matilainen |
e91c67 |
+ if (m/^[a-z]/) {
|
|
Panu Matilainen |
e91c67 |
+ $len = length $_;
|
|
Panu Matilainen |
e91c67 |
+ seek MANIFEST, $len * -1, 1;
|
|
Panu Matilainen |
e91c67 |
+ last;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ $syspkgs .= "$_";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ $syspkgs =~ s/\s+//g;
|
|
Panu Matilainen |
e91c67 |
+ $syspkgs =~ s/\\//g;
|
|
Panu Matilainen |
e91c67 |
+ @bundles = split /,/, $syspkgs;
|
|
Panu Matilainen |
e91c67 |
+ foreach $bundle (@bundles) {
|
|
Panu Matilainen |
e91c67 |
+ print "osgi(" . $bundle . ")\n";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
sub parsePkgString {
|
|
Panu Matilainen |
e91c67 |
- my $bunstr = $_[0];
|
|
Panu Matilainen |
e91c67 |
- my @return;
|
|
Panu Matilainen |
e91c67 |
+ my $bunstr = $_[0];
|
|
Panu Matilainen |
e91c67 |
+ my $file = $_[1];
|
|
Panu Matilainen |
e91c67 |
+ my @return;
|
|
Panu Matilainen |
e91c67 |
$bunstr =~ s/ //g;
|
|
Panu Matilainen |
e91c67 |
- $bunstr =~ s/\n//g;
|
|
Panu Matilainen |
e91c67 |
- $bunstr =~ s/[^[:print:]]//g;
|
|
Panu Matilainen |
e91c67 |
- $bunstr =~ s/("[[:alnum:]|\-|\_|\.|\(|\)|\[|\]]+)(,)([[:alnum:]|\-|\_|\.|\(|\)|\[|\]]+")/$1 $3/g;
|
|
Panu Matilainen |
e91c67 |
- @reqcomp = split /,/g, $bunstr;
|
|
Panu Matilainen |
e91c67 |
- foreach $reqelement (@reqcomp) {
|
|
Panu Matilainen |
e91c67 |
- @reqelementfrmnt = split /;/g, $reqelement;
|
|
Panu Matilainen |
e91c67 |
- $name="";
|
|
Panu Matilainen |
e91c67 |
- $version="";
|
|
Panu Matilainen |
e91c67 |
- $name = $reqelementfrmnt[0];
|
|
Panu Matilainen |
e91c67 |
- for $i (1 .. $#reqelementfrmnt) {
|
|
Panu Matilainen |
e91c67 |
- if ($reqelementfrmnt[$i] =~ m/(^(bundle-|)version=")(.*)(")/){
|
|
Panu Matilainen |
e91c67 |
- $version = $3;
|
|
Panu Matilainen |
e91c67 |
- last;
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- $version = parseVersion($version);
|
|
Panu Matilainen |
e91c67 |
- $version = fixVersion($version);
|
|
Panu Matilainen |
e91c67 |
- # dirty fix for provides that contain " char
|
|
Panu Matilainen |
e91c67 |
+ $bunstr =~ s/\n//g;
|
|
Panu Matilainen |
e91c67 |
+ $bunstr =~ s/[^[:print:]]//g;
|
|
Panu Matilainen |
e91c67 |
+ $bunstr =~ s/("[[:alnum:]|\-|\_|\.|\(|\)|\[|\]]+)(,)([[:alnum:]|\-|\_|\.|\(|\)|\[|\]]+")/$1 $3/g;
|
|
Panu Matilainen |
e91c67 |
+ # remove uses bundle from Export-Package attribute
|
|
Panu Matilainen |
e91c67 |
+ $bunstr =~ s/uses:="[[:alnum:]|\-|\_|\.|\(|\)|\[|\]|,]+"//g;
|
|
Panu Matilainen |
e91c67 |
+ # remove optional dependencies
|
|
Panu Matilainen |
e91c67 |
+ $bunstr =~ s/,.*;resolution:=optional//g;
|
|
Panu Matilainen |
e91c67 |
+ # remove x-friends
|
|
Panu Matilainen |
e91c67 |
+ $bunstr =~ s/;x-friends:="[[:alnum:]|\-|\_|\.|\(|\)|\[|\]|,]+"//g;
|
|
Panu Matilainen |
e91c67 |
+ # remove signatures
|
|
Panu Matilainen |
e91c67 |
+ $bunstr =~ s/Name:.*SHA1-Digest:.*//g;
|
|
Panu Matilainen |
e91c67 |
+ @reqcomp = split /,/, $bunstr;
|
|
Panu Matilainen |
e91c67 |
+ foreach $reqelement (@reqcomp) {
|
|
Panu Matilainen |
e91c67 |
+ @reqelementfrmnt = split /;/, $reqelement;
|
|
Panu Matilainen |
e91c67 |
+ $name = "";
|
|
Panu Matilainen |
e91c67 |
+ $version = "";
|
|
Panu Matilainen |
e91c67 |
+ $name = $reqelementfrmnt[0];
|
|
Panu Matilainen |
e91c67 |
$name =~ s/\"//g;
|
|
Panu Matilainen |
e91c67 |
- push @return, { NAME=>"$name", VERSION=>"$version"};
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
-
|
|
Panu Matilainen |
e91c67 |
- return @return;
|
|
Panu Matilainen |
e91c67 |
+ # ignore 'system.bundle'.
|
|
Panu Matilainen |
e91c67 |
+ # see http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.platform.doc.isv/porting/3.3/incompatibilities.html
|
|
Panu Matilainen |
e91c67 |
+ next if ( $name =~ m/^system\.bundle$/ );
|
|
Panu Matilainen |
e91c67 |
+ for $i ( 1 .. $#reqelementfrmnt ) {
|
|
Panu Matilainen |
e91c67 |
+ if ( $reqelementfrmnt[$i] =~ m/(^(bundle-|)version=")(.*)(")/ ) {
|
|
Panu Matilainen |
e91c67 |
+ $version = $3;
|
|
Panu Matilainen |
e91c67 |
+ last;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ $version = parseVersion($version);
|
|
Panu Matilainen |
e91c67 |
+ push @return, { FILE => "$file", NAME => "$name", VERSION => "$version" };
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ return @return;
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
sub parseVersion {
|
|
Panu Matilainen |
e91c67 |
- my $ver = $_[0];
|
|
Panu Matilainen |
e91c67 |
- if ($ver eq "") { return "";}
|
|
Panu Matilainen |
e91c67 |
- if ($ver =~ m/(^[\[|\(])(.+)\ (.+)([\]|\)]$)/) {
|
|
Panu Matilainen |
e91c67 |
- # FIXME: The right rpm match of osgi version [1,2) seems to be <= 2
|
|
Panu Matilainen |
e91c67 |
- # but when you look at the requires >= look more permssive/correct?
|
|
Panu Matilainen |
e91c67 |
- ($1 eq "\[") ? return " >= $2" : return " > $2";
|
|
Panu Matilainen |
e91c67 |
- } else {
|
|
Panu Matilainen |
e91c67 |
- return " = $ver";
|
|
Panu Matilainen |
e91c67 |
- }
|
|
Panu Matilainen |
e91c67 |
- return $ver;
|
|
Panu Matilainen |
e91c67 |
+ my $ver = $_[0];
|
|
Panu Matilainen |
e91c67 |
+ if ( $ver eq "" ) { return ""; }
|
|
Panu Matilainen |
e91c67 |
+ if ( $ver =~ m/(^[\[|\(])(.+)\ (.+)([\]|\)]$)/ ) {
|
|
Panu Matilainen |
e91c67 |
+ if ( $1 eq "\[" ) {
|
|
Panu Matilainen |
e91c67 |
+ $ver = " >= $2";
|
|
Panu Matilainen |
e91c67 |
+ } else {
|
|
Panu Matilainen |
e91c67 |
+ $ver = " > $2";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ } else {
|
|
Panu Matilainen |
e91c67 |
+ $ver = " = $ver";
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ # we always return a full OSGi version to be able to match 1.0
|
|
Panu Matilainen |
e91c67 |
+ # and 1.0.0 as equal in RPM.
|
|
Panu Matilainen |
e91c67 |
+ ( $major, $minor, $micro, $qualifier ) = split( '\.', $ver );
|
|
Panu Matilainen |
e91c67 |
+ if ( !defined($minor) || !$minor ) {
|
|
Panu Matilainen |
e91c67 |
+ $minor = 0;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ if ( !defined($micro) || !$micro ) {
|
|
Panu Matilainen |
e91c67 |
+ $micro = 0;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ if ( !defined($qualifier) || !$qualifier ) {
|
|
Panu Matilainen |
e91c67 |
+ $qualifier = "";
|
|
Panu Matilainen |
e91c67 |
+ } else {
|
|
Panu Matilainen |
e91c67 |
+ $qualifier = "." . $qualifier;
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ $ver = $major . "." . $minor . "." . $micro . $qualifier;
|
|
Panu Matilainen |
e91c67 |
+ return $ver;
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
-sub fixVersion {
|
|
Panu Matilainen |
e91c67 |
- my $version = $_[0];
|
|
Panu Matilainen |
e91c67 |
- # remove version qualifier.
|
|
Panu Matilainen |
e91c67 |
- $version =~ s/\.v.[0-9]*.*//g;
|
|
Panu Matilainen |
e91c67 |
- # We try to match RPM version, so remove last .0
|
|
Panu Matilainen |
e91c67 |
- $version =~ s/\.0$//g;
|
|
Panu Matilainen |
e91c67 |
- return $version;
|
|
Panu Matilainen |
e91c67 |
+# this function put the max version on each bundles to be able to remove
|
|
Panu Matilainen |
e91c67 |
+# duplicate deps with 'sort -u' command.
|
|
Panu Matilainen |
e91c67 |
+sub prepareOSGiBundlesList {
|
|
Panu Matilainen |
e91c67 |
+ foreach $bundle (@_) {
|
|
Panu Matilainen |
e91c67 |
+ foreach $cmp (@_) {
|
|
Panu Matilainen |
e91c67 |
+ if ( $bundle->{NAME} eq $cmp->{NAME} ) {
|
|
Panu Matilainen |
e91c67 |
+ $result = compareVersion( $bundle->{VERSION}, $cmp->{VERSION} );
|
|
Panu Matilainen |
e91c67 |
+ if ( $result < 0 ) {
|
|
Panu Matilainen |
e91c67 |
+ $bundle->{VERSION} = $cmp->{VERSION};
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ }
|
|
Panu Matilainen |
e91c67 |
+ return @_;
|
|
Panu Matilainen |
e91c67 |
}
|
|
Panu Matilainen |
e91c67 |
|
|
Panu Matilainen |
e91c67 |
+# this function returns a negative integer, zero, or a positive integer if
|
|
Panu Matilainen |
e91c67 |
+# $ver1 is less than, equal to, or greater than $ver2.
|
|
Panu Matilainen |
e91c67 |
+#
|
|
Panu Matilainen |
e91c67 |
+# REMEMBER: we mimic org.osgi.framework.Version#compareTo method but
|
|
Panu Matilainen |
e91c67 |
+# *at this time* we don't take care of the qualifier part of the version.
|
|
Panu Matilainen |
e91c67 |
+sub compareVersion {
|
|
Panu Matilainen |
e91c67 |
+ my $ver1 = $_[0];
|
|
Panu Matilainen |
e91c67 |
+ my $ver2 = $_[1];
|
|
Panu Matilainen |
e91c67 |
+
|
|
Panu Matilainen |
e91c67 |
+ $ver1 = "0.0.0" if ( $ver1 eq "" );
|
|
Panu Matilainen |
e91c67 |
+ $ver2 = "0.0.0" if ( $ver2 eq "" );
|
|
Panu Matilainen |
e91c67 |
+
|
|
Panu Matilainen |
e91c67 |
+ $ver1 =~ m/([0-9]+)(\.)([0-9]+)(\.)([0-9]+)/;
|
|
Panu Matilainen |
e91c67 |
+ $major1 = $1;
|
|
Panu Matilainen |
e91c67 |
+ $minor1 = $3;
|
|
Panu Matilainen |
e91c67 |
+ $micro1 = $5;
|
|
Panu Matilainen |
e91c67 |
+
|
|
Panu Matilainen |
e91c67 |
+ $ver2 =~ m/([0-9]+)(\.)([0-9]+)(\.)([0-9]+)/;
|
|
Panu Matilainen |
e91c67 |
+ $major2 = $1;
|
|
Panu Matilainen |
e91c67 |
+ $minor2 = $3;
|
|
Panu Matilainen |
e91c67 |
+ $micro2 = $5;
|
|
Panu Matilainen |
e91c67 |
+
|
|
Panu Matilainen |
e91c67 |
+ $result = $major1 - $major2;
|
|
Panu Matilainen |
e91c67 |
+ return $result if ( $result != 0 );
|
|
Panu Matilainen |
e91c67 |
+
|
|
Panu Matilainen |
e91c67 |
+ $result = $minor1 - $minor2;
|
|
Panu Matilainen |
e91c67 |
+ return $result if ( $result != 0 );
|
|
Panu Matilainen |
e91c67 |
+
|
|
Panu Matilainen |
e91c67 |
+ $result = $micro1 - $micro2;
|
|
Panu Matilainen |
e91c67 |
+ return $result if ( $result != 0 );
|
|
Panu Matilainen |
e91c67 |
+
|
|
Panu Matilainen |
e91c67 |
+ return $result;
|
|
Panu Matilainen |
e91c67 |
+}
|