From: Panu Matilainen Date: Tue, 11 Nov 2008 12:50:53 +0000 (+0200) Subject: Figure out cpio mapflags in rpmfiNew() X-Git-Tag: tznext/4.11.0.1.tizen20130304~3471 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d168d173a4c361cc1f548304743cb63bdc5946d;p=tools%2Flibrpm-tizen.git Figure out cpio mapflags in rpmfiNew() - all the necessary info is there, no need to litter the logic all over the place --- diff --git a/build/files.c b/build/files.c index db9335d..5872aa9 100644 --- a/build/files.c +++ b/build/files.c @@ -1279,11 +1279,6 @@ static void genCpioListAndHeader(FileList fl, fi->fuser = _free(fi->fuser); fi->fgroup = _free(fi->fgroup); - fi->mapflags = CPIO_MAP_PATH | - CPIO_MAP_TYPE | CPIO_MAP_MODE | CPIO_MAP_UID | CPIO_MAP_GID; - if (isSrc) - fi->mapflags |= CPIO_FOLLOW_SYMLINKS; - /* Make the cpio list */ for (i = 0, flp = fl->fileList; i < fi->fc; i++, flp++) { char * b; diff --git a/lib/psm.c b/lib/psm.c index 3b74379..8d279ce 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -300,8 +300,6 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd, } } - fi->mapflags = CPIO_MAP_PATH | CPIO_MAP_MODE | CPIO_MAP_UID | CPIO_MAP_GID; - fi->astriplen = 0; fi->striplen = 0; @@ -1292,8 +1290,6 @@ assert(psm->mi == NULL); } fi->striplen = p ? strlen(p) + 1 : 1; } - fi->mapflags = - CPIO_MAP_PATH | CPIO_MAP_MODE | CPIO_MAP_UID | CPIO_MAP_GID | (fi->mapflags & CPIO_SBIT_CHECK); { struct rpmtd_s filenames; rpmTag ftag = RPMTAG_FILENAMES; diff --git a/lib/rpmfi.c b/lib/rpmfi.c index cb1a093..481e489 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -1285,8 +1285,20 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTag tagN, rpmfiFlags flags) fi->actions = xcalloc(fi->fc, sizeof(*fi->actions)); /* XXX TR_REMOVED needs CPIO_MAP_{ABSOLUTE,ADDDOT} CPIO_ALL_HARDLINKS */ - fi->mapflags = - CPIO_MAP_PATH | CPIO_MAP_MODE | CPIO_MAP_UID | CPIO_MAP_GID; + + /* Figure out mapflags: + * - path, mode, uid and gid are used by everything + * - all binary packages get SBIT_CHECK set + * - if archive size is not known, we're only building this package, + * different rules apply + */ + fi->mapflags = CPIO_MAP_PATH | CPIO_MAP_MODE | CPIO_MAP_UID | CPIO_MAP_GID; + if (asize) { + if (!headerIsSource(h)) fi->mapflags |= CPIO_SBIT_CHECK; + } else { + fi->mapflags |= CPIO_MAP_TYPE; + if (headerIsSource(h)) fi->mapflags |= CPIO_FOLLOW_SYMLINKS; + } _hgfi(h, RPMTAG_FILELINKTOS, &td, defFlags, fi->flinks); _hgfi(h, RPMTAG_FILELANGS, &td, defFlags, fi->flangs); diff --git a/lib/transaction.c b/lib/transaction.c index f7d5e17..f442b82 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -124,13 +124,6 @@ static int handleInstInstalledFiles(const rpmts ts, if (XFA_SKIPPING(fi->actions[fileNum])) continue; - if (!(fi->mapflags & CPIO_SBIT_CHECK)) { - rpm_mode_t omode = rpmfiFMode(otherFi); - if (S_ISREG(omode) && (omode & 06000) != 0) { - fi->mapflags |= CPIO_SBIT_CHECK; - } - } - if (rpmfiCompare(otherFi, fi)) { int rConflicts; @@ -1225,20 +1218,6 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) case TR_REMOVED: break; } - /* check for s-bit files to be removed */ - if (rpmteType(p) == TR_REMOVED) { - fi = rpmfiInit(fi, 0); - while ((i = rpmfiNext(fi)) >= 0) { - rpm_mode_t mode; - if (XFA_SKIPPING(fi->actions[i])) - continue; - (void) rpmfiSetFX(fi, i); - mode = rpmfiFMode(fi); - if (S_ISREG(mode) && (mode & 06000) != 0) { - fi->mapflags |= CPIO_SBIT_CHECK; - } - } - } (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc); } pi = rpmtsiFree(pi); @@ -1352,7 +1331,6 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) char * fstates = fi->fstates; rpmFileAction * actions = fi->actions; sharedFileInfo replaced = fi->replaced; - cpioMapFlags mapflags = fi->mapflags; rpmte savep; int numShared = 0; @@ -1386,8 +1364,6 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) fi->actions = actions; if (replaced != NULL) fi->replaced = replaced; - if (mapflags & CPIO_SBIT_CHECK) - fi->mapflags |= CPIO_SBIT_CHECK; p->fi = fi; } }