diff options
author | jbj <devnull@localhost> | 2001-02-05 22:22:43 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-02-05 22:22:43 +0000 |
commit | 29045caf73b54f5a72b93e41010a263a2d7e3cdb (patch) | |
tree | 469d4c2dc6191f59b245fd3cc398695fc62e9d5d | |
parent | 62ff3348fdfe8712cf49efd52476670bf5245b6b (diff) | |
download | librpm-tizen-29045caf73b54f5a72b93e41010a263a2d7e3cdb.tar.gz librpm-tizen-29045caf73b54f5a72b93e41010a263a2d7e3cdb.tar.bz2 librpm-tizen-29045caf73b54f5a72b93e41010a263a2d7e3cdb.zip |
fix: links weren't renamed correctly.
Use hge/hfd vectors most everywhere.
CVS patchset: 4522
CVS date: 2001/02/05 22:22:43
-rw-r--r-- | lib/cpio.c | 45 | ||||
-rw-r--r-- | lib/install.c | 102 | ||||
-rw-r--r-- | lib/rollback.c | 4 | ||||
-rw-r--r-- | lib/rollback.h | 2 | ||||
-rw-r--r-- | lib/uninstall.c | 2 | ||||
-rw-r--r-- | po/rpm.pot | 59 |
6 files changed, 110 insertions, 104 deletions
diff --git a/lib/cpio.c b/lib/cpio.c index da3797d79..d4bf9d41b 100644 --- a/lib/cpio.c +++ b/lib/cpio.c @@ -246,7 +246,7 @@ int pkgAction(const rpmTransactionSet ts, TFI_t fi, int i, /*@unused@*/fileStage /*@notreached@*/ break; } - rpmMessage(RPMMESS_DEBUG, _(" file: %s%s action: %s\n"), + rpmMessage(RPMMESS_DEBUG, _(" file: %s%s action: %s\n"), fi->dnl[fi->dil[i]], fi->bnl[i], fileActionString((fi->actions ? fi->actions[i] : FA_UNKNOWN)) ); @@ -852,21 +852,6 @@ int fsmMapPath(FSM_t fsm) #undef _tsmask fsm->mapFlags = 0; - if (fsm->goal == FSM_INSTALL) { - if (fsm->iter == NULL) - return rc; - fsm->ix = mapFind(fsm->iter, fsm->path); - } else { - fsm->ix = mapNextIterator(fsm->iter); - } - - if (fsm->goal == FSM_BUILD) { - if (fsm->ix < 0) { - rc = CPIOERR_HDR_TRAILER; - return rc; - } - } - i = fsm->ix; if (fi && i >= 0 && i < fi->fc) { @@ -921,6 +906,7 @@ fprintf(stderr, "*** %s:%s %s\n", fiTypeString(fi), fileActionString(fsm->action break; case FA_ALTNAME: +if (_fsm_debug) fprintf(stderr, "*** %s:%s %s\n", fiTypeString(fi), fileActionString(fsm->action), fsm->path); assert(fi->type == TR_ADDED); fsm->nsuffix = SUFFIX_RPMNEW; @@ -1240,12 +1226,15 @@ static int fsmCommitLinks(FSM_t fsm) { const char * path = fsm->path; const char * nsuffix = fsm->nsuffix; + int iterIndex = fsm->ix; struct stat * st = &fsm->sb; - FSMI_t iter = fsm->iter; - int iterIndex = iter->i; int rc = 0; int i; + fsm->path = NULL; + fsm->nsuffix = NULL; + fsm->ix = -1; + for (fsm->li = fsm->links; fsm->li; fsm->li = fsm->li->next) { if (fsm->li->inode == st->st_ino && fsm->li->dev == st->st_dev) break; @@ -1253,14 +1242,15 @@ static int fsmCommitLinks(FSM_t fsm) for (i = 0; i < fsm->li->nlink; i++) { if (fsm->li->files[i] == NULL) continue; - iter->i = fsm->li->filex[i]; - fsm->path = xstrdup(fsm->li->files[i]); + fsm->ix = fsm->li->filex[i]; + rc = fsmStage(fsm, FSM_MAP); rc = fsmStage(fsm, FSM_COMMIT); fsm->path = _free(fsm->path); + fsm->li->files[i] = _free(fsm->li->files[i]); fsm->li->filex[i] = -1; } - iter->i = iterIndex; + fsm->ix = iterIndex; fsm->nsuffix = nsuffix; fsm->path = path; return rc; @@ -1351,11 +1341,21 @@ int fsmStage(FSM_t fsm, fileStage stage) fsm->mkdirsdone = 1; } - /* Read next header from payload. */ + /* Read next header from payload, checking for end-of-payload. */ rc = fsmStage(fsm, FSM_NEXT); } if (rc) break; + /* Identify mapping index. */ + fsm->ix = ((fsm->goal == FSM_INSTALL) + ? mapFind(fsm->iter, fsm->path) : mapNextIterator(fsm->iter)); + + /* On build, detect end-of-loop. */ + if (fsm->goal == FSM_BUILD && fsm->ix < 0) { + rc = CPIOERR_HDR_TRAILER; + break; + } + /* Generate file path. */ rc = fsmMapPath(fsm); if (rc) break; @@ -1389,6 +1389,7 @@ int fsmStage(FSM_t fsm, fileStage stage) case FSM_PRE: break; case FSM_MAP: + rc = fsmMapPath(fsm); break; case FSM_MKDIRS: { const char * path = fsm->path; diff --git a/lib/install.c b/lib/install.c index a4789675b..ebd4a5239 100644 --- a/lib/install.c +++ b/lib/install.c @@ -37,8 +37,9 @@ static struct tagMacro { * @param h header * @return 0 always */ -static int rpmInstallLoadMacros(Header h) +static int rpmInstallLoadMacros(TFI_t fi, Header h) { + HGE_t hge = (HGE_t)fi->hge; struct tagMacro *tagm; union { const char * ptr; @@ -48,7 +49,7 @@ static int rpmInstallLoadMacros(Header h) int_32 type; for (tagm = tagMacros; tagm->macroname != NULL; tagm++) { - if (!headerGetEntry(h, tagm->tag, &type, (void **) &body, NULL)) + if (!hge(h, tagm->tag, &type, (void **) &body, NULL)) continue; switch (type) { case RPM_INT32_TYPE: @@ -100,10 +101,13 @@ static void setFileOwners(TFI_t fi) * @param h header * @return none */ -static void trimChangelog(Header h) +static void trimChangelog(TFI_t fi, Header h) { + HGE_t hge = (HGE_t)fi->hge; + HFD_t hfd = fi->hfd; int * times; - char ** names, ** texts; + const char ** names, ** texts; + int cnt, ctt; long numToKeep = rpmExpandNumeric( "%{?_instchangelog:%{_instchagelog}}%{!?_instchangelog:5}"); char * end; @@ -118,11 +122,11 @@ static void trimChangelog(Header h) return; } - if (!headerGetEntry(h, RPMTAG_CHANGELOGTIME, NULL, (void **) ×, - &count) || + if (!hge(h, RPMTAG_CHANGELOGTIME, NULL, (void **) ×, &count) || count < numToKeep) return; - headerGetEntry(h, RPMTAG_CHANGELOGNAME, NULL, (void **) &names, &count); - headerGetEntry(h, RPMTAG_CHANGELOGTEXT, NULL, (void **) &texts, &count); + + hge(h, RPMTAG_CHANGELOGNAME, &cnt, (void **) &names, &count); + hge(h, RPMTAG_CHANGELOGTEXT, &ctt, (void **) &texts, &count); headerModifyEntry(h, RPMTAG_CHANGELOGTIME, RPM_INT32_TYPE, times, numToKeep); @@ -131,8 +135,8 @@ static void trimChangelog(Header h) headerModifyEntry(h, RPMTAG_CHANGELOGTEXT, RPM_STRING_ARRAY_TYPE, texts, numToKeep); - free(names); - free(texts); + names = hfd(names, cnt); + texts = hfd(texts, ctt); } #endif /* DYING */ @@ -143,8 +147,10 @@ static void trimChangelog(Header h) * @param actions array of file dispositions * @return 0 on success, 1 on failure */ -static int mergeFiles(Header h, Header newH, TFI_t fi) +static int mergeFiles(TFI_t fi, Header h, Header newH) { + HGE_t hge = (HGE_t)fi->hge; + HFD_t hfd = fi->hfd; fileAction * actions = fi->actions; int i, j, k, fc; int_32 type = 0; @@ -179,18 +185,18 @@ static int mergeFiles(Header h, Header newH, TFI_t fi) RPMTAG_CONFLICTNAME, RPMTAG_CONFLICTVERSION, RPMTAG_CONFLICTFLAGS }; - headerGetEntry(h, RPMTAG_SIZE, NULL, (void **) &fileSizes, NULL); + hge(h, RPMTAG_SIZE, NULL, (void **) &fileSizes, NULL); fileSize = *fileSizes; - headerGetEntry(newH, RPMTAG_FILESIZES, NULL, (void **) &fileSizes, &count); + hge(newH, RPMTAG_FILESIZES, NULL, (void **) &fileSizes, &count); for (i = 0, fc = 0; i < count; i++) if (actions[i] != FA_SKIPMULTILIB) { fc++; fileSize += fileSizes[i]; } headerModifyEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE, &fileSize, 1); + for (i = 0; mergeTags[i]; i++) { - if (!headerGetEntryMinMemory(newH, mergeTags[i], &type, - (const void **) &data, &count)) + if (!hge(newH, mergeTags[i], &type, (void **) &data, &count)) continue; switch (type) { case RPM_CHAR_TYPE: @@ -232,15 +238,12 @@ static int mergeFiles(Header h, Header newH, TFI_t fi) return 1; /*@notreached@*/ break; } - data = headerFreeData(data, type); + data = hfd(data, type); } - headerGetEntry(newH, RPMTAG_DIRINDEXES, NULL, (void **) &newDirIndexes, - &count); - headerGetEntryMinMemory(newH, RPMTAG_DIRNAMES, NULL, - (const void **) &newDirNames, NULL); - headerGetEntry(h, RPMTAG_DIRINDEXES, NULL, (void **) &dirIndexes, NULL); - headerGetEntryMinMemory(h, RPMTAG_DIRNAMES, NULL, (const void **) &data, - &dirNamesCount); + hge(newH, RPMTAG_DIRINDEXES, NULL, (void **) &newDirIndexes, &count); + hge(newH, RPMTAG_DIRNAMES, NULL, (void **) &newDirNames, NULL); + hge(h, RPMTAG_DIRINDEXES, NULL, (void **) &dirIndexes, NULL); + hge(h, RPMTAG_DIRNAMES, NULL, (void **) &data, &dirNamesCount); dirNames = xcalloc(dirNamesCount + fc, sizeof(char *)); for (i = 0; i < dirNamesCount; i++) @@ -262,29 +265,26 @@ static int mergeFiles(Header h, Header newH, TFI_t fi) headerAddOrAppendEntry(h, RPMTAG_DIRNAMES, RPM_STRING_ARRAY_TYPE, dirNames + dirNamesCount, dirCount - dirNamesCount); - if (data) free (data); - if (newDirNames) free (newDirNames); + data = hfd(data, -1); + newDirNames = hfd(newDirNames, -1); free (newdata); free (dirNames); for (i = 0; i < 9; i += 3) { const char **Names, **EVR, **newNames, **newEVR; + int nnt, nvt, rnt; uint_32 *Flags, *newFlags; int Count = 0, newCount = 0; - if (!headerGetEntryMinMemory(newH, requireTags[i], NULL, - (const void **) &newNames, &newCount)) + if (!hge(newH, requireTags[i], &nnt, (void **) &newNames, &newCount)) continue; - headerGetEntryMinMemory(newH, requireTags[i+1], NULL, - (const void **) &newEVR, NULL); - headerGetEntry(newH, requireTags[i+2], NULL, (void **) &newFlags, NULL); - if (headerGetEntryMinMemory(h, requireTags[i], NULL, - (const void **) &Names, &Count)) + hge(newH, requireTags[i+1], &nvt, (void **) &newEVR, NULL); + hge(newH, requireTags[i+2], NULL, (void **) &newFlags, NULL); + if (hge(h, requireTags[i], &rnt, (void **) &Names, &Count)) { - headerGetEntryMinMemory(h, requireTags[i+1], NULL, - (const void **) &EVR, NULL); - headerGetEntry(h, requireTags[i+2], NULL, (void **) &Flags, NULL); + hge(h, requireTags[i+1], NULL, (void **) &EVR, NULL); + hge(h, requireTags[i+2], NULL, (void **) &Flags, NULL); for (j = 0; j < newCount; j++) for (k = 0; k < Count; k++) if (!strcmp (newNames[j], Names[k]) @@ -314,6 +314,9 @@ static int mergeFiles(Header h, Header newH, TFI_t fi) headerAddOrAppendEntry(h, requireTags[i+2], RPM_INT32_TYPE, newFlags, k); } + newNames = hfd(newNames, nnt); + newEVR = hfd(newEVR, nvt); + Names = hfd(Names, rnt); } return 0; } @@ -326,6 +329,7 @@ static int mergeFiles(Header h, Header newH, TFI_t fi) */ static int markReplacedFiles(const rpmTransactionSet ts, const TFI_t fi) { + HGE_t hge = (HGE_t)fi->hge; rpmdb rpmdb = ts->rpmdb; const struct sharedFileInfo * replaced = fi->replaced; const struct sharedFileInfo * sfi; @@ -368,7 +372,7 @@ static int markReplacedFiles(const rpmTransactionSet ts, const TFI_t fi) modified = 0; - if (!headerGetEntry(h, RPMTAG_FILESTATES, NULL, (void **)&secStates, &count)) + if (!hge(h, RPMTAG_FILESTATES, NULL, (void **)&secStates, &count)) continue; prev = rpmdbGetIteratorOffset(mi); @@ -696,7 +700,7 @@ int rpmInstallSourcePackage(const char * rootDir, FD_t fd, rpmBuildFileList(fi->h, &fi->apath, NULL); - rpmInstallLoadMacros(fi->h); + rpmInstallLoadMacros(fi, fi->h); rc = installSources(ts, fi, specFile); @@ -716,7 +720,8 @@ exit: */ int installBinaryPackage(const rpmTransactionSet ts, TFI_t fi) { -/*@observer@*/ static char * stepName = "install"; + HGE_t hge = (HGE_t)fi->hge; +/*@observer@*/ static char * stepName = " install"; Header oldH = NULL; int otherOffset = 0; int ec = 2; /* assume error return */ @@ -760,8 +765,7 @@ int installBinaryPackage(const rpmTransactionSet ts, TFI_t fi) * prefix stripped to form the cpio list, while all other packages * need the leading / stripped. */ - rc = headerGetEntry(fi->h, RPMTAG_DEFAULTPREFIX, NULL, - (void **) &p, NULL); + rc = hge(fi->h, RPMTAG_DEFAULTPREFIX, NULL, (void **) &p, NULL); fi->striplen = (rc ? strlen(p) + 1 : 1); fi->mapflags = CPIO_MAP_PATH | CPIO_MAP_MODE | CPIO_MAP_UID | CPIO_MAP_GID; @@ -772,11 +776,9 @@ int installBinaryPackage(const rpmTransactionSet ts, TFI_t fi) rpmBuildFileList(fi->h, &fi->apath, NULL); if (fi->fuser == NULL) - headerGetEntryMinMemory(fi->h, RPMTAG_FILEUSERNAME, NULL, - (const void **) &fi->fuser, NULL); + hge(fi->h, RPMTAG_FILEUSERNAME, NULL, (void **) &fi->fuser, NULL); if (fi->fgroup == NULL) - headerGetEntryMinMemory(fi->h, RPMTAG_FILEGROUPNAME, NULL, - (const void **) &fi->fgroup, NULL); + hge(fi->h, RPMTAG_FILEGROUPNAME, NULL, (void **) &fi->fgroup, NULL); if (fi->fuids == NULL) fi->fuids = xcalloc(sizeof(*fi->fuids), fi->fc); if (fi->fgids == NULL) @@ -833,7 +835,7 @@ int installBinaryPackage(const rpmTransactionSet ts, TFI_t fi) for (i = 0; i < fi->fc; i++) { if (fi->actions && fi->actions[i] == FA_CREATE) continue; - rpmMessage(RPMMESS_DEBUG, _(" file: %s%s action: %s\n"), + rpmMessage(RPMMESS_DEBUG, _(" file: %s%s action: %s\n"), fi->dnl[fi->dil[i]], fi->bnl[i], fileActionString((fi->actions ? fi->actions[i] : FA_UNKNOWN)) ); } @@ -863,7 +865,7 @@ int installBinaryPackage(const rpmTransactionSet ts, TFI_t fi) } #ifdef DYING - trimChangelog(h); + trimChangelog(fi, fi->h); #endif /* if this package has already been installed, remove it from the database @@ -874,16 +876,14 @@ int installBinaryPackage(const rpmTransactionSet ts, TFI_t fi) if (ts->transFlags & RPMTRANS_FLAG_MULTILIB) { uint_32 multiLib, * newMultiLib, * p; - if (headerGetEntry(fi->h, RPMTAG_MULTILIBS, NULL, - (void **) &newMultiLib, NULL) - && headerGetEntry(oldH, RPMTAG_MULTILIBS, NULL, - (void **) &p, NULL)) { + if (hge(fi->h, RPMTAG_MULTILIBS, NULL, (void **) &newMultiLib, NULL) && + hge(oldH, RPMTAG_MULTILIBS, NULL, (void **) &p, NULL)) { multiLib = *p; multiLib |= *newMultiLib; headerModifyEntry(oldH, RPMTAG_MULTILIBS, RPM_INT32_TYPE, &multiLib, 1); } - if (mergeFiles(oldH, fi->h, fi)) + if (mergeFiles(fi, oldH, fi->h)) goto exit; } diff --git a/lib/rollback.c b/lib/rollback.c index 7f50481e4..3678f0306 100644 --- a/lib/rollback.c +++ b/lib/rollback.c @@ -168,8 +168,8 @@ void freeFi(TFI_t fi) /*@observer@*/ const char *const fiTypeString(TFI_t fi) { switch(fi->type) { - case TR_ADDED: return "install"; - case TR_REMOVED: return " erase"; + case TR_ADDED: return " install"; + case TR_REMOVED: return " erase"; default: return "???"; } /*@noteached@*/ diff --git a/lib/rollback.h b/lib/rollback.h index b30dcbbc5..18fbf5f0f 100644 --- a/lib/rollback.h +++ b/lib/rollback.h @@ -37,7 +37,7 @@ typedef enum fileStage_e { FSM_BUILD = 9, FSM_CREATE = _fi(17), - FSM_MAP = _fd(18), + FSM_MAP = _fi(18), FSM_MKDIRS = _fi(19), FSM_RMDIRS = _fi(20), FSM_MKLINKS = _fi(21), diff --git a/lib/uninstall.c b/lib/uninstall.c index 4907292ee..f8542e5fe 100644 --- a/lib/uninstall.c +++ b/lib/uninstall.c @@ -16,7 +16,7 @@ int removeBinaryPackage(const rpmTransactionSet ts, TFI_t fi) { -/*@observer@*/ static char * stepName = "erase"; +/*@observer@*/ static char * stepName = " erase"; Header h; const void * pkgKey = NULL; int rc = 0; diff --git a/po/rpm.pot b/po/rpm.pot index 3be20501d..d1da401ba 100644 --- a/po/rpm.pot +++ b/po/rpm.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2001-02-05 12:47-0500\n" +"POT-Creation-Date: 2001-02-05 17:21-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" @@ -2185,9 +2185,9 @@ msgstr "" msgid "line %d: Bad %s number: %s\n" msgstr "" -#: lib/cpio.c:249 lib/install.c:836 +#: lib/cpio.c:249 #, c-format -msgid " file: %s%s action: %s\n" +msgid " file: %s%s action: %s\n" msgstr "" #: lib/cpio.c:284 @@ -2224,50 +2224,50 @@ msgstr "" msgid "%9d %s\n" msgstr "" -#: lib/cpio.c:1546 +#: lib/cpio.c:1547 #, c-format msgid "%s saved as %s\n" msgstr "" -#: lib/cpio.c:1651 +#: lib/cpio.c:1652 #, c-format msgid "%s created as %s\n" msgstr "" -#: lib/cpio.c:2131 +#: lib/cpio.c:2132 #, c-format msgid "(error 0x%x)" msgstr "" -#: lib/cpio.c:2134 +#: lib/cpio.c:2135 msgid "Bad magic" msgstr "" -#: lib/cpio.c:2135 +#: lib/cpio.c:2136 msgid "Bad/unreadable header" msgstr "" -#: lib/cpio.c:2156 +#: lib/cpio.c:2157 msgid "Header size too big" msgstr "" -#: lib/cpio.c:2157 +#: lib/cpio.c:2158 msgid "Unknown file type" msgstr "" -#: lib/cpio.c:2158 +#: lib/cpio.c:2159 msgid "Missing hard link" msgstr "" -#: lib/cpio.c:2159 +#: lib/cpio.c:2160 msgid "MD5 sum mismatch" msgstr "" -#: lib/cpio.c:2160 +#: lib/cpio.c:2161 msgid "Internal error" msgstr "" -#: lib/cpio.c:2169 +#: lib/cpio.c:2170 msgid " failed - " msgstr "" @@ -2546,7 +2546,7 @@ msgstr "" msgid "dataLength() RPM_STRING_TYPE count must be 1.\n" msgstr "" -#: lib/header.c:207 lib/header.c:1017 lib/install.c:230 +#: lib/header.c:207 lib/header.c:1017 lib/install.c:236 #, c-format msgid "Data type %d not supported\n" msgstr "" @@ -2631,12 +2631,12 @@ msgstr "" msgid "(unknown type)" msgstr "" -#: lib/install.c:79 +#: lib/install.c:80 #, c-format msgid "user %s does not exist - using root\n" msgstr "" -#: lib/install.c:87 +#: lib/install.c:88 #, c-format msgid "group %s does not exist - using root\n" msgstr "" @@ -2646,51 +2646,56 @@ msgstr "" #. * was used up - if so, we should return a different error. #. #. XXX FIXME: Fclose with libio destroys errno -#: lib/install.c:455 +#: lib/install.c:459 #, c-format msgid "unpacking of archive failed%s%s: %s\n" msgstr "" -#: lib/install.c:456 +#: lib/install.c:460 msgid " on file " msgstr "" -#: lib/install.c:497 +#: lib/install.c:501 #, c-format msgid "cannot create %s %s\n" msgstr "" -#: lib/install.c:503 +#: lib/install.c:507 #, c-format msgid "cannot write to %s\n" msgstr "" -#: lib/install.c:524 +#: lib/install.c:528 msgid "installing a source package\n" msgstr "" -#: lib/install.c:576 +#: lib/install.c:580 msgid "source package contains no .spec file\n" msgstr "" -#: lib/install.c:656 +#: lib/install.c:660 msgid "source package expected, binary found\n" msgstr "" -#: lib/install.c:725 lib/uninstall.c:24 +#: lib/install.c:730 lib/uninstall.c:24 #, c-format msgid "%s: %s-%s-%s has %d files, test = %d\n" msgstr "" -#: lib/install.c:792 lib/install.c:893 lib/uninstall.c:62 lib/uninstall.c:83 +#: lib/install.c:794 lib/install.c:893 lib/uninstall.c:62 lib/uninstall.c:83 #, c-format msgid "%s: running %s script(s) (if any)\n" msgstr "" -#: lib/install.c:799 +#: lib/install.c:801 msgid "skipping %s-%s-%s install, %%pre scriptlet failed rc %d\n" msgstr "" +#: lib/install.c:838 +#, c-format +msgid " file: %s%s action: %s\n" +msgstr "" + #: lib/misc.c:328 lib/misc.c:333 lib/misc.c:339 #, c-format msgid "error creating temporary file %s\n" |