Fix minor typo in pristine-bz2.
Factorize external program names into variables

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>
Update .gitignore

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
Makefile.PL: handle PREFIX consistently

This patch fixes the handling of the PREFIX variable in the generated
Makefile.  The following issues are addressed:

 * drop explicit PREFIX in WriteMakefile call

   By default, the local $Config{prefix} setting should be fine.
   This allows to specify either PREFIX or INSTALL_BASE as Makefile.PL
   parameter, depending on the user needs.

 * use PREFIX in extra_install target

   Previously, pristine-tar, pristine-gz, pristine-bz2, pristine-xz, and
   zgz were always installed to /usr/bin (if $DESTDIR was not set). Also,
   the man pages were always installed to /usr/share/man/man1.

 * call $(MAKE) and pass PREFIX to the build of suse-bzip2

   Although PREFIX is not really used during the build of suse-bzip2,
   it should be passed to the build to enable e.g. the inclusion
   of the "correct" location during the linking process.

Reported-by: Torsten Maehne <torsten.maehne@gmx.de>
Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
Makefile.PL: drop unused suse-bzip2 target

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
Makefile.PL: use #!/usr/bin/env perl

To run the Makefile.PL script on other platforms, this
patch changes the shebang line to '/usr/bin/env perl'.

This is more likely to succeed on platforms (SunOS, *BSD,
Mac OS X), where the Perl binary is not located at /usr/bin.

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
Makefile.PL: avoid in-place editing with sed

This patch avoids the usage of the in-place editing option '-i' of sed for
version number extraction from debian/changelog to update pristine-tar.spec.

The -i option is not supported by all versions of sed (e.g. not by SunOS 5.9
nor by NetBSD 6.0).  Additionally, the exact syntax may vary.  E.g., the sed
of Mac OS X requires -i to be followed by a suffix, which is added to the
original filename to create a backup file.  The portable solution is to avoid
the in-place editing altogether and to instead write first to a temporary
file, which is then moved back to the original filename.

In addition to the use of a temporary file, the rule has been changed to
use the PERLRUN variable to invoke the correct perl interpreter and a
dependency on debian/changelog (the phonyness of the rule could be
dropped as well).

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
Makefile.PL: use MAN1PODS to build and install manpages

The installation (and removal/cleanup) of the generated manpages
can be done by MakeMaker directly.

This patch adds the corresponding configuration in a Debian Perl
Policy-compliant way (e.g. create .1 files instead of .1p files).

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
Makefile.PL: use EXE_FILES and clean rules, add info

Installation of the scripts and cleanup of the zgz binary
by using MakeMake magic instead of manual rules.

Additionally, AUTHOR and ABSTRACT information is added to the
WriteMakefile call.
suse-bzip2/Makefile: add Mac OS X support

This commit changes the  suse-bzip2 Makefile to compile a dynamic
libbz2.dylib on Mac OS X and ensures that zgz sets DYLD_LIBRARY_PATH
on Mac OS X to swap in a different library.

The suse-bzip2 Makefile was only able to handle the compilation of
shared object libraries like they are used on Linux. Mac OS X uses
dynamic libraries, which require different compiler and linker switches.

MacPorts checks all binaries installed by a port for broken linkage.
This requires that the install_name for libbz2 is set in the suse-bzip2
Makefile to its pristine-tar install location (based on PREFIX).

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
(cherry picked from commit 295dda0608a979d11b7acfb565745b7f507a27a1)
zgz: dynamic library handling on Mac OS X

On Mac OS X, DYLD_LIBRARY_PATH has to be set instead of LD_LIBRARY_PATH
to find dynamic libraries in a non-standard path.

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
(cherry picked from commit 19748569d2d98100dabbc3c3ec9d93b8f32e5ef7)
Revert "Makefile.PL: use MAN1PODS to build and install manpages"

This reverts commit 86d0f72ba700b7e13e42e0660695d2cda02e7f66 (mostly)

Caused lintian warnings about manpage sections being 1p instead of 1
changelog
Makefile.PL: add custom build parameters

This patch introduces three custom build parameters

 * PERL_SHEBANG
     Configure the #! line in the installed perl scripts.
     May be needed on some passwords, in case MakeMaker
     does not get the installation right
 * TAR_PROGRAM, XDELTA_PROGRAM
     Set a custom name (or location) for the required (GNU) tar and
     xdelta programs, in case they are not callable through their
     default names from the $PATH

If set, the variables are used to munge the corresponding parts of
the scripts.  The $tar_program and $xdelta_program variables in
pristine-tar are now marked as such.

The patch itself extends the "macro" section of the MakeMaker generated
Makefile.  To call the inherited function, the package needs to be set
explicitly.

This patch is an updated version, incorporating a spacing fix when
using multiple replacements, as discovered by Torsten Maehne during
his review.

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
Reviewed-by: Torsten Maehne <Torsten.Maehne@gmx.de>
Makefile.PL: add message about custom parameters

Since adding custom parameters to Makefile.PL scripts is not
transparently supported by MakeMaker, recent versions print a
note about unknown options given to the script.

Nevertheless, such parameters are handled correctly and are
passed through to a reinvocation in case of a changed Makefile.PL.
A message is printed to inform the user about this fact.

Signed-off-by: Philipp A. Hartmann <philipp.hartmann@offis.de>
Improve INSTALL instructions.
changelog
zgz: Don't hardcode /lib, avoid segfaulting on > 128 character paths

There were a number of issues with zgz:

* It had a fixed 128 (!) size limit on paths, and if we happened
  to be installed into one longer than that, the program would
  likely segfault.
* Calling exit(system()) is inefficient; we might as well just
  execve() and avoid having a process just blocked in waitpid()
  on another.
* We should honor LIBDIR, in order to support lib64-style "multilib"
  as well as full Debian-style "multiarch".

Based on a patch from Colin Walters <walters@verbum.org>
changelog
Fix typo that led to incorrect error message when pristine-tar branch does not exist. Closes: #700448 Thanks, paul cannon