On Wed, Mar 07, 2001 at 03:48:06AM +1100, Michael (Micksa) Slade wrote: > I sure hope this hasn't already been done :) > > This patch allows you to do two things. > > (1) you can specify files twice and add flags, like: > > %files > / > %config /etc > > (2) you can exclude files from a list, thus: > > %files > / > %exclude /usr/lib/*.so > %exclude /usr/include > > etc. etc. > > If there is enough demand I'll merge it into 4 (as soon as I install 4 > on my machine...) > Here it is (not tested as well as I should) for 4.0 (cvs). -- Rodrigo Barbosa (morcego) - rodrigob at conectiva.com.br Conectiva R&D Team - http://distro.conectiva.com.br "Quis custodiet ipsos custodiet?" - http://www.conectiva.com
diff -urN rpm40/build/files.c rpm40.new/build/files.c
--- rpm40/build/files.c Fri Jan 19 03:50:56 2001
+++ rpm40.new/build/files.c Wed Mar 7 17:11:06 2001
@@ -26,6 +26,18 @@
#define MAXDOCDIR 1024
+#define SPECD_DEFFILEMODE (1<<0)
+#define SPECD_DEFDIRMODE (1<<1)
+#define SPECD_DEFUID (1<<2)
+#define SPECD_DEFGID (1<<3)
+#define SPECD_DEFVERIFY (1<<4)
+
+#define SPECD_FILEMODE (1<<8)
+#define SPECD_DIRMODE (1<<9)
+#define SPECD_UID (1<<10)
+#define SPECD_GID (1<<11)
+#define SPECD_VERIFY (1<<12)
+
/**
*/
typedef struct {
@@ -45,6 +57,7 @@
/*@observer@*/ const char *uname;
/*@observer@*/ const char *gname;
int flags;
+ int specdFlags; /* which attributes have been explicitly specfified. */
int verifyFlags;
const char *langs; /* XXX locales separated with | */
} FileListRec;
@@ -81,9 +94,11 @@
int isDir;
int inFtw;
int currentFlags;
+ int currectSpecdFlags;
int currentVerifyFlags;
AttrRec cur_ar;
AttrRec def_ar;
+ int defSpecdFlags;
int defVerifyFlags;
int nLangs;
/*@only@*/ const char **currentLangs;
@@ -261,11 +276,14 @@
int *resultVerify;
int not;
int verifyFlags;
+ int *specdFlags;
if ((p = strstr(buf, (name = "%verify"))) != NULL) {
resultVerify = &(fl->currentVerifyFlags);
+ specdFlags = &fl->currectSpecdFlags;
} else if ((p = strstr(buf, (name = "%defverify"))) != NULL) {
resultVerify = &(fl->defVerifyFlags);
+ specdFlags = &fl->defSpecdFlags;
} else
return 0;
@@ -331,6 +349,7 @@
}
*resultVerify = not ? ~(verifyFlags) : verifyFlags;
+ *specdFlags |= SPECD_VERIFY;
return 0;
}
@@ -346,11 +365,14 @@
const char *name;
int x;
AttrRec arbuf, *ar = &arbuf, *ret_ar;
+ int *specdFlags;
if ((p = strstr(buf, (name = "%attr"))) != NULL) {
ret_ar = &(fl->cur_ar);
+ specdFlags = &fl->currentSpecdFlags;
} else if ((p = strstr(buf, (name = "%defattr"))) != NULL) {
ret_ar = &(fl->def_ar);
+ specdFlags = &fl->defSpecdFlags;
} else
return 0;
@@ -451,6 +473,9 @@
ar->ar_group = NULL;
dupAttrRec(ar, ret_ar);
+
+ /* XXX fix all this */
+ *specdFlags |= SPECD_UID | SPECD_GID | SPECD_FILEMODE | SPECD_DIRMODE;
return 0;
}
@@ -685,6 +710,7 @@
{ "%dir", 0 }, /* XXX why not RPMFILE_DIR? */
{ "%doc", RPMFILE_DOC },
{ "%ghost", RPMFILE_GHOST },
+ { "%exclude", RPMFILE_EXCLUDE },
{ "%readme", RPMFILE_README },
{ "%license", RPMFILE_LICENSE },
{ "%multilib", 0 },
@@ -945,11 +971,52 @@
clp = *cpioList = xmalloc(sizeof(**cpioList) * fl->fileListRecsUsed);
for (flp = fl->fileList, count = fl->fileListRecsUsed; count > 0; flp++, count--) {
- if ((count > 1) && !strcmp(flp->fileURL, flp[1].fileURL)) {
- rpmError(RPMERR_BADSPEC, _("File listed twice: %s\n"),
- flp->fileURL);
- fl->processingFailed = 1;
- }
+ while ((count > 1) && !strcmp(flp->fileURL, flp[1].fileURL)) {
+ /* two entries for the same file found. */
+ /* merge these two entries. */
+
+ /* file flags */
+ flp[1].flags |= flp->flags;
+
+ /* file mode */
+ if(S_ISDIR(flp->fl_mode)) {
+ if( flp[1].specdFlags & (SPECD_DIRMODE | SPECD_DEFDIRMODE) <
+ flp->specdFlags & (SPECD_DIRMODE | SPECD_DEFDIRMODE)) {
+ flp[1].fl_mode = flp->fl_mode;
+ }
+ } else {
+ if(flp[1].specdFlags & (SPECD_FILEMODE | SPECD_DEFFILEMODE) <
+ flp->specdFlags & (SPECD_FILEMODE | SPECD_DEFFILEMODE)) {
+ flp[1].fl_mode = flp->fl_mode;
+ }
+ }
+
+ /* uid */
+ if( flp[1].specdFlags & (SPECD_UID | SPECD_DEFUID) <
+ flp->specdFlags & (SPECD_UID | SPECD_DEFUID)) {
+ flp[1].fl_uid = flp->fl_uid;
+ flp[1].uname = flp->uname;
+ }
+
+ /* gid */
+ if( flp[1].specdFlags & (SPECD_GID | SPECD_DEFGID) <
+ flp->specdFlags & (SPECD_GID | SPECD_DEFGID)) {
+ flp[1].fl_gid = flp->fl_gid;
+ flp[1].gname = flp->gname;
+ }
+
+ /* verify flags */
+ if( flp[1].specdFlags & (SPECD_VERIFY | SPECD_DEFVERIFY) <
+ flp->specdFlags & (SPECD_VERIFY | SPECD_DEFVERIFY)) {
+ flp[1].verifyFlags = flp->verifyFlags;
+ }
+ /* XXX leakage here :) */
+ /* XXX to-do: language */
+
+ flp++; count--;
+ }
+
+ if(flp->flags & RPMFILE_EXCLUDE ) continue;
if (flp->flags & RPMFILE_MULTILIB_MASK)
multiLibMask |=
@@ -1262,6 +1329,7 @@
}
flp->flags = fl->currentFlags;
+ flp->specdFlags = fl->currectSpecdFlags;
flp->verifyFlags = fl->currentVerifyFlags;
if (multiLib
@@ -1427,6 +1495,9 @@
fl.nLangs = 0;
fl.currentLangs = NULL;
+ fl.currentSpecdFlags = 0;
+ fl.defSpecdFlags = 0;
+
fl.docDirCount = 0;
fl.docDirs[fl.docDirCount++] = xstrdup("/usr/doc");
fl.docDirs[fl.docDirCount++] = xstrdup("/usr/man");
@@ -1458,6 +1529,8 @@
fl.isDir = 0;
fl.inFtw = 0;
fl.currentFlags = 0;
+ /* turn explicit flags into %def'd ones (gosh this is hacky...) */
+ fl.currentSpecdFlags = fl.defSpecdFlags>>8;
fl.currentVerifyFlags = fl.defVerifyFlags;
fl.isSpecialDoc = 0;
diff -urN rpm40/lib/rpmlib.h rpm40.new/lib/rpmlib.h
--- rpm40/lib/rpmlib.h Tue Jan 16 03:37:01 2001
+++ rpm40.new/lib/rpmlib.h Wed Mar 7 17:11:47 2001
@@ -319,7 +319,8 @@
RPMFILE_SPECFILE = (1 << 5), /*!< @todo (unnecessary) marks 1st file in srpm. */
RPMFILE_GHOST = (1 << 6), /*!< from %%ghost */
RPMFILE_LICENSE = (1 << 7), /*!< from %%license */
- RPMFILE_README = (1 << 8) /*!< from %%readme */
+ RPMFILE_README = (1 << 8), /*!< from %%readme */
+ RPMFILE_EXCLUDE = (1 << 9) /*!< from %%exclude */
} rpmfileAttrs;
#define RPMFILE_MULTILIB_SHIFT 9
#define RPMFILE_MULTILIB(N) ((N) << RPMFILE_MULTILIB_SHIFT)
Attachment:
pgp00000.pgp
Description: PGP signature