rpmbuild.c
Go to the documentation of this file.
#include "system.h"
const char *__progname;
#include <errno.h>
#include <libgen.h>
#include <ctype.h>
#include <rpm/rpmcli.h>
#include <rpm/rpmlib.h> /* RPMSIGTAG, rpmReadPackageFile .. */
#include <rpm/rpmbuild.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmfileutil.h>
#include <rpm/rpmdb.h>
#include <rpm/rpmps.h>
#include <rpm/rpmts.h>
#include "lib/signature.h"
#include "cliutils.h"
#include "debug.h"
static struct rpmBuildArguments_s rpmBTArgs;
#define POPT_NOLANG -1012
#define POPT_RMSOURCE -1013
#define POPT_RMBUILD -1014
#define POPT_BUILDROOT -1015
#define POPT_TARGETPLATFORM -1016
#define POPT_NOBUILD -1017
#define POPT_RMSPEC -1019
#define POPT_NODIRTOKENS -1020
#define POPT_BUILDINPLACE -1021
#define POPT_REBUILD 0x4262 /* Bb */
#define POPT_RECOMPILE 0x4369 /* Ci */
#define POPT_BA 0x6261
#define POPT_BB 0x6262
#define POPT_BC 0x6263
#define POPT_BI 0x6269
#define POPT_BL 0x626c
#define POPT_BP 0x6270
#define POPT_BS 0x6273
#define POPT_RA 0x4261
#define POPT_RB 0x4262
#define POPT_RC 0x4263
#define POPT_RI 0x4269
#define POPT_RL 0x426c
#define POPT_RP 0x4270
#define POPT_RS 0x4273
#define POPT_TA 0x7461
#define POPT_TB 0x7462
#define POPT_TC 0x7463
#define POPT_TI 0x7469
#define POPT_TL 0x746c
#define POPT_TP 0x7470
#define POPT_TS 0x7473
extern int _fsm_debug;
static rpmSpecFlags spec_flags = 0;
static int noDeps = 0;
static int shortCircuit = 0;
static char buildMode = 0;
static char buildChar = 0;
static rpmBuildFlags nobuildAmount = 0;
static ARGV_t build_targets = NULL;
static int buildInPlace = 0;
static void buildArgCallback( poptContext con,
enum poptCallbackReason reason,
const struct poptOption * opt, const char * arg,
const void * data)
{
BTA_t rba = &rpmBTArgs;
switch (opt->val) {
case POPT_REBUILD:
case POPT_RECOMPILE:
case POPT_BA:
case POPT_BB:
case POPT_BC:
case POPT_BI:
case POPT_BL:
case POPT_BP:
case POPT_BS:
case POPT_RA:
/* case POPT_RB: same value as POPT_REBUILD */
case POPT_RC:
case POPT_RI:
case POPT_RL:
case POPT_RP:
case POPT_RS:
case POPT_TA:
case POPT_TB:
case POPT_TC:
case POPT_TI:
case POPT_TL:
case POPT_TP:
case POPT_TS:
if (opt->val == POPT_BS || opt->val == POPT_TS)
noDeps = 1;
if (buildMode == '\0' && buildChar == '\0') {
buildMode = (((unsigned)opt->val) >> 8) & 0xff;
buildChar = (opt->val ) & 0xff;
}
break;
case POPT_NODIRTOKENS: rba->pkgFlags |= RPMBUILD_PKG_NODIRTOKENS; break;
case POPT_NOBUILD: rba->buildAmount |= RPMBUILD_NOBUILD; break;
case POPT_NOLANG: spec_flags |= RPMSPEC_NOLANG; break;
case POPT_RMSOURCE: rba->buildAmount |= RPMBUILD_RMSOURCE; break;
case POPT_RMSPEC: rba->buildAmount |= RPMBUILD_RMSPEC; break;
case POPT_RMBUILD: rba->buildAmount |= RPMBUILD_RMBUILD; break;
case POPT_BUILDROOT:
if (rba->buildRootOverride) {
rpmlog(RPMLOG_ERR, _("buildroot already specified, ignoring %s\n"), arg);
break;
}
rba->buildRootOverride = xstrdup(arg);
break;
case POPT_TARGETPLATFORM:
argvSplit(&build_targets, arg, ",");
break;
case RPMCLI_POPT_FORCE:
spec_flags |= RPMSPEC_FORCE;
break;
case POPT_BUILDINPLACE:
rpmDefineMacro(NULL, "_build_in_place 1", 0);
buildInPlace = 1;
break;
}
}
static struct poptOption rpmBuildPoptTable[] = {
{ NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
buildArgCallback, 0, NULL, NULL },
{ "bp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BP,
N_("build through %prep (unpack sources and apply patches) from <specfile>"),
N_("<specfile>") },
{ "bc", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BC,
N_("build through %build (%prep, then compile) from <specfile>"),
N_("<specfile>") },
{ "bi", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BI,
N_("build through %install (%prep, %build, then install) from <specfile>"),
N_("<specfile>") },
{ "bl", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BL,
N_("verify %files section from <specfile>"),
N_("<specfile>") },
{ "ba", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BA,
N_("build source and binary packages from <specfile>"),
N_("<specfile>") },
{ "bb", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BB,
N_("build binary package only from <specfile>"),
N_("<specfile>") },
{ "bs", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BS,
N_("build source package only from <specfile>"),
N_("<specfile>") },
{ "rp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_RP,
N_("build through %prep (unpack sources and apply patches) from <source package>"),
N_("<source package>") },
{ "rc", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_RC,
N_("build through %build (%prep, then compile) from <source package>"),
N_("<source package>") },
{ "ri", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_RI,
N_("build through %install (%prep, %build, then install) from <source package>"),
N_("<source package>") },
{ "rl", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_RL,
N_("verify %files section from <source package>"),
N_("<source package>") },
{ "ra", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_RA,
N_("build source and binary packages from <source package>"),
N_("<source package>") },
{ "rb", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_RB,
N_("build binary package only from <source package>"),
N_("<source package>") },
{ "rs", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_RS,
N_("build source package only from <source package>"),
N_("<source package>") },
{ "tp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TP,
N_("build through %prep (unpack sources and apply patches) from <tarball>"),
N_("<tarball>") },
{ "tc", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TC,
N_("build through %build (%prep, then compile) from <tarball>"),
N_("<tarball>") },
{ "ti", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TI,
N_("build through %install (%prep, %build, then install) from <tarball>"),
N_("<tarball>") },
{ "tl", 0, POPT_ARGFLAG_ONEDASH|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_TL,
N_("verify %files section from <tarball>"),
N_("<tarball>") },
{ "ta", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TA,
N_("build source and binary packages from <tarball>"),
N_("<tarball>") },
{ "tb", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TB,
N_("build binary package only from <tarball>"),
N_("<tarball>") },
{ "ts", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TS,
N_("build source package only from <tarball>"),
N_("<tarball>") },
{ "rebuild", '\0', 0, 0, POPT_REBUILD,
N_("build binary package from <source package>"),
N_("<source package>") },
{ "recompile", '\0', 0, 0, POPT_RECOMPILE,
N_("build through %install (%prep, %build, then install) from <source package>"),
N_("<source package>") },
{ "buildroot", '\0', POPT_ARG_STRING, 0, POPT_BUILDROOT,
N_("override build root"), "DIRECTORY" },
{ "build-in-place", '\0', 0, 0, POPT_BUILDINPLACE,
N_("run build in current directory"), NULL },
{ "clean", '\0', 0, 0, POPT_RMBUILD,
N_("remove build tree when done"), NULL},
{ "force", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_FORCE,
N_("ignore ExcludeArch: directives from spec file"), NULL},
{ "fsmdebug", '\0', (POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN), &_fsm_debug, -1,
N_("debug file state machine"), NULL},
{ "nobuild", '\0', 0, 0, POPT_NOBUILD,
N_("do not execute any stages of the build"), NULL },
{ "nodeps", '\0', POPT_ARG_VAL, &noDeps, 1,
N_("do not verify build dependencies"), NULL },
{ "nodirtokens", '\0', 0, 0, POPT_NODIRTOKENS,
N_("generate package header(s) compatible with (legacy) rpm v3 packaging"),
NULL},
{ "noclean", '\0', POPT_BIT_SET, &nobuildAmount, RPMBUILD_CLEAN,
N_("do not execute %clean stage of the build"), NULL },
{ "noprep", '\0', POPT_BIT_SET, &nobuildAmount, RPMBUILD_PREP,
N_("do not execute %prep stage of the build"), NULL },
{ "nocheck", '\0', POPT_BIT_SET, &nobuildAmount, RPMBUILD_CHECK,
N_("do not execute %check stage of the build"), NULL },
{ "nolang", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NOLANG,
N_("do not accept i18N msgstr's from specfile"), NULL},
{ "rmsource", '\0', 0, 0, POPT_RMSOURCE,
N_("remove sources when done"), NULL},
{ "rmspec", '\0', 0, 0, POPT_RMSPEC,
N_("remove specfile when done"), NULL},
{ "short-circuit", '\0', POPT_ARG_VAL, &shortCircuit, 1,
N_("skip straight to specified stage (only for c,i)"), NULL },
{ "target", '\0', POPT_ARG_STRING, 0, POPT_TARGETPLATFORM,
N_("override target platform"), "CPU-VENDOR-OS" },
POPT_TABLEEND
};
enum modes {
MODE_BUILD = (1 << 4),
MODE_REBUILD = (1 << 5),
MODE_RECOMPILE = (1 << 8),
MODE_TARBUILD = (1 << 11),
};
static int quiet;
/* the structure describing the options we take and the defaults */
static struct poptOption optionsTable[] = {
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmBuildPoptTable, 0,
N_("Build options with [ <specfile> | <tarball> | <source package> ]:"),
NULL },
{ "quiet", '\0', POPT_ARGFLAG_DOC_HIDDEN, &quiet, 0, NULL, NULL},
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
N_("Common options for all rpm modes and executables:"),
NULL },
POPT_AUTOALIAS
POPT_AUTOHELP
POPT_TABLEEND
};
static int checkSpec(rpmts ts, rpmSpec spec)
{
int rc;
rpmps ps = rpmSpecCheckDeps(ts, spec);
if (ps) {
rpmlog(RPMLOG_ERR, _("Failed build dependencies:\n"));
rpmpsPrint(NULL, ps);
}
rc = (ps != NULL);
rpmpsFree(ps);
return rc;
}
static int isSpecFile(const char * specfile)
{
char buf[256];
const char * s;
FILE * f;
int count;
int checking;
f = fopen(specfile, "r");
if (f == NULL) {
rpmlog(RPMLOG_ERR, _("Unable to open spec file %s: %s\n"),
specfile, strerror(errno));
return 0;
}
count = fread(buf, sizeof(buf[0]), sizeof(buf), f);
(void) fclose(f);
if (count == 0)
return 0;
checking = 1;
for (s = buf; count--; s++) {
switch (*s) {
case '\r':
case '\n':
checking = 1;
break;
case ':':
checking = 0;
break;
default:
#if 0
if (checking && !(isprint(*s) || isspace(*s))) return 0;
break;
#else
if (checking && !(isprint(*s) || isspace(*s)) && *(unsigned char *)s < 32) return 0;
break;
#endif
}
}
return 1;
}
/*
* Try to find a spec from a tarball pointed to by arg.
* Return absolute path to spec name on success, otherwise NULL.
*/
static char * getTarSpec(const char *arg)
{
char *specFile = NULL;
char *specDir;
char *specBase;
char *tmpSpecFile;
const char **spec;
char tarbuf[BUFSIZ];
int gotspec = 0, res;
static const char *tryspec[] = { "Specfile", "\\*.spec", NULL };
specDir = rpmGetPath("%{_specdir}", NULL);
tmpSpecFile = rpmGetPath("%{_specdir}/", "rpm-spec.XXXXXX", NULL);
(void) close(mkstemp(tmpSpecFile));
for (spec = tryspec; *spec != NULL; spec++) {
FILE *fp;
char *cmd;
int specfiles = 0;
cmd = rpmExpand("%{uncompress: ", arg, "} | ",
"%{__tar} xOvof - --wildcards ", *spec,
" 2>&1 > ", tmpSpecFile, NULL);
if (!(fp = popen(cmd, "r"))) {
rpmlog(RPMLOG_ERR, _("Failed to open tar pipe: %m\n"));
} else {
char *fok;
for (;;) {
fok = fgets(tarbuf, sizeof(tarbuf) - 1, fp);
if (!fok) break;
/* tar sometimes prints "tar: Record size = 16" messages */
if (strstr(fok, "tar: ")) {
continue;
}
specfiles++;
}
pclose(fp);
gotspec = (specfiles == 1) && isSpecFile(tmpSpecFile);
if (specfiles > 1) {
rpmlog(RPMLOG_ERR, _("Found more than one spec file in %s\n"), arg);
goto exit;
}
}
if (!gotspec)
unlink(tmpSpecFile);
free(cmd);
}
if (!gotspec) {
rpmlog(RPMLOG_ERR, _("Failed to read spec file from %s\n"), arg);
goto exit;
}
specBase = basename(tarbuf);
/* remove trailing \n */
specBase[strlen(specBase)-1] = '\0';
rasprintf(&specFile, "%s/%s", specDir, specBase);
res = rename(tmpSpecFile, specFile);
if (res) {
rpmlog(RPMLOG_ERR, _("Failed to rename %s to %s: %m\n"),
tmpSpecFile, specFile);
free(specFile);
specFile = NULL;
} else {
/* mkstemp() can give unnecessarily strict permissions, fixup */
mode_t mask;
umask(mask = umask(0));
(void) chmod(specFile, 0666 & ~mask);
}
exit:
(void) unlink(tmpSpecFile);
free(tmpSpecFile);
free(specDir);
return specFile;
}
static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
{
int buildAmount = ba->buildAmount;
char * buildRootURL = NULL;
char * specFile = NULL;
rpmSpec spec = NULL;
int rc = 1; /* assume failure */
int justRm = ((buildAmount & ~(RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC)) == 0);
rpmSpecFlags specFlags = spec_flags;
/* Override default BUILD value for _builddir */
if (buildInPlace) {
char *cwd = rpmGetCwd();
addMacro(NULL, "_builddir", NULL, cwd, 0);
free(cwd);
}
if (ba->buildRootOverride)
buildRootURL = rpmGenPath(NULL, ba->buildRootOverride, NULL);
/* Create build tree if necessary */
const char * buildtree = "%{_topdir}:%{_specdir}:%{_sourcedir}:%{_builddir}:%{_rpmdir}:%{_srcrpmdir}:%{_buildrootdir}";
const char * rootdir = rpmtsRootDir(ts);
if (rpmMkdirs(!rstreq(rootdir, "/") ? rootdir : NULL , buildtree)) {
goto exit;
}
if (buildMode == 't') {
char *srcdir = NULL, *dir;
specFile = getTarSpec(arg);
if (!specFile)
goto exit;
/* Make the directory of the tarball %_sourcedir for this run */
/* dirname() may modify contents so extra hoops needed. */
if (*arg != '/') {
dir = rpmGetCwd();
rstrscat(&dir, "/", arg, NULL);
} else {
dir = xstrdup(arg);
}
srcdir = dirname(dir);
addMacro(NULL, "_sourcedir", NULL, srcdir, RMIL_TARBALL);
free(dir);
} else {
specFile = xstrdup(arg);
}
if (*specFile != '/') {
char *cwd = rpmGetCwd();
char *s = NULL;
rasprintf(&s, "%s/%s", cwd, specFile);
free(cwd);
free(specFile);
specFile = s;
}
struct stat st;
if (stat(specFile, &st) < 0) {
rpmlog(RPMLOG_ERR, _("failed to stat %s: %m\n"), specFile);
goto exit;
}
if (! S_ISREG(st.st_mode)) {
rpmlog(RPMLOG_ERR, _("File %s is not a regular file.\n"), specFile);
goto exit;
}
/* Try to verify that the file is actually a specfile */
if (!isSpecFile(specFile)) {
rpmlog(RPMLOG_ERR,
_("File %s does not appear to be a specfile.\n"), specFile);
goto exit;
}
/* Don't parse spec if only its removal is requested */
if (ba->buildAmount == RPMBUILD_RMSPEC) {
rc = unlink(specFile);
goto exit;
}
/* Parse the spec file */
#define _anyarch(_f) \
(((_f)&(RPMBUILD_PREP|RPMBUILD_BUILD|RPMBUILD_INSTALL|RPMBUILD_PACKAGEBINARY)) == 0)
if (_anyarch(buildAmount))
specFlags |= RPMSPEC_ANYARCH;
#undef _anyarch
spec = rpmSpecParse(specFile, specFlags, buildRootURL);
if (spec == NULL) {
goto exit;
}
/* Check build prerequisites if necessary, unless disabled */
if (!justRm && !noDeps && checkSpec(ts, spec)) {
goto exit;
}
if (rpmSpecBuild(spec, ba)) {
goto exit;
}
if (buildMode == 't')
(void) unlink(specFile);
rc = 0;
exit:
free(specFile);
rpmSpecFree(spec);
free(buildRootURL);
return rc;
}
static int build(rpmts ts, const char * arg, BTA_t ba, const char * rcfile)
{
int rc = 0;
char * targets = argvJoin(build_targets, ",");
#define buildCleanMask (RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC)
int cleanFlags = ba->buildAmount & buildCleanMask;
rpmVSFlags vsflags, ovsflags;
vsflags = rpmExpandNumeric("%{_vsflags_build}");
if (rpmcliQueryFlags & VERIFY_DIGEST)
vsflags |= _RPMVSF_NODIGESTS;
if (rpmcliQueryFlags & VERIFY_SIGNATURE)
vsflags |= _RPMVSF_NOSIGNATURES;
if (rpmcliQueryFlags & VERIFY_HDRCHK)
vsflags |= RPMVSF_NOHDRCHK;
ovsflags = rpmtsSetVSFlags(ts, vsflags);
if (build_targets == NULL) {
rc = buildForTarget(ts, arg, ba);
goto exit;
}
/* parse up the build operators */
printf(_("Building target platforms: %s\n"), targets);
ba->buildAmount &= ~buildCleanMask;
for (ARGV_const_t target = build_targets; target && *target; target++) {
/* Perform clean-up after last target build. */
if (*(target + 1) == NULL)
ba->buildAmount |= cleanFlags;
printf(_("Building for target %s\n"), *target);
/* Read in configuration for target. */
rpmFreeMacros(NULL);
if (buildInPlace) {
/* Need to redefine this after freeing all the macros */
rpmDefineMacro(NULL, "_build_in_place 1", 0);
}
rpmFreeRpmrc();
(void) rpmReadConfigFiles(rcfile, *target);
rc = buildForTarget(ts, arg, ba);
if (rc)
break;
}
exit:
rpmtsSetVSFlags(ts, ovsflags);
/* Restore original configuration. */
rpmFreeMacros(NULL);
rpmFreeRpmrc();
(void) rpmReadConfigFiles(rcfile, NULL);
free(targets);
return rc;
}
int main(int argc, char *argv[])
{
rpmts ts = NULL;
enum modes bigMode = MODE_BUILD;
BTA_t ba = &rpmBTArgs;
const char *pkg = NULL;
int ec = 0;
poptContext optCon = rpmcliInit(argc, argv, optionsTable);
/* Args required only when building, let lone --eval etc through */
if (ba->buildAmount && poptPeekArg(optCon) == NULL) {
printUsage(optCon, stderr, 0);
exit(EXIT_FAILURE);
}
switch (buildMode) {
case 'b': bigMode = MODE_BUILD; break;
case 't': bigMode = MODE_TARBUILD; break;
case 'B': bigMode = MODE_REBUILD; break;
case 'C': bigMode = MODE_RECOMPILE; break;
}
if (rpmcliRootDir && rpmcliRootDir[0] != '/') {
argerror(_("arguments to --root (-r) must begin with a /"));
}
/* rpmbuild is rather chatty by default */
rpmSetVerbosity(quiet ? RPMLOG_WARNING : RPMLOG_INFO);
if (rpmcliPipeOutput && initPipe())
exit(EXIT_FAILURE);
ts = rpmtsCreate();
(void) rpmtsSetRootDir(ts, rpmcliRootDir);
switch (buildChar) {
case 'a':
ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
case 'b':
ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
ba->buildAmount |= RPMBUILD_CLEAN;
if ((buildChar == 'b') && shortCircuit)
break;
case 'i':
ba->buildAmount |= RPMBUILD_INSTALL;
ba->buildAmount |= RPMBUILD_CHECK;
if ((buildChar == 'i') && shortCircuit)
break;
case 'c':
ba->buildAmount |= RPMBUILD_BUILD;
if ((buildChar == 'c') && shortCircuit)
break;
case 'p':
ba->buildAmount |= RPMBUILD_PREP;
break;
case 'l':
ba->buildAmount |= RPMBUILD_FILECHECK;
break;
case 's':
ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
break;
}
ba->buildAmount &= ~(nobuildAmount);
switch (bigMode) {
case MODE_REBUILD:
case MODE_RECOMPILE:
if (bigMode == MODE_REBUILD &&
buildChar != 'p' &&
buildChar != 'c' &&
buildChar != 'i' &&
buildChar != 'l') {
ba->buildAmount |= RPMBUILD_RMSOURCE;
ba->buildAmount |= RPMBUILD_RMSPEC;
ba->buildAmount |= RPMBUILD_RMBUILD;
}
ba->buildAmount &= ~(nobuildAmount);
while ((pkg = poptGetArg(optCon))) {
char * specFile = NULL;
ba->cookie = NULL;
ec = rpmInstallSource(ts, pkg, &specFile, &ba->cookie);
if (ec == 0) {
ba->rootdir = rpmcliRootDir;
ec = build(ts, specFile, ba, rpmcliRcfile);
}
ba->cookie = _free(ba->cookie);
specFile = _free(specFile);
if (ec)
break;
}
break;
case MODE_BUILD:
case MODE_TARBUILD:
while ((pkg = poptGetArg(optCon))) {
ba->rootdir = rpmcliRootDir;
ba->cookie = NULL;
ec = build(ts, pkg, ba, rpmcliRcfile);
if (ec)
break;
rpmFreeMacros(NULL);
(void) rpmReadConfigFiles(rpmcliRcfile, NULL);
}
break;
}
rpmtsFree(ts);
if (finishPipe())
ec = EXIT_FAILURE;
free(ba->buildRootOverride);
argvFree(build_targets);
rpmcliFini(optCon);
return RETVAL(ec);
}
rpmBuildPoptTable
static struct poptOption rpmBuildPoptTable[]
Definition: rpmbuild.c:135
nobuildAmount
static rpmBuildFlags nobuildAmount
Definition: rpmbuild.c:64
RETVAL
#define RETVAL(rc)
Definition: cliutils.h:14
rpmcliRcfile
const char * rpmcliRcfile
rpmtsSetRootDir
int rpmtsSetRootDir(rpmts ts, const char *rootDir)
Set transaction rootDir, i.e.
POPT_BC
#define POPT_BC
Definition: rpmbuild.c:37
RPMLOG_WARNING
Definition: rpmlog.h:34
rpmcliQueryFlags
rpmQueryFlags rpmcliQueryFlags
Bit(s) from common command line options.
printUsage
void printUsage(poptContext con, FILE *fp, int flags)
Definition: cliutils.c:36
POPT_BL
#define POPT_BL
Definition: rpmbuild.c:39
POPT_BA
#define POPT_BA
Definition: rpmbuild.c:35
RPMBUILD_FILECHECK
Definition: rpmbuild.h:28
POPT_RL
#define POPT_RL
Definition: rpmbuild.c:46
rpmSpecCheckDeps
rpmps rpmSpecCheckDeps(rpmts ts, rpmSpec spec)
Verify build depencies of a spec against.
POPT_NOLANG
#define POPT_NOLANG
Definition: rpmbuild.c:23
buildForTarget
static int buildForTarget(rpmts ts, const char *arg, BTA_t ba)
Definition: rpmbuild.c:420
ARGV_t
char ** ARGV_t
Definition: argv.h:17
spec_flags
static rpmSpecFlags spec_flags
Definition: rpmbuild.c:59
debug.h
build
static int build(rpmts ts, const char *arg, BTA_t ba, const char *rcfile)
Definition: rpmbuild.c:533
RPMLOG_INFO
Definition: rpmlog.h:36
rpmBTArgs
static struct rpmBuildArguments_s rpmBTArgs
Definition: rpmbuild.c:21
rstrscat
char * rstrscat(char **dest, const char *arg,...) RPM_GNUC_NULL_TERMINATED
Concatenate multiple strings with dynamically (re)allocated memory.
RPMSPEC_FORCE
Definition: rpmspec.h:37
POPT_RB
#define POPT_RB
Definition: rpmbuild.c:43
isSpecFile
static int isSpecFile(const char *specfile)
Definition: rpmbuild.c:291
POPT_BUILDINPLACE
#define POPT_BUILDINPLACE
Definition: rpmbuild.c:31
rpmcliInit
poptContext rpmcliInit(int argc, char *const argv[], struct poptOption *optionsTable)
Initialize most everything needed by an rpm CLI executable context.
buildInPlace
static int buildInPlace
Definition: rpmbuild.c:66
rpmcliFini
poptContext rpmcliFini(poptContext optCon)
Destroy most everything needed by an rpm CLI executable context.
rpmSpecFree
rpmSpec rpmSpecFree(rpmSpec spec)
Destroy Spec structure.
RPMBUILD_NOBUILD
Definition: rpmbuild.h:39
build_targets
static ARGV_t build_targets
Definition: rpmbuild.c:65
cliutils.h
Misc helpers for RPM CLI tools.
rpmBuildArguments_s::pkgFlags
rpmBuildPkgFlags pkgFlags
Definition: rpmbuild.h:58
POPT_RECOMPILE
#define POPT_RECOMPILE
Definition: rpmbuild.c:34
rpmtsRootDir
const char * rpmtsRootDir(rpmts ts)
Get transaction rootDir, i.e.
finishPipe
int finishPipe(void)
Definition: cliutils.c:73
RPMLOG_ERR
Definition: rpmlog.h:33
POPT_TC
#define POPT_TC
Definition: rpmbuild.c:51
POPT_BUILDROOT
#define POPT_BUILDROOT
Definition: rpmbuild.c:26
POPT_RMSPEC
#define POPT_RMSPEC
Definition: rpmbuild.c:29
POPT_NODIRTOKENS
#define POPT_NODIRTOKENS
Definition: rpmbuild.c:30
_
#define _(Text)
Definition: system.h:112
MODE_BUILD
Definition: rpmbuild.c:251
MODE_REBUILD
Definition: rpmbuild.c:252
RPMBUILD_RMBUILD
Definition: rpmbuild.h:32
POPT_BB
#define POPT_BB
Definition: rpmbuild.c:36
rpmSpecBuild
rpmRC rpmSpecBuild(rpmSpec spec, BTA_t buildArgs)
Spec build stages state machine driver.
rpmReadConfigFiles
int rpmReadConfigFiles(const char *file, const char *target)
Read macro configuration file(s) for a target.
POPT_NOBUILD
#define POPT_NOBUILD
Definition: rpmbuild.c:28
shortCircuit
static int shortCircuit
Definition: rpmbuild.c:61
buildArgCallback
static void buildArgCallback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data)
Definition: rpmbuild.c:68
POPT_TARGETPLATFORM
#define POPT_TARGETPLATFORM
Definition: rpmbuild.c:27
RPMBUILD_INSTALL
Definition: rpmbuild.h:25
POPT_TP
#define POPT_TP
Definition: rpmbuild.c:54
RPMBUILD_PACKAGESOURCE
Definition: rpmbuild.h:29
rpmBuildArguments_s::rootdir
const char * rootdir
Definition: rpmbuild.h:62
argvSplit
int argvSplit(ARGV_t *argvp, const char *str, const char *seps)
Split a string into an argv array.
RPMBUILD_PACKAGEBINARY
Definition: rpmbuild.h:30
rpmcliPipeOutput
const char * rpmcliPipeOutput
argerror
void argerror(const char *desc)
Definition: cliutils.c:19
rpmBuildArguments_s::buildAmount
rpmBuildFlags buildAmount
Definition: rpmbuild.h:59
VERIFY_SIGNATURE
Definition: rpmvf.h:68
rstreq
static int rstreq(const char *s1, const char *s2)
Test for string equality.
Definition: rpmstring.h:113
modes
modes
Definition: rpmbuild.c:250
getTarSpec
static char * getTarSpec(const char *arg)
Definition: rpmbuild.c:338
rpmBuildArguments_s::buildRootOverride
char * buildRootOverride
Definition: rpmbuild.h:60
xstrdup
#define xstrdup(_str)
Definition: system.h:88
rpmExpandNumeric
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
rpmps
struct rpmps_s * rpmps
Definition: rpmtypes.h:71
POPT_TL
#define POPT_TL
Definition: rpmbuild.c:53
rpmInstallSource
int rpmInstallSource(rpmts ts, const char *arg, char **specFilePtr, char **cookie)
Install source rpm package.
POPT_RC
#define POPT_RC
Definition: rpmbuild.c:44
initPipe
int initPipe(void)
Definition: cliutils.c:48
RPMBUILD_CHECK
Definition: rpmbuild.h:26
POPT_RMBUILD
#define POPT_RMBUILD
Definition: rpmbuild.c:25
_anyarch
#define _anyarch(_f)
RPMSPEC_ANYARCH
Definition: rpmspec.h:36
optionsTable
static struct poptOption optionsTable[]
Definition: rpmbuild.c:260
rpmVSFlags
rpmFlags rpmVSFlags
Definition: rpmts.h:110
VERIFY_DIGEST
Definition: rpmvf.h:67
target
const char * target
Definition: rpmspec.c:21
rpmMkdirs
int rpmMkdirs(const char *root, const char *pathstr)
Create several directories (including parents if needed) in one go.
rpmcliRootDir
const char * rpmcliRootDir
POPT_BP
#define POPT_BP
Definition: rpmbuild.c:40
rpmpsFree
rpmps rpmpsFree(rpmps ps)
Destroy a problem set.
_fsm_debug
int _fsm_debug
POPT_RI
#define POPT_RI
Definition: rpmbuild.c:45
POPT_BS
#define POPT_BS
Definition: rpmbuild.c:41
rpmGetPath
char * rpmGetPath(const char *path,...) RPM_GNUC_NULL_TERMINATED
Return (malloc'ed) expanded, canonicalized, file path.
RPMCLI_POPT_FORCE
#define RPMCLI_POPT_FORCE
Definition: rpmcli.h:64
addMacro
void addMacro(rpmMacroContext mc, const char *n, const char *o, const char *b, int level)
Add macro to context.
POPT_RP
#define POPT_RP
Definition: rpmbuild.c:47
argvFree
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
ARGV_const_t
char *const * ARGV_const_t
Definition: argv.h:18
_free
#define _free(_ptr)
Definition: system.h:89
_RPMVSF_NOSIGNATURES
#define _RPMVSF_NOSIGNATURES
Definition: rpmts.h:118
rpmtsFree
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
POPT_RMSOURCE
#define POPT_RMSOURCE
Definition: rpmbuild.c:24
checkSpec
static int checkSpec(rpmts ts, rpmSpec spec)
Definition: rpmbuild.c:277
rpmFreeMacros
void rpmFreeMacros(rpmMacroContext mc)
Destroy macro context.
rpmSpecParse
rpmSpec rpmSpecParse(const char *specFile, rpmSpecFlags flags, const char *buildRoot)
Parse spec file into spec control structure.
rpmtsSetVSFlags
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
rpmExpand
char * rpmExpand(const char *arg,...) RPM_GNUC_NULL_TERMINATED
Return (malloc'ed) concatenated macro expansion(s).
POPT_TI
#define POPT_TI
Definition: rpmbuild.c:52
rpmts
struct rpmts_s * rpmts
The main types involved in transaction manipulation.
Definition: rpmtypes.h:63
rpmSpecFlags
rpmFlags rpmSpecFlags
Definition: rpmspec.h:42
system.h
Some misc low-level API.
buildMode
static char buildMode
Definition: rpmbuild.c:62
RPMBUILD_PREP
Definition: rpmbuild.h:23
rpmDefineMacro
int rpmDefineMacro(rpmMacroContext mc, const char *macro, int level)
Define macro in context.
rasprintf
int rasprintf(char **strp, const char *fmt,...) RPM_GNUC_PRINTF(2
asprintf() clone
RPMBUILD_BUILD
Definition: rpmbuild.h:24
POPT_RS
#define POPT_RS
Definition: rpmbuild.c:48
rpmFreeRpmrc
void rpmFreeRpmrc(void)
Destroy rpmrc arch/os compatibility tables.
RPMVSF_NOHDRCHK
Definition: rpmts.h:95
POPT_TB
#define POPT_TB
Definition: rpmbuild.c:50
buildChar
static char buildChar
Definition: rpmbuild.c:63
rpmBuildArguments_s::cookie
char * cookie
Definition: rpmbuild.h:61
RMIL_TARBALL
#define RMIL_TARBALL
Definition: rpmmacro.h:43
__progname
#define __progname
Definition: system.h:98
_RPMVSF_NODIGESTS
#define _RPMVSF_NODIGESTS
Definition: rpmts.h:112
VERIFY_HDRCHK
Definition: rpmvf.h:70
RPMBUILD_RMSPEC
Definition: rpmbuild.h:34
N_
#define N_(Text)
Definition: system.h:115
MODE_RECOMPILE
Definition: rpmbuild.c:253
rpmSetVerbosity
#define rpmSetVerbosity(_lvl)
Definition: rpmlog.h:264
RPMBUILD_RMSOURCE
Definition: rpmbuild.h:31
rpmpsPrint
void rpmpsPrint(FILE *fp, rpmps ps)
Print problems to file handle.
POPT_BI
#define POPT_BI
Definition: rpmbuild.c:38
RPMSPEC_NOLANG
Definition: rpmspec.h:38
rpmtsCreate
rpmts rpmtsCreate(void)
Create an empty transaction set.
buildCleanMask
#define buildCleanMask
rpmGenPath
char * rpmGenPath(const char *urlroot, const char *urlmdir, const char *urlfile)
Merge 3 args into path, any or all of which may be a url.
POPT_TS
#define POPT_TS
Definition: rpmbuild.c:55
rpmBuildArguments_s
Describe build request.
Definition: rpmbuild.h:57
RPMBUILD_CLEAN
Definition: rpmbuild.h:27
rpmBuildFlags
rpmFlags rpmBuildFlags
Definition: rpmbuild.h:42
RPMBUILD_PKG_NODIRTOKENS
Definition: rpmbuild.h:49
rpmGetCwd
char * rpmGetCwd(void)
Like getcwd() but the result is malloced.
rpmcliAllPoptTable
struct poptOption rpmcliAllPoptTable[]
Popt option table for options shared by all modes and executables.
POPT_RA
#define POPT_RA
Definition: rpmbuild.c:42
MODE_TARBUILD
Definition: rpmbuild.c:254
argvJoin
char * argvJoin(ARGV_const_t argv, const char *sep)
Join an argv array into a string.
main
int main(int argc, char *argv[])
Definition: rpmbuild.c:591
quiet
static int quiet
Definition: rpmbuild.c:257
rpmlog
void rpmlog(int code, const char *fmt,...) RPM_GNUC_PRINTF(2
Generate a log message using FMT string and option arguments.
POPT_REBUILD
#define POPT_REBUILD
Definition: rpmbuild.c:33
rpmSpec
struct rpmSpec_s * rpmSpec
Definition: rpmtypes.h:90
noDeps
static int noDeps
Definition: rpmbuild.c:60
POPT_TA
#define POPT_TA
Definition: rpmbuild.c:49