summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/build.c238
-rw-r--r--build/files.c26
-rw-r--r--build/myftw.c8
-rw-r--r--build/pack.c16
-rw-r--r--build/parsePreamble.c50
-rw-r--r--build/parsePrep.c10
-rw-r--r--build/parseSpec.c21
-rw-r--r--build/rpmspec.h6
-rw-r--r--build/spec.c8
9 files changed, 233 insertions, 150 deletions
diff --git a/build/build.c b/build/build.c
index f07ea0ce5..48d273c05 100644
--- a/build/build.c
+++ b/build/build.c
@@ -35,136 +35,232 @@ static void doRmSource(Spec spec)
* The _preScript string is expanded to export values to a script environment.
*/
-static char *_preScriptEnvironment = "%{_preScriptEnvironment}";
-
-static char *_preScriptChdir =
- "umask 022\n"
- "cd %{_builddir}\n"
-;
-
int doScript(Spec spec, int what, const char *name, StringBuf sb, int test)
{
+ const char * rootURL = spec->rootURL;
+ const char * rootDir;
+ const char *scriptName = NULL;
+ const char * buildURL = rpmGenPath(rootURL, "%{_builddir}", "");
+#ifdef DYING
+ const char * buildDir;
+ const char * buildSubdir;
+ const char * buildScript;
+ const char * remsh = rpmGetPath("%{?_remsh:%{_remsh}}", NULL);
+ const char * remchroot = rpmGetPath("%{?_remchroot:%{_remchroot}}", NULL);
+ const char * buildShell =
+ rpmGetPath("%{?_buildshell:%{_buildshell}}%{!?_buildshell:/bin/sh}", NULL);
+ const char * buildEnv = rpmExpand("%{_preScriptEnvironment}", NULL);
+#else
+ const char * buildScript;
+ const char * buildCmd = NULL;
+ const char * buildTemplate = NULL;
+ const char * buildPost = NULL;
+ const char * mTemplate = NULL;
+ const char * mPost = NULL;
+ int argc = 0;
+ const char **argv = NULL;
+#endif
+ FILE * fp = NULL;
+ urlinfo u = NULL;
+
FD_t fd;
FD_t xfd;
- const char *scriptName;
- int pid;
+ int child;
int status;
- char buf[BUFSIZ];
- FILE * fp = NULL;
+ int rc;
switch (what) {
case RPMBUILD_PREP:
name = "%prep";
sb = spec->prep;
+ mTemplate = "%{__spec_prep_template}";
+ mPost = "%{__spec_prep_post}";
break;
case RPMBUILD_BUILD:
name = "%build";
sb = spec->build;
+ mTemplate = "%{__spec_build_template}";
+ mPost = "%{__spec_build_post}";
break;
case RPMBUILD_INSTALL:
name = "%install";
sb = spec->install;
+ mTemplate = "%{__spec_install_template}";
+ mPost = "%{__spec_install_post}";
break;
case RPMBUILD_CLEAN:
name = "%clean";
sb = spec->clean;
+ mTemplate = "%{__spec_clean_template}";
+ mPost = "%{__spec_clean_post}";
break;
case RPMBUILD_RMBUILD:
name = "--clean";
+ mTemplate = "%{__spec_clean_template}";
+ mPost = "%{__spec_clean_post}";
break;
case RPMBUILD_STRINGBUF:
+ default:
+ mTemplate = "%{___build_template}";
+ mPost = "%{___build_post}";
break;
}
- if ((what != RPMBUILD_RMBUILD) && sb == NULL)
- return 0;
+ if ((what != RPMBUILD_RMBUILD) && sb == NULL) {
+ rc = 0;
+ goto exit;
+ }
- if (makeTempFile(spec->rootdir, &scriptName, &fd)) {
- Fclose(fd);
- FREE(scriptName);
- rpmError(RPMERR_SCRIPT, _("Unable to open temp file"));
- return RPMERR_SCRIPT;
+ if (makeTempFile(rootURL, &scriptName, &fd)) {
+ Fclose(fd);
+ rpmError(RPMERR_SCRIPT, _("Unable to open temp file"));
+ rc = RPMERR_SCRIPT;
+ goto exit;
}
+
#ifdef HAVE_FCHMOD
- (void)fchmod(Fileno(fd), 0600); /* XXX fubar on ufdio */
-#endif
-#ifdef DYING
-/* XXX FIXME: build/build.c Fdopen assertion failure, makeTempFile uses fdio */
- xfd = Fdopen(fd, "w.fdio");
-#else
- xfd = Fdopen(fd, "w.fpio");
+ switch (rootut) {
+ case URL_IS_PATH:
+ case URL_IS_UNKNOWN:
+ (void)fchmod(Fileno(fd), 0600); /* XXX fubar on ufdio */
+ break;
+ default:
+ break;
+ }
#endif
- fp = fdGetFp(fd);
+
+ if (fdGetFp(fd) == NULL)
+ xfd = Fdopen(fd, "w.fpio");
+ else
+ xfd = fd;
+ if ((fp = fdGetFp(xfd)) == NULL) {
+ rc = RPMERR_SCRIPT;
+ goto exit;
+ }
- strcpy(buf, _preScriptEnvironment);
- expandMacros(spec, spec->macros, buf, sizeof(buf));
- strcat(buf, "\n");
- fputs(buf, fp);
+ (void) urlPath(rootURL, &rootDir);
+ if (*rootDir == '\0') rootDir = "/";
+#ifdef DYING
+ (void) urlPath(buildURL, &buildDir);
+ (void) urlPath(spec->buildSubdir, &buildSubdir);
+#endif
- fprintf(fp, rpmIsVerbose() ? "set -x\n\n" : "exec > /dev/null\n\n");
+ (void) urlPath(scriptName, &buildScript);
-/* XXX umask 022; cd %{_builddir} */
- strcpy(buf, _preScriptChdir);
- expandMacros(spec, spec->macros, buf, sizeof(buf));
- fputs(buf, fp);
+ buildTemplate = rpmExpand(mTemplate, NULL);
+ buildPost = rpmExpand(mPost, NULL);
+#ifdef DYING
+ fprintf(fp, "#!%s\n", buildShell);
+ fputs(buildEnv, fp);
+ fputs("\n", fp);
+
+ fprintf(fp, rpmIsVerbose()
+ ? "set -x\n\n"
+ : "exec > /dev/null\n\n");
+
+ fprintf(fp, "umask 022\ncd %s\n", buildDir);
+#else
+ fputs(buildTemplate, fp);
+#endif
+
+ if (what != RPMBUILD_PREP && what != RPMBUILD_RMBUILD && spec->buildSubdir)
+ fprintf(fp, "cd %s\n", spec->buildSubdir);
- if (what != RPMBUILD_PREP && what != RPMBUILD_RMBUILD) {
- if (spec->buildSubdir)
- fprintf(fp, "cd %s\n", spec->buildSubdir);
- }
if (what == RPMBUILD_RMBUILD) {
if (spec->buildSubdir)
fprintf(fp, "rm -rf %s\n", spec->buildSubdir);
} else
fprintf(fp, "%s", getStringBuf(sb));
+
+#ifdef DYING
fprintf(fp, "\nexit 0\n");
+#else
+ fputs(buildPost, fp);
+#endif
Fclose(xfd);
if (test) {
- FREE(scriptName);
- return 0;
+ rc = 0;
+ goto exit;
}
- rpmMessage(RPMMESS_NORMAL, _("Executing: %s\n"), name);
- if (!(pid = fork())) {
- const char *buildShell = rpmGetPath("%{_buildshell}", NULL);
-
- if (spec->rootdir)
- Chroot(spec->rootdir);
- chdir("/");
-
- switch (urlIsURL(scriptName)) {
- case URL_IS_PATH:
- scriptName += sizeof("file://") - 1;
- scriptName = strchr(scriptName, '/');
- /*@fallthrough@*/
- case URL_IS_UNKNOWN:
- execl(buildShell, buildShell, "-e", scriptName, scriptName, NULL);
- break;
- default:
- break;
+ if (buildURL && buildURL[0] != '/' && (urlSplit(buildURL, &u) != 0)) {
+ rc = RPMERR_SCRIPT;
+ goto exit;
+ }
+ if (u)
+ addMacro(spec->macros, "_build_hostname", NULL, u->path, RMIL_SPEC);
+
+ buildCmd = rpmExpand("%{___build_cmd}", " ", buildScript, NULL);
+ poptParseArgvString(buildCmd, &argc, &argv);
+
+ rpmMessage(RPMMESS_NORMAL, _("Executing(%s): %s\n"), name, buildCmd);
+ if (!(child = fork())) {
+
+#ifdef DYING
+fprintf(stderr, "*** root %s buildDir %s script %s remsh %s \n", rootDir, buildDir, scriptName, remsh);
+
+ if (u == NULL || *remsh == '\0') {
+fprintf(stderr, "*** LOCAL %s %s -e %s %s\n", buildShell, buildShell, buildScript, buildScript);
+ if (rootURL) {
+ if (!(rootDir[0] == '/' && rootDir[1] == '\0')) {
+ chroot(rootDir);
+ chdir("/");
+ }
+ }
+ errno = 0;
+ execl(buildShell, buildShell, "-e", buildScript, buildScript, NULL);
+ } else {
+ if (*remchroot == '\0') {
+fprintf(stderr, "*** REMSH %s %s %s -e %s %s\n", remsh, u->host, buildShell, buildScript, buildScript);
+ errno = 0;
+ execl(remsh, remsh, u->host, buildShell, "-e", buildScript, buildScript, NULL);
+ } else {
+fprintf(stderr, "*** REMCHROOT %s %s %s %s -e %s %s\n", remsh, u->host, remchroot, buildShell, buildScript, buildScript);
+ errno = 0;
+ execl(remsh, remsh, u->host, remchroot, buildShell, "-e", buildScript, buildScript, NULL);
+ }
}
+#else
+ execvp(argv[0], (char *const *)argv);
+#endif
+
+ rpmError(RPMERR_SCRIPT, _("Exec of %s failed (%s): %s"), scriptName, name, strerror(errno));
- rpmError(RPMERR_SCRIPT, _("Exec of %s failed (%s)"), scriptName, name);
_exit(-1);
}
- (void)wait(&status);
- if (! WIFEXITED(status) || WEXITSTATUS(status)) {
+ rc = waitpid(child, &status, 0);
+
+ if (!WIFEXITED(status) || WEXITSTATUS(status)) {
rpmError(RPMERR_SCRIPT, _("Bad exit status from %s (%s)"),
scriptName, name);
-#if HACK
- Unlink(scriptName);
-#endif
- FREE(scriptName);
- return RPMERR_SCRIPT;
- }
+ rc = RPMERR_SCRIPT;
+ } else
+ rc = 0;
- Unlink(scriptName);
- FREE(scriptName);
+exit:
+ if (scriptName) {
+ if (!rc)
+ Unlink(scriptName);
+ xfree(scriptName);
+ }
+#ifdef DYING
+ FREE(buildShell);
+ FREE(buildEnv);
+ FREE(remsh);
+ FREE(remchroot);
+#else
+ if (u)
+ delMacro(spec->macros, "_build_hostname");
+ FREE(argv);
+ FREE(buildCmd);
+ FREE(buildTemplate);
+#endif
+ FREE(buildURL);
- return 0;
+ return rc;
}
int buildSpec(Spec spec, int what, int test)
diff --git a/build/files.c b/build/files.c
index 797b87e09..04421104f 100644
--- a/build/files.c
+++ b/build/files.c
@@ -50,7 +50,7 @@ typedef struct {
} AttrRec;
struct FileList {
- const char *buildRoot;
+ const char *buildURL;
const char *prefix;
int fileCount;
@@ -929,14 +929,14 @@ static int addFile(struct FileList *fl, const char *diskName, struct stat *statp
const char *fileGname;
char *lang;
- /* Path may have prepended buildroot, so locate the original filename. */
+ /* Path may have prepended buildURL, so locate the original filename. */
{ const char *s;
char c;
- if ((s = fl->buildRoot) != NULL) {
+ if ((s = fl->buildURL) != NULL) {
c = '\0';
while (*s) {
- if (c == '/')
+ if (c == '/' && !(s[0] == '/' && s[1] == ':'))
while(*s && *s == '/') s++;
if (*s) {
fileName++;
@@ -977,7 +977,7 @@ static int addFile(struct FileList *fl, const char *diskName, struct stat *statp
/* instead of lstat(), which causes it to follow symlinks! */
/* It also has better callback support. */
- fl->inFtw = 1; /* Flag to indicate file has buildRoot prefixed */
+ fl->inFtw = 1; /* Flag to indicate file has buildURL prefixed */
fl->isDir = 1; /* Keep it from following myftw() again */
myftw(diskName, 16, (myftwFunc) addFile, fl);
fl->isDir = 0;
@@ -1100,16 +1100,16 @@ static int processBinaryFile(/*@unused@*/Package pkg, struct FileList *fl,
/* Copy file name or glob pattern removing multiple "/" chars. */
{ const char *s;
- char c, *t = alloca((fl->buildRoot ? strlen(fl->buildRoot) : 0) +
+ char c, *t = alloca((fl->buildURL ? strlen(fl->buildURL) : 0) +
strlen(fileName) + 1);
fn = t;
*t = c = '\0';
- /* With a buildroot, prepend the buildroot now. */
- if ((s = fl->buildRoot) != NULL) {
+ /* With a buildroot, prepend the buildURL now. */
+ if ((s = fl->buildURL) != NULL) {
while (*s) {
- if (c == '/')
+ if (c == '/' && !(s[0] == '/' && s[1] == ':'))
while(*s && *s == '/') s++;
if (*s)
*t++ = c = *s++;
@@ -1119,7 +1119,7 @@ static int processBinaryFile(/*@unused@*/Package pkg, struct FileList *fl,
}
if ((s = fileName) != NULL) {
while (*s) {
- if (c == '/')
+ if (c == '/' && !(s[0] == '/' && s[1] == ':'))
while(*s && *s == '/') s++;
if (*s)
*t++ = c = *s++;
@@ -1198,8 +1198,8 @@ static int processPackageFiles(Spec spec, Package pkg,
/* Init the file list structure */
- /* XXX spec->buildRoot == NULL, then xstrdup("") is returned */
- fl.buildRoot = rpmGetPath(spec->buildRoot, NULL);
+ /* XXX spec->buildURL == NULL, then xstrdup("") is returned */
+ fl.buildURL = rpmGenPath(spec->rootURL, spec->buildURL, NULL);
if (headerGetEntry(pkg->header, RPMTAG_DEFAULTPREFIX,
NULL, (void **)&fl.prefix, NULL)) {
@@ -1333,7 +1333,7 @@ static int processPackageFiles(Spec spec, Package pkg,
}
/* Clean up */
- FREE(fl.buildRoot);
+ FREE(fl.buildURL);
FREE(fl.prefix);
freeAttrRec(&fl.cur_ar);
diff --git a/build/myftw.c b/build/myftw.c
index b8ae93406..971061f33 100644
--- a/build/myftw.c
+++ b/build/myftw.c
@@ -1,4 +1,4 @@
-/* Modified ftw() -- uses lstat() instead of stat() */
+/* Modified ftw() -- uses Lstat() instead of stat() */
/* Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -21,6 +21,8 @@ Cambridge, MA 02139, USA. */
#include "system.h"
+#include <rpmio.h>
+
#ifndef NAMLEN
#define NAMLEN(a) strlen((a)->d_name)
#endif
@@ -84,7 +86,7 @@ myftw_dir (DIR **dirs, int level, int descriptors,
dir[len] = '/';
memcpy ((void *) (dir + len + 1), (void *) entry->d_name, d_namlen);
- if (lstat (dir, &s) < 0)
+ if (Lstat (dir, &s) < 0)
{
/* Following POSIX.1 2.4 ENOENT is returned if the file cannot
* be stat'ed. This can happen for a file returned by readdir
@@ -182,7 +184,7 @@ int myftw (const char *dir,
while (i-- > 0)
dirs[i] = NULL;
- if (lstat (dir, &s) < 0)
+ if (Lstat (dir, &s) < 0)
{
/* Following POSIX.1 2.4 ENOENT is returned if the file cannot
* be stat'ed. This can happen for a file returned by readdir
diff --git a/build/pack.c b/build/pack.c
index aa16e4357..95c52044e 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -245,9 +245,6 @@ int writeRPM(Header h, const char *fileName, int type,
char buf[BUFSIZ];
Header sig;
struct rpmlead lead;
-#ifdef DYING
- int fdno;
-#endif
if (Fileno(csa->cpioFdIn) < 0) {
csa->cpioArchiveSize = 0;
@@ -271,11 +268,6 @@ int writeRPM(Header h, const char *fileName, int type,
return RPMERR_CREATE;
}
-#ifdef DYING
- fd = fdLink(fd, "persist"); /* XXX keep fd from being freed */
- fdno = Fileno(fd); /* XXX HACK HACK HACK to keep fdno open */
-#endif
-
if (headerWrite(fd, h, HEADER_MAGIC_YES)) {
rc = RPMERR_NOSPACE;
} else { /* Write the archive and get the size */
@@ -289,10 +281,6 @@ int writeRPM(Header h, const char *fileName, int type,
}
}
-#ifdef DYING
- fdSetFdno(fd, fdno); /* XXX HACK HACK HACK to keep fdno open */
-#endif
-
if (rc != 0) {
Fclose(fd);
unlink(sigtarget);
@@ -434,11 +422,7 @@ static int cpio_doio(FD_t fdo, CSA_t * csa, const char * fmode)
const char *failedFile = NULL;
(void) Fflush(fdo);
-#ifndef DYING
cfd = Fdopen(fdDup(Fileno(fdo)), fmode);
-#else
- cfd = Fdopen(fdo, fmode);
-#endif
rc = cpioBuildArchive(cfd, csa->cpioList, csa->cpioCount, NULL, NULL,
&csa->cpioArchiveSize, &failedFile);
if (rc) {
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index d4ed8e51d..d4b181897 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -1,6 +1,7 @@
#include "system.h"
#include <rpmbuild.h>
+#include <rpmurl.h>
static int_32 copyTagsDuringParse[] = {
RPMTAG_EPOCH,
@@ -229,9 +230,6 @@ static int readIcon(Header h, const char *file)
{
const char *fn = NULL;
char *icon;
-#ifdef DYING
- struct stat statbuf;
-#endif
FD_t fd;
int rc = 0;
off_t size;
@@ -240,14 +238,6 @@ static int readIcon(Header h, const char *file)
/* XXX use rpmGenPath(rootdir, "%{_sourcedir}/", file) for icon path. */
fn = rpmGetPath("%{_sourcedir}/", file, NULL);
-#ifdef DYING
- if (Stat(fn, &statbuf)) {
- rpmError(RPMERR_BADSPEC, _("Unable to stat icon: %s"), fn);
- rc = RPMERR_BADSPEC;
- goto exit;
- }
-#endif
-
fd = Fopen(fn, "r.ufdio");
if (fd == NULL || Ferror(fd)) {
rpmError(RPMERR_BADSPEC, _("Unable to open icon %s: %s"),
@@ -330,8 +320,8 @@ if (multiToken) { \
extern int noLang; /* XXX FIXME: pass as arg */
-static int handlePreambleTag(Spec spec, Package pkg, int tag, char *macro,
- char *lang)
+static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro,
+ const char *lang)
{
char *field = spec->line;
char *end;
@@ -406,28 +396,38 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, char *macro,
break;
case RPMTAG_BUILDROOT:
SINGLE_TOKEN_ONLY;
- if (spec->buildRoot == NULL) {
- /* XXX use rpmGenPath(rootdir, "%{buildroot}/", file) for buildroot path. */
- const char *buildroot = rpmGetPath("%{buildroot}", NULL);
- /* XXX FIXME make sure that buildroot has path, add urlbuildroot. */
- if (buildroot && *buildroot != '%') {
- spec->buildRoot = xstrdup(cleanFileName(buildroot));
+ { 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;
macro = NULL;
} else {
- spec->buildRoot = xstrdup(cleanFileName(field));
+ const char * specURL = field;
+
+ (void) urlPath(specURL, (const char **)&field);
+
+ xfree(buildURL);
+ buildURL = rpmGenPath(NULL, specURL, NULL);
+ spec->buildURL = buildURL;
}
- xfree(buildroot);
} else {
macro = NULL;
}
- if (!strcmp(spec->buildRoot, "/")) {
+ (void) urlPath(buildURL, &buildRoot);
+ if (*buildRoot == '\0') buildRoot = "/";
+ if (!strcmp(buildRoot, "/")) {
rpmError(RPMERR_BADSPEC,
_("line %d: BuildRoot can not be \"/\": %s"),
spec->lineNum, spec->line);
return RPMERR_BADSPEC;
}
- spec->gotBuildRoot = 1;
- break;
+ spec->gotBuildURL = 1;
+ } break;
case RPMTAG_PREFIXES:
addOrAppendListEntry(pkg->header, tag, field);
headerGetEntry(pkg->header, tag, NULL, (void **)&array, &num);
@@ -735,7 +735,7 @@ int parsePreamble(Spec spec, int initialPackage)
/* Do some final processing on the header */
- if (!spec->gotBuildRoot && spec->buildRoot) {
+ if (!spec->gotBuildURL && spec->buildURL) {
rpmError(RPMERR_BADSPEC, _("Spec file can't use BuildRoot"));
return RPMERR_BADSPEC;
}
diff --git a/build/parsePrep.c b/build/parsePrep.c
index 9830f6bce..8987082f6 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -200,7 +200,6 @@ static int checkOwners(const char *file)
static int doSetupMacro(Spec spec, char *line)
{
- char *version, *name;
char buf[BUFSIZ];
StringBuf before;
StringBuf after;
@@ -264,19 +263,18 @@ static int doSetupMacro(Spec spec, char *line)
if (dirName) {
spec->buildSubdir = xstrdup(dirName);
} else {
- headerGetEntry(spec->packages->header, RPMTAG_VERSION, NULL,
- (void **) &version, NULL);
- headerGetEntry(spec->packages->header, RPMTAG_NAME, NULL,
- (void **) &name, NULL);
+ const char *name, *version;
+ headerNVR(spec->packages->header, &name, &version, NULL);
sprintf(buf, "%s-%s", name, version);
spec->buildSubdir = xstrdup(buf);
}
+ addMacro(spec->macros, "buildsubdir", NULL, spec->buildSubdir, RMIL_SPEC);
free(argv);
poptFreeContext(optCon);
/* cd to the build dir */
- { const char * buildURL = rpmGenPath(spec->rootdir, "%{_builddir}", "");
+ { const char * buildURL = rpmGenPath(spec->rootURL, "%{_builddir}", "");
const char *buildDir;
(void) urlPath(buildURL, &buildDir);
diff --git a/build/parseSpec.c b/build/parseSpec.c
index b74ab0038..36201a74b 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -1,6 +1,7 @@
#include "system.h"
-#include "rpmbuild.h"
+#include <rpmbuild.h>
+#include <rpmurl.h>
static struct PartRec {
int part;
@@ -326,8 +327,8 @@ void closeSpec(Spec spec)
int noLang = 0; /* XXX FIXME: pass as arg */
-int parseSpec(Spec *specp, const char *specFile, const char *rootdir,
- const char *buildRoot, int inBuildArch, const char *passPhrase,
+int parseSpec(Spec *specp, const char *specFile, const char *rootURL,
+ const char *buildURL, int inBuildArch, const char *passPhrase,
char *cookie, int anyarch, int force)
{
int parsePart = PART_PREAMBLE;
@@ -345,9 +346,11 @@ int parseSpec(Spec *specp, const char *specFile, const char *rootdir,
spec->fileStack->fileName = xstrdup(specFile);
spec->specFile = xstrdup(specFile);
- if (buildRoot) {
- spec->gotBuildRoot = 1;
- spec->buildRoot = xstrdup(buildRoot);
+ if (buildURL) {
+ const char * buildRoot;
+ spec->gotBuildURL = 1;
+ spec->buildURL = xstrdup(buildURL);
+ (void) urlPath(buildURL, &buildRoot);
addMacro(spec->macros, "buildroot", NULL, buildRoot, RMIL_SPEC);
}
addMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC);
@@ -355,8 +358,8 @@ int parseSpec(Spec *specp, const char *specFile, const char *rootdir,
spec->anyarch = anyarch;
spec->force = force;
- if (rootdir && strcmp(rootdir, "/"))
- spec->rootdir = xstrdup(rootdir);
+ if (rootURL)
+ spec->rootURL = xstrdup(rootURL);
if (passPhrase)
spec->passPhrase = xstrdup(passPhrase);
if (cookie)
@@ -435,7 +438,7 @@ int parseSpec(Spec *specp, const char *specFile, const char *rootdir,
saveArch = xstrdup(saveArch);
rpmSetMachine(spec->buildArchitectures[x], NULL);
if (parseSpec(&(spec->buildArchitectureSpecs[index]),
- specFile, spec->rootdir, buildRoot, 1,
+ specFile, spec->rootURL, buildURL, 1,
passPhrase, cookie, anyarch, force)) {
spec->buildArchitectureCount = index;
freeSpec(spec);
diff --git a/build/rpmspec.h b/build/rpmspec.h
index 060ed6aa4..c87e1582d 100644
--- a/build/rpmspec.h
+++ b/build/rpmspec.h
@@ -97,8 +97,8 @@ struct SpecStruct {
int force;
int anyarch;
- int gotBuildRoot;
- /*@only@*/ const char *buildRoot;
+ int gotBuildURL;
+ /*@only@*/ const char *buildURL;
/*@only@*/ const char *buildSubdir;
char *passPhrase;
@@ -115,7 +115,7 @@ struct SpecStruct {
/*@dependent@*/ struct MacroContext *macros;
- /*@only@*/ const char *rootdir;
+ /*@only@*/ const char *rootURL;
/*@only@*/ StringBuf prep;
/*@only@*/ StringBuf build;
/*@only@*/ StringBuf install;
diff --git a/build/spec.c b/build/spec.c
index 2e9270f16..613f9984e 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -413,7 +413,7 @@ Spec newSpec(void)
spec->readStack->next = NULL;
spec->readStack->reading = 1;
- spec->rootdir = NULL;
+ spec->rootURL = NULL;
spec->prep = NULL;
spec->build = NULL;
spec->install = NULL;
@@ -429,8 +429,8 @@ Spec newSpec(void)
spec->sourceCpioCount = 0;
spec->sourceCpioList = NULL;
- spec->gotBuildRoot = 0;
- spec->buildRoot = NULL;
+ spec->gotBuildURL = 0;
+ spec->buildURL = NULL;
spec->buildSubdir = NULL;
spec->passPhrase = NULL;
@@ -464,7 +464,7 @@ void freeSpec(/*@only@*/ Spec spec)
freeStringBuf(spec->install); spec->install = NULL;
freeStringBuf(spec->clean); spec->clean = NULL;
- FREE(spec->buildRoot);
+ FREE(spec->buildURL);
FREE(spec->buildSubdir);
FREE(spec->specFile);
FREE(spec->sourceRpmName);