| 51 | | chomp($file); |
|---|
| 52 | | # we don't follow symlinks for provides |
|---|
| 53 | | next if -f $file && -r $file && -l $file; |
|---|
| 54 | | $file =~ s/[^[:print:]]//g; |
|---|
| 55 | | if ( $file =~ m/$MANIFEST_NAME$/ || $file =~ m/\.jar$/ ) { |
|---|
| 56 | | if ( $file =~ m/\.jar$/ ) { |
|---|
| 57 | | if ( `jar tf $file | grep -e \^$MANIFEST_NAME` eq "$MANIFEST_NAME\n" ) { |
|---|
| 58 | | # extract MANIFEST.MF file from jar to temporary directory |
|---|
| 59 | | chdir $TEMPDIR; |
|---|
| 60 | | `jar xf $file $MANIFEST_NAME`; |
|---|
| 61 | | open( MANIFEST, "$MANIFEST_NAME" ); |
|---|
| 62 | | chdir $cdir; |
|---|
| | 45 | $queue->enqueue($file); |
|---|
| | 46 | } |
|---|
| | 47 | |
|---|
| | 48 | my @workers; |
|---|
| | 49 | push @workers, threads->create('getProvidesWorker'); |
|---|
| | 50 | push @workers, threads->create('getProvidesWorker'); |
|---|
| | 51 | push @workers, threads->create('getProvidesWorker'); |
|---|
| | 52 | push @workers, threads->create('getProvidesWorker'); |
|---|
| | 53 | |
|---|
| | 54 | map { $_->join } @workers; |
|---|
| | 55 | |
|---|
| | 56 | sub getProvidesWorker { |
|---|
| | 57 | while ( my $file = $queue->dequeue_nb ) { |
|---|
| | 58 | chomp($file); |
|---|
| | 59 | # we don't follow symlinks for provides |
|---|
| | 60 | next if ( -f $file && -r $file && -l $file ); |
|---|
| | 61 | $file =~ s/[^[:print:]]//g; |
|---|
| | 62 | if ( $file =~ m/$MANIFEST_NAME$/ || $file =~ m/\.jar$/ ) { |
|---|
| | 63 | if ( $file =~ m/\.jar$/ ) { |
|---|
| | 64 | if ( `zipinfo -1 $file 2> /dev/null | grep -e \^$MANIFEST_NAME` eq "$MANIFEST_NAME\n" ) { |
|---|
| | 65 | # extract MANIFEST.MF file from jar to temporary directory |
|---|
| | 66 | $tmpdir = tempdir( CLEANUP => 1 ); |
|---|
| | 67 | `unzip -d $tmpdir -qqo $file $MANIFEST_NAME`; |
|---|
| | 68 | open( MANIFEST, "$tmpdir/$MANIFEST_NAME" ); |
|---|
| | 69 | } |
|---|
| | 70 | } else { |
|---|
| | 71 | open( MANIFEST, "$file" ); |
|---|
| 64 | | } else { |
|---|
| 65 | | open( MANIFEST, "$file" ); |
|---|
| 66 | | } |
|---|
| 67 | | my $bundleName = ""; |
|---|
| 68 | | my $version = ""; |
|---|
| 69 | | # parse Bundle-SymbolicName, Bundle-Version and Export-Package attributes |
|---|
| 70 | | while (<MANIFEST>) { |
|---|
| 71 | | # get rid of non-print chars (some manifest files contain weird chars) |
|---|
| 72 | | s/[^[:print]]//g; |
|---|
| 73 | | if ( m/(^(Bundle-SymbolicName): )(.*)$/ ) { |
|---|
| 74 | | $bundleName = "$3" . "\n"; |
|---|
| 75 | | while (<MANIFEST>) { |
|---|
| 76 | | if ( m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) { |
|---|
| 77 | | $len = length $_; |
|---|
| 78 | | seek MANIFEST, $len * -1, 1; |
|---|
| 79 | | last; |
|---|
| | 73 | my $bundleName = ""; |
|---|
| | 74 | my $version = ""; |
|---|
| | 75 | # parse Bundle-SymbolicName, Bundle-Version and Export-Package attributes |
|---|
| | 76 | while (<MANIFEST>) { |
|---|
| | 77 | # get rid of non-print chars (some manifest files contain weird chars) |
|---|
| | 78 | s/[^[:print]]//g; |
|---|
| | 79 | if ( m/(^(Bundle-SymbolicName): )(.*)$/ ) { |
|---|
| | 80 | $bundleName = "$3" . "\n"; |
|---|
| | 81 | while (<MANIFEST>) { |
|---|
| | 82 | if ( m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) { |
|---|
| | 83 | $len = length $_; |
|---|
| | 84 | seek MANIFEST, $len * -1, 1; |
|---|
| | 85 | last; |
|---|
| | 86 | } |
|---|
| | 87 | $bundleName .= "$_"; |
|---|
| 83 | | $bundleName =~ s/\s+//g; |
|---|
| 84 | | $bundleName =~ s/;.*//g; |
|---|
| 85 | | } |
|---|
| 86 | | if ( m/(^Bundle-Version: )(.*)/ ) { |
|---|
| 87 | | $version = $2; |
|---|
| 88 | | } |
|---|
| 89 | | if ( m/(^(Export-Package): )(.*)$/ ) { |
|---|
| 90 | | my $bunlist = "$3" . "\n"; |
|---|
| 91 | | while (<MANIFEST>) { |
|---|
| 92 | | if ( m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) { |
|---|
| 93 | | $len = length $_; |
|---|
| 94 | | seek MANIFEST, $len * -1, 1; |
|---|
| 95 | | last; |
|---|
| | 92 | if ( m/(^Bundle-Version: )(.*)/ ) { |
|---|
| | 93 | $version = $2; |
|---|
| | 94 | } |
|---|
| | 95 | if ( m/(^(Export-Package): )(.*)$/ ) { |
|---|
| | 96 | my $bunlist = "$3" . "\n"; |
|---|
| | 97 | while (<MANIFEST>) { |
|---|
| | 98 | if ( m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) { |
|---|
| | 99 | $len = length $_; |
|---|
| | 100 | seek MANIFEST, $len * -1, 1; |
|---|
| | 101 | last; |
|---|
| | 102 | } |
|---|
| | 103 | $bunlist .= "$_"; |
|---|
| 97 | | $bunlist .= "$_"; |
|---|
| | 105 | push @bundlelist, parsePkgString($bunlist, $file); |
|---|
| | 106 | } |
|---|
| | 107 | } |
|---|
| | 108 | |
|---|
| | 109 | # skip this jar if no bundle name exists |
|---|
| | 110 | if ( !$bundleName eq "" ) { |
|---|
| | 111 | if ( !$version eq "" ) { |
|---|
| | 112 | $version = parseVersion($version); |
|---|
| | 113 | push @bundlelist, { FILE => "$file", NAME => "$bundleName", VERSION => "$version" }; |
|---|
| | 114 | } else { |
|---|
| | 115 | push @bundlelist, { FILE => "$file", NAME => "$bundleName", VERSION => "" }; |
|---|
| 99 | | push @bundlelist, parsePkgString($bunlist, $file); |
|---|
| 100 | | } |
|---|
| 101 | | } |
|---|
| 102 | | |
|---|
| 103 | | # skip this jar if no bundle name exists |
|---|
| 104 | | if ( !$bundleName eq "" ) { |
|---|
| 105 | | if ( !$version eq "" ) { |
|---|
| 106 | | $version = parseVersion($version); |
|---|
| 107 | | push @bundlelist, { FILE => "$file", NAME => "$bundleName", VERSION => "$version" }; |
|---|
| 108 | | } else { |
|---|
| 109 | | push @bundlelist, { FILE => "$file", NAME => "$bundleName", VERSION => "" }; |
|---|
| 113 | | } |
|---|
| 114 | | if ( !$debug ) { @bundlelist = prepareOSGiBundlesList(@bundlelist); } |
|---|
| 115 | | $list = ""; |
|---|
| 116 | | for $bundle (@bundlelist) { |
|---|
| 117 | | if ( !$debug ) { |
|---|
| 118 | | $list .= "osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n"; |
|---|
| 119 | | } else { |
|---|
| 120 | | $list .= $bundle->{FILE} . " osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n"; |
|---|
| | 121 | if ( !$debug ) { @bundlelist = prepareOSGiBundlesList(@bundlelist); } |
|---|
| | 122 | $list = ""; |
|---|
| | 123 | for $bundle (@bundlelist) { |
|---|
| | 124 | if ( !$debug ) { |
|---|
| | 125 | $list .= "osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n"; |
|---|
| | 126 | } else { |
|---|
| | 127 | $list .= $bundle->{FILE} . " osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n"; |
|---|
| | 128 | } |
|---|
| 129 | | next if (-f $file && -r $file); |
|---|
| 130 | | # we explicitly requires symlinked jars |
|---|
| 131 | | if (-l $file) { |
|---|
| 132 | | $file = readlink $file; |
|---|
| 133 | | if ( !$file eq "" ) { |
|---|
| 134 | | print "$file" . "\n"; |
|---|
| 135 | | } |
|---|
| 136 | | next; |
|---|
| 137 | | } |
|---|
| 138 | | $file =~ s/[^[:print:]]//g; |
|---|
| 139 | | if ( $file =~ m/$MANIFEST_NAME$/ || $file =~ m/\.jar$/ ) { |
|---|
| 140 | | if ( $file =~ m/\.jar$/ ) { |
|---|
| 141 | | if ( `jar tf $file | grep -e \^$MANIFEST_NAME` eq "$MANIFEST_NAME\n" ) { |
|---|
| 142 | | # extract MANIFEST.MF file from jar to temporary directory |
|---|
| 143 | | chdir $TEMPDIR; |
|---|
| 144 | | `jar xf $file $MANIFEST_NAME`; |
|---|
| 145 | | open( MANIFEST, "$MANIFEST_NAME" ); |
|---|
| 146 | | chdir $cdir; |
|---|
| 147 | | } |
|---|
| 148 | | } else { |
|---|
| 149 | | open( MANIFEST, "$file" ); |
|---|
| 150 | | } |
|---|
| 151 | | while (<MANIFEST>) { |
|---|
| 152 | | if ( m/(^(Require-Bundle|Import-Package): )(.*)$/ ) { |
|---|
| 153 | | my $bunlist = "$3" . "\n"; |
|---|
| 154 | | while (<MANIFEST>) { |
|---|
| 155 | | if (m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) { |
|---|
| 156 | | $len = length $_; |
|---|
| 157 | | seek MANIFEST, $len * -1, 1; |
|---|
| | 139 | $queue->enqueue($file); |
|---|
| | 140 | } |
|---|
| | 141 | |
|---|
| | 142 | my @workers; |
|---|
| | 143 | push @workers, threads->create('getRequiresWorker'); |
|---|
| | 144 | push @workers, threads->create('getRequiresWorker'); |
|---|
| | 145 | push @workers, threads->create('getRequiresWorker'); |
|---|
| | 146 | push @workers, threads->create('getRequiresWorker'); |
|---|
| | 147 | |
|---|
| | 148 | map { $_->join } @workers; |
|---|
| | 149 | |
|---|
| | 150 | sub getRequiresWorker { |
|---|
| | 151 | while ( my $file = $queue->dequeue_nb ) { |
|---|
| | 152 | next if ( -f $file && -r $file ); |
|---|
| | 153 | $file =~ s/[^[:print:]]//g; |
|---|
| | 154 | if ( $file =~ m/$MANIFEST_NAME$/ || $file =~ m/\.jar$/ ) { |
|---|
| | 155 | # we explicitly requires symlinked jars |
|---|
| | 156 | # _that_reside_outside_the_package_ |
|---|
| | 157 | if (-l $file) { |
|---|
| | 158 | $exist = 0; |
|---|
| | 159 | $lnksrc = `readlink -qen $file`; |
|---|
| | 160 | foreach $exfile ( @allfiles ) { |
|---|
| | 161 | $exfile =~ s/[^[:print:]]//g; |
|---|
| | 162 | if ( $lnksrc =~ m/$exfile$/ ) { |
|---|
| | 163 | $exist = 1; |
|---|
| 162 | | push @bundlelist, parsePkgString($bunlist, $file); |
|---|
| | 167 | print "$lnksrc\n" if (!$exist); |
|---|
| | 168 | next; |
|---|
| | 169 | } |
|---|
| | 170 | |
|---|
| | 171 | if ( $file =~ m/\.jar$/ ) { |
|---|
| | 172 | if ( `zipinfo -1 $file 2> /dev/null | grep -e \^$MANIFEST_NAME` eq "$MANIFEST_NAME\n" ) { |
|---|
| | 173 | # extract MANIFEST.MF file from jar to temporary directory |
|---|
| | 174 | $tmpdir = tempdir( CLEANUP => 1 ); |
|---|
| | 175 | `unzip -d $tmpdir -qqo $file $MANIFEST_NAME`; |
|---|
| | 176 | open( MANIFEST, "$tmpdir/$MANIFEST_NAME" ); |
|---|
| | 177 | } |
|---|
| | 178 | } else { |
|---|
| | 179 | open( MANIFEST, "$file" ); |
|---|
| 164 | | # we also explicitly require symlinked jars define by |
|---|
| 165 | | # Bundle-ClassPath attribut |
|---|
| 166 | | if ( m/(^(Bundle-ClassPath): )(.*)$/ ) { |
|---|
| 167 | | $bunclp = "$3" . "\n"; |
|---|
| 168 | | while (<MANIFEST>) { |
|---|
| 169 | | if ( m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) { |
|---|
| 170 | | $len = length $_; |
|---|
| 171 | | seek MANIFEST, $len * -1, 1; |
|---|
| 172 | | last; |
|---|
| | 181 | while (<MANIFEST>) { |
|---|
| | 182 | if ( m/(^(Require-Bundle|Import-Package): )(.*)$/ ) { |
|---|
| | 183 | my $bunlist = "$3" . "\n"; |
|---|
| | 184 | while (<MANIFEST>) { |
|---|
| | 185 | if (m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) { |
|---|
| | 186 | $len = length $_; |
|---|
| | 187 | seek MANIFEST, $len * -1, 1; |
|---|
| | 188 | last; |
|---|
| | 189 | } |
|---|
| | 190 | $bunlist .= "$_"; |
|---|
| 176 | | $bunclp =~ s/\ //g; |
|---|
| 177 | | $bunclp =~ s/\n//g; |
|---|
| 178 | | $bunclp =~ s/[^[:print:]]//g; |
|---|
| 179 | | $dir = `dirname $file`; |
|---|
| 180 | | $dir =~ s/\n//g; |
|---|
| 181 | | @jars = split /,/, $bunclp; |
|---|
| 182 | | for $jarfile (@jars) { |
|---|
| 183 | | $jarfile = "$dir\/\.\.\/$jarfile"; |
|---|
| 184 | | $jarfile = readlink $jarfile; |
|---|
| 185 | | if ( !$jarfile eq "" ) { |
|---|
| 186 | | print "$jarfile" . "\n"; |
|---|
| | 194 | # we also explicitly require symlinked jars define by |
|---|
| | 195 | # Bundle-ClassPath attribut |
|---|
| | 196 | if ( m/(^(Bundle-ClassPath): )(.*)$/ ) { |
|---|
| | 197 | $bunclp = "$3" . "\n"; |
|---|
| | 198 | while (<MANIFEST>) { |
|---|
| | 199 | if ( m/^[[:upper:]][[:alpha:]]+-[[:upper:]][[:alpha:]]+: .*/ ) { |
|---|
| | 200 | $len = length $_; |
|---|
| | 201 | seek MANIFEST, $len * -1, 1; |
|---|
| | 202 | last; |
|---|
| | 203 | } |
|---|
| | 204 | $bunclp .= "$_"; |
|---|
| | 205 | } |
|---|
| | 206 | $bunclp =~ s/\ //g; |
|---|
| | 207 | $bunclp =~ s/\n//g; |
|---|
| | 208 | $bunclp =~ s/[^[:print:]]//g; |
|---|
| | 209 | $dir = `dirname $file`; |
|---|
| | 210 | $dir =~ s/\n//g; |
|---|
| | 211 | @jars = split /,/, $bunclp; |
|---|
| | 212 | for $jarfile (@jars) { |
|---|
| | 213 | $jarfile = "$dir\/\.\.\/$jarfile"; |
|---|
| | 214 | $jarfile = readlink $jarfile; |
|---|
| | 215 | if ( !$jarfile eq "" ) { |
|---|
| | 216 | print "$jarfile" . "\n"; |
|---|
| | 217 | } |
|---|
| 192 | | } |
|---|
| 193 | | if ( !$debug ) { @bundlelist = prepareOSGiBundlesList(@bundlelist); } |
|---|
| 194 | | $list = ""; |
|---|
| 195 | | for $bundle (@bundlelist) { |
|---|
| 196 | | # replace '=' by '>=' because qualifiers are set on provides |
|---|
| 197 | | # but not on requires. |
|---|
| 198 | | $bundle->{VERSION} =~ s/\ =/\ >=/g; |
|---|
| 199 | | if ( !$debug ) { |
|---|
| 200 | | $list .= "osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n"; |
|---|
| 201 | | } else { |
|---|
| 202 | | $list .= $bundle->{FILE} . " osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n"; |
|---|
| | 224 | if ( !$debug ) { @bundlelist = prepareOSGiBundlesList(@bundlelist); } |
|---|
| | 225 | $list = ""; |
|---|
| | 226 | for $bundle (@bundlelist) { |
|---|
| | 227 | # replace '=' by '>=' because qualifiers are set on provides |
|---|
| | 228 | # but not on requires. |
|---|
| | 229 | $bundle->{VERSION} =~ s/\ =/\ >=/g; |
|---|
| | 230 | if ( !$debug ) { |
|---|
| | 231 | $list .= "osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n"; |
|---|
| | 232 | } else { |
|---|
| | 233 | $list .= $bundle->{FILE} . " osgi(" . $bundle->{NAME} . ")" . $bundle->{VERSION} . "\n"; |
|---|
| | 234 | } |
|---|