rpm  5.4.14
rpmqv.c
Go to the documentation of this file.
1 #include "system.h"
2 extern const char *__progname;
3 
4 /* Copyright (C) 1998-2002 - Red Hat, Inc. */
5 
6 #define _AUTOHELP
7 
8 #if defined(IAM_RPM) || defined(__LCLINT__)
9 #define IAM_RPMBT
10 #define IAM_RPMDB
11 #define IAM_RPMEIU
12 #define IAM_RPMQV
13 #define IAM_RPMK
14 #endif
15 
16 #if defined(RPM_VENDOR_OPENPKG) /* integrity-checking */
17 #define _RPMIOB_INTERNAL /* XXX rpmiobSlurp */
18 #include "rpmio_internal.h"
19 #endif
20 
21 #include <rpmio.h>
22 #include <rpmiotypes.h>
23 #include <poptIO.h>
24 
25 #include <rpmtypes.h>
26 #include <rpmtag.h>
27 #include "rpmdb.h"
28 
29 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
30 #include "signature.h"
31 #endif
32 
33 #if defined(RPM_VENDOR_OPENPKG) /* integrity-checking */
34 #include "rpmns.h"
35 #define _RPMLUA_INTERNAL
36 #include "rpmlua.h"
37 #include "rpmluaext.h"
38 #endif
39 
40 #include "rpmversion.h"
41 #include "rpmps.h"
42 #include "rpmts.h"
43 
44 #include "fs.h" /* XXX for rpmFreeFilesystems() */
45 
46 #include <rpmbuild.h>
47 
48 #ifdef IAM_RPMBT
49 #include "build.h"
50 #define GETOPT_REBUILD 1003
51 #define GETOPT_RECOMPILE 1004
52 #endif
53 
54 #include <rpmcli.h>
55 #include <rpmrollback.h>
56 
57 #include "debug.h"
58 
59 
60 #ifdef __cplusplus
61 
62 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
63 #define QVA_SET(_qvaflags, _FLAG) \
64  (*((unsigned *)&(_qvaflags)) |= (VERIFY_##_FLAG))
65 #define QVA_CLR(_qvaflags, _FLAG) \
66  (*((unsigned *)&(_qvaflags)) &= ~(VERIFY_##_FLAG))
67 
68 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
69 #define VSF_SET(_vsflags, _FLAG) \
70  (*((unsigned *)&(_vsflags)) |= (RPMVSF_##_FLAG))
71 #define VSF_CLR(_vsflags, _FLAG) \
72  (*((unsigned *)&(_vsflags)) &= ~(RPMVSF_##_FLAG))
73 
74 #define TSF_ISSET(_tsflags, _FLAG) ((_tsflags) & (RPMTRANS_FLAG_##_FLAG))
75 #define TSF_SET(_tsflags, _FLAG) \
76  (*((unsigned *)&(_tsflags)) |= (RPMTRANS_FLAG_##_FLAG))
77 #define TSF_CLR(_tsflags, _FLAG) \
78  (*((unsigned *)&(_tsflags)) &= ~(RPMTRANS_FLAG_##_FLAG))
79 
80 #define IIF_ISSET(_iflags, _FLAG) ((_iflags) & (INSTALL_##_FLAG))
81 #define IIF_SET(_iflags, _FLAG) \
82  (*((unsigned *)&(_iflags)) |= (INSTALL_##_FLAG))
83 #define IIF_CLR(_iflags, _FLAG) \
84  (*((unsigned *)&(_iflags)) &= ~(INSTALL_##_FLAG))
85 
86 #define PFF_ISSET(_pfflags, _FLAG) ((_pfflags) & (RPMPROB_FILTER_##_FLAG))
87 #define PFF_SET(_pfflags, _FLAG) \
88  (*((unsigned *)&(_pfflags)) |= (RPMPROB_FILTER_##_FLAG))
89 #define PFF_CLR(_pfflags, _FLAG) \
90  (*((unsigned *)&(_pfflags)) &= ~(RPMPROB_FILTER_##_FLAG))
91 
92 #else /* __cplusplus */
93 
94 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
95 #define QVA_SET(_qvaflags, _FLAG) (_qvaflags) |= (VERIFY_##_FLAG)
96 #define QVA_CLR(_qvaflags, _FLAG) (_qvaflags) &= ~(VERIFY_##_FLAG)
97 
98 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
99 #define VSF_SET(_vsflags, _FLAG) (_vsflags) |= (RPMVSF_##_FLAG)
100 #define VSF_CLR(_vsflags, _FLAG) (_vsflags) &= ~(RPMVSF_##_FLAG)
101 
102 #define TSF_ISSET(_tsflags, _FLAG) ((_tsflags) & (RPMTRANS_FLAG_##_FLAG))
103 #define TSF_SET(_tsflags, _FLAG) (_tsflags) |= (RPMTRANS_FLAG_##_FLAG)
104 #define TSF_CLR(_tsflags, _FLAG) (_tsflags) &= ~(RPMTRANS_FLAG_##_FLAG)
105 
106 #define IIF_ISSET(_iflags, _FLAG) ((_iflags) & (INSTALL_##_FLAG))
107 #define IIF_SET(_iflags, _FLAG) (_iflags) |= (INSTALL_##_FLAG)
108 #define IIF_CLR(_iflags, _FLAG) (_iflags) &= ~(INSTALL_##_FLAG)
109 
110 #define PFF_ISSET(_pfflags, _FLAG) ((_pfflags) & (RPMPROB_FILTER_##_FLAG))
111 #define PFF_SET(_pfflags, _FLAG) (_pfflags) |= (RPMPROB_FILTER_##_FLAG)
112 #define PFF_CLR(_pfflags, _FLAG) (_pfflags) &= ~(RPMPROB_FILTER_##_FLAG)
113 
114 #endif /* __cplusplus */
115 
116 enum modes {
118 
119  MODE_QUERY = (1 << 0),
120  MODE_VERIFY = (1 << 3),
121 #define MODES_QV (MODE_QUERY | MODE_VERIFY)
122 
123  MODE_INSTALL = (1 << 1),
124  MODE_ERASE = (1 << 2),
125 #define MODES_IE (MODE_INSTALL | MODE_ERASE)
126 
127  MODE_BUILD = (1 << 4),
128  MODE_REBUILD = (1 << 5),
129  MODE_RECOMPILE = (1 << 8),
130  MODE_TARBUILD = (1 << 11),
131 #define MODES_BT (MODE_BUILD | MODE_TARBUILD | MODE_REBUILD | MODE_RECOMPILE)
132 
133  MODE_CHECKSIG = (1 << 6),
134  MODE_RESIGN = (1 << 7),
135 #define MODES_K (MODE_CHECKSIG | MODE_RESIGN)
136 
137  MODE_REBUILDDB = (1 << 12),
139 };
140 
141 #define MODES_FOR_DBPATH (MODES_BT | MODES_IE | MODES_QV | MODES_DB)
142 #define MODES_FOR_NODEPS (MODES_BT | MODES_IE | MODE_VERIFY)
143 #define MODES_FOR_TEST (MODES_BT | MODES_IE)
144 #define MODES_FOR_ROOT (MODES_BT | MODES_IE | MODES_QV | MODES_DB | MODES_K)
145 
146 /* the structure describing the options we take and the defaults */
147 /*@unchecked@*/
148 static struct poptOption optionsTable[] = {
149 
150 #ifdef IAM_RPMQV
151  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQueryPoptTable, 0,
152  N_("Query options (with -q or --query):"),
153  NULL },
154  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmVerifyPoptTable, 0,
155  N_("Verify options (with -V or --verify):"),
156  NULL },
157 #ifdef NOTYET
158  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliQVSourcePoptTable, 0,
159  N_("Source options (with --query or --verify):"),
160  NULL },
161 #endif
162 #endif /* IAM_RPMQV */
163 
164 #if defined(IAM_RPMQV) || defined(IAM_RPMEIU)
165  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliDepFlagsPoptTable, 0,
166  N_("Dependency check/order options:"),
167  NULL },
168 #endif /* IAM_RPMQV */
169 
170 #ifdef IAM_RPMQV
171  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmioFtsPoptTable, 0,
172  N_("File tree walk options (with --ftswalk):"),
173  NULL },
174 #endif /* IAM_RPMQV */
175 
176 #ifdef IAM_RPMK
177  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmSignPoptTable, 0,
178  N_("Signature options:"),
179  NULL },
180 #endif /* IAM_RPMK */
181 
182 #ifdef IAM_RPMDB
183  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmDatabasePoptTable, 0,
184  N_("Database options:"),
185  NULL },
186 #endif /* IAM_RPMDB */
187 
188 #ifdef IAM_RPMBT
189  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmBuildPoptTable, 0,
190  N_("Build options with [ <specfile> | <tarball> | <source package> ]:"),
191  NULL },
192 #endif /* IAM_RPMBT */
193 
194 #ifdef IAM_RPMEIU
195  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmInstallPoptTable, 0,
196  N_("Install/Upgrade/Erase options:"),
197  NULL },
198 #endif /* IAM_RPMEIU */
199 
200  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
201  N_("Common options:"),
202  NULL },
203 
204  POPT_AUTOALIAS
205  POPT_AUTOHELP
206  POPT_TABLEEND
207 };
208 
209 #ifdef __MINT__
210 /* MiNT cannot dynamically increase the stack. */
211 long _stksize = 64 * 1024L;
212 #endif
213 
214 /*@exits@*/ static void argerror(const char * desc)
215  /*@globals __assert_program_name, fileSystem @*/
216  /*@modifies fileSystem @*/
217 {
218  fprintf(stderr, _("%s: %s\n"), __progname, desc);
220 }
221 
222 #ifdef DYING /* XXX rpmIsVerbose alone stops usage spewage with every --eval */
223 static void printVersion(FILE * fp)
224  /*@globals rpmEVR, fileSystem @*/
225  /*@modifies *fp, fileSystem @*/
226 {
227  fprintf(fp, "%s (" RPM_NAME ") %s\n", __progname, rpmEVR);
228  if (rpmIsVerbose())
229  fprintf(fp, "rpmlib 0x%08x,0x%08x,0x%08x\n",
231 }
232 
233 static void printUsage(poptContext con, FILE * fp, int flags)
234  /*@globals rpmEVR, fileSystem, internalState @*/
235  /*@modifies *fp, fileSystem, internalState @*/
236 {
237  printVersion(fp);
238  fprintf(fp, "\n");
239 
240  if (rpmIsVerbose())
241  poptPrintHelp(con, fp, flags);
242  else
243  poptPrintUsage(con, fp, flags);
244 }
245 #endif
246 
247 #if defined(RPM_VENDOR_OPENPKG) /* integrity-checking */
248 
249 #if !defined(RPM_INTEGRITY_FP)
250 #error required RPM_INTEGRITY_FP (fingerprint of public key of integrity authority) not defined!
251 #endif
252 
253 enum {
254  INTEGRITY_OK = 0,
255  INTEGRITY_WARNING = 1,
256  INTEGRITY_ERROR = 2
257 };
258 
259 static void integrity_check_message(const char *fmt, ...)
260 {
261  va_list ap;
262 
263  va_start(ap, fmt);
264  fprintf(stderr, "rpm: ATTENTION: INTEGRITY CHECKING DETECTED AN ENVIRONMENT ANOMALY!\nrpm: ");
265  vfprintf(stderr, fmt, ap);
266  va_end(ap);
267  return;
268 }
269 
270 static void integrity_check(const char *progname, enum modes progmode_num)
271 {
272  rpmts ts = NULL;
273  rpmlua lua = NULL;
274  char *spec_fn = NULL;
275  char *proc_fn = NULL;
276  char *pkey_fn = NULL;
277  char *spec = NULL;
278  char *proc = NULL;
279  rpmiob spec_iob = NULL;
280  rpmiob proc_iob = NULL;
281  const char *result = NULL;
282  const char *error = NULL;
283  int xx;
284  const char *progmode;
285  int rc = INTEGRITY_ERROR;
286 
287  /* determine paths of integrity checking related files */
288  spec_fn = rpmExpand("%{?_integrity_spec_cfg}%{!?_integrity_spec_cfg:scripts/integrity.cfg}", NULL);
289  if (spec_fn == NULL || spec_fn[0] == '\0') {
290  integrity_check_message("ERROR: Integrity Configuration Specification file not configured.\n"
291  "rpm: HINT: macro %%{_integrity_spec_cfg} not configured correctly.\n");
292  goto failure;
293  }
294  proc_fn = rpmExpand("%{?_integrity_proc_lua}%{!?_integrity_proc_lua:scripts/integrity.lua}", NULL);
295  if (proc_fn == NULL || proc_fn[0] == '\0') {
296  integrity_check_message("ERROR: Integrity Validation Processor file not configured.\n"
297  "rpm: HINT: macro %%{_integrity_proc_lua} not configured correctly.\n");
298  goto failure;
299  }
300  pkey_fn = rpmExpand("%{?_integrity_pkey_pgp}%{!?_integrity_pkey_pgp:scripts/integrity.pgp}", NULL);
301  if (pkey_fn == NULL || pkey_fn[0] == '\0') {
302  integrity_check_message("ERROR: Integrity Authority Public-Key file not configured.\n"
303  "rpm: HINT: macro %%{_integrity_pkey_pgp} not configured correctly.\n");
304  goto failure;
305  }
306 
307  /* create RPM transaction environment and open RPM database */
308  ts = rpmtsCreate();
309  (void)rpmtsOpenDB(ts, O_RDONLY);
310 
311  /* check signature on integrity configuration specification file */
312  if (rpmnsProbeSignature(ts, spec_fn, NULL, pkey_fn, RPM_INTEGRITY_FP, 0) != RPMRC_OK) {
313  integrity_check_message("ERROR: Integrity Configuration Specification file contains invalid signature.\n"
314  "rpm: HINT: Check file \"%s\".\n", spec_fn);
315  goto failure;
316  }
317 
318  /* check signature on integrity validation processor file */
319  if (rpmnsProbeSignature(ts, proc_fn, NULL, pkey_fn, RPM_INTEGRITY_FP, 0) != RPMRC_OK) {
320  integrity_check_message("ERROR: Integrity Validation Processor file contains invalid signature.\n"
321  "rpm: HINT: Check file \"%s\".\n", proc_fn);
322  goto failure;
323  }
324 
325  /* load integrity configuration specification file */
326  xx = rpmiobSlurp(spec_fn, &spec_iob);
327  if (!(xx == 0 && spec_iob != NULL)) {
328  integrity_check_message("ERROR: Unable to load Integrity Configuration Specification file.\n"
329  "rpm: HINT: Check file \"%s\".\n", spec_fn);
330  goto failure;
331  }
332  spec = rpmiobStr(spec_iob);
333 
334  /* load integrity validation processor file */
335  xx = rpmiobSlurp(proc_fn, &proc_iob);
336  if (!(xx == 0 && proc_iob != NULL)) {
337  integrity_check_message("ERROR: Unable to load Integrity Validation Processor file.\n"
338  "rpm: HINT: Check file \"%s\".\n", proc_fn);
339  goto failure;
340  }
341  proc = rpmiobStr(proc_iob);
342 
343  /* provision program name and mode */
344  if (progname == NULL || progname[0] == '\0')
345  progname = "rpm";
346  switch (progmode_num) {
347  case MODE_QUERY: progmode = "query"; break;
348  case MODE_VERIFY: progmode = "verify"; break;
349  case MODE_CHECKSIG: progmode = "checksig"; break;
350  case MODE_RESIGN: progmode = "resign"; break;
351  case MODE_INSTALL: progmode = "install"; break;
352  case MODE_ERASE: progmode = "erase"; break;
353  case MODE_BUILD: progmode = "build"; break;
354  case MODE_REBUILD: progmode = "rebuild"; break;
355  case MODE_RECOMPILE: progmode = "recompile"; break;
356  case MODE_TARBUILD: progmode = "tarbuild"; break;
357  case MODE_REBUILDDB: progmode = "rebuilddb"; break;
358  case MODE_UNKNOWN: progmode = "unknown"; break;
359  default: progmode = "unknown"; break;
360  }
361 
362  /* execute Integrity Validation Processor via Lua glue code */
363  lua = rpmluaNew();
364  rpmluaSetPrintBuffer(lua, 1);
365  rpmluaextActivate(lua);
366  lua_getfield(lua->L, LUA_GLOBALSINDEX, "integrity");
367  lua_getfield(lua->L, -1, "processor");
368  lua_remove(lua->L, -2);
369  lua_pushstring(lua->L, progname);
370  lua_pushstring(lua->L, progmode);
371  lua_pushstring(lua->L, spec_fn);
372  lua_pushstring(lua->L, spec);
373  lua_pushstring(lua->L, proc_fn);
374  lua_pushstring(lua->L, proc);
375 #ifdef RPM_INTEGRITY_MV
376  lua_pushstring(lua->L, RPM_INTEGRITY_MV);
377 #else
378  lua_pushstring(lua->L, "0");
379 #endif
380  if (lua_pcall(lua->L, 7, 1, 0) != 0) {
381  error = lua_isstring(lua->L, -1) ? lua_tostring(lua->L, -1) : "unknown error";
382  lua_pop(lua->L, 1);
383  integrity_check_message("ERROR: Failed to execute Integrity Validation Processor.\n"
384  "rpm: ERROR: Lua: %s.\n"
385  "rpm: HINT: Check file \"%s\".\n", error, proc_fn);
386  goto failure;
387  }
388 
389  /* check Integrity Validation Processor results */
390  if (!lua_isstring(lua->L, -1)) {
391  integrity_check_message("ERROR: Failed to fetch Integrity Validation Processor results.\n"
392  "rpm: HINT: Check file \"%s\".\n", proc_fn);
393  goto failure;
394  }
395  result = lua_tostring(lua->L, -1);
396  if (strcmp(result, "OK") == 0)
397  rc = INTEGRITY_OK;
398  else if (strncmp(result, "WARNING:", 8) == 0) {
399  rc = INTEGRITY_WARNING;
400  integrity_check_message("%s\n", result);
401  }
402  else {
403  rc = INTEGRITY_ERROR;
404  integrity_check_message("%s\n", result);
405  }
406 
407  /* cleanup processing */
408  failure:
409  if (lua != NULL)
410  rpmluaFree(lua);
411  if (ts != NULL)
412  (void)rpmtsFree(ts);
413  ts = NULL;
414  if (spec_iob != NULL)
415  spec_iob = rpmiobFree(spec_iob);
416  if (proc_iob != NULL)
417  proc_iob = rpmiobFree(proc_iob);
418 
419  /* final result handling */
420  if (rc != INTEGRITY_OK) {
421  if (isatty(STDIN_FILENO) || isatty(STDOUT_FILENO))
422  sleep(4);
423  if (rc == INTEGRITY_ERROR)
424  exit(42);
425  }
426  return;
427 }
428 #endif
429 
430 /*@-bounds@*/ /* LCL: segfault */
431 /*@-mods@*/ /* FIX: shrug */
432 #if !defined(__GLIBC__) && !defined(__LCLINT__)
433 int main(int argc, const char ** argv, /*@unused@*/ char ** envp)
434 #else
435 int main(int argc, const char ** argv)
436 #endif
437  /*@globals rpmEVR, RPMVERSION,
438  rpmGlobalMacroContext, rpmCLIMacroContext,
439  h_errno, fileSystem, internalState@*/
440  /*@modifies fileSystem, internalState@*/
441 {
442  poptContext optCon = rpmcliInit(argc, (char *const *)argv, optionsTable);
443 
444  rpmts ts = NULL;
445  enum modes bigMode = MODE_UNKNOWN;
446 
447 #if defined(IAM_RPMQV)
448  QVA_t qva = &rpmQVKArgs;
449 #endif
450 
451 #ifdef IAM_RPMBT
452  BTA_t ba = &rpmBTArgs;
453 #endif
454 
455 #ifdef IAM_RPMEIU
456  QVA_t ia = &rpmIArgs;
457 #endif
458 
459 #if defined(IAM_RPMDB)
460  QVA_t da = &rpmDBArgs;
461 #endif
462 
463 #if defined(IAM_RPMK)
464  QVA_t ka = &rpmQVKArgs;
465 #endif
466 
467 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
468  char * passPhrase = (char *) "";
469 #endif
470 
471  pid_t pipeChild = 0;
472  int ec = 0;
473  int status;
474  int p[2];
475 #ifdef IAM_RPMEIU
476  int xx;
477 #endif
478 
479 #if !defined(__GLIBC__) && !defined(__LCLINT__)
480  environ = envp;
481 #else
482 /* XXX limit the fiddle up to linux for now. */
483 #if 0 && !defined(HAVE_SETPROCTITLE) && defined(__linux__)
484  (void) initproctitle(argc, (char **)argv, environ);
485 #endif
486 #endif
487 
488  /* Set the major mode based on argv[0] */
489  /*@-nullpass@*/
490 #ifdef IAM_RPMBT
491  if (!strcmp(__progname, "rpmb")) bigMode = MODE_BUILD;
492  if (!strcmp(__progname, "lt-rpmb")) bigMode = MODE_BUILD;
493  if (!strcmp(__progname, "rpmt")) bigMode = MODE_TARBUILD;
494  if (!strcmp(__progname, "rpmbuild")) bigMode = MODE_BUILD;
495 #endif
496 #ifdef IAM_RPMQV
497  if (!strcmp(__progname, "rpmq")) bigMode = MODE_QUERY;
498  if (!strcmp(__progname, "lt-rpmq")) bigMode = MODE_QUERY;
499  if (!strcmp(__progname, "rpmv")) bigMode = MODE_VERIFY;
500  if (!strcmp(__progname, "rpmquery")) bigMode = MODE_QUERY;
501  if (!strcmp(__progname, "rpmverify")) bigMode = MODE_VERIFY;
502 #endif
503 #ifdef RPMEIU
504  if (!strcmp(__progname, "rpme")) bigMode = MODE_ERASE;
505  if (!strcmp(__progname, "rpmi")) bigMode = MODE_INSTALL;
506  if (!strcmp(__progname, "lt-rpmi")) bigMode = MODE_INSTALL;
507  if (!strcmp(__progname, "rpmu")) bigMode = MODE_INSTALL;
508 #endif
509  /*@=nullpass@*/
510 
511 #if defined(IAM_RPMQV)
512  /* Jumpstart option from argv[0] if necessary. */
513  switch (bigMode) {
514  case MODE_QUERY: qva->qva_mode = 'q'; break;
515  case MODE_VERIFY: qva->qva_mode = 'V'; break;
516  case MODE_CHECKSIG: qva->qva_mode = 'K'; break;
517  case MODE_RESIGN: qva->qva_mode = 'R'; break;
518  case MODE_INSTALL:
519  case MODE_ERASE:
520  case MODE_BUILD:
521  case MODE_REBUILD:
522  case MODE_RECOMPILE:
523  case MODE_TARBUILD:
524  case MODE_REBUILDDB:
525  case MODE_UNKNOWN:
526  default:
527  break;
528  }
529 #endif
530 
532 
533 #ifdef IAM_RPMBT
534  switch (ba->buildMode) {
535  case 'b': bigMode = MODE_BUILD; break;
536  case 't': bigMode = MODE_TARBUILD; break;
537  case 'B': bigMode = MODE_REBUILD; break;
538  case 'C': bigMode = MODE_RECOMPILE; break;
539  }
540 
541  if ((ba->buildAmount & RPMBUILD_RMSOURCE) && bigMode == MODE_UNKNOWN)
542  bigMode = MODE_BUILD;
543 
544  if ((ba->buildAmount & RPMBUILD_RMSPEC) && bigMode == MODE_UNKNOWN)
545  bigMode = MODE_BUILD;
546 #endif /* IAM_RPMBT */
547 
548 #ifdef IAM_RPMDB
549  if (bigMode == MODE_UNKNOWN || (bigMode & MODES_DB)) {
550  if (da->rebuild) {
551  if (bigMode != MODE_UNKNOWN)
552  argerror(_("only one major mode may be specified"));
553  else
554  bigMode = MODE_REBUILDDB;
555  }
556  }
557 #endif /* IAM_RPMDB */
558 
559 #ifdef IAM_RPMQV
560  if (bigMode == MODE_UNKNOWN || (bigMode & MODES_QV)) {
561  switch (qva->qva_mode) {
562  case 'q': bigMode = MODE_QUERY; break;
563  case 'V': bigMode = MODE_VERIFY; break;
564  }
565 
566  if (qva->qva_sourceCount) {
567  if (qva->qva_sourceCount > 2)
568  argerror(_("one type of query/verify may be performed at a "
569  "time"));
570  }
571  if (qva->qva_flags && (bigMode & ~MODES_QV))
572  argerror(_("unexpected query flags"));
573 
574  if (qva->qva_queryFormat && (bigMode & ~MODES_QV))
575  argerror(_("unexpected query format"));
576 
577  if (qva->qva_source != RPMQV_PACKAGE && (bigMode & ~MODES_QV))
578  argerror(_("unexpected query source"));
579  }
580 #endif /* IAM_RPMQV */
581 
582 #ifdef IAM_RPMEIU
583  if (bigMode == MODE_UNKNOWN || (bigMode & MODES_IE))
584  { int iflags = (ia->installInterfaceFlags &
586  int eflags = (ia->installInterfaceFlags & INSTALL_ERASE);
587 
588  if (iflags & eflags)
589  argerror(_("only one major mode may be specified"));
590  else if (iflags)
591  bigMode = MODE_INSTALL;
592  else if (eflags)
593  bigMode = MODE_ERASE;
594  }
595 #endif /* IAM_RPMEIU */
596 
597 #ifdef IAM_RPMK
598  if (bigMode == MODE_UNKNOWN || (bigMode & MODES_K)) {
599  switch (ka->qva_mode) {
600  case RPMSIGN_NONE:
601  ka->sign = 0;
602  break;
605  bigMode = MODE_CHECKSIG;
606  ka->sign = 0;
607  break;
611  bigMode = MODE_RESIGN;
612  ka->sign = (ka->qva_mode != RPMSIGN_DEL_SIGNATURE);
613  break;
614  }
615  }
616 #endif /* IAM_RPMK */
617 
618 #if defined(IAM_RPMEIU)
619  if (!( bigMode == MODE_INSTALL ) &&
621  argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
622  if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_FORCERELOCATE))
623  argerror(_("files may only be relocated during package installation"));
624 
625  if (ia->relocations && ia->qva_prefix)
626  argerror(_("cannot use --prefix with --relocate or --excludepath"));
627 
628  if (bigMode != MODE_INSTALL && ia->relocations)
629  argerror(_("--relocate and --excludepath may only be used when installing new packages"));
630 
631  if (bigMode != MODE_INSTALL && ia->qva_prefix)
632  argerror(_("--prefix may only be used when installing new packages"));
633 
634  if (ia->qva_prefix && ia->qva_prefix[0] != '/')
635  argerror(_("arguments to --prefix must begin with a /"));
636 
637  if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_HASH))
638  argerror(_("--hash (-h) may only be specified during package "
639  "installation"));
640 
641  if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_PERCENT))
642  argerror(_("--percent may only be specified during package "
643  "installation"));
644 
645  if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_REPLACEPKG))
646  argerror(_("--replacepkgs may only be specified during package "
647  "installation"));
648 
649  if (bigMode != MODE_INSTALL && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
650  argerror(_("--excludedocs may only be specified during package "
651  "installation"));
652 
653  if (bigMode != MODE_INSTALL && ia->incldocs)
654  argerror(_("--includedocs may only be specified during package "
655  "installation"));
656 
657  if (ia->incldocs && (ia->transFlags & RPMTRANS_FLAG_NODOCS))
658  argerror(_("only one of --excludedocs and --includedocs may be "
659  "specified"));
660 
661  if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREARCH))
662  argerror(_("--ignorearch may only be specified during package "
663  "installation"));
664 
665  if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_IGNOREOS))
666  argerror(_("--ignoreos may only be specified during package "
667  "installation"));
668 
669  if ((ia->installInterfaceFlags & INSTALL_ALLMATCHES) && bigMode != MODE_ERASE)
670  argerror(_("--allmatches may only be specified during package "
671  "erasure"));
672 
673  if ((ia->transFlags & RPMTRANS_FLAG_ALLFILES) && bigMode != MODE_INSTALL)
674  argerror(_("--allfiles may only be specified during package "
675  "installation"));
676 
677  if ((ia->transFlags & RPMTRANS_FLAG_JUSTDB) &&
678  bigMode != MODE_INSTALL && bigMode != MODE_ERASE)
679  argerror(_("--justdb may only be specified during package "
680  "installation and erasure"));
681 
682  if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
684  argerror(_("script disabling options may only be specified during "
685  "package installation and erasure"));
686 
687  if (bigMode != MODE_INSTALL && bigMode != MODE_ERASE &&
689  argerror(_("trigger disabling options may only be specified during "
690  "package installation and erasure"));
691 
692  if (ia->noDeps & (bigMode & ~MODES_FOR_NODEPS))
693  argerror(_("--nodeps may only be specified during package "
694  "building, rebuilding, recompilation, installation, "
695  "erasure, and verification"));
696 
697  if ((ia->transFlags & RPMTRANS_FLAG_TEST) && (bigMode & ~MODES_FOR_TEST))
698  argerror(_("--test may only be specified during package installation, "
699  "erasure, and building"));
700 #endif /* IAM_RPMEIU */
701 
702  if (rpmioRootDir && rpmioRootDir[1] && (bigMode & ~MODES_FOR_ROOT))
703  argerror(_("--root (-r) may only be specified during "
704  "installation, erasure, querying, and "
705  "database rebuilds"));
706 
707  if (rpmioRootDir) {
708  switch (urlIsURL(rpmioRootDir)) {
709  default:
710  if (bigMode & MODES_FOR_ROOT)
711  break;
712  /*@fallthrough@*/
713  case URL_IS_UNKNOWN:
714  if (rpmioRootDir[0] != '/')
715  argerror(_("arguments to --root (-r) must begin with a /"));
716  break;
717  }
718  }
719 
720 #if defined(RPM_VENDOR_OPENPKG) /* integrity-checking */
721  integrity_check(__progname, bigMode);
722 #endif
723 
724 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
725  if (0
726 #if defined(IAM_RPMBT)
727  || ba->sign
728 #endif
729 #if defined(IAM_RPMK)
730  || ka->sign
731 #endif
732  )
733  /*@-branchstate@*/
734  {
735  if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
736  bigMode == MODE_RESIGN || bigMode == MODE_TARBUILD)
737  {
738  const char ** av;
739  struct stat sb;
740  int errors = 0;
741 
742  if ((av = poptGetArgs(optCon)) == NULL) {
743  fprintf(stderr, _("no files to sign\n"));
744  errors++;
745  } else
746  while (*av) {
747  if (Stat(*av, &sb)) {
748  fprintf(stderr, _("cannot access file %s\n"), *av);
749  errors++;
750  }
751  av++;
752  }
753 
754  if (errors) {
755  ec = errors;
756  goto exit;
757  }
758 
759 
760  if (poptPeekArg(optCon)
761 #if defined(IAM_RPMBT)
762  && !ba->nopassword
763 #endif
764 #if defined(IAM_RPMK)
765  && !ka->nopassword
766 #endif
767  )
768  {
769  passPhrase = Getpass(_("Enter pass phrase: "));
770  if (rpmCheckPassPhrase(passPhrase)) {
771  fprintf(stderr, _("Pass phrase check failed\n"));
772  ec = EXIT_FAILURE;
773  goto exit;
774  }
775  fprintf(stderr, _("Pass phrase is good.\n"));
776  /* XXX Getpass() should realloc instead. */
777  passPhrase = xstrdup(passPhrase);
778  }
779  }
780  }
781  /*@=branchstate@*/
782 #endif /* IAM_RPMBT || IAM_RPMK */
783 
784  if (rpmioPipeOutput) {
785  if (pipe(p) < 0) {
786  fprintf(stderr, _("creating a pipe for --pipe failed: %m\n"));
787  goto exit;
788  }
789 
790  if (!(pipeChild = fork())) {
791  (void) close(p[1]);
792  (void) dup2(p[0], STDIN_FILENO);
793  (void) close(p[0]);
794  (void) execl("/bin/sh", "/bin/sh", "-c", rpmioPipeOutput, NULL);
795  fprintf(stderr, _("exec failed\n"));
796  }
797 
798  (void) close(p[0]);
799  (void) dup2(p[1], STDOUT_FILENO);
800  (void) close(p[1]);
801  }
802 
803  ts = rpmtsCreate();
805  switch (bigMode) {
806 #ifdef IAM_RPMDB
807  case MODE_REBUILDDB:
809  rpmVSFlags ovsflags;
810 
811  vsflags = (rpmVSFlags) rpmExpandNumeric("%{?_vsflags_rebuilddb}");
812  vsflags = (rpmVSFlags) 0; /* XXX FIXME: ignore default disablers. */
813 #if defined(SUPPORT_NOSIGNATURES)
814  if (!QVA_ISSET(rpmcliQueryFlags, DIGEST)) {
815  VSF_SET(vsflags, NOSHA1HEADER);
816  VSF_SET(vsflags, NOMD5HEADER);
817  VSF_SET(vsflags, NOSHA1);
818  VSF_SET(vsflags, NOMD5);
819  }
820  if (!QVA_ISSET(rpmcliQueryFlags, SIGNATURE)) {
821  VSF_SET(vsflags, NODSAHEADER);
822  VSF_SET(vsflags, NORSAHEADER);
823  VSF_SET(vsflags, NODSA);
824  VSF_SET(vsflags, NORSA);
825  }
826  if (!QVA_ISSET(rpmcliQueryFlags, HDRCHK)) {
827  VSF_SET(vsflags, NOHDRCHK);
828  }
829  VSF_CLR(vsflags, NEEDPAYLOAD);
830 #endif
831 
832  ovsflags = rpmtsSetVSFlags(ts, vsflags);
833  ec = rpmtsRebuildDB(ts);
834  vsflags = rpmtsSetVSFlags(ts, ovsflags);
835  } break;
836 #endif /* IAM_RPMDB */
837 
838 #ifdef IAM_RPMBT
839  case MODE_REBUILD:
840  case MODE_RECOMPILE:
841  { const char * pkg;
842  int nbuilds = 0;
843 
844  while (!rpmIsVerbose())
846 
847  if (!poptPeekArg(optCon))
848  argerror(_("no packages files given for rebuild"));
849 
850  ba->buildAmount =
852  if (bigMode == MODE_REBUILD) {
858  }
859 
860  while ((pkg = poptGetArg(optCon))) {
861  if (nbuilds++ > 0) {
863  rpmFreeRpmrc();
865  }
866  ba->specFile = NULL;
867  ba->cookie = NULL;
868  ec = rpmInstallSource(ts, pkg, &ba->specFile, &ba->cookie);
869  if (ec == 0) {
870  ba->rootdir = rpmioRootDir;
871  ba->passPhrase = passPhrase;
872  ec = build(ts, ba, NULL);
873  }
874  ba->cookie = _free(ba->cookie);
875  ba->specFile = _free(ba->specFile);
876 
877  if (ec)
878  /*@loopbreak@*/ break;
879  }
880 
881  } break;
882 
883  case MODE_BUILD:
884  case MODE_TARBUILD:
885  { int nbuilds = 0;
886 
887 #if defined(RPM_VENDOR_OPENPKG) /* no-auto-verbose-increase-for-track-and-fetch */
888  if (ba->buildChar != 't' && ba->buildChar != 'f')
889 #endif
890  while (!rpmIsVerbose())
892 
893  switch (ba->buildChar) {
894  case 'a':
896  /*@fallthrough@*/
897  case 'b':
900 #if defined(RPM_VENDOR_MANDRIVA)
901  if ((ba->buildChar == 'a' || ba->buildChar == 'b') && ba->shortCircuit)
902 #else
903  if ((ba->buildChar == 'b') && ba->shortCircuit)
904 #endif
905  /*@innerbreak@*/ break;
906  /*@fallthrough@*/
907  case 'i':
910  if ((ba->buildChar == 'i') && ba->shortCircuit)
911  /*@innerbreak@*/ break;
912  /*@fallthrough@*/
913  case 'c':
915  if ((ba->buildChar == 'c') && ba->shortCircuit)
916  /*@innerbreak@*/ break;
917  /*@fallthrough@*/
918  case 'p':
919  ba->buildAmount |= RPMBUILD_PREP;
920  /*@innerbreak@*/ break;
921 
922  case 'l':
924  /*@innerbreak@*/ break;
925  case 's':
927 #if defined(RPM_VENDOR_OPENPKG) || defined(RPM_VENDOR_MANDRIVA) || defined(RPM_VENDOR_ARK) /* no-deps-on-building-srpms */
928  /* enforce no dependency checking when rolling a source RPM */
929  ba->noDeps = 1;
930 #endif
931  /*@innerbreak@*/ break;
932  case 't': /* support extracting the "%track" script/section */
934  /* enforce no dependency checking and expansion of %setup, %patch and %prep macros */
935  ba->noDeps = 1;
936  rpmDefineMacro(NULL, "setup #", RMIL_CMDLINE);
937  rpmDefineMacro(NULL, "patch #", RMIL_CMDLINE);
938  rpmDefineMacro(NULL, "prep %%prep", RMIL_CMDLINE);
939  /*@innerbreak@*/ break;
940  case 'f':
942  ba->noDeps = 1;
943  /*@innerbreak@*/ break;
944  }
945 
946  if (!poptPeekArg(optCon)) {
947  if (bigMode == MODE_BUILD)
948  argerror(_("no spec files given for build"));
949  else
950  argerror(_("no tar files given for build"));
951  }
952 
953  while ((ba->specFile = poptGetArg(optCon))) {
954  if (nbuilds++ > 0) {
956  rpmFreeRpmrc();
958  }
959  ba->rootdir = rpmioRootDir;
960  ba->passPhrase = passPhrase;
961  ba->cookie = NULL;
962  ec = build(ts, ba, NULL);
963  if (ec)
964  /*@loopbreak@*/ break;
965  }
966  } break;
967 #endif /* IAM_RPMBT */
968 
969 #ifdef IAM_RPMEIU
970  case MODE_ERASE:
972  if (ia->noDeps) IIF_SET(ia->installInterfaceFlags, NODEPS);
973 
974  if (!poptPeekArg(optCon)) {
975  if (ia->rbtid == 0)
976  argerror(_("no packages given for erase"));
977 TSF_SET(ia->transFlags, NOFDIGESTS);
978 PFF_SET(ia->probFilter, OLDPACKAGE);
981 ia->rbRun = rpmcliInstallRun;
982  ec += rpmRollback(ts, ia, NULL);
983  } else {
984  ec += rpmErase(ts, ia, (const char **) poptGetArgs(optCon));
985  }
986  break;
987 
988  case MODE_INSTALL:
989 
990  /* RPMTRANS_FLAG_KEEPOBSOLETE */
991 
993  if (!ia->incldocs) {
994  if (ia->transFlags & RPMTRANS_FLAG_NODOCS) {
995  ;
996  } else if (rpmExpandNumeric("%{_excludedocs}"))
997  TSF_SET(ia->transFlags, NODOCS);
998  }
999 
1000  if (ia->noDeps) IIF_SET(ia->installInterfaceFlags, NODEPS);
1001 
1002  /* we've already ensured !(!ia->prefix && !ia->relocations) */
1003  /*@-branchstate@*/
1004  if (ia->qva_prefix) {
1006  NULL, ia->qva_prefix);
1008  NULL, NULL);
1009  } else if (ia->relocations) {
1011  NULL, NULL);
1012  }
1013  /*@=branchstate@*/
1014 
1015  if (!poptPeekArg(optCon)) {
1016  if (ia->rbtid == 0)
1017  argerror(_("no packages given for install"));
1018 TSF_SET(ia->transFlags, NOFDIGESTS);
1019 PFF_SET(ia->probFilter, OLDPACKAGE);
1022 ia->rbRun = rpmcliInstallRun;
1023 /*@i@*/ ec += rpmRollback(ts, ia, NULL);
1024  } else {
1025  /*@-compdef -compmempass@*/ /* FIX: ia->relocations[0].newPath undefined */
1026  ec += rpmcliInstall(ts, ia, (const char **)poptGetArgs(optCon));
1027  /*@=compdef =compmempass@*/
1028  }
1029  break;
1030 
1031 #endif /* IAM_RPMEIU */
1032 
1033 #ifdef IAM_RPMQV
1034  case MODE_QUERY:
1035  if (!poptPeekArg(optCon)
1036  && !(qva->qva_source == RPMQV_ALL || qva->qva_source == RPMQV_HDLIST))
1037  argerror(_("no arguments given for query"));
1038 
1040  qva->qva_specQuery = rpmspecQuery;
1041  ec = rpmcliQuery(ts, qva, (const char **) poptGetArgs(optCon));
1042  qva->qva_specQuery = NULL;
1043  break;
1044 
1045  case MODE_VERIFY:
1047 
1049 #ifdef __cplusplus
1050  *((unsigned *)&vflags) &= ~qva->qva_flags;
1051 #else
1052  vflags &= ~qva->qva_flags;
1053 #endif
1054  qva->qva_flags = (rpmQueryFlags) vflags;
1055 
1056  if (!poptPeekArg(optCon)
1057  && !(qva->qva_source == RPMQV_ALL || qva->qva_source == RPMQV_HDLIST))
1058  argerror(_("no arguments given for verify"));
1059  ec = rpmcliVerify(ts, qva, (const char **) poptGetArgs(optCon));
1060  } break;
1061 #endif /* IAM_RPMQV */
1062 
1063 #ifdef IAM_RPMK
1064  case MODE_CHECKSIG:
1065  { rpmVerifyFlags vflags = (rpmVerifyFlags) 0;
1066 
1067  QVA_SET(vflags, FDIGEST);
1068  QVA_SET(vflags, HDRCHK);
1069  QVA_SET(vflags, DIGEST);
1070  QVA_SET(vflags, SIGNATURE);
1071 #ifdef __cplusplus
1072  *((unsigned *)&vflags) &= ~ka->qva_flags;
1073 #else
1074  vflags &= ~ka->qva_flags;
1075 #endif
1076  ka->qva_flags = (rpmQueryFlags) vflags;
1077  } /*@fallthrough@*/
1078  case MODE_RESIGN:
1079  if (!poptPeekArg(optCon))
1080  argerror(_("no arguments given"));
1081  ka->passPhrase = passPhrase;
1082  ec = rpmcliSign(ts, ka, (const char **)poptGetArgs(optCon));
1083  break;
1084 #endif /* IAM_RPMK */
1085 
1086 #if !defined(IAM_RPMQV)
1087  case MODE_QUERY:
1088  case MODE_VERIFY:
1089 #endif
1090 #if !defined(IAM_RPMK)
1091  case MODE_CHECKSIG:
1092  case MODE_RESIGN:
1093 #endif
1094 #if !defined(IAM_RPMDB)
1095  case MODE_REBUILDDB:
1096 #endif
1097 #if !defined(IAM_RPMBT)
1098  case MODE_BUILD:
1099  case MODE_REBUILD:
1100  case MODE_RECOMPILE:
1101  case MODE_TARBUILD:
1102 #endif
1103 #if !defined(IAM_RPMEIU)
1104  case MODE_INSTALL:
1105  case MODE_ERASE:
1106 #endif
1107  case MODE_UNKNOWN:
1108 #ifdef DYING /* XXX rpmIsVerbose alone stops usage spewage with every --eval */
1109  if (poptPeekArg(optCon) != NULL || argc <= 1 || rpmIsVerbose()) {
1110  printUsage(optCon, stderr, 0);
1111  ec = argc;
1112  }
1113 #endif
1114  break;
1115  }
1116 
1117 #if defined(IAM_RPMBT) || defined(IAM_RPMK)
1118 exit:
1119 #endif /* IAM_RPMBT || IAM_RPMK */
1120 
1121  (void)rpmtsFree(ts);
1122  ts = NULL;
1123 
1124  if (pipeChild) {
1125  (void) fclose(stdout);
1126  (void) waitpid(pipeChild, &status, 0);
1127  }
1128 
1129 #ifdef IAM_RPMQV
1130  qva->qva_queryFormat = _free(qva->qva_queryFormat);
1131 #endif
1132 
1133 #ifdef IAM_RPMBT
1134  freeNames();
1135  /* XXX _specPool/_pkgPool teardown should be done somewhere else. */
1136  { extern rpmioPool _pkgPool;
1137  extern rpmioPool _specPool;
1138  _pkgPool = rpmioFreePool(_pkgPool);
1139  _specPool = rpmioFreePool(_specPool);
1140  }
1141 #endif
1142 
1143 #ifdef IAM_RPMEIU
1145 #endif
1146 
1147  optCon = rpmcliFini(optCon);
1148 
1149 /* XXX limit the fiddle up to linux for now. */
1150 #if 0 && !defined(HAVE_SETPROCTITLE) && defined(__linux__)
1151  (void) finiproctitle();
1152 #endif
1153 
1154  /* XXX don't overflow single byte exit status */
1155  /* XXX status 255 is special to xargs(1) */
1156  if (ec > 254) ec = 254;
1157 
1158  rpmlog(RPMLOG_DEBUG, D_("exit code: %d\n"), ec);
1159 
1160  /*@-globstate@*/
1161  return ec;
1162  /*@=globstate@*/
1163 }
1164 /*@=mods@*/
1165 /*@=bounds@*/
rpmRelocation relocations
Definition: rpmcli.h:683
int xx
Definition: spec.c:744
rpmdepFlags depFlags
Definition: rpmcli.h:671
rpmioPool _specPool
Definition: spec.c:626
int build(rpmts ts, BTA_t ba, const char *rcfile)
Definition: build.c:281
int qva_sourceCount
Definition: rpmcli.h:632
rpmlog(RPMLOG_ERR,"%s\n", buf)
struct poptOption rpmcliDepFlagsPoptTable[]
Definition: poptALL.c:382
#define VSF_SET(_vsflags, _FLAG)
Definition: rpmqv.c:99
struct poptOption rpmBuildPoptTable[]
Definition: poptBT.c:119
const char * qva_prefix
Definition: rpmcli.h:657
#define EXIT_FAILURE
char * xstrdup(const char *str)
Definition: rpmmalloc.c:321
int rpmCheckPassPhrase(const char *passPhrase)
Check for valid pass phrase by invoking a helper.
Definition: signature.c:489
#define MODES_K
Definition: rpmqv.c:135
int rpmReadConfigFiles(const char *file, const char *target)
Definition: rpmrc.c:1095
void rpmluaSetPrintBuffer(rpmlua _lua, int flag)
#define __progname
Definition: system.h:363
int rpmspecQuery(rpmts ts, QVA_t qva, const char *arg)
Function to query spec file(s).
Definition: spec.c:968
const char * rpmEVR
Definition: depends.c:46
struct rpmts_s * rpmts
The RPM Transaction Set.
Definition: rpmtypes.h:14
int rc
Definition: poptALL.c:670
static struct poptOption optionsTable[]
Definition: rpmqv.c:148
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
urltype urlIsURL(const char *url)
Return type of URL.
Definition: url.c:409
int main(int argc, const char **argv, char **envp)
Definition: rpmqv.c:433
#define PFF_SET(_pfflags, _FLAG)
Definition: rpmqv.c:111
rpmQueryFlags qva_flags
Definition: rpmcli.h:633
struct poptOption rpmioFtsPoptTable[]
Definition: poptIO.c:529
struct rpmBuildArguments_s rpmBTArgs
Definition: poptBT.c:29
int Stat(const char *path, struct stat *st)
stat(2) clone.
Definition: rpmrpc.c:1361
#define MODES_FOR_NODEPS
Definition: rpmqv.c:142
Access mounted file system information.
char ** environ
int rpmtsRebuildDB(rpmts ts)
Rebuild the database used by the transaction.
Definition: rpmts.c:136
rpmiob rpmiobFree(rpmiob iob)
Destroy a I/O buffer instance.
#define QVA_ISSET(_qvaflags, _FLAG)
Definition: rpmqv.c:94
#define _noTransScripts
Definition: rpmts.h:103
int rpmcliVerify(rpmts ts, QVA_t qva, const char **argv)
Verify package install.
Definition: verify.c:656
argv
Definition: rpmmtree.c:3679
pid_t result
Definition: rpmsq.c:737
Command line option information.
Definition: rpmcli.h:630
const char * rpmioPipeOutput
Definition: poptIO.c:123
int rpmiobSlurp(const char *fn, rpmiob *iobp)
Definition: rpmiob.c:129
QSpecF_t qva_specQuery
Definition: rpmcli.h:646
struct rpmiob_s * rpmiob
Definition: rpmiotypes.h:60
char * passPhrase
Definition: rpmts-py.c:1340
#define MODES_QV
Definition: rpmqv.c:121
#define MODES_FOR_TEST
Definition: rpmqv.c:143
#define _noTransTriggers
Definition: rpmts.h:112
struct rpmQVKArguments_s rpmQVKArgs
Definition: poptQV.c:19
goto exit
Definition: db3.c:1903
#define VSF_CLR(_vsflags, _FLAG)
Definition: rpmqv.c:100
int rpmcliInstallOrder(rpmts ts)
Order package elements in a transaction set, reporting problems.
Definition: rpminstall.c:350
rpmuint32_t rpmlibVendor(void)
Definition: rpmversion.c:21
rpmFreeMacros(NULL)
rpmts rpmtsCreate(void)
Create an empty transaction set.
Definition: rpmts.c:1468
void rpmtsSetRootDir(rpmts ts, const char *rootDir)
Set transaction rootDir, i.e.
Definition: rpmts.c:925
rpmQueryFlags rpmcliQueryFlags
Bit(s) from common command line options.
Definition: poptALL.c:172
const char * specFile
Definition: rpmcli.h:725
struct poptOption rpmInstallPoptTable[]
Definition: poptI.c:204
const char * rootdir
Definition: rpmcli.h:735
rpmRC rpmnsProbeSignature(void *_ts, const char *fn, const char *sigfn, const char *pubfn, const char *pubid, int flags)
Verify OpenPGP signature on a file.
Definition: rpmns.c:323
enum rpmVerifyFlags_e rpmVerifyFlags
Bit(s) to control rpmVerify() operation, stored in qva_flags.
char * p
Definition: macro.c:413
Structures and prototypes used for an &quot;rpmps&quot; problem set.
HE_t ec
Definition: hdrfmt.c:6710
fprintf(stderr,"--> %s(%p,%p,%p) sig %p sigp %p\n", __FUNCTION__, dig, t, rsactx, sig, sigp)
#define N_(Text)
Definition: system.h:531
struct poptOption rpmQueryPoptTable[]
Query mode options.
Definition: poptQV.c:325
#define MODES_FOR_ROOT
Definition: rpmqv.c:144
const char * rpmioRootDir
Definition: poptIO.c:126
#define QVA_SET(_qvaflags, _FLAG)
Definition: rpmqv.c:95
int rpmcliInstall(rpmts ts, QVA_t ia, const char **argv)
Install/upgrade/freshen binary rpm package.
Definition: rpminstall.c:535
int rpmDefineMacro(MacroContext mc, const char *macro, int level)
Define macro in context.
Definition: macro.c:2789
int rpmfiAddRelocation(rpmRelocation *relp, int *nrelp, const char *oldPath, const char *newPath)
Add relocation element to array.
Definition: rpmfi.c:1726
rpmtransFlags transFlags
Definition: rpmcli.h:672
rpmuint32_t rbtid
Definition: rpmcli.h:676
static void argerror(const char *desc)
Definition: rpmqv.c:214
char * progname
Definition: rpmdeps.c:20
rpmQVSources qva_source
Definition: rpmcli.h:631
#define MODES_DB
Definition: rpmqv.c:138
rpmioPool _pkgPool
Definition: spec.c:188
int rpmRollback(rpmts ts, QVA_t ia, const char **argv)
Definition: rpmrollback.c:421
#define RPM_NAME
Definition: config.h:1148
Generate and verify rpm package signatures.
const char * qva_queryFormat
Definition: rpmcli.h:650
void * rpmluaFree(rpmlua lua)
void freeNames(void)
Destroy uid/gid caches.
Definition: names.c:32
char * rpmExpand(const char *arg,...)
Return (malloc&#39;ed) concatenated macro expansion(s).
Definition: macro.c:3178
struct poptOption rpmDatabasePoptTable[]
Definition: poptDB.c:36
int rpmtsOpenDB(rpmts ts, int dbmode)
Open the database used by the transaction.
Definition: rpmts.c:115
rpmlua rpmluaNew(void)
rpmRelocation rpmfiFreeRelocations(rpmRelocation relocs)
Free relocation array.
Definition: rpmfi.c:1738
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
Definition: rpmts.h:35
rpmInstallInterfaceFlags installInterfaceFlags
Definition: rpmcli.h:674
const char * passPhrase
Definition: rpmcli.h:655
rpmuint32_t rpmlibVersion(void)
Definition: rpmversion.c:11
rpmprobFilterFlags probFilter
Definition: rpmcli.h:673
rpmFreeRpmrc()
Definition: rpmrc.c:1006
optCon
Definition: poptALL.c:604
int rpmcliQuery(rpmts ts, QVA_t qva, const char **argv)
Display package information.
Definition: query.c:956
int rpmInstallSource(rpmts ts, const char *arg, const char **specFilePtr, const char **cookie)
Install source rpm package.
Definition: rpminstall.c:893
rpmuint32_t rpmlibTimestamp(void)
Definition: rpmversion.c:16
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
Definition: rpmts.c:843
struct poptOption rpmcliAllPoptTable[]
Popt option table for options shared by all modes and executables.
Definition: poptALL.c:417
char * rpmiobStr(rpmiob iob)
Return I/O buffer (as string).
Definition: rpmiob.c:112
#define L(CS)
Definition: fnmatch.c:161
int global_depFlags
Definition: poptALL.c:379
return strcmp(ame->name, bme->name)
#define IIF_SET(_iflags, _FLAG)
Definition: rpmqv.c:107
This is the only module users of librpmbuild should need to include.
struct rpmQVKArguments_s rpmIArgs
Definition: poptI.c:23
struct rpmQVKArguments_s rpmDBArgs
Definition: poptDB.c:32
void rpmcliConfigured(void)
Make sure that rpm configuration has been read.
Definition: poptALL.c:203
Structures and prototypes used for an &quot;rpmts&quot; transaction set.
int flags
Definition: fnmatch.c:282
struct poptOption rpmVerifyPoptTable[]
Verify mode options.
Definition: poptQV.c:382
enum rpmQueryFlags_e rpmQueryFlags
Bit(s) to control rpmQuery() operation, stored in qva_flags.
int rpmcliInstallCheck(rpmts ts)
Check package element dependencies in a transaction set, reporting problems.
Definition: rpminstall.c:343
int(* rbOrder)(rpmts ts)
Definition: rpmcli.h:691
#define rpmIsVerbose()
Definition: rpmcb.h:21
#define TSF_SET(_tsflags, _FLAG)
Definition: rpmqv.c:103
return NULL
Definition: poptALL.c:613
int rpmErase(rpmts ts, QVA_t ia, const char **argv)
Erase binary rpm package.
Definition: rpminstall.c:781
int(* rbCheck)(rpmts ts)
Definition: rpmcli.h:690
struct rpmlua_s * rpmlua
Definition: rpmlua.h:53
int rpmcliSign(rpmts ts, QVA_t qva, const char **argv)
Create/Modify/Check elements from signature header.
Definition: rpmchecksig.c:1304
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
Definition: spec.c:737
#define _(Text)
Definition: system.h:29
status
Definition: rpmsq.c:792
#define RMIL_CMDLINE
Definition: rpmmacro.h:59
Access RPM indices using Berkeley DB interface(s).
#define MODES_IE
Definition: rpmqv.c:125
#define D_(Text)
Definition: system.h:526
poptContext
Definition: poptALL.c:525
rpmVSFlags vsflags
Definition: rpmrepo.c:161
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Definition: rpmiotypes.h:647
static void printVersion(FILE *fp)
Display rpm version.
Definition: poptALL.c:193
Describe build command line request.
Definition: rpmcli.h:718
enum rpmdepFlags_e rpmdepFlags
Bit(s) to control rpmtsCheck() and rpmtsOrder() operation.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
Definition: macro.c:3252
struct poptOption rpmSignPoptTable[]
Signature mode options.
Definition: poptQV.c:489
const char ** av
Definition: rpmts-py.c:788
const char * cookie
Definition: rpmcli.h:724
modes
Definition: rpmqv.c:116
const char * passPhrase
Definition: rpmcli.h:722
rpmioPool rpmioFreePool(rpmioPool pool)
Reclaim memory pool items.
Definition: rpmmalloc.c:72
#define rpmIncreaseVerbosity()
Definition: rpmcb.h:15
int(* rbRun)(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
Definition: rpmcli.h:692
int rpmcliInstallRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
Install/erase package elements in a transaction set, reporting problems.
Definition: rpminstall.c:357
Spec spec
Definition: spec-py.c:121
char *(* Getpass)(const char *prompt)
Return a password.
Definition: rpmku.c:154