Factorize external program names into variables
authorTorsten Maehne <Torsten.Maehne@gmx.de>
Mon, 30 Jul 2012 17:00:31 +0000 (19:00 +0200)
committerPhilipp A. Hartmann <philipp.hartmann@offis.de>
Mon, 27 Aug 2012 11:09:31 +0000 (13:09 +0200)
The external programs (tar, xdelta) called by the pristine-tar script have
been hardcoded until now.  This requires that both program names are the
first in the user's PATH, which can lead to problems, especially on
non-GNU/Linux platforms:

 * Pristine-tar uses options (e.g., "--owner"), which are only present
   in GNU tar.
 * Pristine-tar uses the old 1.1 release series Xdelta, which is
   syntactically incompatible to the 3.0 release series of Xdelta.

This commit centralizes the definition of the program names of tar and
xdelta so that their exact names (or locations)  can be easily configured.

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
pristine-tar

index c75e4fc08521352b003da5c6176dca6735413730..c670d2d096e754af274b92daa5644898f248e5dc 100755 (executable)
@@ -189,6 +189,9 @@ $ENV{LANG}='C';
 delete $ENV{TAR_OPTIONS};
 delete $ENV{TAPE};
 
+my $tar_program = "tar";
+my $xdelta_program = "xdelta";
+
 my $message;
 
 dispatch(
@@ -345,7 +348,7 @@ sub recreatetarball_helper {
        
        my $ret="$tempdir/recreatetarball";
 
-       doit("tar", "cf", $ret, "--owner", 0, "--group", 0, 
+       doit($tar_program, "cf", $ret, "--owner", 0, "--group", 0, 
                "--numeric-owner", "-C", "$tempdir/workdir",
                "--no-recursion", "--mode", "0644", 
                "--files-from", "$tempdir/manifest");
@@ -391,7 +394,7 @@ sub gentar {
        my $ok;
        foreach my $variant (@try) {
                my $recreatetarball=$variant->();
-               my $ret=try_doit("xdelta", "patch", $delta->{delta}, $recreatetarball, $out);
+               my $ret=try_doit($xdelta_program, "patch", $delta->{delta}, $recreatetarball, $out);
                if ($ret == 0) {
                        $ok=1;
                        last;
@@ -489,7 +492,7 @@ sub gendelta {
        if (! exists $opts{recreatetarball}) {
                my $sourcedir="$tempdir/tmp";
                doit("mkdir", $sourcedir);
-               doit("tar", "xf", File::Spec->rel2abs($tarball), "-C", $sourcedir);
+               doit($tar_program, "xf", File::Spec->rel2abs($tarball), "-C", $sourcedir);
                # if all files were in a subdir, use the subdir as the sourcedir
                my @out=grep { $_ ne "$sourcedir/.." && $_ ne "$sourcedir/." }
                        (glob("$sourcedir/*"), glob("$sourcedir/.*"));
@@ -503,7 +506,7 @@ sub gendelta {
        }
 
        $delta{delta}="$tempdir/delta";
-       my $ret=system("xdelta delta -0 --pristine $recreatetarball $tarball $delta{delta}") >> 8;
+       my $ret=system("$xdelta_program delta -0 --pristine $recreatetarball $tarball $delta{delta}") >> 8;
        # xdelta exits 1 on success if there were differences
        if ($ret != 1 && $ret != 0) {
                error "xdelta failed with return code $ret";