2000-08-28 03:18:25 +08:00
|
|
|
/** \ingroup rpmbuild
|
|
|
|
* \file build/pack.c
|
2000-01-25 04:02:32 +08:00
|
|
|
* Assemble components of an RPM package.
|
|
|
|
*/
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
|
|
|
|
2010-01-05 21:25:31 +08:00
|
|
|
#include <errno.h>
|
2010-08-24 18:54:04 +08:00
|
|
|
#include <netdb.h>
|
|
|
|
#include <time.h>
|
2013-08-17 22:26:30 +08:00
|
|
|
#include <sys/wait.h>
|
2010-01-05 21:25:31 +08:00
|
|
|
|
2008-01-30 19:53:51 +08:00
|
|
|
#include <rpm/rpmlib.h> /* RPMSIGTAG*, rpmReadPackageFile */
|
2008-01-30 23:05:29 +08:00
|
|
|
#include <rpm/rpmfileutil.h>
|
|
|
|
#include <rpm/rpmlog.h>
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2008-01-30 23:05:29 +08:00
|
|
|
#include "rpmio/rpmio_internal.h" /* fdInitDigest, fdFiniDigest */
|
2007-11-23 18:37:54 +08:00
|
|
|
#include "lib/fsm.h"
|
|
|
|
#include "lib/signature.h"
|
|
|
|
#include "lib/rpmlead.h"
|
2010-08-25 20:41:09 +08:00
|
|
|
#include "build/rpmbuild_internal.h"
|
|
|
|
#include "build/rpmbuild_misc.h"
|
2008-01-30 23:05:29 +08:00
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2013-11-25 15:59:27 +08:00
|
|
|
static int rpmPackageFilesArchive(rpmfiles fi, int isSrc,
|
|
|
|
FD_t cfd, ARGV_t dpaths,
|
|
|
|
rpm_loff_t * archiveSize, char ** failedFile)
|
2013-11-12 18:23:20 +08:00
|
|
|
{
|
2013-11-19 01:53:52 +08:00
|
|
|
int rc = 0;
|
2013-11-25 15:59:27 +08:00
|
|
|
rpmfi archive = rpmfiNewArchiveWriter(cfd, fi);
|
2013-11-12 18:23:20 +08:00
|
|
|
|
2013-11-19 01:53:52 +08:00
|
|
|
while (!rc && (rc = rpmfiNext(archive)) >= 0) {
|
2013-11-12 18:23:20 +08:00
|
|
|
/* Copy file into archive. */
|
2013-11-20 19:36:34 +08:00
|
|
|
FD_t rfd = NULL;
|
|
|
|
const char *path = dpaths[rpmfiFX(archive)];
|
|
|
|
|
|
|
|
rfd = Fopen(path, "r.ufdio");
|
|
|
|
if (Ferror(rfd)) {
|
2013-11-26 16:51:23 +08:00
|
|
|
rc = RPMERR_OPEN_FAILED;
|
2013-11-20 19:36:34 +08:00
|
|
|
} else {
|
|
|
|
rc = rpmfiArchiveWriteFile(archive, rfd);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc && failedFile)
|
|
|
|
*failedFile = xstrdup(path);
|
|
|
|
if (rfd) {
|
|
|
|
/* preserve any prior errno across close */
|
|
|
|
int myerrno = errno;
|
|
|
|
Fclose(rfd);
|
|
|
|
errno = myerrno;
|
|
|
|
}
|
2013-11-12 18:23:20 +08:00
|
|
|
}
|
|
|
|
|
2013-11-26 16:51:23 +08:00
|
|
|
if (rc == RPMERR_ITER_END)
|
2013-11-19 01:53:52 +08:00
|
|
|
rc = 0;
|
2013-11-12 18:23:20 +08:00
|
|
|
|
|
|
|
if (archiveSize)
|
2013-11-19 01:53:52 +08:00
|
|
|
*archiveSize = (rc == 0) ? rpmfiArchiveTell(archive) : 0;
|
2013-11-12 18:23:20 +08:00
|
|
|
|
|
|
|
/* Finish the payload stream */
|
|
|
|
if (!rc)
|
2013-11-19 01:53:52 +08:00
|
|
|
rc = rpmfiArchiveClose(archive);
|
|
|
|
|
|
|
|
rpmfiFree(archive);
|
2013-11-12 18:23:20 +08:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2001-01-11 22:13:04 +08:00
|
|
|
/**
|
2001-01-26 04:26:35 +08:00
|
|
|
* @todo Create transaction set *much* earlier.
|
2001-01-11 22:13:04 +08:00
|
|
|
*/
|
2013-04-15 18:53:45 +08:00
|
|
|
static rpmRC cpio_doio(FD_t fdo, Package pkg, const char * fmodeMacro)
|
1998-04-08 07:58:01 +08:00
|
|
|
{
|
2007-12-18 16:10:03 +08:00
|
|
|
char *failedFile = NULL;
|
2000-01-25 04:02:32 +08:00
|
|
|
FD_t cfd;
|
2012-04-24 17:36:26 +08:00
|
|
|
int fsmrc;
|
2011-03-16 00:58:31 +08:00
|
|
|
|
|
|
|
(void) Fflush(fdo);
|
2011-05-18 16:55:59 +08:00
|
|
|
cfd = Fdopen(fdDup(Fileno(fdo)), fmodeMacro);
|
2001-05-04 05:00:18 +08:00
|
|
|
if (cfd == NULL)
|
2007-12-07 15:28:39 +08:00
|
|
|
return RPMRC_FAIL;
|
2001-02-02 23:04:44 +08:00
|
|
|
|
2013-04-15 18:53:45 +08:00
|
|
|
fsmrc = rpmPackageFilesArchive(pkg->cpioList, headerIsSource(pkg->header),
|
2013-11-19 16:20:53 +08:00
|
|
|
cfd, pkg->dpaths,
|
|
|
|
&pkg->cpioArchiveSize, &failedFile);
|
2011-03-16 00:58:31 +08:00
|
|
|
|
2012-01-11 21:11:37 +08:00
|
|
|
if (fsmrc) {
|
2013-11-26 22:28:31 +08:00
|
|
|
char *emsg = rpmfileStrerror(fsmrc);
|
2001-06-20 14:29:20 +08:00
|
|
|
if (failedFile)
|
2012-07-02 21:15:41 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("create archive failed on file %s: %s\n"),
|
2013-02-20 03:55:24 +08:00
|
|
|
failedFile, emsg);
|
2001-06-20 14:29:20 +08:00
|
|
|
else
|
2013-02-20 03:55:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("create archive failed: %s\n"), emsg);
|
|
|
|
free(emsg);
|
1998-11-20 02:10:28 +08:00
|
|
|
}
|
2011-03-16 00:58:31 +08:00
|
|
|
|
2011-05-18 17:04:12 +08:00
|
|
|
free(failedFile);
|
2012-01-11 21:11:37 +08:00
|
|
|
Fclose(cfd);
|
1999-01-06 07:13:56 +08:00
|
|
|
|
2012-01-11 21:11:37 +08:00
|
|
|
return (fsmrc == 0) ? RPMRC_OK : RPMRC_FAIL;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
2011-05-18 18:23:29 +08:00
|
|
|
static rpmRC addFileToTag(rpmSpec spec, const char * file,
|
|
|
|
Header h, rpmTagVal tag, int append)
|
1998-10-12 04:58:58 +08:00
|
|
|
{
|
2011-05-18 18:23:29 +08:00
|
|
|
StringBuf sb = NULL;
|
2000-01-25 04:02:32 +08:00
|
|
|
char buf[BUFSIZ];
|
2008-03-25 01:01:12 +08:00
|
|
|
char * fn;
|
2001-05-01 06:32:22 +08:00
|
|
|
FILE * f;
|
2011-05-18 17:47:50 +08:00
|
|
|
rpmRC rc = RPMRC_FAIL; /* assume failure */
|
1998-10-12 04:58:58 +08:00
|
|
|
|
2011-05-18 18:23:29 +08:00
|
|
|
/* no script file is not an error */
|
|
|
|
if (file == NULL)
|
|
|
|
return RPMRC_OK;
|
|
|
|
|
2007-04-16 20:06:24 +08:00
|
|
|
fn = rpmGetPath("%{_builddir}/%{?buildsubdir:%{buildsubdir}/}", file, NULL);
|
1998-10-12 04:58:58 +08:00
|
|
|
|
2008-03-25 01:00:48 +08:00
|
|
|
f = fopen(fn, "r");
|
2011-05-18 18:23:29 +08:00
|
|
|
if (f == NULL) {
|
|
|
|
rpmlog(RPMLOG_ERR,_("Could not open %s file: %s\n"),
|
|
|
|
rpmTagGetName(tag), file);
|
2008-03-25 01:01:12 +08:00
|
|
|
goto exit;
|
2011-05-18 18:23:29 +08:00
|
|
|
}
|
2011-05-18 17:47:50 +08:00
|
|
|
|
2011-05-18 18:23:29 +08:00
|
|
|
sb = newStringBuf();
|
2011-05-18 17:47:50 +08:00
|
|
|
if (append) {
|
|
|
|
const char *s = headerGetString(h, tag);
|
|
|
|
if (s) {
|
|
|
|
appendLineStringBuf(sb, s);
|
|
|
|
headerDel(h, tag);
|
|
|
|
}
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
2011-05-18 17:47:50 +08:00
|
|
|
|
2001-05-01 06:32:22 +08:00
|
|
|
while (fgets(buf, sizeof(buf), f)) {
|
2000-01-25 04:02:32 +08:00
|
|
|
if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
|
2008-03-25 01:01:12 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("%s: line: %s\n"), fn, buf);
|
2011-05-18 17:47:50 +08:00
|
|
|
goto exit;
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
|
|
|
appendStringBuf(sb, buf);
|
1998-10-12 04:58:58 +08:00
|
|
|
}
|
2011-05-18 17:47:50 +08:00
|
|
|
headerPutString(h, tag, getStringBuf(sb));
|
|
|
|
rc = RPMRC_OK;
|
1999-10-28 07:18:10 +08:00
|
|
|
|
2008-03-25 01:01:12 +08:00
|
|
|
exit:
|
2011-05-18 17:47:50 +08:00
|
|
|
if (f) fclose(f);
|
2008-03-25 01:01:12 +08:00
|
|
|
free(fn);
|
2011-05-18 17:47:50 +08:00
|
|
|
freeStringBuf(sb);
|
2008-03-25 01:01:12 +08:00
|
|
|
|
2011-05-18 17:47:50 +08:00
|
|
|
return rc;
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
1998-10-12 04:58:58 +08:00
|
|
|
|
2010-08-24 18:54:04 +08:00
|
|
|
static rpm_time_t * getBuildTime(void)
|
|
|
|
{
|
|
|
|
static rpm_time_t buildTime[1];
|
|
|
|
|
|
|
|
if (buildTime[0] == 0)
|
|
|
|
buildTime[0] = (int32_t) time(NULL);
|
|
|
|
return buildTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char * buildHost(void)
|
|
|
|
{
|
|
|
|
static char hostname[1024];
|
|
|
|
static int oneshot = 0;
|
|
|
|
struct hostent *hbn;
|
|
|
|
|
|
|
|
if (! oneshot) {
|
|
|
|
(void) gethostname(hostname, sizeof(hostname));
|
|
|
|
hbn = gethostbyname(hostname);
|
|
|
|
if (hbn)
|
|
|
|
strcpy(hostname, hbn->h_name);
|
|
|
|
else
|
|
|
|
rpmlog(RPMLOG_WARNING,
|
|
|
|
_("Could not canonicalize hostname: %s\n"), hostname);
|
|
|
|
oneshot = 1;
|
|
|
|
}
|
|
|
|
return(hostname);
|
|
|
|
}
|
1998-10-12 04:58:58 +08:00
|
|
|
|
2007-12-07 16:43:53 +08:00
|
|
|
static rpmRC processScriptFiles(rpmSpec spec, Package pkg)
|
1996-02-19 10:24:47 +08:00
|
|
|
{
|
2000-01-25 04:02:32 +08:00
|
|
|
struct TriggerFileEntry *p;
|
2010-03-11 18:06:49 +08:00
|
|
|
int addflags = 0;
|
2011-05-18 18:23:29 +08:00
|
|
|
rpmRC rc = RPMRC_FAIL;
|
|
|
|
Header h = pkg->header;
|
2000-01-25 04:02:32 +08:00
|
|
|
|
2011-05-18 18:23:29 +08:00
|
|
|
if (addFileToTag(spec, pkg->preInFile, h, RPMTAG_PREIN, 1) ||
|
|
|
|
addFileToTag(spec, pkg->preUnFile, h, RPMTAG_PREUN, 1) ||
|
|
|
|
addFileToTag(spec, pkg->preTransFile, h, RPMTAG_PRETRANS, 1) ||
|
|
|
|
addFileToTag(spec, pkg->postInFile, h, RPMTAG_POSTIN, 1) ||
|
|
|
|
addFileToTag(spec, pkg->postUnFile, h, RPMTAG_POSTUN, 1) ||
|
|
|
|
addFileToTag(spec, pkg->postTransFile, h, RPMTAG_POSTTRANS, 1) ||
|
|
|
|
addFileToTag(spec, pkg->verifyFile, h, RPMTAG_VERIFYSCRIPT, 1))
|
|
|
|
{
|
|
|
|
goto exit;
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
|
|
|
|
2010-03-11 18:06:49 +08:00
|
|
|
/* if any trigger has flags, we need to add flags entry for all of them */
|
|
|
|
for (p = pkg->triggerFiles; p != NULL; p = p->next) {
|
|
|
|
if (p->flags) {
|
|
|
|
addflags = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
for (p = pkg->triggerFiles; p != NULL; p = p->next) {
|
2011-05-18 18:23:29 +08:00
|
|
|
headerPutString(h, RPMTAG_TRIGGERSCRIPTPROG, p->prog);
|
2010-03-11 18:06:49 +08:00
|
|
|
if (addflags) {
|
2011-05-18 18:23:29 +08:00
|
|
|
headerPutUint32(h, RPMTAG_TRIGGERSCRIPTFLAGS, &p->flags, 1);
|
2010-03-11 18:06:49 +08:00
|
|
|
}
|
2008-06-17 17:10:01 +08:00
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
if (p->script) {
|
2011-05-18 18:23:29 +08:00
|
|
|
headerPutString(h, RPMTAG_TRIGGERSCRIPTS, p->script);
|
2000-01-25 04:02:32 +08:00
|
|
|
} else if (p->fileName) {
|
2011-05-18 18:23:29 +08:00
|
|
|
if (addFileToTag(spec, p->fileName, h, RPMTAG_TRIGGERSCRIPTS, 0)) {
|
|
|
|
goto exit;
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* This is dumb. When the header supports NULL string */
|
|
|
|
/* this will go away. */
|
2011-05-18 18:23:29 +08:00
|
|
|
headerPutString(h, RPMTAG_TRIGGERSCRIPTS, "");
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
|
|
|
}
|
2011-05-18 18:23:29 +08:00
|
|
|
rc = RPMRC_OK;
|
2000-01-25 04:02:32 +08:00
|
|
|
|
2011-05-18 18:23:29 +08:00
|
|
|
exit:
|
|
|
|
return rc;
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
|
|
|
|
2012-04-23 16:04:02 +08:00
|
|
|
static int depContainsTilde(Header h, rpmTagVal tagEVR)
|
|
|
|
{
|
|
|
|
struct rpmtd_s evrs;
|
|
|
|
const char *evr = NULL;
|
|
|
|
|
|
|
|
if (headerGet(h, tagEVR, &evrs, HEADERGET_MINMEM)) {
|
|
|
|
while ((evr = rpmtdNextString(&evrs)) != NULL)
|
|
|
|
if (strchr(evr, '~'))
|
|
|
|
break;
|
|
|
|
rpmtdFreeData(&evrs);
|
|
|
|
}
|
|
|
|
return evr != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static rpmTagVal depevrtags[] = {
|
|
|
|
RPMTAG_PROVIDEVERSION,
|
|
|
|
RPMTAG_REQUIREVERSION,
|
|
|
|
RPMTAG_OBSOLETEVERSION,
|
|
|
|
RPMTAG_CONFLICTVERSION,
|
|
|
|
RPMTAG_ORDERVERSION,
|
|
|
|
RPMTAG_TRIGGERVERSION,
|
2014-02-17 18:27:49 +08:00
|
|
|
RPMTAG_SUGGESTVERSION,
|
|
|
|
RPMTAG_ENHANCEVERSION,
|
|
|
|
RPMTAG_RECOMMENDVERSION,
|
|
|
|
RPMTAG_SUPPLEMENTVERSION,
|
2012-04-23 16:04:02 +08:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static int haveTildeDep(Header h)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; depevrtags[i] != 0; i++)
|
|
|
|
if (depContainsTilde(h, depevrtags[i]))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-04-30 16:45:13 +08:00
|
|
|
static rpm_loff_t estimateCpioSize(Package pkg)
|
|
|
|
{
|
|
|
|
rpmfi fi;
|
|
|
|
rpm_loff_t size = 0;
|
|
|
|
|
|
|
|
fi = rpmfilesIter(pkg->cpioList, RPMFI_ITER_FWD);
|
|
|
|
while (rpmfiNext(fi) >= 0) {
|
|
|
|
size += strlen(rpmfiDN(fi)) + strlen(rpmfiBN(fi));
|
|
|
|
size += rpmfiFSize(fi);
|
|
|
|
size += 300;
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static rpmRC generateSignature(char *SHA1, uint8_t *MD5, rpm_loff_t size,
|
|
|
|
rpm_loff_t payloadSize, FD_t fd)
|
|
|
|
{
|
|
|
|
Header sig = NULL;
|
|
|
|
struct rpmtd_s td;
|
|
|
|
rpmTagVal sizetag;
|
|
|
|
rpmTagVal payloadtag;
|
|
|
|
rpm_tagtype_t typetag;
|
|
|
|
rpmRC rc = RPMRC_OK;
|
2014-05-15 16:15:27 +08:00
|
|
|
char *reservedSpace;
|
|
|
|
int spaceSize = 0;
|
2014-04-30 16:45:13 +08:00
|
|
|
|
|
|
|
/* Prepare signature */
|
|
|
|
sig = rpmNewSignature();
|
|
|
|
|
|
|
|
rpmtdReset(&td);
|
|
|
|
td.tag = RPMSIGTAG_SHA1;
|
|
|
|
td.count = 1;
|
|
|
|
td.type = RPM_STRING_TYPE;
|
|
|
|
td.data = SHA1;
|
|
|
|
headerPut(sig, &td, HEADERPUT_DEFAULT);
|
|
|
|
|
|
|
|
rpmtdReset(&td);
|
|
|
|
td.tag = RPMSIGTAG_MD5;
|
|
|
|
td.count = 16;
|
|
|
|
td.type = RPM_BIN_TYPE;
|
|
|
|
td.data = MD5;
|
|
|
|
headerPut(sig, &td, HEADERPUT_DEFAULT);
|
|
|
|
|
|
|
|
if (payloadSize < UINT32_MAX) {
|
|
|
|
sizetag = RPMSIGTAG_SIZE;
|
|
|
|
payloadtag = RPMSIGTAG_PAYLOADSIZE;
|
|
|
|
typetag = RPM_INT32_TYPE;
|
|
|
|
} else {
|
|
|
|
sizetag = RPMSIGTAG_LONGSIZE;
|
|
|
|
payloadtag = RPMSIGTAG_LONGARCHIVESIZE;
|
|
|
|
typetag = RPM_INT64_TYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpmtdReset(&td);
|
|
|
|
td.tag = payloadtag;
|
|
|
|
td.count = 1;
|
|
|
|
td.type = typetag;
|
|
|
|
td.data = &payloadSize;
|
|
|
|
headerPut(sig, &td, HEADERPUT_DEFAULT);
|
|
|
|
|
|
|
|
rpmtdReset(&td);
|
|
|
|
td.tag = sizetag;
|
|
|
|
td.count = 1;
|
|
|
|
td.type = typetag;
|
|
|
|
td.data = &size;
|
|
|
|
headerPut(sig, &td, HEADERPUT_DEFAULT);
|
|
|
|
|
2014-05-15 16:15:27 +08:00
|
|
|
spaceSize = rpmExpandNumeric("%{__gpg_reserved_space}");
|
|
|
|
if(spaceSize > 0) {
|
|
|
|
reservedSpace = xcalloc(spaceSize, sizeof(char));
|
|
|
|
rpmtdReset(&td);
|
|
|
|
td.tag = RPMSIGTAG_RESERVEDSPACE;
|
|
|
|
td.count = spaceSize;
|
|
|
|
td.type = RPM_BIN_TYPE;
|
|
|
|
td.data = reservedSpace;
|
|
|
|
headerPut(sig, &td, HEADERPUT_DEFAULT);
|
|
|
|
free(reservedSpace);
|
|
|
|
}
|
|
|
|
|
2014-04-30 16:45:13 +08:00
|
|
|
/* Reallocate the signature into one contiguous region. */
|
|
|
|
sig = headerReload(sig, RPMTAG_HEADERSIGNATURES);
|
|
|
|
if (sig == NULL) { /* XXX can't happen */
|
|
|
|
rpmlog(RPMLOG_ERR, _("Unable to reload signature header.\n"));
|
|
|
|
rc = RPMRC_FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the signature section into the package. */
|
|
|
|
if (rpmWriteSignature(fd, sig)) {
|
|
|
|
rc = RPMRC_FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
rpmFreeSignature(sig);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-15 18:44:09 +08:00
|
|
|
static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
|
2013-04-15 18:53:45 +08:00
|
|
|
const char *fileName, char **cookie)
|
2000-01-25 04:02:32 +08:00
|
|
|
{
|
2000-11-07 21:16:43 +08:00
|
|
|
FD_t fd = NULL;
|
2007-12-15 01:52:11 +08:00
|
|
|
char * rpmio_flags = NULL;
|
2007-12-17 03:24:44 +08:00
|
|
|
char * SHA1 = NULL;
|
2014-04-30 16:45:13 +08:00
|
|
|
uint8_t * MD5 = NULL;
|
2010-08-23 14:51:52 +08:00
|
|
|
const char *s;
|
2007-12-07 15:28:39 +08:00
|
|
|
rpmRC rc = RPMRC_OK;
|
2014-04-30 16:45:13 +08:00
|
|
|
rpm_loff_t estimatedCpioSize;
|
|
|
|
unsigned char buf[32*BUFSIZ];
|
|
|
|
uint8_t zeros[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
|
char *zerosS = "0000000000000000000000000000000000000000";
|
|
|
|
off_t sigStart;
|
|
|
|
off_t sigTargetStart;
|
|
|
|
off_t sigTargetSize;
|
1996-02-19 10:24:47 +08:00
|
|
|
|
2002-12-24 10:41:45 +08:00
|
|
|
if (pkgidp)
|
|
|
|
*pkgidp = NULL;
|
2002-12-22 04:37:37 +08:00
|
|
|
|
2000-06-23 09:19:45 +08:00
|
|
|
/* Save payload information */
|
2013-04-15 18:44:09 +08:00
|
|
|
if (headerIsSource(pkg->header))
|
2001-12-07 02:34:49 +08:00
|
|
|
rpmio_flags = rpmExpand("%{?_source_payload}", NULL);
|
2007-12-02 03:06:00 +08:00
|
|
|
else
|
2001-12-07 02:34:49 +08:00
|
|
|
rpmio_flags = rpmExpand("%{?_binary_payload}", NULL);
|
2007-12-02 03:06:00 +08:00
|
|
|
|
2011-05-18 16:55:59 +08:00
|
|
|
/* If not configured or bogus, fall back to gz */
|
|
|
|
if (rpmio_flags[0] != 'w') {
|
|
|
|
free(rpmio_flags);
|
2000-06-23 09:19:45 +08:00
|
|
|
rpmio_flags = xstrdup("w9.gzdio");
|
|
|
|
}
|
|
|
|
s = strchr(rpmio_flags, '.');
|
|
|
|
if (s) {
|
2011-05-18 20:53:54 +08:00
|
|
|
char *buf = NULL;
|
2008-04-15 14:16:05 +08:00
|
|
|
const char *compr = NULL;
|
2013-04-15 18:44:09 +08:00
|
|
|
headerPutString(pkg->header, RPMTAG_PAYLOADFORMAT, "cpio");
|
2008-06-17 17:10:01 +08:00
|
|
|
|
2011-02-15 20:39:29 +08:00
|
|
|
if (rstreq(s+1, "ufdio")) {
|
|
|
|
compr = NULL;
|
|
|
|
} else if (rstreq(s+1, "gzdio")) {
|
2008-04-15 14:16:05 +08:00
|
|
|
compr = "gzip";
|
2009-04-13 18:58:39 +08:00
|
|
|
#if HAVE_BZLIB_H
|
2009-08-31 16:08:05 +08:00
|
|
|
} else if (rstreq(s+1, "bzdio")) {
|
2008-04-15 14:16:05 +08:00
|
|
|
compr = "bzip2";
|
2000-06-23 09:19:45 +08:00
|
|
|
/* Add prereq on rpm version that understands bzip2 payloads */
|
2013-04-15 19:08:24 +08:00
|
|
|
(void) rpmlibNeedsFeature(pkg, "PayloadIsBzip2", "3.0.5-1");
|
2009-04-13 18:58:39 +08:00
|
|
|
#endif
|
|
|
|
#if HAVE_LZMA_H
|
2009-08-31 16:08:05 +08:00
|
|
|
} else if (rstreq(s+1, "xzdio")) {
|
2009-03-18 15:42:23 +08:00
|
|
|
compr = "xz";
|
2013-04-15 19:08:24 +08:00
|
|
|
(void) rpmlibNeedsFeature(pkg, "PayloadIsXz", "5.2-1");
|
2009-08-31 16:08:05 +08:00
|
|
|
} else if (rstreq(s+1, "lzdio")) {
|
2009-03-18 17:24:52 +08:00
|
|
|
compr = "lzma";
|
2013-04-15 19:08:24 +08:00
|
|
|
(void) rpmlibNeedsFeature(pkg, "PayloadIsLzma", "4.4.6-1");
|
2009-04-13 18:58:39 +08:00
|
|
|
#endif
|
2008-04-15 14:16:05 +08:00
|
|
|
} else {
|
|
|
|
rpmlog(RPMLOG_ERR, _("Unknown payload compression: %s\n"),
|
|
|
|
rpmio_flags);
|
|
|
|
rc = RPMRC_FAIL;
|
|
|
|
goto exit;
|
2000-06-23 09:19:45 +08:00
|
|
|
}
|
2008-04-15 14:16:05 +08:00
|
|
|
|
2011-02-15 20:39:29 +08:00
|
|
|
if (compr)
|
2013-04-15 18:44:09 +08:00
|
|
|
headerPutString(pkg->header, RPMTAG_PAYLOADCOMPRESSOR, compr);
|
2008-03-23 20:48:49 +08:00
|
|
|
buf = xstrdup(rpmio_flags);
|
2000-07-10 07:10:25 +08:00
|
|
|
buf[s - rpmio_flags] = '\0';
|
2013-04-15 18:44:09 +08:00
|
|
|
headerPutString(pkg->header, RPMTAG_PAYLOADFLAGS, buf+1);
|
2008-03-23 20:48:49 +08:00
|
|
|
free(buf);
|
2000-06-23 09:19:45 +08:00
|
|
|
}
|
|
|
|
|
2012-04-23 16:04:02 +08:00
|
|
|
/* check if the package has a dependency with a '~' */
|
2013-04-15 18:44:09 +08:00
|
|
|
if (haveTildeDep(pkg->header))
|
2013-04-15 19:08:24 +08:00
|
|
|
(void) rpmlibNeedsFeature(pkg, "TildeInVersions", "4.10.0-1");
|
2012-04-23 16:04:02 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
/* Create and add the cookie */
|
|
|
|
if (cookie) {
|
2008-03-23 20:48:49 +08:00
|
|
|
rasprintf(cookie, "%s %d", buildHost(), (int) (*getBuildTime()));
|
2013-04-15 18:44:09 +08:00
|
|
|
headerPutString(pkg->header, RPMTAG_COOKIE, *cookie);
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
2000-11-09 01:07:01 +08:00
|
|
|
/* Reallocate the header into one contiguous region. */
|
2013-04-15 18:44:09 +08:00
|
|
|
pkg->header = headerReload(pkg->header, RPMTAG_HEADERIMMUTABLE);
|
|
|
|
if (pkg->header == NULL) {
|
2007-12-07 15:28:39 +08:00
|
|
|
rc = RPMRC_FAIL;
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("Unable to create immutable header region.\n"));
|
2001-05-04 05:00:18 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
2000-11-09 01:07:01 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
/* Open the output file */
|
2014-04-30 16:45:13 +08:00
|
|
|
fd = Fopen(fileName, "w+.ufdio");
|
1999-11-13 01:20:49 +08:00
|
|
|
if (fd == NULL || Ferror(fd)) {
|
2007-12-07 15:28:39 +08:00
|
|
|
rc = RPMRC_FAIL;
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("Could not open %s: %s\n"),
|
1999-11-13 01:20:49 +08:00
|
|
|
fileName, Fstrerror(fd));
|
2000-11-07 21:16:43 +08:00
|
|
|
goto exit;
|
1996-03-30 04:06:02 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2000-12-03 05:53:44 +08:00
|
|
|
/* Write the lead section into the package. */
|
2007-12-02 00:31:09 +08:00
|
|
|
{
|
2013-04-15 18:44:09 +08:00
|
|
|
rpmlead lead = rpmLeadFromHeader(pkg->header);
|
2007-12-07 15:28:39 +08:00
|
|
|
rc = rpmLeadWrite(fd, lead);
|
2011-05-27 21:46:23 +08:00
|
|
|
rpmLeadFree(lead);
|
2007-12-02 00:31:09 +08:00
|
|
|
if (rc != RPMRC_OK) {
|
2007-12-07 15:28:39 +08:00
|
|
|
rc = RPMRC_FAIL;
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("Unable to write package: %s\n"),
|
1999-11-11 06:09:49 +08:00
|
|
|
Fstrerror(fd));
|
2000-12-03 05:53:44 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
1996-02-19 10:24:47 +08:00
|
|
|
}
|
|
|
|
|
2014-04-30 16:45:13 +08:00
|
|
|
/* Estimate cpio archive size to decide if use 32 bits or 64 bit tags. */
|
|
|
|
estimatedCpioSize = estimateCpioSize(pkg);
|
|
|
|
|
|
|
|
/* Save the position of signature section */
|
|
|
|
sigStart = Ftell(fd);
|
|
|
|
|
|
|
|
/* Generate and write a placeholder signature header */
|
|
|
|
rc = generateSignature(zerosS, zeros, 0, estimatedCpioSize, fd);
|
|
|
|
if (rc != RPMRC_OK) {
|
2007-12-07 15:28:39 +08:00
|
|
|
rc = RPMRC_FAIL;
|
2000-11-07 21:16:43 +08:00
|
|
|
goto exit;
|
2007-12-07 15:28:39 +08:00
|
|
|
}
|
2000-12-03 05:53:44 +08:00
|
|
|
|
2014-04-30 16:45:13 +08:00
|
|
|
/* Write the header and archive section. Calculate SHA1 from them. */
|
|
|
|
sigTargetStart = Ftell(fd);
|
|
|
|
fdInitDigest(fd, PGPHASHALGO_SHA1, 0);
|
|
|
|
if (headerWrite(fd, pkg->header, HEADER_MAGIC_YES)) {
|
2007-12-07 15:28:39 +08:00
|
|
|
rc = RPMRC_FAIL;
|
2014-04-30 16:45:13 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("Unable to write temp header\n"));
|
2000-11-07 21:16:43 +08:00
|
|
|
goto exit;
|
1999-11-13 01:20:49 +08:00
|
|
|
}
|
2014-04-30 16:45:13 +08:00
|
|
|
(void) Fflush(fd);
|
|
|
|
fdFiniDigest(fd, PGPHASHALGO_SHA1, (void **)&SHA1, NULL, 1);
|
2000-12-03 05:53:44 +08:00
|
|
|
|
2014-04-30 16:45:13 +08:00
|
|
|
/* Write payload section (cpio archive) */
|
|
|
|
if (pkg->cpioList == NULL) {
|
|
|
|
rc = RPMRC_FAIL;
|
|
|
|
rpmlog(RPMLOG_ERR, _("Bad CSA data\n"));
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
rc = cpio_doio(fd, pkg, rpmio_flags);
|
|
|
|
if (rc != RPMRC_OK)
|
|
|
|
goto exit;
|
2000-12-03 05:53:44 +08:00
|
|
|
|
2014-04-30 16:45:13 +08:00
|
|
|
sigTargetSize = Ftell(fd) - sigTargetStart;
|
2000-12-03 05:53:44 +08:00
|
|
|
|
2014-04-30 16:45:13 +08:00
|
|
|
if(Fseek(fd, sigTargetStart, SEEK_SET) < 0) {
|
|
|
|
rc = RPMRC_FAIL;
|
|
|
|
rpmlog(RPMLOG_ERR, _("Could not seek in file %s: %s\n"),
|
|
|
|
fileName, Fstrerror(fd));
|
|
|
|
goto exit;
|
|
|
|
}
|
2000-12-03 05:53:44 +08:00
|
|
|
|
2014-04-30 16:45:13 +08:00
|
|
|
/* Calculate MD5 checksum from header and archive section. */
|
|
|
|
fdInitDigest(fd, PGPHASHALGO_MD5, 0);
|
|
|
|
while (Fread(buf, sizeof(buf[0]), sizeof(buf), fd) > 0)
|
|
|
|
;
|
|
|
|
if (Ferror(fd)) {
|
|
|
|
rc = RPMRC_FAIL;
|
|
|
|
rpmlog(RPMLOG_ERR, _("Fread failed in file %s: %s\n"),
|
|
|
|
fileName, Fstrerror(fd));
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
fdFiniDigest(fd, PGPHASHALGO_MD5, (void **)&MD5, NULL, 0);
|
|
|
|
|
|
|
|
if(Fseek(fd, sigStart, SEEK_SET) < 0) {
|
|
|
|
rc = RPMRC_FAIL;
|
|
|
|
rpmlog(RPMLOG_ERR, _("Could not seek in file %s: %s\n"),
|
|
|
|
fileName, Fstrerror(fd));
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate the signature. Now with right values */
|
|
|
|
rc = generateSignature(SHA1, MD5, sigTargetSize, pkg->cpioArchiveSize, fd);
|
|
|
|
if (rc != RPMRC_OK) {
|
|
|
|
rc = RPMRC_FAIL;
|
|
|
|
goto exit;
|
2000-12-03 05:53:44 +08:00
|
|
|
}
|
1996-06-28 01:21:31 +08:00
|
|
|
|
2000-11-07 21:16:43 +08:00
|
|
|
exit:
|
2011-05-27 20:38:54 +08:00
|
|
|
free(rpmio_flags);
|
|
|
|
free(SHA1);
|
2002-12-24 10:41:45 +08:00
|
|
|
|
|
|
|
/* XXX Fish the pkgid out of the signature header. */
|
2014-04-30 16:45:13 +08:00
|
|
|
if (pkgidp != NULL) {
|
|
|
|
if (MD5 != NULL) {
|
|
|
|
*pkgidp = MD5;
|
2008-05-26 20:25:11 +08:00
|
|
|
}
|
2002-12-24 10:41:45 +08:00
|
|
|
}
|
|
|
|
|
2011-05-19 16:08:07 +08:00
|
|
|
Fclose(fd);
|
|
|
|
|
2007-12-07 15:28:39 +08:00
|
|
|
if (rc == RPMRC_OK)
|
2007-10-09 19:50:42 +08:00
|
|
|
rpmlog(RPMLOG_NOTICE, _("Wrote: %s\n"), fileName);
|
2000-11-07 21:16:43 +08:00
|
|
|
else
|
2007-12-03 22:33:18 +08:00
|
|
|
(void) unlink(fileName);
|
2000-11-07 21:16:43 +08:00
|
|
|
|
|
|
|
return rc;
|
1995-12-21 06:49:40 +08:00
|
|
|
}
|
|
|
|
|
2010-10-22 18:31:34 +08:00
|
|
|
static const rpmTagVal copyTags[] = {
|
2000-01-25 04:02:32 +08:00
|
|
|
RPMTAG_CHANGELOGTIME,
|
|
|
|
RPMTAG_CHANGELOGNAME,
|
|
|
|
RPMTAG_CHANGELOGTEXT,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2010-08-24 18:39:42 +08:00
|
|
|
static rpmRC checkPackages(char *pkgcheck)
|
2008-11-10 22:52:29 +08:00
|
|
|
{
|
|
|
|
int fail = rpmExpandNumeric("%{?_nonzero_exit_pkgcheck_terminate_build}");
|
|
|
|
int xx;
|
|
|
|
|
|
|
|
rpmlog(RPMLOG_NOTICE, _("Executing \"%s\":\n"), pkgcheck);
|
|
|
|
xx = system(pkgcheck);
|
|
|
|
if (WEXITSTATUS(xx) == -1 || WEXITSTATUS(xx) == 127) {
|
|
|
|
rpmlog(RPMLOG_ERR, _("Execution of \"%s\" failed.\n"), pkgcheck);
|
2010-09-21 16:37:21 +08:00
|
|
|
if (fail) return RPMRC_NOTFOUND;
|
2008-11-10 22:52:29 +08:00
|
|
|
}
|
|
|
|
if (WEXITSTATUS(xx) != 0) {
|
|
|
|
rpmlog(RPMLOG_ERR, _("Package check \"%s\" failed.\n"), pkgcheck);
|
|
|
|
if (fail) return RPMRC_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RPMRC_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-02 16:01:15 +08:00
|
|
|
rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
|
1999-09-18 07:18:24 +08:00
|
|
|
{
|
2007-12-07 16:43:53 +08:00
|
|
|
rpmRC rc;
|
2000-01-25 04:02:32 +08:00
|
|
|
const char *errorString;
|
|
|
|
Package pkg;
|
2008-11-10 22:52:29 +08:00
|
|
|
char *pkglist = NULL;
|
1998-12-06 07:22:41 +08:00
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
|
2007-12-15 16:39:15 +08:00
|
|
|
char *fn;
|
1995-12-21 06:49:40 +08:00
|
|
|
|
2010-12-23 15:24:25 +08:00
|
|
|
if (pkg->fileList == NULL)
|
|
|
|
continue;
|
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
if ((rc = processScriptFiles(spec, pkg)))
|
|
|
|
return rc;
|
|
|
|
|
2010-09-01 19:00:54 +08:00
|
|
|
if (cookie) {
|
|
|
|
headerPutString(pkg->header, RPMTAG_COOKIE, cookie);
|
1998-07-25 23:33:15 +08:00
|
|
|
}
|
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
/* Copy changelog from src rpm */
|
|
|
|
headerCopyTags(spec->packages->header, pkg->header, copyTags);
|
|
|
|
|
2008-06-19 20:43:45 +08:00
|
|
|
headerPutString(pkg->header, RPMTAG_RPMVERSION, VERSION);
|
|
|
|
headerPutString(pkg->header, RPMTAG_BUILDHOST, buildHost());
|
|
|
|
headerPutUint32(pkg->header, RPMTAG_BUILDTIME, getBuildTime(), 1);
|
1999-11-13 01:20:49 +08:00
|
|
|
|
2014-06-11 19:13:11 +08:00
|
|
|
for (int i=0; i<PACKAGE_NUM_DEPS; i++) {
|
2014-08-21 21:05:02 +08:00
|
|
|
/* Nuke any previously added dependencies from the header */
|
2014-08-18 21:31:14 +08:00
|
|
|
headerDel(pkg->header, rpmdsTagN(pkg->dependencies[i]));
|
|
|
|
headerDel(pkg->header, rpmdsTagEVR(pkg->dependencies[i]));
|
|
|
|
headerDel(pkg->header, rpmdsTagF(pkg->dependencies[i]));
|
2014-08-21 21:05:02 +08:00
|
|
|
headerDel(pkg->header, rpmdsTagTi(pkg->dependencies[i]));
|
2014-08-18 21:31:14 +08:00
|
|
|
/* ...and add again, now with automatic dependencies included */
|
2014-06-11 19:13:11 +08:00
|
|
|
rpmdsPutToHeader(pkg->dependencies[i], pkg->header);
|
|
|
|
}
|
2014-06-16 21:01:22 +08:00
|
|
|
|
2002-12-22 04:37:37 +08:00
|
|
|
if (spec->sourcePkgId != NULL) {
|
2008-06-19 20:43:45 +08:00
|
|
|
headerPutBin(pkg->header, RPMTAG_SOURCEPKGID, spec->sourcePkgId,16);
|
2010-06-23 20:37:56 +08:00
|
|
|
}
|
|
|
|
|
2010-09-02 16:01:15 +08:00
|
|
|
if (cheating) {
|
2013-04-15 19:08:24 +08:00
|
|
|
(void) rpmlibNeedsFeature(pkg, "ShortCircuited", "4.9.0-1");
|
2002-12-22 04:37:37 +08:00
|
|
|
}
|
2000-01-25 04:02:32 +08:00
|
|
|
|
2007-12-15 16:39:15 +08:00
|
|
|
{ char *binFormat = rpmGetPath("%{_rpmfilename}", NULL);
|
2000-01-25 04:02:32 +08:00
|
|
|
char *binRpm, *binDir;
|
2008-05-12 21:20:13 +08:00
|
|
|
binRpm = headerFormat(pkg->header, binFormat, &errorString);
|
2011-05-27 21:46:23 +08:00
|
|
|
free(binFormat);
|
2000-01-25 04:02:32 +08:00
|
|
|
if (binRpm == NULL) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("Could not generate output "
|
2009-09-02 16:55:42 +08:00
|
|
|
"filename for package %s: %s\n"),
|
|
|
|
headerGetString(pkg->header, RPMTAG_NAME), errorString);
|
2007-12-07 16:43:53 +08:00
|
|
|
return RPMRC_FAIL;
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
|
|
|
fn = rpmGetPath("%{_rpmdir}/", binRpm, NULL);
|
|
|
|
if ((binDir = strchr(binRpm, '/')) != NULL) {
|
|
|
|
struct stat st;
|
2007-12-15 16:39:15 +08:00
|
|
|
char *dn;
|
2000-01-25 04:02:32 +08:00
|
|
|
*binDir = '\0';
|
|
|
|
dn = rpmGetPath("%{_rpmdir}/", binRpm, NULL);
|
2007-12-03 22:33:18 +08:00
|
|
|
if (stat(dn, &st) < 0) {
|
2000-01-25 04:02:32 +08:00
|
|
|
switch(errno) {
|
|
|
|
case ENOENT:
|
2007-12-03 22:33:18 +08:00
|
|
|
if (mkdir(dn, 0755) == 0)
|
2007-09-12 05:03:27 +08:00
|
|
|
break;
|
2000-01-25 04:02:32 +08:00
|
|
|
default:
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR,_("cannot create %s: %s\n"),
|
2000-01-25 04:02:32 +08:00
|
|
|
dn, strerror(errno));
|
2007-09-12 05:03:27 +08:00
|
|
|
break;
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
|
|
|
}
|
2011-05-27 20:38:54 +08:00
|
|
|
free(dn);
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
2011-05-27 20:38:54 +08:00
|
|
|
free(binRpm);
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
1998-03-21 06:38:00 +08:00
|
|
|
|
2013-04-15 18:53:45 +08:00
|
|
|
rc = writeRPM(pkg, NULL, fn, NULL);
|
2008-11-10 22:52:29 +08:00
|
|
|
if (rc == RPMRC_OK) {
|
|
|
|
/* Do check each written package if enabled */
|
|
|
|
char *pkgcheck = rpmExpand("%{?_build_pkgcheck} ", fn, NULL);
|
|
|
|
if (pkgcheck[0] != ' ') {
|
|
|
|
rc = checkPackages(pkgcheck);
|
|
|
|
}
|
2011-05-27 20:38:54 +08:00
|
|
|
free(pkgcheck);
|
2008-11-10 22:52:29 +08:00
|
|
|
rstrcat(&pkglist, fn);
|
|
|
|
rstrcat(&pkglist, " ");
|
|
|
|
}
|
2011-05-27 20:38:54 +08:00
|
|
|
free(fn);
|
2008-11-10 22:52:29 +08:00
|
|
|
if (rc != RPMRC_OK) {
|
|
|
|
pkglist = _free(pkglist);
|
2000-01-25 04:02:32 +08:00
|
|
|
return rc;
|
2008-11-10 22:52:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now check the package set if enabled */
|
|
|
|
if (pkglist != NULL) {
|
|
|
|
char *pkgcheck_set = rpmExpand("%{?_build_pkgcheck_set} ", pkglist, NULL);
|
|
|
|
if (pkgcheck_set[0] != ' ') { /* run only if _build_pkgcheck_set is defined */
|
|
|
|
checkPackages(pkgcheck_set);
|
|
|
|
}
|
2011-05-27 20:38:54 +08:00
|
|
|
free(pkgcheck_set);
|
2008-11-10 22:52:29 +08:00
|
|
|
pkglist = _free(pkglist);
|
1998-03-21 06:38:00 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2007-12-07 16:43:53 +08:00
|
|
|
return RPMRC_OK;
|
1995-12-21 06:49:40 +08:00
|
|
|
}
|
|
|
|
|
2010-09-01 19:00:54 +08:00
|
|
|
rpmRC packageSources(rpmSpec spec, char **cookie)
|
1998-03-21 06:38:00 +08:00
|
|
|
{
|
2013-04-15 18:23:48 +08:00
|
|
|
Package sourcePkg = spec->sourcePackage;
|
2007-12-07 16:43:53 +08:00
|
|
|
rpmRC rc;
|
1998-03-21 06:38:00 +08:00
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
/* Add some cruft */
|
2013-04-15 18:23:48 +08:00
|
|
|
headerPutString(sourcePkg->header, RPMTAG_RPMVERSION, VERSION);
|
|
|
|
headerPutString(sourcePkg->header, RPMTAG_BUILDHOST, buildHost());
|
|
|
|
headerPutUint32(sourcePkg->header, RPMTAG_BUILDTIME, getBuildTime(), 1);
|
1998-03-21 06:38:00 +08:00
|
|
|
|
2014-08-25 16:03:00 +08:00
|
|
|
for (int i=0; i<PACKAGE_NUM_DEPS; i++) {
|
|
|
|
/* Nuke any previously added dependencies from the header */
|
|
|
|
headerDel(sourcePkg->header, rpmdsTagN(sourcePkg->dependencies[i]));
|
|
|
|
headerDel(sourcePkg->header, rpmdsTagEVR(sourcePkg->dependencies[i]));
|
|
|
|
headerDel(sourcePkg->header, rpmdsTagF(sourcePkg->dependencies[i]));
|
|
|
|
headerDel(sourcePkg->header, rpmdsTagTi(sourcePkg->dependencies[i]));
|
|
|
|
/* ...and add again, now with automatic dependencies included */
|
|
|
|
rpmdsPutToHeader(sourcePkg->dependencies[i], sourcePkg->header);
|
|
|
|
}
|
|
|
|
|
2000-01-25 04:02:32 +08:00
|
|
|
/* XXX this should be %_srpmdir */
|
2007-12-15 16:39:15 +08:00
|
|
|
{ char *fn = rpmGetPath("%{_srcrpmdir}/", spec->sourceRpmName,NULL);
|
2008-11-10 22:52:29 +08:00
|
|
|
char *pkgcheck = rpmExpand("%{?_build_pkgcheck_srpm} ", fn, NULL);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2002-12-24 10:41:45 +08:00
|
|
|
spec->sourcePkgId = NULL;
|
2013-04-15 18:53:45 +08:00
|
|
|
rc = writeRPM(sourcePkg, &spec->sourcePkgId, fn, cookie);
|
2002-12-24 10:41:45 +08:00
|
|
|
|
2008-11-10 22:52:29 +08:00
|
|
|
/* Do check SRPM package if enabled */
|
|
|
|
if (rc == RPMRC_OK && pkgcheck[0] != ' ') {
|
|
|
|
rc = checkPackages(pkgcheck);
|
|
|
|
}
|
|
|
|
|
2011-05-27 20:38:54 +08:00
|
|
|
free(pkgcheck);
|
|
|
|
free(fn);
|
2000-01-25 04:02:32 +08:00
|
|
|
}
|
|
|
|
return rc;
|
1995-12-21 06:49:40 +08:00
|
|
|
}
|