previous hack in spec2make was too intrusive
[build.git] / spec2make.c
index 30af6d0..f457208 100644 (file)
@@ -6,7 +6,6 @@
  * Mark Huang <mlhuang@cs.princeton.edu>
  * Copyright (C) 2006 The Trustees of Princeton University
  *
- * $Id$
  */
 
 #include <stdio.h>
 #ifndef PATH_MAX
 #include <linux/limits.h>
 #endif
-
 extern size_t strnlen(const char *s, size_t maxlen);
 
 /* the structure describing the options we take and the defaults */
 static struct poptOption optionsTable[] = {
+  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmBuildPoptTable, 0,
+    "Build options with [ <specfile> | <tarball> | <source package> ]:",
+    NULL },
   { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
     "Common options for all rpm modes and executables:",
     NULL },
@@ -78,12 +80,13 @@ main(int argc, char *argv[])
   int  alen, i;
   char *target = NULL;
   int args = 1;
-  int tlen = strlen("--target");
-
+  int hack=0;
 
   /* walk argv list looking for --target */
   while ((args+1)<argc) {
-    if(strncmp(argv[args],"--target",tlen)==0){
+    if (strcmp(argv[args],"--hack")==0) {
+      hack=1;
+    } else if (strcmp(argv[args],"--target")==0) {
       char **dash;
 
       /* get arch component of the --target option */
@@ -173,20 +176,28 @@ 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. 
+       * Thierry : trigerring this based on the package's NEEDSPEC2MAKEHACK instead of hard-wiring it for kernel here
+       */
+
+      if (pkg->fileList || hack) {
+        /* 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);
       }
     }
   }