From 62c5a919309223a72c05bbcd2e26559bce67def1 Mon Sep 17 00:00:00 2001 From: jbj Date: Thu, 2 Nov 2000 17:57:25 +0000 Subject: - add support for unzip rodrigob@conectiva.com.br> CVS patchset: 4243 CVS date: 2000/11/02 17:57:25 --- build/parsePrep.c | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'build') diff --git a/build/parsePrep.c b/build/parsePrep.c index 11553e741..da99e357b 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -61,7 +61,7 @@ static int checkOwners(const char *urlfn) static char buf[BUFSIZ]; char args[BUFSIZ]; struct Source *sp; - int compressed = 0; + rpmCompressedMagic compressed = COMPRESSED_NOT; int urltype; for (sp = spec->sources; sp != NULL; sp = sp->next) { @@ -149,8 +149,9 @@ static int checkOwners(const char *urlfn) const char *fn, *urlfn; static char buf[BUFSIZ]; char *taropts; + char *t = NULL; struct Source *sp; - int compressed = 0; + rpmCompressedMagic compressed = COMPRESSED_NOT; int urltype; for (sp = spec->sources; sp != NULL; sp = sp->next) { @@ -205,21 +206,42 @@ static int checkOwners(const char *urlfn) /*@notreached@*/ break; } - if (compressed) { - const char *zipper = rpmGetPath( - (compressed == COMPRESSED_BZIP2 ? "%{_bzip2bin}" : "%{_gzipbin}"), - NULL); - sprintf(buf, - "%s -dc %s | tar %s -\n" + if (compressed != COMPRESSED_NOT) { + const char *zipper; + int needtar = 1; + + switch (compressed) { + case COMPRESSED_NOT: /* XXX can't happen */ + case COMPRESSED_OTHER: + t = "%{_gzipbin} -dc"; + break; + case COMPRESSED_BZIP2: + t = "%{_bzip2bin} -dc"; + break; + case COMPRESSED_ZIP: + t = "%{_unzipbin}"; + needtar = 0; + break; + } + zipper = rpmGetPath(t, NULL); + buf[0] = '\0'; + t = stpcpy(buf, zipper); + xfree(zipper); + *t++ = ' '; + t = stpcpy(t, fn); + if (needtar) + t = stpcpy( stpcpy( stpcpy(t, " | tar "), taropts), " -"); + t = stpcpy(t, + "\n" "STATUS=$?\n" "if [ $STATUS -ne 0 ]; then\n" " exit $STATUS\n" - "fi", - zipper, - fn, taropts); - xfree(zipper); + "fi"); } else { - sprintf(buf, "tar %s %s", taropts, fn); + buf[0] = '\0'; + t = stpcpy( stpcpy(buf, "tar "), taropts); + *t++ = ' '; + t = stpcpy(t, fn); } xfree(urlfn); -- cgit v1.2.3