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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
#!/usr/bin/perl
=head1 NAME
jh_installlibs - installs jar files in usr/share/java of a package
=cut
use strict;
use warnings;
use Debian::Debhelper::Dh_Lib;
=head1 SYNOPSIS
B<jh_installlibs> [S<I<debhelper options>>]
B<jh_installlibs> [S<I<debhelper options>>] [B<-p>I<package>] [B<--classpath=>I<cp>] [S<I<jar [...]>>]
=head1 DESCRIPTION
For library packages Debian Java policy currently requires that the
libraries be installed to /usr/share/java in a versioned format and
with an unversioned symlink. B<jh_installlibs> will take a jar and
correctly install it.
As with debhelper programs, this can either take a jar as a parameter,
or read a list of jars from a file in the Debian directory. It also
follows the -p, -i and -a semantics of debhelper for selecting which
packages to install the jar to. When operating on a package,
B<jh_installlibs> will read the list of library jars from
F<debian/I<package>.jlibs> or F<debian/jlibs>.
The F<jlibs> file is a list of jars to install, one per line, and works
exactly the same as listing them on the command line. Each jar is
installed to debian/I<package>/usr/share/java/ in the appropriate
versioned and unversioned forms.
If the jars built by upstream already contain the version number, this
will be stripped before installing. B<jh_installlibs> will also try to
strip the upstream version number of any ds or dfsg suffix. Other
version-mangling options or explicit version numbers can also be
provided.
=head1 FILES
=over 4
=item F<debian/I<package>.jlibs>, F<debian/jlibs>
The F<jlibs> file is a list of jars to install, one per line, and works
exactly the same as listing them on the command line. Each jar is
installed to debian/I<package>/usr/share/java/ in the appropriate
versioned and unversioned forms.
Note that unlike most other debhelper commands,
B<jh_installlibs> will use F<debian/jlibs> 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".
=back
=head1 OPTIONS
=over 4
=item B<--no-mangle>
Do not try to sanitize the upstream version number.
=item B<--upstream-version=>I<version>
Use I<version> as the upstream version. This option implies B<--no-mangle>
=item B<--version-strip=>I<regex>
Use I<regex> instead of the built-in rules for sanitizing the upstream
version number.
This option is ignored when B<--no-mangle> is passed (or implied by another
option).
=back
Beyond the above, B<jh_classpath> also accepts the shared
debhelper options documented in L<debhelper(7)>.
=cut
my ($UPSTREAM_VERSION, $NO_MANGLE);
# Strip ds and dfsg in various forms by default.
my $VERSION_STRIP = '[\.+~-](?:ds|dfsg)[0-9]*$';
init(options => {
'upstream-version=s' => \$UPSTREAM_VERSION,
'no-mangle' => \$NO_MANGLE,
'version-strip=s' => \$VERSION_STRIP,
});
# Explicitly defined upstream version
if (defined($UPSTREAM_VERSION)) {
$NO_MANGLE = 1;
} else {
# For the side effect of setting $dh{VERSION}
isnative($dh{MAINPACKAGE});
my $full_version = $dh{'VERSION'};
# Strip epoch
$full_version =~ s/^\d+://;
# Strip debian revision
$full_version =~ s/-[^-]+$//;
if (not $NO_MANGLE) {
$full_version =~ s/$VERSION_STRIP//;
}
$UPSTREAM_VERSION = $full_version;
}
sub process_jars {
my ($tmpdir, @jars) = @_;
for my $jar (@jars) {
my $basename = basename($jar);
# Strip trailing -<VERSION>.jar or .jar
$basename =~ s/(?:-\Q${UPSTREAM_VERSION}\E)?[.]jar$//;
install_dir("${tmpdir}/usr/share/java");
install_file($jar, "${tmpdir}/usr/share/java/${basename}-${UPSTREAM_VERSION}.jar");
rm_files("${tmpdir}/usr/share/java/${basename}.jar");
make_symlink_raw_target("${basename}-${UPSTREAM_VERSION}.jar", "${tmpdir}/usr/share/java/${basename}.jar");
}
}
if (@ARGV) {
my $tmpdir = tmpdir($dh{FIRSTPACKAGE});
process_jars($tmpdir, @ARGV);
exit(0);
}
# read debian/$package.jlibs
foreach my $package (@{$dh{DOPACKAGES}}) {
my $pkgfile = pkgfile($package, 'jlibs');
if (not $pkgfile and -f 'debian/jlibs') {
$pkgfile = 'debian/jlibs';
}
next if not $pkgfile;
my @jars = filearray($pkgfile, ['.']);
my $tmpdir = tmpdir($package);
process_jars($tmpdir, @jars);
}
=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
|