From fc4658803ad5b590b7fc4e6f2cefd8e347213b54 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 4 Jan 2012 17:39:33 -0400 Subject: [PATCH] run external program from zgz --- Makefile.PL | 7 ++++--- zgz/zgz.c | 25 ++++++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 9e2a14e..becc2fa 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -13,6 +13,7 @@ pure_install:: extra_install ZOMBIES=zgz/pit/suse-bzip2/suse-bzip2 BINS=zgz/zgz $(ZOMBIES) +ZGZ_LIB=$(PREFIX)/lib/zgz extra_build: $(BINS) pristine-tar.spec pod2man -c pristine-tar pristine-tar > pristine-tar.1 @@ -22,7 +23,7 @@ extra_build: $(BINS) pristine-tar.spec ZGZ_SOURCES = zgz/zgz.c zgz/gzip/*.c zgz/old-bzip2/*.c zgz/zgz: $(ZGZ_SOURCES) - gcc -Wall -O2 -o $@ $(ZGZ_SOURCES) -lz + gcc -Wall -O2 -o $@ $(ZGZ_SOURCES) -lz -DZGZ_LIB=\"$(ZGZ_LIB)\" SUSE_BZIP2_SOURCES = zgz/pit/suse-bzip2/*.c zgz/pit/suse-bzip2/suse-bzip2: $(SUSE_BZIP2_SOURCES) @@ -33,8 +34,8 @@ extra_install: install -d $(DESTDIR)/usr/share/man/man1 install pristine-tar pristine-gz pristine-bz2 zgz/zgz $(DESTDIR)/usr/bin install -m 0644 *.1 $(DESTDIR)/usr/share/man/man1 - install -d $(DESTDIR)/usr/lib/zgz - install $(ZOMBIES) $(DESTDIR)/usr/lib/zgz + install -d $(DESTDIR)$(ZGZ_LIB) + install $(ZOMBIES) $(DESTDIR)$(ZGZ_LIB) extra_clean: pristine-tar.spec rm -f *.1 $(BINS) diff --git a/zgz/zgz.c b/zgz/zgz.c index f2eb05b..8c37e77 100644 --- a/zgz/zgz.c +++ b/zgz/zgz.c @@ -132,6 +132,7 @@ static void gz_compress(int, int, const char *, uint32_t, int, int, int, int, in static void usage(void); static void display_version(void); static void display_license(void); +static void shamble(char *, int); int main(int, char **p); @@ -181,6 +182,7 @@ main(int argc, char **argv) int mflag = 0; int fflag = 0; int xflag = -1; + int suse_quirk = 0; int ntfs_quirk = 0; int level = 6; int osflag = GZIP_OS_UNIX; @@ -269,6 +271,9 @@ main(int argc, char **argv) /* maximum compression but without indicating so */ level = 9; xflag = 0; + } else if (strcmp(optarg, "suse") == 0) { + /* SuSe's patched bzip2. (Inexact emulation.) */ + suse_quirk = 1; } else { fprintf(stderr, "%s: unknown quirk!\n", progname); usage(); @@ -324,11 +329,12 @@ main(int argc, char **argv) } gnuzip(STDIN_FILENO, STDOUT_FILENO, origname, timestamp, level, osflag, rsync, new_rsync); } else if (bzold) { - if (quirks) { - fprintf(stderr, "%s: quirks not supported with --old-bzip\n", progname); - return 1; + if (suse_quirk) { + shamble("suse-bzip2", level); + } + else { + old_bzip2(level); } - old_bzip2(level); } else { if (rsync || new_rsync) { fprintf(stderr, "%s: --rsyncable not supported with --zlib\n", progname); @@ -499,6 +505,15 @@ gz_compress(int in, int out, const char *origname, uint32_t mtime, int level, in free(outbufp); } +/* runs an external, reanimated compressor program */ +static void +shamble(char *zombie, int level) +{ + char buf[128]; + sprintf(buf, "%s/%s %i", ZGZ_LIB, zombie, level); + exit(system(buf)); +} + /* display usage */ static void usage(void) @@ -530,7 +545,7 @@ usage(void) " -R --rsyncable make rsync-friendly archive\n" " -r --new-rsyncable make rsync-friendly archive (new version)\n" " \nzlib-specific options:\n" - " -k --quirk QUIRK enable a format quirk (buggy-bsd, ntfs, perl)\n"); + " -k --quirk QUIRK enable a format quirk (buggy-bsd, ntfs, perl, suse)\n"); exit(0); } -- 2.7.4