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