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