Commit 4d3e2123 authored by Niels Thykier's avatar Niels Thykier
Browse files

Rewrite jh_exec using Debhelper's Dh_Lib



Signed-off-by: default avatarNiels Thykier <niels@thykier.net>
parent 045b5b32
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
jh_build.1
jh_depends.1
jh_exec.1
jh_installlibs.1
jh_linkjars.1
jh_makepkg.1
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ 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_manifest tmp/jh_manifest.1
	$(POD2MAN) jh_classpath tmp/jh_classpath.1
	$(POD2MAN) jh_installjavadoc tmp/jh_installjavadoc.1
+62 −55
Original line number Diff line number Diff line
#!/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>>]

=head1 DESCRIPTION

ARGS="i indep a arch s same-arch p package P tmpdir v verbose n no-act" parseargs "$@"
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.

VERBOSE="`getarg v verbose`"
dh_testdir
Note that executable jar files requires L<jarwrapper(1)>.  Please see
the tutorials in /usr/share/doc/javahelper for more information.

for p in `findpackages`; do
=head1 OPTIONS

   PACKAGEDIR="`getarg P tmpdir`"
   if [ -z "$PACKAGEDIR" ]; then
      PACKAGEDIR="`pwd`/debian/$p"
   else
      PACKAGEDIR=`readlink -f $PACKAGEDIR`
   fi
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

jh_exec.1

deleted100644 → 0
+0 −25
Original line number Diff line number Diff line
.\" 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
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ plan skip_all => 'Test::Strict required to run this test' if $@;

my @FILES = qw(
  jh_compilefeatures
  jh_exec
  jh_generateorbitdir
  jh_installeclipse
  jh_installjavadoc