2001-03-15 07:09:09 +08:00
|
|
|
|
/** \ingroup rpmcli
|
|
|
|
|
* Parse spec file and build package.
|
|
|
|
|
*/
|
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
|
#include "system.h"
|
1998-12-02 01:18:38 +08:00
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
|
#include <rpmcli.h>
|
1999-10-30 07:03:12 +08:00
|
|
|
|
#include <rpmbuild.h>
|
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
|
#include "rpmps.h"
|
2002-04-12 00:55:19 +08:00
|
|
|
|
#include "rpmte.h"
|
|
|
|
|
#include "rpmts.h"
|
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
|
#include "build.h"
|
2000-12-13 04:03:45 +08:00
|
|
|
|
#include "debug.h"
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
|
/*@access rpmts @*/ /* XXX compared with NULL @*/
|
2001-05-04 05:00:18 +08:00
|
|
|
|
/*@access rpmdb @*/ /* XXX compared with NULL @*/
|
|
|
|
|
/*@access FD_t @*/ /* XXX compared with NULL @*/
|
|
|
|
|
|
2001-03-15 07:09:09 +08:00
|
|
|
|
/**
|
|
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
|
static int checkSpec(rpmts ts, Header h)
|
2003-05-09 04:39:29 +08:00
|
|
|
|
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
|
2002-07-22 06:06:19 +08:00
|
|
|
|
/*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/
|
1999-04-17 22:23:42 +08:00
|
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
|
rpmps ps;
|
1999-04-17 22:23:42 +08:00
|
|
|
|
int rc;
|
|
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
|
if (!headerIsEntry(h, RPMTAG_REQUIRENAME)
|
|
|
|
|
&& !headerIsEntry(h, RPMTAG_CONFLICTNAME))
|
1999-04-17 22:23:42 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
|
rc = rpmtsAddInstallElement(ts, h, NULL, 0, NULL);
|
2002-05-17 00:55:21 +08:00
|
|
|
|
|
|
|
|
|
rc = rpmtsCheck(ts);
|
2002-04-12 00:55:19 +08:00
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
|
ps = rpmtsProblems(ts);
|
2002-06-12 22:54:06 +08:00
|
|
|
|
if (rc == 0 && rpmpsNumProblems(ps) > 0) {
|
2002-04-14 02:52:18 +08:00
|
|
|
|
rpmMessage(RPMMESS_ERROR, _("Failed build dependencies:\n"));
|
2002-06-29 05:54:24 +08:00
|
|
|
|
rpmpsPrint(NULL, ps);
|
1999-04-17 22:23:42 +08:00
|
|
|
|
rc = 1;
|
|
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
|
ps = rpmpsFree(ps);
|
1999-04-17 22:23:42 +08:00
|
|
|
|
|
2002-04-12 00:55:19 +08:00
|
|
|
|
/* XXX nuke the added package. */
|
2002-05-17 00:55:21 +08:00
|
|
|
|
rpmtsClean(ts);
|
2002-04-12 00:55:19 +08:00
|
|
|
|
|
1999-04-17 22:23:42 +08:00
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-23 03:38:25 +08:00
|
|
|
|
/*
|
|
|
|
|
* Kurwa, durni ameryka?ce sobe zawsze my?l?, ?e ca?y ?wiat m<EFBFBD>wi po
|
|
|
|
|
* angielsku...
|
|
|
|
|
*/
|
|
|
|
|
/* XXX this is still a dumb test but at least it's i18n aware */
|
2001-03-15 07:09:09 +08:00
|
|
|
|
/**
|
|
|
|
|
*/
|
2001-05-04 05:00:18 +08:00
|
|
|
|
static int isSpecFile(const char * specfile)
|
2003-05-09 04:39:29 +08:00
|
|
|
|
/*@globals h_errno, fileSystem, internalState @*/
|
2002-07-08 22:21:26 +08:00
|
|
|
|
/*@modifies fileSystem, internalState @*/
|
1999-07-23 03:38:25 +08:00
|
|
|
|
{
|
|
|
|
|
char buf[256];
|
|
|
|
|
const char * s;
|
|
|
|
|
FD_t fd;
|
|
|
|
|
int count;
|
|
|
|
|
int checking;
|
|
|
|
|
|
1999-11-05 05:26:08 +08:00
|
|
|
|
fd = Fopen(specfile, "r.ufdio");
|
1999-11-19 02:07:46 +08:00
|
|
|
|
if (fd == NULL || Ferror(fd)) {
|
2001-01-16 07:09:42 +08:00
|
|
|
|
rpmError(RPMERR_OPEN, _("Unable to open spec file %s: %s\n"),
|
|
|
|
|
specfile, Fstrerror(fd));
|
1999-07-23 03:38:25 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
1999-11-11 06:09:49 +08:00
|
|
|
|
count = Fread(buf, sizeof(buf[0]), sizeof(buf), fd);
|
2001-05-04 05:00:18 +08:00
|
|
|
|
(void) Fclose(fd);
|
1999-07-23 03:38:25 +08:00
|
|
|
|
|
|
|
|
|
checking = 1;
|
|
|
|
|
for (s = buf; count--; s++) {
|
|
|
|
|
switch (*s) {
|
|
|
|
|
case '\r':
|
|
|
|
|
case '\n':
|
|
|
|
|
checking = 1;
|
2001-10-14 06:01:38 +08:00
|
|
|
|
/*@switchbreak@*/ break;
|
1999-07-23 03:38:25 +08:00
|
|
|
|
case ':':
|
|
|
|
|
checking = 0;
|
2001-10-14 06:01:38 +08:00
|
|
|
|
/*@switchbreak@*/ break;
|
2002-07-03 07:54:35 +08:00
|
|
|
|
/*@-boundsread@*/
|
1999-07-23 03:38:25 +08:00
|
|
|
|
default:
|
2007-06-08 21:07:05 +08:00
|
|
|
|
#if 0
|
1999-07-23 03:38:25 +08:00
|
|
|
|
if (checking && !(isprint(*s) || isspace(*s))) return 0;
|
2001-10-14 06:01:38 +08:00
|
|
|
|
/*@switchbreak@*/ break;
|
2007-06-08 21:07:05 +08:00
|
|
|
|
#else
|
|
|
|
|
if (checking && !(isprint(*s) || isspace(*s)) && *(unsigned char *)s < 32) return 0;
|
|
|
|
|
/*@switchbreak@*/ break;
|
|
|
|
|
#endif
|
2002-07-03 07:54:35 +08:00
|
|
|
|
/*@=boundsread@*/
|
1999-07-23 03:38:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2001-03-15 07:09:09 +08:00
|
|
|
|
/**
|
|
|
|
|
*/
|
2002-06-24 03:47:08 +08:00
|
|
|
|
/*@-boundswrite@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
|
static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
|
2003-05-09 04:39:29 +08:00
|
|
|
|
/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
|
2002-07-22 06:06:19 +08:00
|
|
|
|
/*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/
|
1998-08-09 06:27:08 +08:00
|
|
|
|
{
|
2001-10-24 00:48:20 +08:00
|
|
|
|
const char * passPhrase = ba->passPhrase;
|
2001-10-24 04:52:51 +08:00
|
|
|
|
const char * cookie = ba->cookie;
|
1999-04-17 22:23:42 +08:00
|
|
|
|
int buildAmount = ba->buildAmount;
|
2001-06-06 03:26:22 +08:00
|
|
|
|
const char * buildRootURL = NULL;
|
1999-11-24 08:03:54 +08:00
|
|
|
|
const char * specFile;
|
|
|
|
|
const char * specURL;
|
|
|
|
|
int specut;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
char buf[BUFSIZ];
|
|
|
|
|
Spec spec = NULL;
|
1999-11-24 08:03:54 +08:00
|
|
|
|
int rc;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
2000-12-03 05:53:44 +08:00
|
|
|
|
#ifndef DYING
|
|
|
|
|
rpmSetTables(RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS);
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-10-16 01:53:34 +08:00
|
|
|
|
/*@-branchstate@*/
|
1999-11-24 08:03:54 +08:00
|
|
|
|
if (ba->buildRootOverride)
|
|
|
|
|
buildRootURL = rpmGenPath(NULL, ba->buildRootOverride, NULL);
|
2001-10-16 01:53:34 +08:00
|
|
|
|
/*@=branchstate@*/
|
1999-11-24 08:03:54 +08:00
|
|
|
|
|
2002-01-19 06:51:30 +08:00
|
|
|
|
/*@-compmempass@*/ /* FIX: static zcmds heartburn */
|
2001-01-02 07:14:47 +08:00
|
|
|
|
if (ba->buildMode == 't') {
|
1999-11-24 08:03:54 +08:00
|
|
|
|
FILE *fp;
|
2001-06-06 03:26:22 +08:00
|
|
|
|
const char * specDir;
|
2003-12-27 01:36:38 +08:00
|
|
|
|
char * tmpSpecFile;
|
2001-06-06 03:26:22 +08:00
|
|
|
|
char * cmd, * s;
|
2000-12-03 05:53:44 +08:00
|
|
|
|
rpmCompressedMagic res = COMPRESSED_OTHER;
|
2001-06-06 03:26:22 +08:00
|
|
|
|
/*@observer@*/ static const char *zcmds[] =
|
|
|
|
|
{ "cat", "gunzip", "bunzip2", "cat" };
|
1998-09-06 05:54:05 +08:00
|
|
|
|
|
1999-01-06 07:13:56 +08:00
|
|
|
|
specDir = rpmGetPath("%{_specdir}", NULL);
|
|
|
|
|
|
2007-07-12 14:16:23 +08:00
|
|
|
|
tmpSpecFile = (char *) rpmGetPath("%{_specdir}/", "rpm-spec.XXXXXX", NULL);
|
2003-12-27 01:36:38 +08:00
|
|
|
|
#if defined(HAVE_MKSTEMP)
|
|
|
|
|
(void) close(mkstemp(tmpSpecFile));
|
|
|
|
|
#else
|
|
|
|
|
(void) mktemp(tmpSpecFile);
|
|
|
|
|
#endif
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
2001-05-04 05:00:18 +08:00
|
|
|
|
(void) isCompressed(arg, &res);
|
2000-01-15 22:17:07 +08:00
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
|
cmd = alloca(strlen(arg) + 50 + strlen(tmpSpecFile));
|
2007-08-29 20:39:55 +08:00
|
|
|
|
sprintf(cmd, "%s < '%s' | tar xOvf - Specfile 2>&1 > '%s'",
|
2000-01-15 22:17:07 +08:00
|
|
|
|
zcmds[res & 0x3], arg, tmpSpecFile);
|
1999-11-24 08:03:54 +08:00
|
|
|
|
if (!(fp = popen(cmd, "r"))) {
|
2001-01-16 07:09:42 +08:00
|
|
|
|
rpmError(RPMERR_POPEN, _("Failed to open tar pipe: %m\n"));
|
2001-05-04 05:00:18 +08:00
|
|
|
|
specDir = _free(specDir);
|
|
|
|
|
tmpSpecFile = _free(tmpSpecFile);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
1999-11-24 08:03:54 +08:00
|
|
|
|
if ((!fgets(buf, sizeof(buf) - 1, fp)) || !strchr(buf, '/')) {
|
1998-04-02 00:02:05 +08:00
|
|
|
|
/* Try again */
|
2001-05-04 05:00:18 +08:00
|
|
|
|
(void) pclose(fp);
|
1998-04-02 00:02:05 +08:00
|
|
|
|
|
2007-08-29 20:39:55 +08:00
|
|
|
|
sprintf(cmd, "%s < '%s' | tar xOvf - --wildcards \\*.spec 2>&1 > '%s'",
|
2000-01-25 06:03:52 +08:00
|
|
|
|
zcmds[res & 0x3], arg, tmpSpecFile);
|
1999-11-24 08:03:54 +08:00
|
|
|
|
if (!(fp = popen(cmd, "r"))) {
|
2001-01-16 07:09:42 +08:00
|
|
|
|
rpmError(RPMERR_POPEN, _("Failed to open tar pipe: %m\n"));
|
2001-05-04 05:00:18 +08:00
|
|
|
|
specDir = _free(specDir);
|
|
|
|
|
tmpSpecFile = _free(tmpSpecFile);
|
1998-04-02 00:02:05 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
1999-11-24 08:03:54 +08:00
|
|
|
|
if (!fgets(buf, sizeof(buf) - 1, fp)) {
|
1998-04-02 00:02:05 +08:00
|
|
|
|
/* Give up */
|
2001-01-16 07:09:42 +08:00
|
|
|
|
rpmError(RPMERR_READ, _("Failed to read spec file from %s\n"),
|
|
|
|
|
arg);
|
2001-05-04 05:00:18 +08:00
|
|
|
|
(void) unlink(tmpSpecFile);
|
|
|
|
|
specDir = _free(specDir);
|
|
|
|
|
tmpSpecFile = _free(tmpSpecFile);
|
1999-01-07 01:33:50 +08:00
|
|
|
|
return 1;
|
1998-04-02 00:02:05 +08:00
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
}
|
2001-05-04 05:00:18 +08:00
|
|
|
|
(void) pclose(fp);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
1999-01-07 01:33:50 +08:00
|
|
|
|
cmd = s = buf;
|
2001-05-04 05:00:18 +08:00
|
|
|
|
while (*cmd != '\0') {
|
1999-01-07 01:33:50 +08:00
|
|
|
|
if (*cmd == '/') s = cmd + 1;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
cmd++;
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-07 01:33:50 +08:00
|
|
|
|
cmd = s;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
|
|
/* remove trailing \n */
|
1999-01-07 01:33:50 +08:00
|
|
|
|
s = cmd + strlen(cmd) - 1;
|
|
|
|
|
*s = '\0';
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
|
specURL = s = alloca(strlen(specDir) + strlen(cmd) + 5);
|
1999-01-07 01:33:50 +08:00
|
|
|
|
sprintf(s, "%s/%s", specDir, cmd);
|
1999-10-30 00:06:01 +08:00
|
|
|
|
res = rename(tmpSpecFile, s);
|
2001-05-04 05:00:18 +08:00
|
|
|
|
specDir = _free(specDir);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
1999-10-30 00:06:01 +08:00
|
|
|
|
if (res) {
|
2001-01-16 07:09:42 +08:00
|
|
|
|
rpmError(RPMERR_RENAME, _("Failed to rename %s to %s: %m\n"),
|
2000-12-03 05:53:44 +08:00
|
|
|
|
tmpSpecFile, s);
|
2001-05-04 05:00:18 +08:00
|
|
|
|
(void) unlink(tmpSpecFile);
|
|
|
|
|
tmpSpecFile = _free(tmpSpecFile);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
2001-05-04 05:00:18 +08:00
|
|
|
|
tmpSpecFile = _free(tmpSpecFile);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
|
|
/* Make the directory which contains the tarball the source
|
|
|
|
|
directory for this run */
|
|
|
|
|
|
|
|
|
|
if (*arg != '/') {
|
2007-04-16 20:18:19 +08:00
|
|
|
|
if (!getcwd(buf, BUFSIZ)) {
|
|
|
|
|
rpmError(RPMERR_STAT, "getcwd failed: %m\n");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
strcat(buf, "/");
|
|
|
|
|
strcat(buf, arg);
|
|
|
|
|
} else
|
|
|
|
|
strcpy(buf, arg);
|
|
|
|
|
|
|
|
|
|
cmd = buf + strlen(buf) - 1;
|
|
|
|
|
while (*cmd != '/') cmd--;
|
|
|
|
|
*cmd = '\0';
|
|
|
|
|
|
1999-04-02 06:26:44 +08:00
|
|
|
|
addMacro(NULL, "_sourcedir", NULL, buf, RMIL_TARBALL);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
} else {
|
1999-11-24 08:03:54 +08:00
|
|
|
|
specURL = arg;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
}
|
2002-01-19 06:51:30 +08:00
|
|
|
|
/*@=compmempass@*/
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
|
specut = urlPath(specURL, &specFile);
|
|
|
|
|
if (*specFile != '/') {
|
|
|
|
|
char *s = alloca(BUFSIZ);
|
2007-04-16 20:18:19 +08:00
|
|
|
|
if (!getcwd(s, BUFSIZ)) {
|
|
|
|
|
rpmError(RPMERR_STAT, "getcwd failed: %m\n");
|
|
|
|
|
rc = 1;
|
|
|
|
|
goto exit;
|
|
|
|
|
}
|
1999-11-24 08:03:54 +08:00
|
|
|
|
strcat(s, "/");
|
|
|
|
|
strcat(s, arg);
|
|
|
|
|
specURL = s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (specut != URL_IS_DASH) {
|
|
|
|
|
struct stat st;
|
2000-09-02 05:15:40 +08:00
|
|
|
|
if (Stat(specURL, &st) < 0) {
|
2001-01-16 07:09:42 +08:00
|
|
|
|
rpmError(RPMERR_STAT, _("failed to stat %s: %m\n"), specURL);
|
2000-09-02 05:15:40 +08:00
|
|
|
|
rc = 1;
|
|
|
|
|
goto exit;
|
|
|
|
|
}
|
1999-11-24 08:03:54 +08:00
|
|
|
|
if (! S_ISREG(st.st_mode)) {
|
2001-01-16 07:09:42 +08:00
|
|
|
|
rpmError(RPMERR_NOTREG, _("File %s is not a regular file.\n"),
|
2000-09-02 05:15:40 +08:00
|
|
|
|
specURL);
|
1999-11-24 08:03:54 +08:00
|
|
|
|
rc = 1;
|
|
|
|
|
goto exit;
|
1999-10-30 07:03:12 +08:00
|
|
|
|
}
|
1999-07-23 03:38:25 +08:00
|
|
|
|
|
1999-10-30 07:03:12 +08:00
|
|
|
|
/* Try to verify that the file is actually a specfile */
|
1999-11-24 08:03:54 +08:00
|
|
|
|
if (!isSpecFile(specURL)) {
|
2001-01-16 07:09:42 +08:00
|
|
|
|
rpmError(RPMERR_BADSPEC,
|
|
|
|
|
_("File %s does not appear to be a specfile.\n"), specURL);
|
1999-11-24 08:03:54 +08:00
|
|
|
|
rc = 1;
|
|
|
|
|
goto exit;
|
1999-10-30 07:03:12 +08:00
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
}
|
1999-07-23 03:38:25 +08:00
|
|
|
|
|
1999-04-17 22:23:42 +08:00
|
|
|
|
/* Parse the spec file */
|
1998-09-25 04:36:54 +08:00
|
|
|
|
#define _anyarch(_f) \
|
1998-11-08 06:05:28 +08:00
|
|
|
|
(((_f)&(RPMBUILD_PREP|RPMBUILD_BUILD|RPMBUILD_INSTALL|RPMBUILD_PACKAGEBINARY)) == 0)
|
2002-12-22 10:11:05 +08:00
|
|
|
|
if (parseSpec(ts, specURL, ba->rootdir, buildRootURL, 0, passPhrase,
|
|
|
|
|
cookie, _anyarch(buildAmount), ba->force))
|
|
|
|
|
{
|
1999-11-24 08:03:54 +08:00
|
|
|
|
rc = 1;
|
|
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
}
|
1998-09-25 04:36:54 +08:00
|
|
|
|
#undef _anyarch
|
2002-12-22 10:11:05 +08:00
|
|
|
|
if ((spec = rpmtsSetSpec(ts, NULL)) == NULL) {
|
|
|
|
|
rc = 1;
|
|
|
|
|
goto exit;
|
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
1999-04-17 22:23:42 +08:00
|
|
|
|
/* Assemble source header from parsed components */
|
|
|
|
|
initSourceHeader(spec);
|
|
|
|
|
|
|
|
|
|
/* Check build prerequisites */
|
2001-10-28 04:09:20 +08:00
|
|
|
|
if (!ba->noDeps && checkSpec(ts, spec->sourceHeader)) {
|
1999-11-24 08:03:54 +08:00
|
|
|
|
rc = 1;
|
|
|
|
|
goto exit;
|
1999-04-17 22:23:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2002-12-24 15:21:04 +08:00
|
|
|
|
if (buildSpec(ts, spec, buildAmount, ba->noBuild)) {
|
1999-11-24 08:03:54 +08:00
|
|
|
|
rc = 1;
|
|
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
2001-05-04 05:00:18 +08:00
|
|
|
|
if (ba->buildMode == 't')
|
|
|
|
|
(void) Unlink(specURL);
|
1999-11-24 08:03:54 +08:00
|
|
|
|
rc = 0;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
1999-11-24 08:03:54 +08:00
|
|
|
|
exit:
|
2001-05-07 03:17:14 +08:00
|
|
|
|
spec = freeSpec(spec);
|
2001-05-04 05:00:18 +08:00
|
|
|
|
buildRootURL = _free(buildRootURL);
|
1999-11-24 08:03:54 +08:00
|
|
|
|
return rc;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
}
|
2002-06-24 03:47:08 +08:00
|
|
|
|
/*@=boundswrite@*/
|
1998-08-09 06:27:08 +08:00
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
|
int build(rpmts ts, const char * arg, BTA_t ba, const char * rcfile)
|
1998-08-09 06:27:08 +08:00
|
|
|
|
{
|
1999-03-18 02:11:01 +08:00
|
|
|
|
char *t, *te;
|
1999-10-30 07:03:12 +08:00
|
|
|
|
int rc = 0;
|
2001-05-04 05:00:18 +08:00
|
|
|
|
char * targets = ba->targets;
|
1999-10-30 07:03:12 +08:00
|
|
|
|
#define buildCleanMask (RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC)
|
|
|
|
|
int cleanFlags = ba->buildAmount & buildCleanMask;
|
2002-08-06 09:41:44 +08:00
|
|
|
|
rpmVSFlags vsflags, ovsflags;
|
2002-07-28 22:52:33 +08:00
|
|
|
|
|
|
|
|
|
vsflags = rpmExpandNumeric("%{_vsflags_build}");
|
|
|
|
|
if (ba->qva_flags & VERIFY_DIGEST)
|
2002-08-06 09:41:44 +08:00
|
|
|
|
vsflags |= _RPMVSF_NODIGESTS;
|
2002-07-28 22:52:33 +08:00
|
|
|
|
if (ba->qva_flags & VERIFY_SIGNATURE)
|
2002-08-06 09:41:44 +08:00
|
|
|
|
vsflags |= _RPMVSF_NOSIGNATURES;
|
2002-07-28 22:52:33 +08:00
|
|
|
|
if (ba->qva_flags & VERIFY_HDRCHK)
|
2002-08-06 09:41:44 +08:00
|
|
|
|
vsflags |= RPMVSF_NOHDRCHK;
|
|
|
|
|
ovsflags = rpmtsSetVSFlags(ts, vsflags);
|
1998-08-09 06:27:08 +08:00
|
|
|
|
|
1998-12-02 07:28:26 +08:00
|
|
|
|
if (targets == NULL) {
|
2001-10-28 04:09:20 +08:00
|
|
|
|
rc = buildForTarget(ts, arg, ba);
|
1999-10-30 07:03:12 +08:00
|
|
|
|
goto exit;
|
1998-08-09 06:27:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
1998-08-16 22:26:04 +08:00
|
|
|
|
/* parse up the build operators */
|
|
|
|
|
|
1999-04-28 22:12:55 +08:00
|
|
|
|
printf(_("Building target platforms: %s\n"), targets);
|
1998-08-16 22:26:04 +08:00
|
|
|
|
|
1999-10-30 07:03:12 +08:00
|
|
|
|
ba->buildAmount &= ~buildCleanMask;
|
1999-03-18 04:01:09 +08:00
|
|
|
|
for (t = targets; *t != '\0'; t = te) {
|
|
|
|
|
char *target;
|
|
|
|
|
if ((te = strchr(t, ',')) == NULL)
|
|
|
|
|
te = t + strlen(t);
|
|
|
|
|
target = alloca(te-t+1);
|
1999-03-18 02:11:01 +08:00
|
|
|
|
strncpy(target, t, (te-t));
|
|
|
|
|
target[te-t] = '\0';
|
2001-05-04 05:00:18 +08:00
|
|
|
|
if (*te != '\0')
|
1999-10-30 07:03:12 +08:00
|
|
|
|
te++;
|
|
|
|
|
else /* XXX Perform clean-up after last target build. */
|
|
|
|
|
ba->buildAmount |= cleanFlags;
|
|
|
|
|
|
1999-04-28 22:12:55 +08:00
|
|
|
|
printf(_("Building for target %s\n"), target);
|
1998-08-09 06:27:08 +08:00
|
|
|
|
|
1999-10-30 07:03:12 +08:00
|
|
|
|
/* Read in configuration for target. */
|
1999-12-13 05:14:05 +08:00
|
|
|
|
rpmFreeMacros(NULL);
|
2004-10-18 03:00:10 +08:00
|
|
|
|
rpmFreeRpmrc();
|
2001-05-04 05:00:18 +08:00
|
|
|
|
(void) rpmReadConfigFiles(rcfile, target);
|
2001-10-28 04:09:20 +08:00
|
|
|
|
rc = buildForTarget(ts, arg, ba);
|
1998-08-09 06:27:08 +08:00
|
|
|
|
if (rc)
|
1999-10-30 07:03:12 +08:00
|
|
|
|
break;
|
1998-08-09 06:27:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-30 07:03:12 +08:00
|
|
|
|
exit:
|
2002-08-06 09:41:44 +08:00
|
|
|
|
vsflags = rpmtsSetVSFlags(ts, ovsflags);
|
1999-10-30 07:03:12 +08:00
|
|
|
|
/* Restore original configuration. */
|
1999-12-13 05:14:05 +08:00
|
|
|
|
rpmFreeMacros(NULL);
|
2004-10-18 03:00:10 +08:00
|
|
|
|
rpmFreeRpmrc();
|
2001-05-04 05:00:18 +08:00
|
|
|
|
(void) rpmReadConfigFiles(rcfile, NULL);
|
2001-10-28 04:09:20 +08:00
|
|
|
|
|
1999-10-30 07:03:12 +08:00
|
|
|
|
return rc;
|
1998-08-09 06:27:08 +08:00
|
|
|
|
}
|