X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=spec2make.c;h=60004ef6448d360b1862ed5bee696737ed8bec6e;hb=f32e6c1558505dd446489c022453e6a8ce3bc10d;hp=1d68503b028c0d4193439c3d8b895f86ce8d3b6d;hpb=d54c43a63e687b59b3e90cb1cd25c95ecf3ecccd;p=build.git diff --git a/spec2make.c b/spec2make.c index 1d68503b..60004ef6 100644 --- a/spec2make.c +++ b/spec2make.c @@ -24,10 +24,11 @@ #define rpmSpec Spec #endif +#define MAX_WHITELIST_SIZE 16 + #ifndef PATH_MAX #include #endif - extern size_t strnlen(const char *s, size_t maxlen); /* the structure describing the options we take and the defaults */ @@ -77,36 +78,63 @@ 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 tlen = strlen("--target"); + 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 */ - /* get arch component of the --target option */ - dash = (char**)strchr(argv[args+1],'-'); - if (dash != NULL) *dash=NULL; + 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) { @@ -180,9 +209,14 @@ main(int argc, char *argv[]) * * Unfortunately, f8 + the RHEL kernel break this bit of cleverness. The following * 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. */ + * Rather than unfolding the kernel package macros in the current specfile, + * this hack should work till f8 dies its natural death. + * To add rpms that are exempted in this way, add a "-WHITELIST-RPMS" tag in the tags file. + */ - if (pkg->fileList || !strncmp(name,"kernel",sizeof("kernel")-1)) { + 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);