diff options
author | jbj <devnull@localhost> | 2000-11-02 17:57:25 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2000-11-02 17:57:25 +0000 |
commit | 62c5a919309223a72c05bbcd2e26559bce67def1 (patch) | |
tree | cf2a4bb2d3bce545f7f0351db4ef59d9533ba228 | |
parent | 5f541ebafd9a1ef35d01f5f169a15533f0396d1c (diff) | |
download | librpm-tizen-62c5a919309223a72c05bbcd2e26559bce67def1.tar.gz librpm-tizen-62c5a919309223a72c05bbcd2e26559bce67def1.tar.bz2 librpm-tizen-62c5a919309223a72c05bbcd2e26559bce67def1.zip |
- add support for unzip rodrigob@conectiva.com.br>
CVS patchset: 4243
CVS date: 2000/11/02 17:57:25
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | build/parsePrep.c | 48 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | macros.in | 4 | ||||
-rw-r--r-- | po/rpm.pot | 40 | ||||
-rw-r--r-- | rpmio/macro.c | 26 | ||||
-rw-r--r-- | rpmio/rpmmacro.h | 11 |
7 files changed, 82 insertions, 49 deletions
@@ -25,6 +25,7 @@ - add support for SHA1 as well as MD5 message digests. - add rpmGetRpmlibProvides() to retrieve rpmlib(...) provides "Pawel A. Gajda" <mis@k2.net.pl>. + - add support for unzip rodrigob@conectiva.com.br> 3.0.6 -> 4.0 - use DIRNAMES/BASENAMES/DIRINDICES not FILENAMES in packages and db. 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); diff --git a/configure.in b/configure.in index e20799106..405c3fdff 100644 --- a/configure.in +++ b/configure.in @@ -166,6 +166,7 @@ dnl AC_PATH_PROG(__CPIO, cpio, /bin/cpio, $MYPATH) AC_PATH_PROG(GZIPBIN, gzip, /bin/gzip, $MYPATH) AC_PATH_PROG(__GREP, grep, /bin/grep, $MYPATH) + AC_PATH_PROG(UNZIPBIN, unzip, /usr/bin/unzip, $MYPATH) AC_PATH_PROG(__ID, id, /usr/bin/id, $MYPATH) AC_MSG_CHECKING(checking whether id supports -u) @@ -1,4 +1,4 @@ -# $Id: macros.in,v 1.68 2000/09/01 21:15:41 jbj Exp $ +# $Id: macros.in,v 1.69 2000/11/02 17:57:26 jbj Exp $ # # This is a global RPM configuration file. All changes made here will # be lost when the rpm package is upgraded. Any per-system configuration @@ -55,6 +55,7 @@ %__sed @__SED@ %__ssh @__SSH@ %__tar @__TAR@ +%__unzip %{_unzipbin} #============================================================================== # ---- Build system path macros. @@ -117,6 +118,7 @@ %_srcrpmdir %{_topdir}/SRPMS %_tmppath %{_var}/tmp %_topdir %{_usrsrc}/redhat +%_unzipbin @UNZIPBIN@ #============================================================================== # ---- Optional rpmrc macros. diff --git a/po/rpm.pot b/po/rpm.pot index ebe150bf5..efee3e310 100644 --- a/po/rpm.pot +++ b/po/rpm.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-10-31 13:18-0500\n" +"POT-Creation-Date: 2000-10-31 15:58-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -2052,53 +2052,53 @@ msgstr "" msgid "No patch number %d" msgstr "" -#: build/parsePrep.c:162 +#: build/parsePrep.c:163 #, c-format msgid "No source number %d" msgstr "" -#: build/parsePrep.c:181 +#: build/parsePrep.c:182 #, c-format msgid "Couldn't download nosource %s: %s" msgstr "" -#: build/parsePrep.c:254 +#: build/parsePrep.c:276 msgid "Error parsing %%setup: %s" msgstr "" -#: build/parsePrep.c:269 +#: build/parsePrep.c:291 msgid "line %d: Bad arg to %%setup %c: %s" msgstr "" -#: build/parsePrep.c:287 +#: build/parsePrep.c:309 msgid "line %d: Bad %%setup option %s: %s" msgstr "" -#: build/parsePrep.c:420 +#: build/parsePrep.c:442 msgid "line %d: Need arg to %%patch -b: %s" msgstr "" -#: build/parsePrep.c:428 +#: build/parsePrep.c:450 msgid "line %d: Need arg to %%patch -z: %s" msgstr "" -#: build/parsePrep.c:440 +#: build/parsePrep.c:462 msgid "line %d: Need arg to %%patch -p: %s" msgstr "" -#: build/parsePrep.c:446 +#: build/parsePrep.c:468 msgid "line %d: Bad arg to %%patch -p: %s" msgstr "" -#: build/parsePrep.c:453 +#: build/parsePrep.c:475 msgid "Too many patches!" msgstr "" -#: build/parsePrep.c:457 +#: build/parsePrep.c:479 msgid "line %d: Bad arg to %%patch: %s" msgstr "" -#: build/parsePrep.c:493 +#: build/parsePrep.c:515 msgid "line %d: second %%prep" msgstr "" @@ -3879,35 +3879,35 @@ msgstr "" msgid "Unknown option %c in %s(%s)" msgstr "" -#: rpmio/macro.c:992 +#: rpmio/macro.c:995 #, c-format msgid "Recursion depth(%d) greater than max(%d)" msgstr "" -#: rpmio/macro.c:1058 rpmio/macro.c:1074 +#: rpmio/macro.c:1061 rpmio/macro.c:1077 #, c-format msgid "Unterminated %c: %s" msgstr "" -#: rpmio/macro.c:1114 +#: rpmio/macro.c:1117 msgid "A %% is followed by an unparseable macro" msgstr "" -#: rpmio/macro.c:1240 +#: rpmio/macro.c:1243 msgid "Macro %%%.*s not found, skipping" msgstr "" -#: rpmio/macro.c:1311 +#: rpmio/macro.c:1314 msgid "Target buffer overflow" msgstr "" #. XXX Fstrerror -#: rpmio/macro.c:1491 rpmio/macro.c:1497 +#: rpmio/macro.c:1494 rpmio/macro.c:1500 #, c-format msgid "File %s: %s" msgstr "" -#: rpmio/macro.c:1500 +#: rpmio/macro.c:1503 #, c-format msgid "File %s is smaller than %d bytes" msgstr "" diff --git a/rpmio/macro.c b/rpmio/macro.c index 66f7672db..d8c3adb6f 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -918,7 +918,7 @@ doFoo(MacroBuf *mb, int negate, const char *f, size_t fn, const char *g, size_t (void)urlPath(buf, (const char **)&b); if (*b == '\0') b = "/"; } else if (STREQ("uncompress", f, fn)) { - int compressed = 1; + rpmCompressedMagic compressed = COMPRESSED_OTHER; for (b = buf; (c = *b) && isblank(c);) b++; for (be = b; (c = *be) && !isblank(c);) @@ -938,6 +938,9 @@ doFoo(MacroBuf *mb, int negate, const char *f, size_t fn, const char *g, size_t case 2: /* COMPRESSED_BZIP2 */ sprintf(be, "%%_bzip2 %s", b); break; + case 3: /* COMPRESSED_ZIP */ + sprintf(be, "%%_unzip %s", b); + break; } b = be; } else if (STREQ("S", f, fn)) { @@ -1476,7 +1479,7 @@ rpmFreeMacros(MacroContext *mc) } /* =============================================================== */ -int isCompressed(const char *file, int *compressed) +int isCompressed(const char *file, rpmCompressedMagic *compressed) { FD_t fd; ssize_t nb; @@ -1507,17 +1510,18 @@ int isCompressed(const char *file, int *compressed) rc = 0; - if (((magic[0] == 0037) && (magic[1] == 0213)) || /* gzip */ - ((magic[0] == 0037) && (magic[1] == 0236)) || /* old gzip */ - ((magic[0] == 0037) && (magic[1] == 0036)) || /* pack */ - ((magic[0] == 0037) && (magic[1] == 0240)) || /* SCO lzh */ - ((magic[0] == 0037) && (magic[1] == 0235)) || /* compress */ - ((magic[0] == 0120) && (magic[1] == 0113) && - (magic[2] == 0003) && (magic[3] == 0004)) /* pkzip */ + if ((magic[0] == 'B') && (magic[1] == 'Z')) { + *compressed = COMPRESSED_BZIP2; + } else if ((magic[0] == 0120) && (magic[1] == 0113) && + (magic[2] == 0003) && (magic[3] == 0004)) { /* pkzip */ + *compressed = COMPRESSED_ZIP; + } else if (((magic[0] == 0037) && (magic[1] == 0213)) || /* gzip */ + ((magic[0] == 0037) && (magic[1] == 0236)) || /* old gzip */ + ((magic[0] == 0037) && (magic[1] == 0036)) || /* pack */ + ((magic[0] == 0037) && (magic[1] == 0240)) || /* SCO lzh */ + ((magic[0] == 0037) && (magic[1] == 0235)) /* compress */ ) { *compressed = COMPRESSED_OTHER; - } else if ((magic[0] == 'B') && (magic[1] == 'Z')) { - *compressed = COMPRESSED_BZIP2; } return rc; diff --git a/rpmio/rpmmacro.h b/rpmio/rpmmacro.h index 2b516843d..712dd8c48 100644 --- a/rpmio/rpmmacro.h +++ b/rpmio/rpmmacro.h @@ -107,9 +107,12 @@ void rpmInitMacros (MacroContext * mc, const char * macrofiles); */ void rpmFreeMacros (MacroContext * mc); -#define COMPRESSED_NOT 0 -#define COMPRESSED_OTHER 1 -#define COMPRESSED_BZIP2 2 +typedef enum rpmCompressedMagic_e { + COMPRESSED_NOT = 0, /*!< not compressed */ + COMPRESSED_OTHER = 1, /*!< gzip can handle */ + COMPRESSED_BZIP2 = 2, /*!< bzip2 can handle */ + COMPRESSED_ZIP = 3 /*!< unzip can handle */ +} rpmCompressedMagic; /** * Return type of compression used in file. @@ -117,7 +120,7 @@ void rpmFreeMacros (MacroContext * mc); * @retval compressed address of compression type * @return 0 on success, 1 on I/O error */ -int isCompressed (const char * file, int * compressed); +int isCompressed (const char * file, rpmCompressedMagic * compressed); /** * Return (malloc'ed) concatenated macro expansion(s). |