5
jh_generateorbitdir - Creates and populates an orbit dir used by pde-build for third-party jar files.
10
use Debian::Debhelper::Dh_Lib;
11
use Debian::Javahelper::Eclipse;
15
B<jh_generateorbitdir> [S<I<debhelper options>>] [B<--orbit-dir=>I<dir>] [S<I<orbit-dep [...]>>]
19
jh_generateorbitdir is a javahelper program that handles creation
20
of an orbit dependency dir. This directory has to be populated with
21
non-eclipse jar files. However, eclipse refers to these jars by
22
their "symbolic name". jh_generateorbitdir can extract this name
23
from the jar's manifest (provided it has the OSGi metadata) and
24
create a symlink to it.
26
jh_generateorbitdir will replace regular files with symlinks
27
if they are present in the orbit dir and clash with the name
28
of one of the orbit jars. If an orbit jar name clashes with a
29
symlink in the orbit dir, then jh_generateorbitdir will assume
30
that the given jar has already been symlinked and skip it.
32
jh_generateorbitdir will also check the default installation for
33
jar files on Debian systems (at the time of writing /usr/share/java),
34
if it cannot find the jar in the current dir.
40
=item debian/eclipse.orbitdeps
42
List of orbit dependencies - one per line. This can be used as an
43
alternative to passing it per command line.
51
=item B<--orbit-dir=dir>
53
Specifies the directory from where the orbit-dir is or should be
54
created. Defauls to "debian/.eclipse_build/orbitdeps".
61
my $cachefile = 'debian/orbitdeps.debhelper';
62
my $infile = 'debian/eclipse.orbitdeps';
64
my @include = ('.', '/usr/share/java');
68
"orbit-dir=s" => \$orbitdir,
71
$orbitdir = "debian/.eclipse-build/orbitdeps" unless(defined($orbitdir));
76
push(@orbitdeps, filearray($infile));
81
# If there is nothing to do then do not bother continuing.
82
exit(0) unless(scalar(@orbitdeps) > 0);
84
# make sure we always clean up our tmpdir in case of common signals.
85
$SIG{'INT'} = \&sighandler;
86
$SIG{'TERM'} = \&sighandler;
89
open(ORBIT_CACHE, ">>", $cachefile) or error("$cachefile: $!");
92
doit("mkdir", "-p", $orbitdir);
94
foreach my $jar (findJars(@orbitdeps)){
95
my $fields = readFields($jar, EOB_SYM_NAME, EOB_BUNDLE_VERSION);
96
my $symName = $fields->{${\EOB_SYM_NAME}};
97
my $version = $fields->{${\EOB_BUNDLE_VERSION}};
99
$symName = '<bundle-name>';
100
$version = '<bundle-version>';
102
error("$jar did not have any OSGi metadata") unless(defined($symName) && defined($version));
103
if( -l "$orbitdir/${symName}_${version}.jar"){
104
my $ltarget = readlink("$orbitdir/${symName}_${version}.jar");
105
if(defined($ltarget)){
107
print ORBIT_CACHE "$ltarget, $symName, $version\n" unless($dh{NO_ACT});
109
warning("Cannot determine target of $orbitdir/${symName}_${version}.jar; jh_installeclipse will not be able to replace this post-install." );
111
# skip if already linked
114
error("No touching $orbitdir/${symName}_${version}.jar - it is a dir") if( -d "$orbitdir/${symName}_${version}.jar");
115
doit("rm", "-f", "$orbitdir/${symName}_${version}.jar") if( -e "$orbitdir/${symName}_${version}.jar");
116
print ORBIT_CACHE "$jar, $symName, $version\n" unless($dh{NO_ACT});
117
doit("ln", "-s", $jar, "$orbitdir/${symName}_${version}.jar");
121
close(ORBIT_CACHE) or error("$cachefile: $!");
130
chomp($tmpdir = `mktemp -d`);
132
$tmpdir = '<tmpdir>';
135
doit("unzip", "-qq", "-n", "-d", $tmpdir, $jar);
136
my $findmancmd = "find $tmpdir -iwholename '*/META-INF/MANIFEST.MF' 2>/dev/null";
139
verbose_print($findmancmd);
140
chomp($manifest = `$findmancmd`);
141
if( $manifest eq '' or ! -e $manifest){
142
error("Cannot find the MANIFEST in $jar");
145
my $cmd = "bash -c \". /usr/share/javahelper/jh_lib.sh && extractline $manifest $f\" 2>/dev/null";
148
error("Could not read the MANIFEST of $jar") if($? != 0);
149
chomp($val = `$cmd`);
150
$fields->{$f} = $val;
153
# print what we would have done.
154
verbose_print($findmancmd);
156
verbose_print("bash -c \". /usr/share/javahelper/jh_lib.sh && extractline <manifest> $f\" 2>/dev/null");
160
doit("rm", "-fr", $tmpdir);
163
#propagate the error.
171
doit("rm", "-fr", $tmpdir) if(defined($tmpdir));
172
error("Caught signal $sig");
176
my @inc = ('.', '/usr/share/java');
178
foreach my $globpattern (@_){
181
# Only use inc-path if there is no path.
182
@i = ('.') if($globpattern =~ m@/@o);
183
glob_loop: foreach my $p (@inc){
184
foreach my $s (''. '.jar') {
185
my @matches = glob("$p/$globpattern$s");
186
# skip if nothing matched or it was not a glob and the file does not exist.
187
next if(scalar(@matches) == 0 or ! -e $matches[0]);
188
push(@res, @matches);
193
die("Could not find any matches for $globpattern") unless($found);
200
jh_generateorbitdir --orbit-dir orbit asm3 oro
202
Will generate a folder called orbit with two symlinks based on asm3 and
209
This program is a part of javahelper and uses debhelper as backend. There are
210
also tutorials in /usr/share/javahelper.
214
Niels Thykier <niels@thykier.net>
216
=head1 COPYRIGHT AND LICENSE
218
Copyright 2010 by Niels Thykier
220
This tool is free software; you may redistribute it and/or modify
221
it under the terms of GNU GPL 2.