1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#!/usr/bin/perl
=head1 NAME
jh_classpath - sets classpaths in jar files
=cut
use strict;
use warnings;
use Debian::Debhelper::Dh_Lib;
=head1 SYNOPSIS
B<jh_classpath> [S<I<debhelper options>>]
B<jh_classpath> [S<I<debhelper options>>] [B<-p>I<package>] [B<--classpath=>I<cp>] [S<I<jar [...]>>]
=head1 DESCRIPTION
B<jh_classpath> is a javahelper program that can set the classpath on
jar files for you.
It has two modes of operations. By default, it will read
F<debian/I<package>.classpath> or F<debian/classpath> and set the
classpath of all jar files listed in that file. In this mode,
B<jh_classpath> does not accept any non-option arguments.
Alternatively, you can pass B<jh_classpath> a list of jar files
to update. It will process each of those and set the classpath
of them to that value set by B<--classpath> if passed. If
B<--classpath> is omitted the environment variable CLASSPATH will
be used instead (rewriting its contents as necessary). In this
mode, B<jh_classpath> will not read F<debian/I<package>.classpath>
nor F<debian/classpath>.
=head1 FILES
=over 4
=item F<debian/I<package>.classpath>, F<debian/classpath>
Parsed to determine which jar files should be processed for the
given package. Note that unlike most other debhelper commands,
B<jh_classpath> will use F<debian/classpath> as a fallback
configuration file for I<all> packages that it acts on. Other
debhelper commands usually only apply this fallback to the
"main package".
The file consists of 0 or more lines with the following:
jarfile classpath-file1 [... classpath-file2]
Note that each file in the classpath is space-separated in
this configuration file.
=back
=head1 OPTIONS
=over 4
=item B<-c>I<cp>, B<--classpath=>I<cp>
=back
Beyond the above, B<jh_classpath> also accepts the shared
debhelper options documented in L<debhelper(7)>.
=cut
my $classpath_arg;
init(options => {
'classpath|c=s' => \$classpath_arg,
});
if (@ARGV) {
# process jars with -c or $CLASSPATH
my $tmpdir = tmpdir($dh{FIRSTPACKAGE});
if (not $classpath_arg) {
$classpath_arg = $ENV{'CLASSPATH'};
$classpath_arg =~ tr/:/ /;
}
if (not $classpath_arg) {
warning('Could not find a classpath, doing nothing');
exit(0);
}
for my $jar (@ARGV) {
if (not -f $jar) {
my $jar_in_tmp = "${tmpdir}/${jar}";
if (not -f $jar_in_tmp) {
warning("Cannot find $jar: skipping");
next;
}
$jar = $jar_in_tmp;
doit('jh_manifest', "-p$dh{FIRSTPACKAGE}", "--classpath=${classpath_arg}", $jar)
}
}
} else {
# read debian/$package.classpath
foreach my $package (@{$dh{DOPACKAGES}}) {
my $tmpdir = tmpdir($package);
my $pkgfile = pkgfile($package, 'classpath');
if (not $pkgfile and -f 'debian/classpath') {
$pkgfile = 'debian/classpath';
}
next if not $pkgfile;
my @lines = filedoublearray($pkgfile);
for my $line (@lines) {
my ($jar, @classpath_parts) = @{$line};
my $classpath = join(' ', @classpath_parts);
if (not -f $jar) {
my $jar_in_tmp = "${tmpdir}/${jar}";
if (not -f $jar_in_tmp) {
warning("Cannot find $jar: skipping");
next;
}
$jar = $jar_in_tmp;
}
doit('jh_manifest', "-p$dh{FIRSTPACKAGE}", "--classpath=${classpath}", $jar)
}
}
}
=head1 SEE ALSO
L<debhelper(7)>
This program is a part of javahelper and uses debhelper as backend. There are
also tutorials in /usr/share/doc/javahelper.
=head1 AUTHOR
Niels Thykier <niels@thykier.net>
=cut
|