X-Git-Url: http://git.onelab.eu/?p=build.git;a=blobdiff_plain;f=spec2make.c;h=60004ef6448d360b1862ed5bee696737ed8bec6e;hp=712ce68633d992658650390bb07c8cf9b5eb513c;hb=1f4f80e0c7dc71ef79614227c195139a56d1421e;hpb=249acd1f0c785b2aa88ba193ce7a1a8e442b3ef5 diff --git a/spec2make.c b/spec2make.c index 712ce686..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) { @@ -176,20 +205,30 @@ main(int argc, char *argv[]) arch=target; } } - /* skip empty packages */ - if (pkg->fileList) { - /* attach (add) rpm path to package */ - printf("%s.rpms += RPMS/%s/%s-%s-%s.%s.rpm\n", - package_name, arch, name, version, release, arch); - /* convenience */ - printf("%s.rpmnames += %s\n", - package_name, name); - /* attach path to rpm name */ - printf("%s.rpm-path := RPMS/%s/%s-%s-%s.%s.rpm\n", - name,arch, name, version, release, arch); - /* attach package to rpm name for backward resolution - should be unique */ - printf("%s.package := %s\n", - name,package_name); + /* skip empty packages + * + * 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. + * To add rpms that are exempted in this way, add a "-WHITELIST-RPMS" tag in the tags file. + */ + + 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); + /* convenience */ + printf("%s.rpmnames += %s\n", + package_name, name); + /* attach path to rpm name */ + printf("%s.rpm-path := RPMS/%s/%s-%s-%s.%s.rpm\n", + name,arch, name, version, release, arch); + /* attach package to rpm name for backward resolution - should be unique */ + printf("%s.package := %s\n", + name,package_name); } } }