[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

%includesrc



Hi everyone! Hi Jeff!

We have some packages here, probably like any other distribution, that
are getting hard to maintain due to the involved complexity (kernel pops
into my mind). After some dicussions, we decided that there was two
paths to follow.

One of them would be to build a system outside of rpm for preprocessing
some meta information and generating the final packages. Unfortunately,
this system would turn these packages into something not self-contained.
Working in these package would require the whole system again, since the
spec is just a stage in the process.

The other one would be to implement some kind of %include in rpm,
and break the package into small pieces more maintainable. When we
discovered that such thing already existed in rpm at that time, we were
just amazed, and though our problems were solved.

Unfortunately, we soon discovered that %include was doing just half the
job. Spec files included trough %include are not automaticaly included
in the SRPM package. Ok, it's not a big deal, but since we're trying to
make things more maintainable, it introduced one more thing in the
deal.

Fortunately, it was not difficult to implement a new command to do the
whole job. Now I'm wondering if it would be possible to introduce this
patch in rpm itself. It would really be useful for us, and
probably for others.

Thank you very much!

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]
--- rpm-4.0.3/build/parseSpec.c.includesrc	Wed Jul 18 19:07:23 2001
+++ rpm-4.0.3/build/parseSpec.c	Thu Oct 18 22:57:03 2001
@@ -298,6 +298,35 @@
 	spec->readStack = spec->readStack->next;
 	free(rl);
 	spec->line[0] = '\0';
+    } else if (! strncmp("%includesrc", s, sizeof("%includesrc")-1)) {
+	char *fileName, *endFileName, *p;
+	const char *fn;
+
+	s += 11;
+	fileName = s;
+	if (! xisspace(*fileName)) {
+	    rpmError(RPMERR_BADSPEC, _("malformed %%includesrc statement\n"));
+	    return RPMERR_BADSPEC;
+	}
+	SKIPSPACE(fileName);
+	endFileName = fileName;
+	SKIPNONSPACE(endFileName);
+	p = endFileName;
+	SKIPSPACE(p);
+	if (*p != '\0') {
+	    rpmError(RPMERR_BADSPEC, _("malformed %%includesrc statement\n"));
+	    return RPMERR_BADSPEC;
+	}
+	*endFileName = '\0';
+
+	if ((rc = addSource(spec, spec->packages, fileName, RPMTAG_INCLUDE)))
+	    return rc;
+
+	fn = rpmGetPath("%{_sourcedir}/", fileName, NULL);
+	forceIncludeFile(spec, fn);
+
+	ofi = spec->fileStack;
+	goto retry;
     } else if (! strncmp("%include", s, sizeof("%include")-1)) {
 	char *fileName, *endFileName, *p;
 
--- rpm-4.0.3/build/spec.c.includesrc	Thu Oct 18 22:47:02 2001
+++ rpm-4.0.3/build/spec.c	Thu Oct 18 22:55:33 2001
@@ -269,10 +269,14 @@
 	flag = RPMBUILD_ISICON;
 	fieldp = NULL;
 	break;
+      case RPMTAG_INCLUDE:
+	flag = RPMBUILD_ISINCLUDE;
+	fieldp = NULL;
+	break;
     }
 
     /* Get the number */
-    if (tag != RPMTAG_ICON) {
+    if (tag != RPMTAG_ICON && tag != RPMTAG_INCLUDE) {
 	/* We already know that a ':' exists, and that there */
 	/* are no spaces before it.                          */
 	/* This also now allows for spaces and tabs between  */
@@ -319,7 +323,7 @@
 
     spec->numSources++;
 
-    if (tag != RPMTAG_ICON) {
+    if (tag != RPMTAG_ICON && tag != RPMTAG_INCLUDE) {
 	/*@-nullpass@*/		/* LCL: varargs needs null annotate. */
 	const char *body = rpmGetPath("%{_sourcedir}/", p->source, NULL);
 	/*@=nullpass@*/
--- rpm-4.0.3/build/rpmspec.h.includesrc	Thu Oct 18 22:50:15 2001
+++ rpm-4.0.3/build/rpmspec.h	Thu Oct 18 22:50:54 2001
@@ -26,6 +26,7 @@
 #define RPMBUILD_ISPATCH     (1 << 1)
 #define RPMBUILD_ISICON      (1 << 2)
 #define RPMBUILD_ISNO        (1 << 3)
+#define RPMBUILD_ISINCLUDE   (1 << 4)
 
 #define RPMBUILD_DEFAULT_LANG "C"
 
--- rpm-4.0.3/lib/rpmlib.h.includesrc	Thu Oct 18 23:00:38 2001
+++ rpm-4.0.3/lib/rpmlib.h	Thu Oct 18 23:00:54 2001
@@ -356,6 +356,7 @@
     RPMTAG_INSTALLTID		= 1128,
     RPMTAG_REMOVETID		= 1129,
     RPMTAG_SHA1RHN		= 1130, /*!< internal */
+    RPMTAG_INCLUDE		= 1131,
 /*@-enummemuse@*/
     RPMTAG_FIRSTFREE_TAG	/*!< internal */
 /*@=enummemuse@*/
--- rpm-4.0.3/build/files.c.includesrc	Thu Oct 18 23:48:25 2001
+++ rpm-4.0.3/build/files.c	Thu Oct 18 23:55:36 2001
@@ -2049,6 +2049,10 @@
 				       RPM_INT32_TYPE, &srcPtr->num, 1);
 	    }
 	}
+	if (srcPtr->flags & RPMBUILD_ISINCLUDE) {
+	    (void) headerAddOrAppendEntry(spec->sourceHeader, RPMTAG_INCLUDE,
+				   RPM_STRING_ARRAY_TYPE, &srcPtr->source, 1);
+	}
 
       {	const char * sfn;
 	sfn = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),

Attachment: pgp00003.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []