#include "system.h"
+#include <rpmcli.h>
#include <rpmbuild.h>
-#include <rpmurl.h>
+
+#include "rpmps.h"
+#include "rpmte.h"
+#include "rpmts.h"
#include "build.h"
#include "debug.h"
-/*@access rpmTransactionSet @*/ /* XXX compared with NULL @*/
+/*@access rpmts @*/ /* XXX compared with NULL @*/
/*@access rpmdb @*/ /* XXX compared with NULL @*/
/*@access FD_t @*/ /* XXX compared with NULL @*/
/**
*/
-static int checkSpec(Header h)
+static int checkSpec(rpmts ts, Header h)
+ /*@globals fileSystem, internalState @*/
+ /*@modifies ts, h, fileSystem, internalState @*/
{
- const char * rootdir = NULL;
- rpmdb db = NULL;
- int mode = O_RDONLY;
- rpmTransactionSet ts;
- struct rpmDependencyConflict * conflicts;
- int numConflicts;
+ rpmps ps;
int rc;
- if (!headerIsEntry(h, RPMTAG_REQUIREFLAGS))
+ if (!headerIsEntry(h, RPMTAG_REQUIRENAME)
+ && !headerIsEntry(h, RPMTAG_CONFLICTNAME))
return 0;
- if (rpmdbOpen(rootdir, &db, mode, 0644)) {
- const char *dn;
- dn = rpmGetPath( (rootdir ? rootdir : ""), "%{_dbpath}", NULL);
- rpmError(RPMERR_OPEN, _("cannot open rpm database in %s\n"), dn);
- dn = _free(dn);
- exit(EXIT_FAILURE);
- }
- ts = rpmtransCreateSet(db, rootdir);
+ rc = rpmtsAddPackage(ts, h, NULL, 0, NULL);
- rc = rpmtransAddPackage(ts, h, NULL, NULL, 0, NULL);
+ rc = rpmtsCheck(ts);
- rc = rpmdepCheck(ts, &conflicts, &numConflicts);
- if (rc == 0 && conflicts) {
- rpmMessage(RPMMESS_ERROR, _("failed build dependencies:\n"));
- printDepProblems(stderr, conflicts, numConflicts);
- rpmdepFreeConflicts(conflicts, numConflicts);
+ ps = rpmtsGetProblems(ts);
+ if (rc == 0 && ps) {
+ rpmMessage(RPMMESS_ERROR, _("Failed build dependencies:\n"));
+ printDepProblems(stderr, ps);
rc = 1;
}
+ ps = rpmpsFree(ps);
- if (ts != NULL)
- rpmtransFree(ts);
- if (db != NULL)
- (void) rpmdbClose(db);
+ /* XXX nuke the added package. */
+ rpmtsClean(ts);
return rc;
}
/**
*/
static int isSpecFile(const char * specfile)
+ /*@globals fileSystem @*/
+ /*@modifies fileSystem @*/
{
char buf[256];
const char * s;
case '\r':
case '\n':
checking = 1;
- break;
+ /*@switchbreak@*/ break;
case ':':
checking = 0;
- break;
+ /*@switchbreak@*/ break;
default:
if (checking && !(isprint(*s) || isspace(*s))) return 0;
- break;
+ /*@switchbreak@*/ break;
}
}
return 1;
/**
*/
-static int buildForTarget(const char * arg, BTA_t ba,
- const char * passPhrase, char * cookie)
+static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
+ /*@globals rpmGlobalMacroContext,
+ fileSystem, internalState @*/
+ /*@modifies ts, rpmGlobalMacroContext,
+ fileSystem, internalState @*/
{
+ const char * passPhrase = ba->passPhrase;
+ const char * cookie = ba->cookie;
int buildAmount = ba->buildAmount;
- const char *buildRootURL = NULL;
+ const char * buildRootURL = NULL;
const char * specFile;
const char * specURL;
int specut;
rpmSetTables(RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS);
#endif
+ /*@-branchstate@*/
if (ba->buildRootOverride)
buildRootURL = rpmGenPath(NULL, ba->buildRootOverride, NULL);
+ /*@=branchstate@*/
+ /*@-compmempass@*/ /* FIX: static zcmds heartburn */
if (ba->buildMode == 't') {
FILE *fp;
- const char *specDir;
+ const char * specDir;
const char * tmpSpecFile;
- char * cmd, *s;
+ char * cmd, * s;
rpmCompressedMagic res = COMPRESSED_OTHER;
- static const char *zcmds[] = { "cat", "gunzip", "bunzip2", "cat" };
+ /*@observer@*/ static const char *zcmds[] =
+ { "cat", "gunzip", "bunzip2", "cat" };
specDir = rpmGetPath("%{_specdir}", NULL);
} else {
specURL = arg;
}
+ /*@=compmempass@*/
specut = urlPath(specURL, &specFile);
if (*specFile != '/') {
initSourceHeader(spec);
/* Check build prerequisites */
- if (!ba->noDeps && checkSpec(spec->sourceHeader)) {
+ if (!ba->noDeps && checkSpec(ts, spec->sourceHeader)) {
rc = 1;
goto exit;
}
rc = 0;
exit:
- if (spec)
- freeSpec(spec);
+ spec = freeSpec(spec);
buildRootURL = _free(buildRootURL);
return rc;
}
-int build(const char * arg, BTA_t ba,
- const char * passPhrase, char * cookie, const char * rcfile)
+int build(rpmts ts, const char * arg, BTA_t ba, const char * rcfile)
{
char *t, *te;
int rc = 0;
int cleanFlags = ba->buildAmount & buildCleanMask;
if (targets == NULL) {
- rc = buildForTarget(arg, ba, passPhrase, cookie);
+ rc = buildForTarget(ts, arg, ba);
goto exit;
}
/* Read in configuration for target. */
rpmFreeMacros(NULL);
(void) rpmReadConfigFiles(rcfile, target);
- rc = buildForTarget(arg, ba, passPhrase, cookie);
+ rc = buildForTarget(ts, arg, ba);
if (rc)
break;
}
/* Restore original configuration. */
rpmFreeMacros(NULL);
(void) rpmReadConfigFiles(rcfile, NULL);
+
return rc;
}