Simplify spec buildroot hysteria
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 6 Aug 2008 09:24:34 +0000 (12:24 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 6 Aug 2008 09:24:34 +0000 (12:24 +0300)
- BuildRoot: in spec is now really ignored
- parseSpec() uses default %{buildroot} unless overridden
- BuildRoot is forced for all builds

build/parsePreamble.c
build/parseSpec.c
build/rpmspec.h
build/spec.c

index 3f944ed..d168978 100644 (file)
@@ -522,44 +522,9 @@ static int handlePreambleTag(rpmSpec spec, Package pkg, rpmTag tag,
            (void) headerAddI18NString(pkg->header, tag, field, lang);
        break;
     case RPMTAG_BUILDROOT:
-       SINGLE_TOKEN_ONLY;
-      {        char * buildRoot = NULL;
-
-       /*
-        * Note: rpmGenPath should guarantee a "canonical" path. That means
-        * that the following pathologies should be weeded out:
-        *          //bin//sh
-        *          //usr//bin/
-        *          /.././../usr/../bin//./sh
-        */
-       if (spec->buildRoot == NULL) {
-           buildRoot = rpmGenPath(NULL, "%{?buildroot:%{buildroot}}", NULL);
-           if (strcmp(buildRoot, "/")) {
-               spec->buildRoot = buildRoot;
-               macro = NULL;
-           } else {
-               const char * specPath = field;
-
-               buildRoot = _free(buildRoot);
-               if (*field == '\0') field = "/";
-               buildRoot = rpmGenPath(spec->rootDir, specPath, NULL);
-               spec->buildRoot = buildRoot;
-               field = (char *) buildRoot;
-           }
-           spec->gotBuildRoot = 1;
-       } else {
-           macro = NULL;
-       }
-       buildRoot = rpmGenPath(NULL, spec->buildRoot, NULL);
-       if (*buildRoot == '\0') buildRoot = "/";
-       if (!strcmp(buildRoot, "/")) {
-           rpmlog(RPMLOG_ERR,
-                    _("BuildRoot can not be \"/\": %s\n"), spec->buildRoot);
-           free(buildRoot);
-           return RPMRC_FAIL;
-       }
-       free(buildRoot);
-      }        break;
+       /* just silently ignore BuildRoot */
+       macro = NULL;
+       break;
     case RPMTAG_PREFIXES: {
        struct rpmtd_s td;
        const char *str;
@@ -896,12 +861,6 @@ int parsePreamble(rpmSpec spec, int initialPackage)
        }
     }
 
-    /* Do some final processing on the header */
-    if (!spec->gotBuildRoot && spec->buildRoot) {
-       rpmlog(RPMLOG_ERR, _("Spec file can't use BuildRoot\n"));
-       goto exit;
-    }
-
     /* XXX Skip valid arch check if not building binary package */
     if (!spec->anyarch && checkForValidArchitectures(spec)) {
        goto exit;
index 833eae0..098bd2b 100644 (file)
@@ -424,28 +424,23 @@ int parseSpec(rpmts ts, const char *specFile, const char *rootDir,
     /* Set up a new Spec structure with no packages. */
     spec = newSpec();
 
-    /*
-     * Note: rpmGetPath should guarantee a "canonical" path. That means
-     * that the following pathologies should be weeded out:
-     *          //bin//sh
-     *          //usr//bin/
-     *          /.././../usr/../bin//./sh (XXX FIXME: dots not handled yet)
-     */
     spec->specFile = rpmGetPath(specFile, NULL);
     spec->fileStack = newOpenFileInfo();
     spec->fileStack->fileName = xstrdup(spec->specFile);
+    /* If buildRoot not specified, use default %{buildroot} */
     if (buildRoot) {
-       if (*buildRoot == '\0') {
-           rpmlog(RPMLOG_ERR, _("BuildRoot couldn't be empty\n"));
-           goto errxit;
-       }
-       if (!strcmp(buildRoot, "/")) {
-           rpmlog(RPMLOG_ERR, _("BuildRoot can not be \"/\"\n"));
-           goto errxit;
-        }
-       spec->gotBuildRoot = 1;
        spec->buildRoot = xstrdup(buildRoot);
-       addMacro(spec->macros, "buildroot", NULL, buildRoot, RMIL_SPEC);
+    } else {
+       spec->buildRoot = rpmGetPath("%{?buildroot:%{buildroot}}", NULL);
+    }
+    addMacro(spec->macros, "buildroot", NULL, spec->buildRoot, RMIL_SPEC);
+    if (*spec->buildRoot == '\0') {
+       rpmlog(RPMLOG_ERR, _("BuildRoot couldn't be empty\n"));
+       goto errxit;
+    }
+    if (!strcmp(spec->buildRoot, "/")) {
+       rpmlog(RPMLOG_ERR, _("BuildRoot can not be \"/\"\n"));
+       goto errxit;
     }
     addMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC);
     spec->recursing = recursing;
index f4226a4..3b115f6 100644 (file)
@@ -119,8 +119,6 @@ struct rpmSpec_s {
     int force;
     int anyarch;
 
-    int gotBuildRoot;
-
     char * passPhrase;
     int timeCheck;
     char * cookie;
index 5a80752..096ff73 100644 (file)
@@ -414,7 +414,6 @@ rpmSpec newSpec(void)
     spec->sourceHeader = NULL;
     spec->sourceCpioList = NULL;
     
-    spec->gotBuildRoot = 0;
     spec->buildRoot = NULL;
     spec->buildSubdir = NULL;