Skip to content
Commits on Source (6)
......@@ -12,6 +12,7 @@ Build-Depends:
libtest-strict-perl,
markdown,
perl
Rules-Requires-Root: no
Standards-Version: 4.1.4
Vcs-Git: https://salsa.debian.org/java-team/javatools.git
Vcs-Browser: https://salsa.debian.org/java-team/javatools
......
jh_build.1
jh_classpath.1
jh_depends.1
jh_exec.1
jh_installjavadoc.1
jh_installlibs.1
jh_linkjars.1
jh_makepkg.1
jh_repack.1
tmp/*.1
......
......@@ -23,7 +23,12 @@ override_dh_auto_build: jh_lib.sh
$(POD2MAN) jh_generateorbitdir tmp/jh_generateorbitdir.1
$(POD2MAN) jh_setupenvironment tmp/jh_setupenvironment.1
$(POD2MAN) jh_compilefeatures tmp/jh_compilefeatures.1
$(POD2MAN) jh_exec tmp/jh_exec.1
$(POD2MAN) jh_linkjars tmp/jh_linkjars.1
$(POD2MAN) jh_manifest tmp/jh_manifest.1
$(POD2MAN) jh_classpath tmp/jh_classpath.1
$(POD2MAN) jh_installjavadoc tmp/jh_installjavadoc.1
$(POD2MAN) jh_installlibs tmp/jh_installlibs.1
$(POD2MAN) fetch-eclipse-source.pod tmp/fetch-eclipse-source.1
$(POD2MAN) -s 1 jh_clean.pod tmp/jh_clean.1
$(POD2MAN) $(MOD_PATH)/Eclipse.pm tmp/Debian::Javahelper::Eclipse.3
......
#!/bin/bash --
set -e
. /usr/share/javahelper/jh_lib.sh
syntax()
{
echo -e "Usage: jh_classpath [options] [jar(s)]"
echo -e "Options:"
echo -e "\t-h --help: show this text"
echo -e "\t-V --version: show the version"
echo -e "\t-i --indep: act on all Arch: all packages"
echo -e "\t-a --arch: act on all Arch-specific packages"
echo -e "\t-s --same-arch: alias of --arch for compatibility with debhelper"
echo -e "\t-p<package> --package=<package>: package to act on (default=all)"
echo -e "\t-P<packagedir> --tmpdir=<package>: package directory (default=\$CWD/debian/package)"
echo -e "\t-c<classpath> --classpath=<classpath>: The classpath to set on the jar(s)"
echo -e "\t-v --verbose: show more information while running"
echo -e "\t-n --no-act: don't actually do anything, just print the results"
exit 1
}
#!/usr/bin/perl
ARGS="i indep a arch s same-arch p package P tmpdir v verbose n no-act c classpath" parseargs "$@"
=head1 NAME
dh_testdir
jh_classpath - sets classpaths in jar files
VERBOSE="`getarg v verbose`"
NOACT="`getarg n noact`"
=cut
if [ "$ARGC" == "0" ]; then
# read debian/$package.classpath
for p in `findpackages`; do
if [ -f "debian/$p.classpath" ]; then
cat "debian/$p.classpath" | while read jar cpath; do
if [ ! -f "$jar" ] ; then
jar="debian/$p/$jar"
fi
if [ -n "$VERBOSE" ]; then
echo "Setting classpath on $jar to $cpath"
fi
if [ -n "$NOACT" ]; then
echo "Would run jh_manifest -p$p --classpath=$cpath $jar"
else
jh_manifest "-p$p" "--classpath=$cpath" "$jar"
fi
done
elif [ -f "debian/classpath" ]; then
cat "debian/classpath" | while read jar cpath; do
if [ ! -f "$jar" ] ; then
jar="debian/$p/$jar"
fi
if [ -n "$VERBOSE" ]; then
echo "Setting classpath on $jar to $cpath"
fi
if [ -n "$NOACT" ]; then
echo "Would run jh_manifest -p$p --classpath=$cpath $jar"
else
jh_manifest "-p$p" "--classpath=$cpath" "$jar"
fi
done
fi
done
else
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
for (( i=0 ; i<ARGC; i++ )); do
jar=${ARGV[i]}
p=$(firstpackage)
if [ -f "$jar" ]; then
cpath="`getarg c classpath`"
if [ ! -f "$jar" ] ; then
jar="debian/$p/$jar"
fi
if [ -z "$cpath" ]; then
cpath="`sed 's/:/ /g' <<< $CLASSPATH`"
fi
if [ -z "$cpath" ]; then
echo "Could not find a classpath, doing nothing"
exit 0
fi
if [ -n "$VERBOSE" ]; then
echo "Setting classpath on $jar to $cpath"
fi
if [ -n "$NOACT" ]; then
echo "Would run jh_manifest -p$p --classpath=$cpath $jar"
else
jh_manifest "-p$p" "--classpath=$cpath" "$jar"
fi
else
echo "Cannot find $jar: skipping"
fi
done
fi
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($dh{FIRSTPACKAGE});
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
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
.TH JAVAHELPER "1" "January 2008" "Javahelper Version 0.5" "User Commands"
.SH NAME
Javahelper \- Part of the Java Helper packaging tools
Refer to the tutorials in /usr/share/doc/javahelper for more detail
.SH SYNOPSIS
.B jh_classpath
[\fIoptions\fR] [\fI<jar> \fR...]
.SH OPTIONS
.HP
\fB\-h\fR \fB\-\-help\fR: show this text
.HP
\fB\-v\fR \fB\-\-verbose\fR: show more information while running
.HP
\fB\-V\fR \fB\-\-version\fR: print the version
.HP
\fB\-n\fR \fB\-\-no\-act\fR: don't actually do anything, just print the results
.SS "When reading manifest files for packages:"
.HP
\fB\-i\fR \fB\-\-indep\fR: run for all Arch: all packages
.HP
\fB\-a\fR \fB\-\-arch\fR: run for all Arch\-specific packages
.HP
\fB\-p\fR<package> \fB\-\-package=\fR<package>: package to act on (default=all)
.HP
\fB\-P\fR<packagedir> \fB\-\-tmpdir=\fR<package>: package directory (default=$CWD/debian/package)
.SS "When acting on a jar from the command line:"
.HP
\fB\-c\fR<classpath> \fB\-\-classpath=\fR<classpath>: The classpath to set (space separated)
.HP
#!/bin/bash --
EXECDIRS="bin usr/bin usr/games"
set -e
. /usr/share/javahelper/jh_lib.sh
syntax()
{
echo "Usage: jh_exec [options]"
echo "Options:"
echo -e "\t-h --help: show this text"
echo -e "\t-V --version: print the version"
echo -e "\t-i --indep: run for all Arch: all packages"
echo -e "\t-a --arch: run for all Arch-specific packages"
echo -e "\t-s --same-arch: alias of --arch for compatibility with debhelper"
echo -e "\t-p<package> --package=<package>: package to act on (default=all)"
echo -e "\t-P<packagedir> --tmpdir=<package>: package directory (default=\$CWD/debian/package)"
echo -e "\t-v --verbose: show more information while running"
echo -e "\t-n --no-act: don't actually do anything, just print the results"
exit 1
}
#!/usr/bin/perl
=head1 NAME
jh_exec - make jar files in PATH executable
=cut
use strict;
use warnings;
use Cwd qw(realpath);
use Debian::Debhelper::Dh_Lib;
=head1 SYNOPSIS
B<jh_exec> [S<I<debhelper options>>]
ARGS="i indep a arch s same-arch p package P tmpdir v verbose n no-act" parseargs "$@"
=head1 DESCRIPTION
VERBOSE="`getarg v verbose`"
dh_testdir
B<jh_exec> will scan package directories for jars in the paths,
or symlinks to jar from the paths, and ensure that they have been set
executable if necessary.
for p in `findpackages`; do
Note that executable jar files requires L<jarwrapper(1)>. Please see
the tutorials in /usr/share/doc/javahelper for more information.
PACKAGEDIR="`getarg P tmpdir`"
if [ -z "$PACKAGEDIR" ]; then
PACKAGEDIR="`pwd`/debian/$p"
else
PACKAGEDIR=`readlink -f $PACKAGEDIR`
fi
=head1 OPTIONS
B<jh_exec> accepts the shared debhelper options documented in L<debhelper(7)>.
=cut
init();
# Define PATH_DIRS next to the NOOP promise as they should be in sync.
use constant PATH_DIRS => qw(bin usr/bin usr/games);
# PROMISE: DH NOOP WITHOUT tmp(bin) tmp(usr/bin) tmp(usr/games)
my @chmod_paths;
foreach my $package (@{$dh{DOPACKAGES}}) {
my $tmpdir = tmpdir($package);
for my $path_dir (PATH_DIRS) {
my $dir = "${tmpdir}/${path_dir}";
opendir(my $dirfd, $dir) or error("opendir($dir) failed: $!");
for my $file (readdir($dirfd)) {
next if $file eq '.' or $file eq '..';
my $path = "${dir}/${file}";
# Must be a (symlink to a) file.
next if not -f $path;
# Resolve as we want to work on the file (and not the symlink)
my $resolved = realpath($path) // error("Cannot resolve $path: $!");
# Only work on .jar files.
next if $resolved !~ m{[.]jar$};
push(@chmod_paths, $resolved);
}
closedir($dirfd) or error("closedir($dir) failed: $!");
}
}
xargs(\@chmod_paths, 'chmod', '-x') if @chmod_paths;
if [ -n "$VERBOSE" ]; then
echo "Searching $PACKAGEDIR for $p"
fi
=head1 SEE ALSO
for d in $EXECDIRS; do
for j in $PACKAGEDIR/$d/*; do
if [ -h "$j" ]; then
TARGET=`readlink -f "$j"`
if [ "${TARGET%.jar}" != "$TARGET" ]; then
if [ -n "$VERBOSE" ]; then
echo "Making $TARGET executable"
fi
L<debhelper(7)>
if [ -z "`getarg n no-act`" ]; then
chmod +x "$TARGET"
else
echo chmod +x "$TARGET"
fi
fi
fi
done
done
This program is a part of javahelper and uses debhelper as backend. There are
also tutorials in /usr/share/doc/javahelper.
unset PACKAGEDIR
=head1 AUTHOR
done
Niels Thykier <niels@thykier.net>
=cut
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
.TH JAVAHELPER "1" "January 2008" "Javahelper Version 0.5" "User Commands"
.SH NAME
Javahelper \- Part of the Java Helper packaging tools
Refer to the tutorials in /usr/share/doc/javahelper for more detail
.SH SYNOPSIS
.B jh_exec
[\fIoptions\fR]
.SH OPTIONS
.HP
\fB\-h\fR \fB\-\-help\fR: show this text
.HP
\fB\-V\fR \fB\-\-version\fR: print the version
.HP
\fB\-i\fR \fB\-\-indep\fR: run for all Arch: all packages
.HP
\fB\-a\fR \fB\-\-arch\fR: run for all Arch\-specific packages
.HP
\fB\-p\fR <package> \fB\-\-package=\fR<package>: package to act on (default=all)
.HP
\fB\-P\fR <packagedir> \fB\-\-tmpdir=\fR<package>: package directory (default=$CWD/debian/package)
.HP
\fB\-v\fR \fB\-\-verbose\fR: show more information while running
.HP
\fB\-n\fR \fB\-\-no\-act\fR: don't actually do anything, just print the results
#!/bin/bash --
set -e
. /usr/share/javahelper/jh_lib.sh
syntax()
{
echo -e "Usage: jh_installjavadoc [options] [src] [target]"
echo -e "Options:"
echo -e "\t-h --help: show this text"
echo -e "\t-V --version: show the version"
echo -e "\t-i --indep: act on all Arch: all packages"
echo -e "\t-a --arch: act on all Arch-specific packages"
echo -e "\t-s --same-arch: alias of --arch for compatibility with debhelper"
echo -e "\t-p<package> --package=<package>: package to act on (default=all)"
echo -e "\t-P<packagedir> --tmpdir=<package>: package directory (default=\$CWD/debian/package)"
echo -e "\t-v --verbose: show more information while running"
echo -e "\t-n --no-act: don't actually do anything, just print the results"
echo -e "\t-A<author> --author=<author>: Author of the javadoc"
exit 1
}
#!/usr/bin/perl
=head1 NAME
jh_installjavadoc - install javadoc into packages
=cut
use strict;
use warnings;
use Debian::Debhelper::Dh_Lib;
=head1 SYNOPSIS
B<jh_installjavadoc> [S<I<debhelper options>>]
B<jh_installjavadoc> [S<I<debhelper options>>] [B<-p>I<package>] [S<I<base-directory-of-javadoc>>] [S<I<install-location>>]
=head1 DESCRIPTION
B<jh_installjavadoc> is a javahelper program that can install generated
javadoc for you.
If you have javadoc which has been built by your build system, then
B<jh_installjavadoc> will install it in the correct location and register
it with doc-base for you. Either run B<jh_installjavadoc> with the
directory containing the javadoc as a parameter, or it will read
F<debian/I<package>.javadoc> or F<debian/javadoc>, which should contain
a single path to the javadoc for that package.
If you have used L<jh_build(1)> that will automatically have created
javadoc. To install that put the string "internal" in the javadoc
file and it will be installed.
The second parameter, or the second string on the line in the javadoc
file, can be used to override the install location, for example, so
that a -doc package can install to F</usr/share/doc/I<library>/api>.
=head1 FILES
=over 4
=item F<debian/I<package>.javadoc>, F<debian/javadoc>
Parsed to determine which javadoc directory should be processed for the
given package. Note that unlike most other debhelper commands,
B<jh_installjavadoc> will use F<debian/javadoc> 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".
ARGS="A author i indep a arch s same-arch p package P tmpdir v verbose n no-act" parseargs "$@"
dh_testdir
VERBOSE="`getarg v verbose`"
AUTHOR="`getarg A author`"
function installjavadoc()
{
package="$1"
src="$2"
target="$3"
if [ -z "$AUTHOR" ]; then
AUTHOR="The authors of $package"
fi
if [ -z "$src" ]; then
echo "Error: trying to install from empty source"
exit 1
fi
if [ ! -d "$src" ]; then
echo "Javadoc source $src does not exist or is not a directory, skipping"
return
fi
if [ -z "$target" ]; then
target="debian/$package/usr/share/doc/$package/api"
docbasepath="/usr/share/doc/$package/api"
else
docbasepath="/$target"
target="debian/$package/$target"
fi
if [ -n "$VERBOSE" ]; then
echo "Installing javadoc from $src into package $package"
fi
if [ -n "`getarg n no-act`" ]; then
echo mkdir -p "`dirname "$target"`"
echo cp -r "$src" "$target"
echo cat \> debian/$package.doc-base.javadoc
else
cat > debian/$package.doc-base.javadoc <<END
The file consists a single line listing the javadoc directory (or
the word "internal"). This is optionally followed path the path
to the desired install location if the default location is
incorrect.
Examples:
internal
build/javadoc /usr/share/doc/somewhere/libapi
=back
=head1 OPTIONS
=over 4
=item B<-A>I<author>, B<--author=>I<author>
=back
Beyond the above, B<jh_installjavadoc> also accepts the shared
debhelper options documented in L<debhelper(7)>.
=cut
my $AUTHOR;
init(options => {
'author|A=s' => \$AUTHOR,
});
sub installjavadoc {
my ($package, $source, $target) = @_;
my $author = $AUTHOR // "The authors of $package";
my $docbase_path;
my $tmpdir = tmpdir($package);
if (not -d $source) {
warning("Javadoc source ${source} does not exist or is not a directory, skipping");
return;
}
if (defined($target)) {
$target = "${tmpdir}/$target";
$docbase_path = "/$target";
} else {
$target = "${tmpdir}/usr/share/doc/$package/api";
$docbase_path="/usr/share/doc/$package/api";
}
verbose_print("Installing javadoc from ${source} into package $package");
doit('cp', '-r', $source, $target);
verbose_print("cat > debian/$package.doc-base.javadoc");
if (not $dh{NO_ACT}) {
open(my $fd, '>', "debian/$package.doc-base.javadoc")
or error("open debian/$package.doc-base.javadoc failed: $!");
print {$fd} <<EOF ;
Document: $package
Title: API JavaDoc for $package
Author: $AUTHOR
Author: $author
Abstract: This is the API JavaDoc for $package
Section: Programming/Java
Format: HTML
Index: $docbasepath
Files: $docbasepath/*.html
END
echo "debian/$package.doc-base.javadoc" >> debian/.javahelper_clean
mkdir -p "`dirname "$target"`"
cp -r "$src" "$target"
fi
Index: $docbase_path
Files: $docbase_path/*.html
EOF
close($fd) or error("close debian/$package.doc-base.javadoc failed: $!");
open(my $cfd, '>>', 'debian/.javahelper_clean') or error("open debian/.javahelper_clean failed: $!");
print {$cfd} "debian/$package.doc-base.javadoc\n";
close($cfd) or error("close debian/.javahelper_clean failed: $!");
}
}
if (@ARGV) {
my ($source, $target) = @ARGV;
installjavadoc($dh{FIRSTPACKAGE}, $source, $target);
exit(0);
}
if [ "$ARGC" != "0" ] ; then
p="`firstpackage`"
installjavadoc "$p" "${ARGV[0]}" "${ARGV[1]}"
exit 0
fi
# read debian/$package.javadoc
foreach my $package (@{$dh{DOPACKAGES}}) {
my $pkgfile = pkgfile($package, 'javadoc');
if (not $pkgfile and -f 'debian/javadoc') {
$pkgfile = 'debian/javadoc';
}
next if not $pkgfile;
my ($source, $target) = filedoublearray($pkgfile);
if ($source eq 'internal' and -d 'debian/_jh_build.javadoc/api') {
$source = 'debian/_jh_build.javadoc/api';
}
installjavadoc($package, $source, $target);
}
for p in `findpackages`; do
PACKAGEDIR="`getarg P tmpdir`"
if [ -z "$PACKAGEDIR" ]; then
PACKAGEDIR="`pwd`/debian/$p"
else
PACKAGEDIR=`readlink -f $PACKAGEDIR`
fi
=head1 SEE ALSO
DIR=
if [ -f debian/$p.javadoc ]; then
DIR="`awk '{print $1}' debian/$p.javadoc`"
TARGET="`awk '{print $2}' debian/$p.javadoc`"
elif [ -f debian/javadoc ]; then
DIR="`awk '{print $1}' debian/javadoc`"
TARGET="`awk '{print $2}' debian/javadoc`"
else
continue
fi
L<debhelper(7)>
if [ "$DIR" = "internal" ] && [ -d debian/_jh_build.javadoc/api ]; then
DIR=debian/_jh_build.javadoc/api
fi
This program is a part of javahelper and uses debhelper as backend. There are
also tutorials in /usr/share/doc/javahelper.
installjavadoc "$p" "$DIR" "$TARGET"
unset PACKAGEDIR
=head1 AUTHOR
done
Niels Thykier <niels@thykier.net>
=cut
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
.TH JAVAHELPER "1" "January 2008" "Javahelper Version 0.5" "User Commands"
.SH NAME
Javahelper \- Part of the Java Helper packaging tools
Refer to the tutorials in /usr/share/doc/javahelper for more detail
.SH SYNOPSIS
.B jh_installjavadoc
[\fIoptions\fR] [\fIsourcedir\fR]
.SH OPTIONS
.HP
\fB\-h\fR \fB\-\-help\fR: show this text
.HP
\fB\-V\fR \fB\-\-version\fR: show the version
.HP
\fB\-i\fR \fB\-\-indep\fR: act on all Arch: all packages
.HP
\fB\-a\fR \fB\-\-arch\fR: act on all Arch\-specific packages
.HP
\fB\-p\fR<package> \fB\-\-package=\fR<package>: package to act on (default=all)
.HP
\fB\-P\fR<packagedir> \fB\-\-tmpdir=\fR<package>: package directory (default=$CWD/debian/package)
.HP
\fB\-v\fR \fB\-\-verbose\fR: show more information while running
.HP
\fB\-n\fR \fB\-\-no\-act\fR: don't actually do anything, just print the results
.HP
\fB\-a\fR<author> \fB\-\-author=\fR<author>: Javadoc author
#!/bin/bash --
set -e
. /usr/share/javahelper/jh_lib.sh
syntax()
{
echo -e "Usage: jh_installlibs [options] [jars]"
echo -e "Options:"
echo -e "\t-h --help: show this text"
echo -e "\t-V --version: show the version"
echo -e "\t-i --indep: act on all Arch: all packages"
echo -e "\t-a --arch: act on all Arch-specific packages"
echo -e "\t-s --same-arch: alias of --arch for compatibility with debhelper"
echo -e "\t-p<package> --package=<package>: package to act on (default=all)"
echo -e "\t-P<packagedir> --tmpdir=<package>: package directory (default=\$CWD/debian/package)"
echo -e "\t-v --verbose: show more information while running"
echo -e "\t-n --no-act: don't actually do anything, just print the results"
echo -e "\t--no-mangle: don't try and sanitize the upstream version number"
echo -e "\t--upstream-version=<version>: manually set the upstream version"
echo -e "\t--version-strip=<regex>: manually supply the regex to remove from the upstream version number"
exit 1
#!/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(?:fg)?[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;
}
ARGS="i indep a arch s same-arch p package P tmpdir v verbose n no-act no-mangle upstream-version version-strip" parseargs "$@"
dh_testdir
FULL_VERSION="`dpkg-parsechangelog | sed -n '/^Version:/s/^[^:]*: \(.*\)$/\1/p'`"
VERSION="`echo "$FULL_VERSION" | sed -n 's/\(.*:\)\?\([^-]*\)\(-.*\)\?/\2/p' `"
VERBOSE="`getarg v verbose`"
DEFAULT_VERSION_MANGLE=".dfsg[0-9]*$"
function processjar()
{
p="$1"
j="$2"
from="$j"
to="`basename "$j"`"
if [ -n "`getarg upstream-version`" ]; then
VERSION="`getarg upstream-version`"
elif [ -n "`getarg no-mangle`" ]; then
true
elif [ -n "`getarg version-strip`" ]; then
VERSION="$(sed "s/`getarg version-strip`//" <<< $VERSION )"
else
VERSION="$(sed "s/$DEFAULT_VERSION_MANGLE//" <<< $VERSION )"
fi
if [ "$to" != "${to%-${VERSION}.jar}" ]; then
to="${to%-${VERSION}.jar}.jar"
fi
if [ -n "`getarg n no-act`" ]; then
echo mkdir -p "$PACKAGEDIR/usr/share/java"
echo install -m 644 "$from" "$PACKAGEDIR/usr/share/java/${to%.jar}-${VERSION}.jar"
echo ln -sf ${to%.jar}-${VERSION}.jar "$PACKAGEDIR/usr/share/java/$to"
else
if [ -n "$VERBOSE" ]; then
echo "Installing library $j into package $p"
fi
mkdir -p "$PACKAGEDIR/usr/share/java"
install -m 644 "$from" "$PACKAGEDIR/usr/share/java/${to%.jar}-${VERSION}.jar"
ln -sf ${to%.jar}-${VERSION}.jar "$PACKAGEDIR/usr/share/java/$to"
fi
sub process_jars {
my ($tmpdir, @jars) = @_;
for my $jar (@jars) {
my $basename = basename($jar);
$basename =~ s/[.]jar$//;
install_dir("${tmpdir}/usr/share/java");
install_file($jar, "${tmpdir}/usr/share/java/${basename}-${UPSTREAM_VERSION}.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);
}
if [ "$ARGC" != "0" ] ; then
p="`firstpackage`"
PACKAGEDIR="`getarg P tmpdir`"
if [ -z "$PACKAGEDIR" ]; then
PACKAGEDIR="`pwd`/debian/$p"
else
PACKAGEDIR=`readlink -f $PACKAGEDIR`
fi
for (( i=0; i < $ARGC; i++ )); do
j=${ARGV[i]}
processjar "$p" "$j"
done
exit 0
fi
for p in `findpackages`; do
PACKAGEDIR="`getarg P tmpdir`"
if [ -z "$PACKAGEDIR" ]; then
PACKAGEDIR="`pwd`/debian/$p"
else
PACKAGEDIR=`readlink -f $PACKAGEDIR`
fi
if [ -n "$VERBOSE" ]; then
echo "Searching $PACKAGEDIR for $p"
fi
FILE=
if [ -f debian/$p.jlibs ]; then
FILE=debian/$p.jlibs
elif [ -f debian/jlibs ]; then
FILE=debian/jlibs
else
continue
fi
IFS='
'
for i in `cat "$FILE"`; do
processjar "$p" "$i"
done
unset PACKAGEDIR
done
=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
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
.TH JAVAHELPER "1" "January 2008" "Javahelper Version 0.5" "User Commands"
.SH NAME
Javahelper \- Part of the Java Helper packaging tools
Refer to the tutorials in /usr/share/doc/javahelper for more detail
.SH SYNOPSIS
.B jh_installlibs
[\fIoptions\fR] [\fIjars\fR]
.SH OPTIONS
.HP
\fB\-h\fR \fB\-\-help\fR: show this text
.HP
\fB\-V\fR \fB\-\-version\fR: show the version
.HP
\fB\-i\fR \fB\-\-indep\fR: act on all Arch: all packages
.HP
\fB\-a\fR \fB\-\-arch\fR: act on all Arch\-specific packages
.HP
\fB\-p\fR<package> \fB\-\-package=\fR<package>: package to act on (default=all)
.HP
\fB\-P\fR<packagedir> \fB\-\-tmpdir=\fR<package>: package directory (default=$CWD/debian/package)
.HP
\fB\-v\fR \fB\-\-verbose\fR: show more information while running
.HP
\fB\-n\fR \fB\-\-no\-act\fR: don't actually do anything, just print the results
.HP
\fB\-\-no\-mangle\fR: don't try and sanitize the upstream version number
.HP
\fB\-\-upstream\-version=\fR<version>: manually set the upstream version
.HP
\fB\-\-version\-strip=\fR<regex>: manually supply the regex to remove from the upstream version number
#!/bin/bash --
set -e
. /usr/share/javahelper/jh_lib.sh
syntax()
{
echo -e "Usage: jh_linkjars [options] [target]"
echo -e "Options:"
echo -e "\t-h --help: show this text"
echo -e "\t-V --version: show the version"
echo -e "\t-v --verbose: show more information while running"
echo -e "\t-t --transitive: transitively link jars"
echo -e "\t-n --no-act: don't actually do anything, just print the results"
echo -e "\t-u --unlink: remove the links instead of adding them"
exit 1
#!/usr/bin/perl
=head1 NAME
jh_linkjars - populate folders with symlinks to 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
If upstream ship convenience copies of third-party jar files which
have been removed (see L<jh_repack(1)>), but the build system refers
to that directory, B<jh_linkjars> can be used to populate the directory
with symlinks to the packaged jars in /usr/share/java.
It is called either with a directory on the command line or by
specifying one target directory per line in the file debian/linkjars.
B<jh_linkjars> will scan all of the (installed) build-dependencies and
create a symlink to every jar which is installed by those packages in
the target directory.
B<jh_linkjars> can be called with -u to remove all the symlinks in the
clean target. This is done automatically by L<jh_clean(1)>.
=head1 FILES
=over 4
=item F<debian/linkjars>
List of directories to populate; one directory per line.
=back
=head1 OPTIONS
=over 4
=item B<-t>, B<--transitive>
Transitively link jar files (i.e. also include indirect dependencies in the target directory).
=item B<-u>, B<--unlink>
Remove all files/links in the target directories that B<jh_linkjars> created
(or would have created).
=back
Beyond the above, B<jh_classpath> also accepts the shared
debhelper options documented in L<debhelper(7)>.
=cut
my ($UNLINK_JARS, $TRANSITIVE, @TARGET_DIRS, @JARS);
init(options => {
'transitive|t' => \$TRANSITIVE,
'unlink|u' => \$UNLINK_JARS,
});
sub parse_deps_fields {
my ($field) = @_;
my @packages;
$field =~ s/^\s++//;
$field =~ s/\s++$//;
for my $clause (split(m/\s*+[,|]\s*+/, $field)) {
# Drop everything after [, ( or <.
$clause =~ s/\s*+[\(\[\<].*$//;
push(@packages, $clause);
}
return @packages;
}
sub parse_dpkg_L {
my ($output) = @_;
my @lines;
for my $line (split(qr/\n/, $output)) {
$line =~ s/\s++$//;
if ($line =~ m{^/usr/share/java/.+\.jar$}) {
push(@lines, $line);
}
}
return @lines;
}
ARGS="v verbose n no-act u unlink t transitive" parseargs "$@"
function findjars()
{
pkg="$1"
if [ -z "$pkg" ]; then
pkg="$(sed -n '/^Source:/s/.*: //p' < debian/control)"
BDS=$(grep-dctrl --no-field-names --show-field Build-Depends,Build-Depends-Indep -F source "$pkg" debian/control | tr , ' ' | sed 's/([^)]*)//g')
else
BDS=$(dpkg -s "$pkg" | sed -n 's/([^)]*)//g;s/,/ /g;/^Depends:/s/.*: //p')
fi
JARS=""
for d in $BDS; do
j="$(dpkg -L $d | grep "^/usr/share/java/.*\.jar$")"
k=""
if [ -n "$j" ] && [ `getarg t transitive` ]; then
k=$(findjars "$d")
fi
JARS="$JARS $j $k"
done
echo $JARS
sub find_jars {
my $source = sourcepackage();
my $bd = `grep-dctrl --no-field-names --show-field Build-Depends,Build-Depends-Indep -F source "${source}" debian/control`;
error_exitcode("grep-dctrl --no-field-names --show-field Build-Depends,Build-Depends-Indep -F source \"${source}\" debian/control")
if $?;
my @packages = parse_deps_fields($bd);
my %seen = map { $_ => 1 } @packages;
my @all_jars;
while (@packages) {
my $pkg = pop(@packages);
my $dpkg_output = `dpkg -L "$pkg"`;
error_exitcode("dpkg -L \"$pkg\"") if $?;
my @jars = parse_dpkg_L($dpkg_output);
push(@all_jars, @jars);
if (@jars and $TRANSITIVE) {
my $raw_deps = `dpkg -s "$pkg" | sed -n '/^Depends:/s/.*: //p'`;
error_exitcode("dpkg -s \"$pkg\" | sed -n '/^Depends:/s/.*: //p'") if $?;
my @deps = grep { not exists($seen{$_}) } parse_deps_fields($raw_deps);
$seen{$_} = 1 for @deps;
push(@packages, @deps);
}
}
return @all_jars;
}
function unlinkjars()
{
target="$1"
JARS="`findjars`"
for j in $JARS; do
if [ -n "`getarg n no-act`" ]; then
echo rm -f "$target/`basename "$j"`"
continue
fi
if [ -n "`getarg v verbose`" ]; then
echo Removing link for $j from $target
fi
rm -f "$target/`basename "$j"`"
done
#function findjars()
#{
# pkg="$1"
# if [ -z "$pkg" ]; then
# pkg="$(sed -n '/^Source:/s/.*: //p' < debian/control)"
# BDS=$(grep-dctrl --no-field-names --show-field Build-Depends,Build-Depends-Indep -F source "$pkg" debian/control | tr , ' ' | sed 's/([^)]*)//g')
# else
# BDS=$(dpkg -s "$pkg" | sed -n 's/([^)]*)//g;s/,/ /g;/^Depends:/s/.*: //p')
# fi
#
# JARS=""
# for d in $BDS; do
# j="$(dpkg -L $d | grep "^/usr/share/java/.*\.jar$")"
# k=""
# if [ -n "$j" ] && [ `getarg t transitive` ]; then
# k=$(findjars "$d")
# fi
# JARS="$JARS $j $k"
# done
# echo $JARS
#}
if (@ARGV) {
@TARGET_DIRS = $ARGV[0];
} elsif ( -f 'debian/linkjars') {
@TARGET_DIRS = filearray('debian/linkjars');
}
function linkjars()
{
target="$1"
JARS="`findjars`"
if [ -z "`getarg n no-act`" ]; then
mkdir -p "$target"
fi
for j in $JARS; do
if [ -f "$j" ]; then
if [ -n "`getarg n no-act`" ]; then
echo ln -sf "$j" "$target/"
continue
fi
if [ -n "`getarg v verbose`" ]; then
echo Adding link for $j to $target
fi
ln -sf "$j" "$target/"
fi
done
# Stop here if there is nothing to do.
exit(0) if not @TARGET_DIRS;
@JARS = find_jars();
if ($UNLINK_JARS) {
my @basenames = map { basename($_) } @JARS;
for my $target_dir (@TARGET_DIRS) {
rm_files(map {"${target_dir}/$_"} @basenames);
}
} else {
doit('mkdir', '-p', @TARGET_DIRS);
for my $target_dir (@TARGET_DIRS) {
for my $jar (@JARS) {
my $basename = basename($jar);
verbose_print("Adding link for $jar to ${target_dir}");
make_symlink_raw_target($jar, "${target_dir}/${basename}");
}
}
}
dh_testdir
if [ "$ARGC" != "0" ] ; then
target="${ARGV[0]}"
if [ -n "`getarg u unlink`" ]; then
unlinkjars "$target"
else
linkjars "$target"
fi
elif [ -f debian/linkjars ]; then
for target in `cat debian/linkjars`; do
if [ -n "`getarg u unlink`" ]; then
unlinkjars "$target"
else
linkjars "$target"
fi
done
fi
=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
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
.TH JAVAHELPER "1" "January 2008" "Javahelper Version 0.5" "User Commands"
.SH NAME
Javahelper \- Part of the Java Helper packaging tools
Refer to the tutorials in /usr/share/doc/javahelper for more detail
.SH SYNOPSIS
.B jh_installlibs
[\fIoptions\fR] [\fIjars\fR]
.SH OPTIONS
.HP
\fB\-h\fR \fB\-\-help\fR: show this text
.HP
\fB\-V\fR \fB\-\-version\fR: show the version
.HP
\fB\-v\fR \fB\-\-verbose\fR: show more information while running
.HP
\fB\-n\fR \fB\-\-no\-act\fR: don't actually do anything, just print the results
.HP
\fB\-u\fR \fB\-\-unlink\fR: Remove the links rather than adding them
......@@ -9,9 +9,14 @@ plan skip_all => 'Test::Strict required to run this test' if $@;
my @FILES = qw(
jh_compilefeatures
jh_exec
jh_generateorbitdir
jh_installeclipse
jh_installjavadoc
jh_installlibs
jh_linkjars
jh_manifest
jh_classpath
jh_scanjavadoc
jh_setupenvironment
);
......