From 1c24f489201689afb53722f2322431c9b9c18ae6 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Thu, 17 Feb 2011 13:48:39 -0500 Subject: [PATCH] Instead of the hardcoded value in spec2make, added new tag option "WHITELIST-RPMS" which lets you force-package a set of rpms based on a prefix. E.g. setting kernel-WHITELIST-RPMS := kernel-devel, kernel-docs will force inclusion of these two packages. --- Makefile | 2 +- spec2make.c | 43 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 62711055..8eb94402 100644 --- a/Makefile +++ b/Makefile @@ -295,7 +295,7 @@ $(1).module := $(firstword $($(1)-MODULES)) $(1).specpath := SPECS/$(notdir $($(1)-SPEC)) $(1).moduledir := MODULES/$$($(1).module) $(1).codespec := MODULES/$$($(1).module)/$($(1)-SPEC) -$(1).spec2makeflags := $(if $($(1)-NEEDSPEC2MAKEHACK),$(if $(filter $(DISTRONAME),f8 centos5),--hack,),) +$(1).spec2makeflags := $(if $($(1)-WHITELIST-RPMS),--whitelist-rpms $($(1)-WHITELIST-RPMS),) endef $(foreach package, $(ALL), $(eval $(call stage1_package_vars,$(package)))) diff --git a/spec2make.c b/spec2make.c index f4572088..fc5dd6f5 100644 --- a/spec2make.c +++ b/spec2make.c @@ -24,6 +24,8 @@ #define rpmSpec Spec #endif +#define MAX_WHITELIST_SIZE 16 + #ifndef PATH_MAX #include #endif @@ -76,16 +78,41 @@ main(int argc, char *argv[]) const char *name, *version, *release, *arch, *unused; const char *package_name; + char **package_whitelist; + /* BEGIN: support to pull out --target from the args list */ int alen, i; char *target = NULL; int args = 1; - int hack=0; + int whitelist_size=0; + package_whitelist = (char **) malloc(MAX_WHITELIST_SIZE * sizeof(char *)); + + if (!package_whitelist) { + perror("Could not allocate package whitelist\n"); + exit(1); + } - /* walk argv list looking for --target */ + /* walk argv list looking for options */ while ((args+1) from argv */ + + int option_offset = 1; + char *whitelist_str = argv[args+1]; + if (whitelist_str != NULL) { + char *saveptr = NULL, *str; + option_offset = 2; + for (str = whitelist_str; ; str = NULL) { + char *token; + token = strtok_r(str, "," , &saveptr); + if (token == NULL) break; + package_whitelist[whitelist_size++] = token; + } + } + for (i=args;ipackages; pkg != NULL; pkg = pkg->next) { + int force = 0; name = version = release = arch = NULL; (void) headerNEVRA(pkg->header, &name, &unused, &version, &release, &arch); if (name && version && release && arch) { @@ -182,10 +211,12 @@ main(int argc, char *argv[]) * line returns false for the kernel-devel package even though it is not empty thereby breaking the build. * Rather than unfolding the kernel package macros in the current specfile, * this hack should work till f8 dies its natural death. - * Thierry : trigerring this based on the package's NEEDSPEC2MAKEHACK instead of hard-wiring it for kernel here + * To add rpms that are exempted in this way, add a "-WHITELIST-RPMS" tag in the tags file. */ - if (pkg->fileList || hack) { + for (i=0;ifileList || force) { /* attach (add) rpm path to package */ printf("%s.rpms += RPMS/%s/%s-%s-%s.%s.rpm\n", package_name, arch, name, version, release, arch); -- 2.43.0