diff options
author | jbj <devnull@localhost> | 1999-11-24 00:03:54 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 1999-11-24 00:03:54 +0000 |
commit | 4221ce1aa1fff15764b1620d904c713f8bc727ae (patch) | |
tree | 50d7cc5e1929acfa9cd571d78d4afdbf8118aab2 /build/parsePreamble.c | |
parent | abe7856bb066b68cffb378cd30771bc57bc49333 (diff) | |
download | librpm-tizen-4221ce1aa1fff15764b1620d904c713f8bc727ae.tar.gz librpm-tizen-4221ce1aa1fff15764b1620d904c713f8bc727ae.tar.bz2 librpm-tizen-4221ce1aa1fff15764b1620d904c713f8bc727ae.zip |
lib/macro.c: Canonicalize paths in rpmGetPath().
build.c: ditto.
build/build.c: ditto.
build/files.c: ditto.
build/parsePreamble.c: ditto.
build/parseSpec.c: ditto.
build/myftw.c: Use Opendir/Readdir/Closedir wrappers.
lib/cpio.c: Use Readlink/Stat/Lstat wrappers while building archive.
lib/rpmio.c: functional ftpLstat, ftpStat and ftpReadlink.
CVS patchset: 3432
CVS date: 1999/11/24 00:03:54
Diffstat (limited to 'build/parsePreamble.c')
-rw-r--r-- | build/parsePreamble.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/build/parsePreamble.c b/build/parsePreamble.c index d4b181897..e40d29cde 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -1,5 +1,7 @@ #include "system.h" +static int _debug = 0; + #include <rpmbuild.h> #include <rpmurl.h> @@ -397,36 +399,49 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro, case RPMTAG_BUILDROOT: SINGLE_TOKEN_ONLY; { const char * buildRoot = NULL; - const char * buildURL = spec->buildURL; - - if (buildURL == NULL) { - - buildURL = rpmGenPath(spec->rootURL, "%{?buildroot:%{buildroot}}", NULL); - - if (strcmp(spec->rootURL, buildURL)) { - spec->buildURL = buildURL; + const char * buildRootURL = spec->buildRootURL; + + /* + * 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 (buildRootURL == NULL) { + buildRootURL = rpmGenPath(NULL, "%{?buildroot:%{buildroot}}", NULL); + if (strcmp(buildRootURL, "/")) { + spec->buildRootURL = buildRootURL; +if (_debug) +fprintf(stderr, "*** PPA BuildRoot %s set from macro\n", buildRootURL); macro = NULL; } else { const char * specURL = field; + xfree(buildRootURL); (void) urlPath(specURL, (const char **)&field); - - xfree(buildURL); - buildURL = rpmGenPath(NULL, specURL, NULL); - spec->buildURL = buildURL; + if (*field == '\0') field = "/"; + buildRootURL = rpmGenPath(spec->rootURL, field, NULL); + field = spec->buildRootURL = buildRootURL; +if (_debug) +fprintf(stderr, "*** PPA BuildRoot %s set from field\n", buildRootURL); } + spec->gotBuildRootURL = 1; } else { +if (_debug) +fprintf(stderr, "*** PPA BuildRoot %s already set, skipping field %s\n", buildRootURL, field); macro = NULL; } - (void) urlPath(buildURL, &buildRoot); + buildRootURL = rpmGenPath(NULL, spec->buildRootURL, NULL); + (void) urlPath(buildRootURL, &buildRoot); if (*buildRoot == '\0') buildRoot = "/"; if (!strcmp(buildRoot, "/")) { rpmError(RPMERR_BADSPEC, - _("line %d: BuildRoot can not be \"/\": %s"), - spec->lineNum, spec->line); + _("BuildRoot can not be \"/\": %s"), spec->buildRootURL); + xfree(buildRootURL); return RPMERR_BADSPEC; } - spec->gotBuildURL = 1; + xfree(buildRootURL); } break; case RPMTAG_PREFIXES: addOrAppendListEntry(pkg->header, tag, field); @@ -735,7 +750,7 @@ int parsePreamble(Spec spec, int initialPackage) /* Do some final processing on the header */ - if (!spec->gotBuildURL && spec->buildURL) { + if (!spec->gotBuildRootURL && spec->buildRootURL) { rpmError(RPMERR_BADSPEC, _("Spec file can't use BuildRoot")); return RPMERR_BADSPEC; } |