rpm: rpmbuild.c Source File

rpm 4.11.2-rc1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

rpmbuild.c
Go to the documentation of this file.
1 #include "system.h"
2 const char *__progname;
3
4 #include <errno.h>
5 #include <libgen.h>
6 #include <ctype.h>
7
8 #include <rpm/rpmcli.h>
9 #include <rpm/rpmlib.h> /* RPMSIGTAG, rpmReadPackageFile .. */
10 #include <rpm/rpmbuild.h>
11 #include <rpm/rpmlog.h>
12 #include <rpm/rpmfileutil.h>
13 #include <rpm/rpmdb.h>
14 #include <rpm/rpmps.h>
15 #include <rpm/rpmts.h>
16 #include "lib/signature.h"
17 #include "cliutils.h"
18
19 #include "debug.h"
20
21 static struct rpmBuildArguments_s rpmBTArgs;
22
23 #define POPT_NOLANG -1012
24 #define POPT_RMSOURCE -1013
25 #define POPT_RMBUILD -1014
26 #define POPT_BUILDROOT -1015
27 #define POPT_TARGETPLATFORM -1016
28 #define POPT_NOBUILD -1017
29 #define POPT_RMSPEC -1019
30 #define POPT_NODIRTOKENS -1020
31
32 #define POPT_REBUILD 0x4220
33 #define POPT_RECOMPILE 0x4320
34 #define POPT_BA 0x6261
35 #define POPT_BB 0x6262
36 #define POPT_BC 0x6263
37 #define POPT_BI 0x6269
38 #define POPT_BL 0x626c
39 #define POPT_BP 0x6270
40 #define POPT_BS 0x6273
41 #define POPT_TA 0x7461
42 #define POPT_TB 0x7462
43 #define POPT_TC 0x7463
44 #define POPT_TI 0x7469
45 #define POPT_TL 0x746c
46 #define POPT_TP 0x7470
47 #define POPT_TS 0x7473
48
49 extern int _fsm_debug;
50
51 static rpmSpecFlags spec_flags = 0;
52 static int noDeps = 0;
53 static int shortCircuit = 0;
54 static char buildMode = 0;
55 static char buildChar = 0;
56 static rpmBuildFlags nobuildAmount = 0;
57 static ARGV_t build_targets = NULL;
59 static void buildArgCallback( poptContext con,
60 enum poptCallbackReason reason,
61 const struct poptOption * opt, const char * arg,
62 const void * data)
63 {
64 BTA_t rba = &rpmBTArgs;
65
66 switch (opt->val) {
67 case POPT_REBUILD:
68 case POPT_RECOMPILE:
69 case POPT_BA:
70 case POPT_BB:
71 case POPT_BC:
72 case POPT_BI:
73 case POPT_BL:
74 case POPT_BP:
75 case POPT_BS:
76 case POPT_TA:
77 case POPT_TB:
78 case POPT_TC:
79 case POPT_TI:
80 case POPT_TL:
81 case POPT_TP:
82 case POPT_TS:
83 if (opt->val == POPT_BS || opt->val == POPT_TS)
84 noDeps = 1;
85 if (buildMode == '\0' && buildChar == '\0') {
86 buildMode = (((unsigned)opt->val) >> 8) & 0xff;
87 buildChar = (opt->val ) & 0xff;
88 }
89 break;
90
91 case POPT_NODIRTOKENS: rba->pkgFlags |= RPMBUILD_PKG_NODIRTOKENS; break;
92 case POPT_NOBUILD: rba->buildAmount |= RPMBUILD_NOBUILD; break;
93 case POPT_NOLANG: spec_flags |= RPMSPEC_NOLANG; break;
94 case POPT_RMSOURCE: rba->buildAmount |= RPMBUILD_RMSOURCE; break;
95 case POPT_RMSPEC: rba->buildAmount |= RPMBUILD_RMSPEC; break;
96 case POPT_RMBUILD: rba->buildAmount |= RPMBUILD_RMBUILD; break;
97 case POPT_BUILDROOT:
98 if (rba->buildRootOverride) {
99 rpmlog(RPMLOG_ERR, _("buildroot already specified, ignoring %s\n"), arg);
100 break;
101 }
102 rba->buildRootOverride = xstrdup(arg);
103 break;
104 case POPT_TARGETPLATFORM:
105 argvSplit(&build_targets, arg, ",");
106 break;
107
108 case RPMCLI_POPT_FORCE:
109 spec_flags |= RPMSPEC_FORCE;
110 break;
111
112 }
113 }
114
115 static struct poptOption rpmBuildPoptTable[] = {
116 { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
117 buildArgCallback, 0, NULL, NULL },
118
119 { "bp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BP,
120 N_("build through %prep (unpack sources and apply patches) from <specfile>"),
121 N_("<specfile>") },
122 { "bc", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BC,
123 N_("build through %build (%prep, then compile) from <specfile>"),
124 N_("<specfile>") },
125 { "bi", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BI,
126 N_("build through %install (%prep, %build, then install) from <specfile>"),
127 N_("<specfile>") },
128 { "bl", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BL,
129 N_("verify %files section from <specfile>"),
130 N_("<specfile>") },
131 { "ba", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BA,
132 N_("build source and binary packages from <specfile>"),
133 N_("<specfile>") },
134 { "bb", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BB,
135 N_("build binary package only from <specfile>"),
136 N_("<specfile>") },
137 { "bs", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_BS,
138 N_("build source package only from <specfile>"),
139 N_("<specfile>") },
140
141 { "tp", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TP,
142 N_("build through %prep (unpack sources and apply patches) from <tarball>"),
143 N_("<tarball>") },
144 { "tc", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TC,
145 N_("build through %build (%prep, then compile) from <tarball>"),
146 N_("<tarball>") },
147 { "ti", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TI,
148 N_("build through %install (%prep, %build, then install) from <tarball>"),
149 N_("<tarball>") },
150 { "tl", 0, POPT_ARGFLAG_ONEDASH|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_TL,
151 N_("verify %files section from <tarball>"),
152 N_("<tarball>") },
153 { "ta", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TA,
154 N_("build source and binary packages from <tarball>"),
155 N_("<tarball>") },
156 { "tb", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TB,
157 N_("build binary package only from <tarball>"),
158 N_("<tarball>") },
159 { "ts", 0, POPT_ARGFLAG_ONEDASH, 0, POPT_TS,
160 N_("build source package only from <tarball>"),
161 N_("<tarball>") },
162
163 { "rebuild", '\0', 0, 0, POPT_REBUILD,
164 N_("build binary package from <source package>"),
165 N_("<source package>") },
166 { "recompile", '\0', 0, 0, POPT_RECOMPILE,
167 N_("build through %install (%prep, %build, then install) from <source package>"),
168 N_("<source package>") },
169
170 { "buildroot", '\0', POPT_ARG_STRING, 0, POPT_BUILDROOT,
171 N_("override build root"), "DIRECTORY" },
172 { "clean", '\0', 0, 0, POPT_RMBUILD,
173 N_("remove build tree when done"), NULL},
174 { "force", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_FORCE,
175 N_("ignore ExcludeArch: directives from spec file"), NULL},
176 { "fsmdebug", '\0', (POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN), &_fsm_debug, -1,
177 N_("debug file state machine"), NULL},
178 { "nobuild", '\0', 0, 0, POPT_NOBUILD,
179 N_("do not execute any stages of the build"), NULL },
180 { "nodeps", '\0', POPT_ARG_VAL, &noDeps, 1,
181 N_("do not verify build dependencies"), NULL },
182 { "nodirtokens", '\0', 0, 0, POPT_NODIRTOKENS,
183 N_("generate package header(s) compatible with (legacy) rpm v3 packaging"),
184 NULL},
185
186 { "noclean", '\0', POPT_BIT_SET, &nobuildAmount, RPMBUILD_CLEAN,
187 N_("do not execute %clean stage of the build"), NULL },
188 { "nocheck", '\0', POPT_BIT_SET, &nobuildAmount, RPMBUILD_CHECK,
189 N_("do not execute %check stage of the build"), NULL },
190
191 { "nolang", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_NOLANG,
192 N_("do not accept i18N msgstr's from specfile"), NULL},
193 { "rmsource", '\0', 0, 0, POPT_RMSOURCE,
194 N_("remove sources when done"), NULL},
195 { "rmspec", '\0', 0, 0, POPT_RMSPEC,
196 N_("remove specfile when done"), NULL},
197 { "short-circuit", '\0', POPT_ARG_VAL, &shortCircuit, 1,
198 N_("skip straight to specified stage (only for c,i)"), NULL },
199 { "target", '\0', POPT_ARG_STRING, 0, POPT_TARGETPLATFORM,
200 N_("override target platform"), "CPU-VENDOR-OS" },
201 POPT_TABLEEND
202 };
203
204 enum modes {
205 MODE_BUILD = (1 << 4),
206 MODE_REBUILD = (1 << 5),
207 MODE_RECOMPILE = (1 << 8),
208 MODE_TARBUILD = (1 << 11),
209 };
210
211 static int quiet;
212
213 /* the structure describing the options we take and the defaults */
214 static struct poptOption optionsTable[] = {
215
216 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmBuildPoptTable, 0,
217 N_("Build options with [ <specfile> | <tarball> | <source package> ]:"),
218 NULL },
219
220 { "quiet", '\0', POPT_ARGFLAG_DOC_HIDDEN, &quiet, 0, NULL, NULL},
221
222 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
223 N_("Common options for all rpm modes and executables:"),
224 NULL },
225
226 POPT_AUTOALIAS
227 POPT_AUTOHELP
228 POPT_TABLEEND
229 };
230
231 static int checkSpec(rpmts ts, rpmSpec spec)
232 {
233 int rc;
234 rpmps ps = rpmSpecCheckDeps(ts, spec);
235
236 if (ps) {
237 rpmlog(RPMLOG_ERR, _("Failed build dependencies:\n"));
238 rpmpsPrint(NULL, ps);
239 }
240 rc = (ps != NULL);
241 rpmpsFree(ps);
242 return rc;
243 }
244
245 static int isSpecFile(const char * specfile)
246 {
247 char buf[256];
248 const char * s;
249 FILE * f;
250 int count;
251 int checking;
252
253 f = fopen(specfile, "r");
254 if (f == NULL) {
255 rpmlog(RPMLOG_ERR, _("Unable to open spec file %s: %s\n"),
256 specfile, strerror(errno));
257 return 0;
258 }
259 count = fread(buf, sizeof(buf[0]), sizeof(buf), f);
260 (void) fclose(f);
261
262 if (count == 0)
263 return 0;
264
265 checking = 1;
266 for (s = buf; count--; s++) {
267 switch (*s) {
268 case '\r':
269 case '\n':
270 checking = 1;
271 break;
272 case ':':
273 checking = 0;
274 break;
275 default:
276 #if 0
277 if (checking && !(isprint(*s) || isspace(*s))) return 0;
278 break;
279 #else
280 if (checking && !(isprint(*s) || isspace(*s)) && *(unsigned char *)s < 32) return 0;
281 break;
282 #endif
283 }
284 }
285 return 1;
286 }
287
288 /*
289 * Try to find a spec from a tarball pointed to by arg.
290 * Return absolute path to spec name on success, otherwise NULL.
291 */
292 static char * getTarSpec(const char *arg)
293 {
294 char *specFile = NULL;
295 char *specDir;
296 char *specBase;
297 char *tmpSpecFile;
298 const char **spec;
299 char tarbuf[BUFSIZ];
300 int gotspec = 0, res;
301 static const char *tryspec[] = { "Specfile", "\\*.spec", NULL };
302
303 specDir = rpmGetPath("%{_specdir}", NULL);
304 tmpSpecFile = rpmGetPath("%{_specdir}/", "rpm-spec.XXXXXX", NULL);
305
306 (void) close(mkstemp(tmpSpecFile));
307
308 for (spec = tryspec; *spec != NULL; spec++) {
309 FILE *fp;
310 char *cmd;
311
312 cmd = rpmExpand("%{uncompress: ", arg, "} | ",
313 "%{__tar} xOvf - --wildcards ", *spec,
314 " 2>&1 > ", tmpSpecFile, NULL);
315
316 if (!(fp = popen(cmd, "r"))) {
317 rpmlog(RPMLOG_ERR, _("Failed to open tar pipe: %m\n"));
318 } else {
319 char *fok;
320 for (;;) {
321 fok = fgets(tarbuf, sizeof(tarbuf) - 1, fp);
322 /* tar sometimes prints "tar: Record size = 16" messages */
323 if (!fok || strncmp(fok, "tar: ", 5) != 0)
324 break;
325 }
326 pclose(fp);
327 gotspec = (fok != NULL) && isSpecFile(tmpSpecFile);
328 }
329
330 if (!gotspec)
331 unlink(tmpSpecFile);
332 free(cmd);
333 }
334
335 if (!gotspec) {
336 rpmlog(RPMLOG_ERR, _("Failed to read spec file from %s\n"), arg);
337 goto exit;
338 }
339
340 specBase = basename(tarbuf);
341 /* remove trailing \n */
342 specBase[strlen(specBase)-1] = '\0';
343
344 rasprintf(&specFile, "%s/%s", specDir, specBase);
345 res = rename(tmpSpecFile, specFile);
346
347 if (res) {
348 rpmlog(RPMLOG_ERR, _("Failed to rename %s to %s: %m\n"),
349 tmpSpecFile, specFile);
350 free(specFile);
351 specFile = NULL;
352 } else {
353 /* mkstemp() can give unnecessarily strict permissions, fixup */
354 mode_t mask;
355 umask(mask = umask(0));
356 (void) chmod(specFile, 0666 & ~mask);
357 }
358
359 exit:
360 (void) unlink(tmpSpecFile);
361 free(tmpSpecFile);
362 free(specDir);
363 return specFile;
364 }
365
366 static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
367 {
368 int buildAmount = ba->buildAmount;
369 char * buildRootURL = NULL;
370 char * specFile = NULL;
371 rpmSpec spec = NULL;
372 int rc = 1; /* assume failure */
373 int justRm = ((buildAmount & ~(RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC)) == 0);
374 rpmSpecFlags specFlags = spec_flags;
375
376 if (ba->buildRootOverride)
377 buildRootURL = rpmGenPath(NULL, ba->buildRootOverride, NULL);
378
379 /* Create build tree if necessary */
380 const char * buildtree = "%{_topdir}:%{_specdir}:%{_sourcedir}:%{_builddir}:%{_rpmdir}:%{_srcrpmdir}:%{_buildrootdir}";
381 const char * rootdir = rpmtsRootDir(ts);
382 if (rpmMkdirs(!rstreq(rootdir, "/") ? rootdir : NULL , buildtree)) {
383 goto exit;
384 }
385
386 if (buildMode == 't') {
387 char *srcdir = NULL, *dir;
388
389 specFile = getTarSpec(arg);
390 if (!specFile)
391 goto exit;
392
393 /* Make the directory of the tarball %_sourcedir for this run */
394 /* dirname() may modify contents so extra hoops needed. */
395 if (*arg != '/') {
396 dir = rpmGetCwd();
397 rstrscat(&dir, "/", arg, NULL);
398 } else {
399 dir = xstrdup(arg);
400 }
401 srcdir = dirname(dir);
402 addMacro(NULL, "_sourcedir", NULL, srcdir, RMIL_TARBALL);
403 free(dir);
404 } else {
405 specFile = xstrdup(arg);
406 }
407
408 if (*specFile != '/') {
409 char *cwd = rpmGetCwd();
410 char *s = NULL;
411 rasprintf(&s, "%s/%s", cwd, specFile);
412 free(cwd);
413 free(specFile);
414 specFile = s;
415 }
416
417 struct stat st;
418 if (stat(specFile, &st) < 0) {
419 rpmlog(RPMLOG_ERR, _("failed to stat %s: %m\n"), specFile);
420 goto exit;
421 }
422 if (! S_ISREG(st.st_mode)) {
423 rpmlog(RPMLOG_ERR, _("File %s is not a regular file.\n"), specFile);
424 goto exit;
425 }
426
427 /* Try to verify that the file is actually a specfile */
428 if (!isSpecFile(specFile)) {
429 rpmlog(RPMLOG_ERR,
430 _("File %s does not appear to be a specfile.\n"), specFile);
431 goto exit;
432 }
433
434 /* Don't parse spec if only its removal is requested */
435 if (ba->buildAmount == RPMBUILD_RMSPEC) {
436 rc = unlink(specFile);
437 goto exit;
438 }
439
440 /* Parse the spec file */
441 #define _anyarch(_f) \
442 (((_f)&(RPMBUILD_PREP|RPMBUILD_BUILD|RPMBUILD_INSTALL|RPMBUILD_PACKAGEBINARY)) == 0)
443 if (_anyarch(buildAmount))
444 specFlags |= RPMSPEC_ANYARCH;
445 #undef _anyarch
446
447 spec = rpmSpecParse(specFile, specFlags, buildRootURL);
448 if (spec == NULL) {
449 goto exit;
450 }
451
452 /* Check build prerequisites if necessary, unless disabled */
453 if (!justRm && !noDeps && checkSpec(ts, spec)) {
454 goto exit;
455 }
456
457 if (rpmSpecBuild(spec, ba)) {
458 goto exit;
459 }
460
461 if (buildMode == 't')
462 (void) unlink(specFile);
463 rc = 0;
464
465 exit:
466 free(specFile);
467 rpmSpecFree(spec);
468 free(buildRootURL);
469 return rc;
470 }
471
472 static int build(rpmts ts, const char * arg, BTA_t ba, const char * rcfile)
473 {
474 int rc = 0;
475 char * targets = argvJoin(build_targets, ",");
476 #define buildCleanMask (RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC)
477 int cleanFlags = ba->buildAmount & buildCleanMask;
478 rpmVSFlags vsflags, ovsflags;
479
480 vsflags = rpmExpandNumeric("%{_vsflags_build}");
481 if (rpmcliQueryFlags & VERIFY_DIGEST)
482 vsflags |= _RPMVSF_NODIGESTS;
483 if (rpmcliQueryFlags & VERIFY_SIGNATURE)
484 vsflags |= _RPMVSF_NOSIGNATURES;
485 if (rpmcliQueryFlags & VERIFY_HDRCHK)
486 vsflags |= RPMVSF_NOHDRCHK;
487 ovsflags = rpmtsSetVSFlags(ts, vsflags);
488
489 if (build_targets == NULL) {
490 rc = buildForTarget(ts, arg, ba);
491 goto exit;
492 }
493
494 /* parse up the build operators */
495
496 printf(_("Building target platforms: %s\n"), targets);
497
498 ba->buildAmount &= ~buildCleanMask;
499 for (ARGV_const_t target = build_targets; target && *target; target++) {
500 /* Perform clean-up after last target build. */
501 if (*(target + 1) == NULL)
502 ba->buildAmount |= cleanFlags;
503
504 printf(_("Building for target %s\n"), *target);
505
506 /* Read in configuration for target. */
507 rpmFreeMacros(NULL);
508 rpmFreeRpmrc();
509 (void) rpmReadConfigFiles(rcfile, *target);
510 rc = buildForTarget(ts, arg, ba);
511 if (rc)
512 break;
513 }
514
515 exit:
516 rpmtsSetVSFlags(ts, ovsflags);
517 /* Restore original configuration. */
518 rpmFreeMacros(NULL);
519 rpmFreeRpmrc();
520 (void) rpmReadConfigFiles(rcfile, NULL);
521 free(targets);
522
523 return rc;
524 }
525
526 int main(int argc, char *argv[])
527 {
528 rpmts ts = NULL;
529 enum modes bigMode = MODE_BUILD;
530 BTA_t ba = &rpmBTArgs;
531
532 const char *pkg = NULL;
533 int ec = 0;
534 poptContext optCon = rpmcliInit(argc, argv, optionsTable);
535
536 /* Args required only when building, let lone --eval etc through */
537 if (ba->buildAmount && poptPeekArg(optCon) == NULL) {
538 printUsage(optCon, stderr, 0);
539 exit(EXIT_FAILURE);
540 }
541
542 switch (buildMode) {
543 case 'b': bigMode = MODE_BUILD; break;
544 case 't': bigMode = MODE_TARBUILD; break;
545 case 'B': bigMode = MODE_REBUILD; break;
546 case 'C': bigMode = MODE_RECOMPILE; break;
547 }
548
549 if (rpmcliRootDir && rpmcliRootDir[0] != '/') {
550 argerror(_("arguments to --root (-r) must begin with a /"));
551 }
552
553 /* rpmbuild is rather chatty by default */
554 rpmSetVerbosity(quiet ? RPMLOG_WARNING : RPMLOG_INFO);
555
556 if (rpmcliPipeOutput && initPipe())
557 exit(EXIT_FAILURE);
558
559 ts = rpmtsCreate();
560 (void) rpmtsSetRootDir(ts, rpmcliRootDir);
561 switch (bigMode) {
562 case MODE_REBUILD:
563 case MODE_RECOMPILE:
564 ba->buildAmount =
565 RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL | RPMBUILD_CHECK;
566 if (bigMode == MODE_REBUILD) {
567 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
568 ba->buildAmount |= RPMBUILD_RMSOURCE;
569 ba->buildAmount |= RPMBUILD_RMSPEC;
570 ba->buildAmount |= RPMBUILD_CLEAN;
571 ba->buildAmount |= RPMBUILD_RMBUILD;
572 }
573 ba->buildAmount &= ~(nobuildAmount);
574
575 while ((pkg = poptGetArg(optCon))) {
576 char * specFile = NULL;
577
578 ba->cookie = NULL;
579 ec = rpmInstallSource(ts, pkg, &specFile, &ba->cookie);
580 if (ec == 0) {
581 ba->rootdir = rpmcliRootDir;
582 ec = build(ts, specFile, ba, rpmcliRcfile);
583 }
584 ba->cookie = _free(ba->cookie);
585 specFile = _free(specFile);
586
587 if (ec)
588 break;
589 }
590 break;
591 case MODE_BUILD:
592 case MODE_TARBUILD:
593 switch (buildChar) {
594 case 'a':
595 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
596 case 'b':
597 ba->buildAmount |= RPMBUILD_PACKAGEBINARY;
598 ba->buildAmount |= RPMBUILD_CLEAN;
599 if ((buildChar == 'b') && shortCircuit)
600 break;
601 case 'i':
602 ba->buildAmount |= RPMBUILD_INSTALL;
603 ba->buildAmount |= RPMBUILD_CHECK;
604 if ((buildChar == 'i') && shortCircuit)
605 break;
606 case 'c':
607 ba->buildAmount |= RPMBUILD_BUILD;
608 if ((buildChar == 'c') && shortCircuit)
609 break;
610 case 'p':
611 ba->buildAmount |= RPMBUILD_PREP;
612 break;
613
614 case 'l':
615 ba->buildAmount |= RPMBUILD_FILECHECK;
616 break;
617 case 's':
618 ba->buildAmount |= RPMBUILD_PACKAGESOURCE;
619 break;
620 }
621 ba->buildAmount &= ~(nobuildAmount);
622
623 while ((pkg = poptGetArg(optCon))) {
624 ba->rootdir = rpmcliRootDir;
625 ba->cookie = NULL;
626 ec = build(ts, pkg, ba, rpmcliRcfile);
627 if (ec)
628 break;
629 rpmFreeMacros(NULL);
630 (void) rpmReadConfigFiles(rpmcliRcfile, NULL);
631 }
632 break;
633 }
634
635 rpmtsFree(ts);
636 if (finishPipe())
637 ec = EXIT_FAILURE;
638 free(ba->buildRootOverride);
639 argvFree(build_targets);
640
641 rpmcliFini(optCon);
642
643 return RETVAL(ec);
644 }
rpmBuildPoptTable
static struct poptOption rpmBuildPoptTable[]
Definition: rpmbuild.c:115
nobuildAmount
static rpmBuildFlags nobuildAmount
Definition: rpmbuild.c:56
RETVAL
#define RETVAL(rc)
Definition: cliutils.h:9
rpmcliRcfile
const char * rpmcliRcfile
POPT_BC
#define POPT_BC
Definition: rpmbuild.c:36
RPMBUILD_PREP
Definition: rpmbuild.h:22
printUsage
void printUsage(poptContext con, FILE *fp, int flags)
Definition: cliutils.c:36
POPT_BL
#define POPT_BL
Definition: rpmbuild.c:38
POPT_BA
#define POPT_BA
Definition: rpmbuild.c:34
POPT_NOLANG
#define POPT_NOLANG
Definition: rpmbuild.c:23
RPMBUILD_RMBUILD
Definition: rpmbuild.h:31
buildForTarget
static int buildForTarget(rpmts ts, const char *arg, BTA_t ba)
Definition: rpmbuild.c:366
ARGV_t
char ** ARGV_t
Definition: argv.h:15
rpmps
struct rpmps_s * rpmps
Definition: rpmtypes.h:70
spec_flags
static rpmSpecFlags spec_flags
Definition: rpmbuild.c:51
debug.h
build
static int build(rpmts ts, const char *arg, BTA_t ba, const char *rcfile)
Definition: rpmbuild.c:472
RPMLOG_ERR
Definition: rpmlog.h:33
RPMBUILD_RMSOURCE
Definition: rpmbuild.h:30
rpmBTArgs
static struct rpmBuildArguments_s rpmBTArgs
Definition: rpmbuild.c:21
rpmSpecParse
rpmSpec rpmSpecParse(const char *specFile, rpmSpecFlags flags, const char *buildRoot)
Parse spec file into spec control structure.
rpmGetCwd
char * rpmGetCwd(void)
Like getcwd() but the result is malloced.
rpmtsFree
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
RPMSPEC_FORCE
Definition: rpmspec.h:37
isSpecFile
static int isSpecFile(const char *specfile)
Definition: rpmbuild.c:245
RPMBUILD_FILECHECK
Definition: rpmbuild.h:27
addMacro
void addMacro(rpmMacroContext mc, const char *n, const char *o, const char *b, int level)
Add macro to context.
RPMLOG_INFO
Definition: rpmlog.h:36
rpmcliInit
poptContext rpmcliInit(int argc, char *const argv[], struct poptOption *optionsTable)
Initialize most everything needed by an rpm CLI executable context.
RPMBUILD_PACKAGESOURCE
Definition: rpmbuild.h:28
build_targets
static ARGV_t build_targets
Definition: rpmbuild.c:57
cliutils.h
rpmBuildArguments_s::pkgFlags
rpmBuildPkgFlags pkgFlags
Definition: rpmbuild.h:54
POPT_RECOMPILE
#define POPT_RECOMPILE
Definition: rpmbuild.c:33
rpmts
struct rpmts_s * rpmts
The main types involved in transaction manipulation.
Definition: rpmtypes.h:63
finishPipe
int finishPipe(void)
Definition: cliutils.c:73
POPT_TC
#define POPT_TC
Definition: rpmbuild.c:43
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:135
RPMBUILD_CHECK
Definition: rpmbuild.h:25
MODE_BUILD
Definition: rpmbuild.c:205
MODE_REBUILD
Definition: rpmbuild.c:206
POPT_BB
#define POPT_BB
Definition: rpmbuild.c:35
POPT_NOBUILD
#define POPT_NOBUILD
Definition: rpmbuild.c:28
shortCircuit
static int shortCircuit
Definition: rpmbuild.c:53
buildArgCallback
static void buildArgCallback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data)
Definition: rpmbuild.c:59
RPMBUILD_INSTALL
Definition: rpmbuild.h:24
rpmpsFree
rpmps rpmpsFree(rpmps ps)
Destroy a problem set.
POPT_TARGETPLATFORM
#define POPT_TARGETPLATFORM
Definition: rpmbuild.c:27
argvFree
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
rpmtsCreate
rpmts rpmtsCreate(void)
Create an empty transaction set.
POPT_TP
#define POPT_TP
Definition: rpmbuild.c:46
rpmcliQueryFlags
rpmQueryFlags rpmcliQueryFlags
Bit(s) from common command line options.
rpmExpand
char * rpmExpand(const char *arg,...) RPM_GNUC_NULL_TERMINATED
Return (malloc'ed) concatenated macro expansion(s).
rpmSpecFree
rpmSpec rpmSpecFree(rpmSpec spec)
Destroy Spec structure.
rpmBuildArguments_s::rootdir
const char * rootdir
Definition: rpmbuild.h:58
rpmInstallSource
int rpmInstallSource(rpmts ts, const char *arg, char **specFilePtr, char **cookie)
Install source rpm package.
rpmcliFini
poptContext rpmcliFini(poptContext optCon)
Destroy most everything needed by an rpm CLI executable context.
RPMBUILD_PACKAGEBINARY
Definition: rpmbuild.h:29
rpmcliPipeOutput
const char * rpmcliPipeOutput
argerror
void argerror(const char *desc)
Definition: cliutils.c:19
rpmBuildArguments_s::buildAmount
rpmBuildFlags buildAmount
Definition: rpmbuild.h:55
VERIFY_SIGNATURE
Definition: rpmvf.h:66
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.
RPMLOG_WARNING
Definition: rpmlog.h:34
rpmReadConfigFiles
int rpmReadConfigFiles(const char *file, const char *target)
Read macro configuration file(s) for a target.
rstreq
static int rstreq(const char *s1, const char *s2)
Test for string equality.
Definition: rpmstring.h:113
modes
modes
Definition: rpmbuild.c:204
getTarSpec
static char * getTarSpec(const char *arg)
Definition: rpmbuild.c:292
rpmBuildArguments_s::buildRootOverride
char * buildRootOverride
Definition: rpmbuild.h:56
xstrdup
#define xstrdup(_str)
Definition: system.h:111
rpmGetPath
char * rpmGetPath(const char *path,...) RPM_GNUC_NULL_TERMINATED
Return (malloc'ed) expanded, canonicalized, file path.
rstrscat
char * rstrscat(char **dest, const char *arg,...) RPM_GNUC_NULL_TERMINATED
Concatenate multiple strings with dynamically (re)allocated memory.
rasprintf
int rasprintf(char **strp, const char *fmt,...) RPM_GNUC_PRINTF(2
asprintf() clone
POPT_TL
#define POPT_TL
Definition: rpmbuild.c:45
rpmtsRootDir
const char * rpmtsRootDir(rpmts ts)
Get transaction rootDir, i.e.
initPipe
int initPipe(void)
Definition: cliutils.c:48
POPT_RMBUILD
#define POPT_RMBUILD
Definition: rpmbuild.c:25
rpmExpandNumeric
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
_anyarch
#define _anyarch(_f)
RPMSPEC_ANYARCH
Definition: rpmspec.h:36
optionsTable
static struct poptOption optionsTable[]
Definition: rpmbuild.c:214
rpmVSFlags
rpmFlags rpmVSFlags
Definition: rpmts.h:107
VERIFY_DIGEST
Definition: rpmvf.h:65
target
const char * target
Definition: rpmspec.c:21
rpmcliRootDir
const char * rpmcliRootDir
POPT_BP
#define POPT_BP
Definition: rpmbuild.c:39
_fsm_debug
int _fsm_debug
POPT_BS
#define POPT_BS
Definition: rpmbuild.c:40
rpmtsSetVSFlags
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
rpmlog
void rpmlog(int code, const char *fmt,...) RPM_GNUC_PRINTF(2
Generate a log message using FMT string and option arguments.
rpmSpecBuild
rpmRC rpmSpecBuild(rpmSpec spec, BTA_t buildArgs)
Spec build stages state machine driver.
RPMCLI_POPT_FORCE
#define RPMCLI_POPT_FORCE
Definition: rpmcli.h:62
rpmcliAllPoptTable
struct poptOption rpmcliAllPoptTable[]
Popt option table for options shared by all modes and executables.
RPMBUILD_BUILD
Definition: rpmbuild.h:23
ARGV_const_t
char *const * ARGV_const_t
Definition: argv.h:16
_free
#define _free(_ptr)
Definition: system.h:112
_RPMVSF_NOSIGNATURES
#define _RPMVSF_NOSIGNATURES
Definition: rpmts.h:115
POPT_RMSOURCE
#define POPT_RMSOURCE
Definition: rpmbuild.c:24
checkSpec
static int checkSpec(rpmts ts, rpmSpec spec)
Definition: rpmbuild.c:231
POPT_TI
#define POPT_TI
Definition: rpmbuild.c:44
rpmSpecFlags
rpmFlags rpmSpecFlags
Definition: rpmspec.h:41
system.h
buildMode
static char buildMode
Definition: rpmbuild.c:54
RPMBUILD_NOBUILD
Definition: rpmbuild.h:35
RPMBUILD_CLEAN
Definition: rpmbuild.h:26
rpmSpecCheckDeps
rpmps rpmSpecCheckDeps(rpmts ts, rpmSpec spec)
Verify build depencies of a spec against.
RPMBUILD_RMSPEC
Definition: rpmbuild.h:33
POPT_TB
#define POPT_TB
Definition: rpmbuild.c:42
buildChar
static char buildChar
Definition: rpmbuild.c:55
rpmBuildArguments_s::cookie
char * cookie
Definition: rpmbuild.h:57
RMIL_TARBALL
#define RMIL_TARBALL
Definition: rpmmacro.h:41
__progname
#define __progname
Definition: system.h:121
_RPMVSF_NODIGESTS
#define _RPMVSF_NODIGESTS
Definition: rpmts.h:109
VERIFY_HDRCHK
Definition: rpmvf.h:68
N_
#define N_(Text)
Definition: system.h:138
RPMBUILD_PKG_NODIRTOKENS
Definition: rpmbuild.h:45
MODE_RECOMPILE
Definition: rpmbuild.c:207
argvSplit
int argvSplit(ARGV_t *argvp, const char *str, const char *seps)
Split a string into an argv array.
rpmSetVerbosity
#define rpmSetVerbosity(_lvl)
Definition: rpmlog.h:264
rpmFreeMacros
void rpmFreeMacros(rpmMacroContext mc)
Destroy macro context.
rpmMkdirs
int rpmMkdirs(const char *root, const char *pathstr)
Create several directories (including parents if needed) in one go.
POPT_BI
#define POPT_BI
Definition: rpmbuild.c:37
RPMSPEC_NOLANG
Definition: rpmspec.h:38
rpmFreeRpmrc
void rpmFreeRpmrc(void)
Destroy rpmrc arch/os compatibility tables.
buildCleanMask
#define buildCleanMask
POPT_TS
#define POPT_TS
Definition: rpmbuild.c:47
rpmtsSetRootDir
int rpmtsSetRootDir(rpmts ts, const char *rootDir)
Set transaction rootDir, i.e.
rpmBuildArguments_s
Describe build request.
Definition: rpmbuild.h:53
RPMVSF_NOHDRCHK
Definition: rpmts.h:92
rpmBuildFlags
rpmFlags rpmBuildFlags
Definition: rpmbuild.h:38
MODE_TARBUILD
Definition: rpmbuild.c:208
rpmpsPrint
void rpmpsPrint(FILE *fp, rpmps ps)
Print problems to file handle.
main
int main(int argc, char *argv[])
Definition: rpmbuild.c:526
quiet
static int quiet
Definition: rpmbuild.c:211
POPT_REBUILD
#define POPT_REBUILD
Definition: rpmbuild.c:32
argvJoin
char * argvJoin(ARGV_const_t argv, const char *sep)
Join an argv array into a string.
rpmSpec
struct rpmSpec_s * rpmSpec
Definition: rpmtypes.h:87
noDeps
static int noDeps
Definition: rpmbuild.c:52
POPT_TA
#define POPT_TA
Definition: rpmbuild.c:41