From 6c0651926aedc302816a0b61e1f1a8ef568be539 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 6 Aug 2008 12:24:34 +0300 Subject: [PATCH] Simplify spec buildroot hysteria - BuildRoot: in spec is now really ignored - parseSpec() uses default %{buildroot} unless overridden - BuildRoot is forced for all builds --- build/parsePreamble.c | 47 +++-------------------------------------------- build/parseSpec.c | 29 ++++++++++++----------------- build/rpmspec.h | 2 -- build/spec.c | 1 - 4 files changed, 15 insertions(+), 64 deletions(-) diff --git a/build/parsePreamble.c b/build/parsePreamble.c index 3f944ed..d168978 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -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; diff --git a/build/parseSpec.c b/build/parseSpec.c index 833eae0..098bd2b 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -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; diff --git a/build/rpmspec.h b/build/rpmspec.h index f4226a4..3b115f6 100644 --- a/build/rpmspec.h +++ b/build/rpmspec.h @@ -119,8 +119,6 @@ struct rpmSpec_s { int force; int anyarch; - int gotBuildRoot; - char * passPhrase; int timeCheck; char * cookie; diff --git a/build/spec.c b/build/spec.c index 5a80752..096ff73 100644 --- a/build/spec.c +++ b/build/spec.c @@ -414,7 +414,6 @@ rpmSpec newSpec(void) spec->sourceHeader = NULL; spec->sourceCpioList = NULL; - spec->gotBuildRoot = 0; spec->buildRoot = NULL; spec->buildSubdir = NULL; -- 2.7.4