1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
/** \ingroup rpmcli
* \file lib/poptI.c
* Popt tables for install modes.
*/
#include "system.h"
#include <rpmcli.h>
#include "debug.h"
/*@-redecl@*/
extern time_t get_date(const char * p, void * now); /* XXX expedient lies */
/*@=redecl@*/
/*@unchecked@*/
struct rpmInstallArguments_s rpmIArgs;
#define POPT_RELOCATE -1021
#define POPT_EXCLUDEPATH -1022
#define POPT_ROLLBACK -1023
/*@exits@*/
static void argerror(const char * desc)
/*@globals stderr, fileSystem @*/
/*@modifies stderr, fileSystem @*/
{
/*@-modfilesys -globs @*/
fprintf(stderr, _("%s: %s\n"), __progname, desc);
/*@=modfilesys =globs @*/
exit(EXIT_FAILURE);
}
/**
*/
/*@-bounds@*/
static void installArgCallback( /*@unused@*/ poptContext con,
/*@unused@*/ enum poptCallbackReason reason,
const struct poptOption * opt, const char * arg,
/*@unused@*/ const void * data)
/*@globals rpmIArgs, stderr, fileSystem @*/
/*@modifies rpmIArgs, stderr, fileSystem @*/
{
struct rpmInstallArguments_s * ia = &rpmIArgs;
/* XXX avoid accidental collisions with POPT_BIT_SET for flags */
/*@-branchstate@*/
if (opt->arg == NULL)
switch (opt->val) {
case 'i':
ia->installInterfaceFlags |= INSTALL_INSTALL;
break;
case POPT_EXCLUDEPATH:
if (arg == NULL || *arg != '/')
argerror(_("exclude paths must begin with a /"));
ia->relocations = xrealloc(ia->relocations,
sizeof(*ia->relocations) * (ia->numRelocations + 1));
/*@-temptrans@*/
ia->relocations[ia->numRelocations].oldPath = xstrdup(arg);
/*@=temptrans@*/
ia->relocations[ia->numRelocations].newPath = NULL;
ia->numRelocations++;
break;
case POPT_RELOCATE:
{ char * oldPath = NULL;
char * newPath = NULL;
if (arg == NULL || *arg != '/')
argerror(_("relocations must begin with a /"));
oldPath = xstrdup(arg);
if (!(newPath = strchr(oldPath, '=')))
argerror(_("relocations must contain a ="));
*newPath++ = '\0';
if (*newPath != '/')
argerror(_("relocations must have a / following the ="));
ia->relocations = xrealloc(ia->relocations,
sizeof(*ia->relocations) * (ia->numRelocations + 1));
/*@-temptrans@*/
ia->relocations[ia->numRelocations].oldPath = oldPath;
/*@=temptrans@*/
/*@-kepttrans -usereleased @*/
ia->relocations[ia->numRelocations].newPath = newPath;
/*@=kepttrans =usereleased @*/
ia->numRelocations++;
} break;
case POPT_ROLLBACK:
{ time_t tid;
if (arg == NULL)
argerror(_("rollback takes a time/date stamp argument"));
/*@-moduncon@*/
tid = get_date(arg, NULL);
/*@=moduncon@*/
if (tid == (time_t)-1 || tid == (time_t)0)
argerror(_("malformed rollback time/date stamp argument"));
ia->rbtid = tid;
} break;
case RPMCLI_POPT_NODIGEST:
ia->qva_flags |= VERIFY_DIGEST;
break;
case RPMCLI_POPT_NOSIGNATURE:
ia->qva_flags |= VERIFY_SIGNATURE;
break;
case RPMCLI_POPT_NOHDRCHK:
ia->qva_flags |= VERIFY_HDRCHK;
break;
case RPMCLI_POPT_NODEPS:
ia->noDeps = 1;
break;
case RPMCLI_POPT_NOMD5:
ia->transFlags |= RPMTRANS_FLAG_NOMD5;
break;
case RPMCLI_POPT_FORCE:
ia->probFilter |=
( RPMPROB_FILTER_REPLACEPKG
| RPMPROB_FILTER_REPLACEOLDFILES
| RPMPROB_FILTER_REPLACENEWFILES
| RPMPROB_FILTER_OLDPACKAGE );
break;
case RPMCLI_POPT_NOSCRIPTS:
ia->transFlags |= (_noTransScripts | _noTransTriggers);
break;
}
/*@=branchstate@*/
}
/*@=bounds@*/
/**
*/
/*@-bitwisesigned -compmempass @*/
/*@unchecked@*/
struct poptOption rpmInstallPoptTable[] = {
/*@-type@*/ /* FIX: cast? */
{ NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
installArgCallback, 0, NULL, NULL },
/*@=type@*/
{ "aid", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
&rpmIArgs.transFlags, RPMTRANS_FLAG_ADDINDEPS,
N_("add suggested packages to transaction"), NULL },
{ "allfiles", '\0', POPT_BIT_SET,
&rpmIArgs.transFlags, RPMTRANS_FLAG_ALLFILES,
N_("install all files, even configurations which might otherwise be skipped"),
NULL},
{ "allmatches", '\0', POPT_BIT_SET,
&rpmIArgs.eraseInterfaceFlags, UNINSTALL_ALLMATCHES,
N_("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"),
NULL},
{ "apply", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
(_noTransScripts|_noTransTriggers|
RPMTRANS_FLAG_APPLYONLY|RPMTRANS_FLAG_PKGCOMMIT),
N_("do not execute package scriptlet(s)"), NULL },
{ "badreloc", '\0', POPT_BIT_SET,
&rpmIArgs.probFilter, RPMPROB_FILTER_FORCERELOCATE,
N_("relocate files in non-relocateable package"), NULL},
{ "dirstash", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
&rpmIArgs.transFlags, RPMTRANS_FLAG_DIRSTASH,
N_("save erased package files by renaming into sub-directory"), NULL},
{ "erase", 'e', POPT_BIT_SET,
&rpmIArgs.installInterfaceFlags, INSTALL_ERASE,
N_("erase (uninstall) package"), N_("<package>+") },
{ "excludedocs", '\0', POPT_BIT_SET,
&rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
N_("do not install documentation"), NULL},
{ "excludepath", '\0', POPT_ARG_STRING, 0, POPT_EXCLUDEPATH,
N_("skip files with leading component <path> "),
N_("<path>") },
#ifdef DYING
{ "force", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
(RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES | RPMPROB_FILTER_OLDPACKAGE),
N_("short hand for --replacepkgs --replacefiles"), NULL},
#else
{ "force", '\0', 0, NULL, RPMCLI_POPT_FORCE,
N_("short hand for --replacepkgs --replacefiles"), NULL},
#endif
{ "freshen", 'F', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags,
(INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL),
N_("upgrade package(s) if already installed"),
N_("<packagefile>+") },
{ "hash", 'h', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags, INSTALL_HASH,
N_("print hash marks as package installs (good with -v)"), NULL},
{ "ignorearch", '\0', POPT_BIT_SET,
&rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREARCH,
N_("don't verify package architecture"), NULL},
{ "ignoreos", '\0', POPT_BIT_SET,
&rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREOS,
N_("don't verify package operating system"), NULL},
{ "ignoresize", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
(RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES),
N_("don't check disk space before installing"), NULL},
{ "includedocs", '\0', POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.incldocs, 0,
N_("install documentation"), NULL},
#ifdef DYING
{ "install", '\0', POPT_BIT_SET,
&rpmIArgs.installInterfaceFlags, INSTALL_INSTALL,
N_("install package(s)"), N_("<packagefile>+") },
#else
{ "install", 'i', 0, NULL, 'i',
N_("install package(s)"), N_("<packagefile>+") },
#endif
{ "justdb", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_JUSTDB,
N_("update the database, but do not modify the filesystem"), NULL},
#ifdef DYING
{ "nodeps", '\0', 0, &rpmIArgs.noDeps, 0,
N_("do not verify package dependencies"), NULL },
#else
{ "nodeps", '\0', 0, NULL, RPMCLI_POPT_NODEPS,
N_("do not verify package dependencies"), NULL },
#endif
{ "nomd5", '\0', 0, NULL, RPMCLI_POPT_NOMD5,
N_("don't verify MD5 digest of files"), NULL },
{ "noorder", '\0', POPT_BIT_SET,
&rpmIArgs.installInterfaceFlags, INSTALL_NOORDER,
N_("do not reorder package installation to satisfy dependencies"),
NULL},
{ "nosuggest", '\0', POPT_BIT_SET, &rpmIArgs.transFlags,
RPMTRANS_FLAG_NOSUGGEST,
N_("do not suggest missing dependency resolution(s)"), NULL},
#ifdef DYING
{ "noscripts", '\0', POPT_BIT_SET, &rpmIArgs.transFlags,
(_noTransScripts|_noTransTriggers),
N_("do not execute package scriptlet(s)"), NULL },
#else
{ "noscripts", '\0', 0, NULL, RPMCLI_POPT_NOSCRIPTS,
N_("do not execute package scriptlet(s)"), NULL },
#endif
{ "nopre", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
RPMTRANS_FLAG_NOPRE,
N_("do not execute %%pre scriptlet (if any)"), NULL },
{ "nopost", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
RPMTRANS_FLAG_NOPOST,
N_("do not execute %%post scriptlet (if any)"), NULL },
{ "nopreun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
RPMTRANS_FLAG_NOPREUN,
N_("do not execute %%preun scriptlet (if any)"), NULL },
{ "nopostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
RPMTRANS_FLAG_NOPOSTUN,
N_("do not execute %%postun scriptlet (if any)"), NULL },
#ifdef DYING
{ "nodigest", '\0', POPT_BIT_SET, &rpmIArgs.qva_flags, VERIFY_DIGEST,
N_("don't verify package digest(s)"), NULL },
{ "nohdrchk", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.qva_flags, VERIFY_HDRCHK,
N_("don't verify database header(s) when retrieved"), NULL },
{ "nosignature", '\0', POPT_BIT_SET, &rpmIArgs.qva_flags, VERIFY_SIGNATURE,
N_("don't verify package signature(s)"), NULL },
#else
{ "nodigest", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NODIGEST,
N_("don't verify package digest(s)"), NULL },
{ "nohdrchk", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOHDRCHK,
N_("don't verify database header(s) when retrieved"), NULL },
{ "nosignature", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOSIGNATURE,
N_("don't verify package signature(s)"), NULL },
#endif
{ "notriggers", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, _noTransTriggers,
N_("do not execute any scriptlet(s) triggered by this package"), NULL},
{ "notriggerprein", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
&rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPREIN,
N_("do not execute any %%triggerprein scriptlet(s)"), NULL},
{ "notriggerin", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
&rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERIN,
N_("do not execute any %%triggerin scriptlet(s)"), NULL},
{ "notriggerun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
&rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERUN,
N_("do not execute any %%triggerun scriptlet(s)"), NULL},
{ "notriggerpostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
&rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPOSTUN,
N_("do not execute any %%triggerpostun scriptlet(s)"), NULL},
{ "oldpackage", '\0', POPT_BIT_SET,
&rpmIArgs.probFilter, RPMPROB_FILTER_OLDPACKAGE,
N_("upgrade to an old version of the package (--force on upgrades does this automatically)"),
NULL},
{ "percent", '\0', POPT_BIT_SET,
&rpmIArgs.installInterfaceFlags, INSTALL_PERCENT,
N_("print percentages as package installs"), NULL},
{ "prefix", '\0', POPT_ARG_STRING, &rpmIArgs.prefix, 0,
N_("relocate the package to <dir>, if relocatable"),
N_("<dir>") },
{ "relocate", '\0', POPT_ARG_STRING, 0, POPT_RELOCATE,
N_("relocate files from path <old> to <new>"),
N_("<old>=<new>") },
{ "repackage", '\0', POPT_BIT_SET,
&rpmIArgs.transFlags, RPMTRANS_FLAG_REPACKAGE,
N_("save erased package files by repackaging"), NULL},
{ "replacefiles", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
(RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES),
N_("install even if the package replaces installed files"), NULL},
{ "replacepkgs", '\0', POPT_BIT_SET,
&rpmIArgs.probFilter, RPMPROB_FILTER_REPLACEPKG,
N_("reinstall if the package is already present"), NULL},
{ "rollback", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_ROLLBACK,
N_("deinstall new, reinstall old, package(s), back to <date>"),
N_("<date>") },
{ "test", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_TEST,
N_("don't install, but tell if it would work or not"), NULL},
{ "upgrade", 'U', POPT_BIT_SET,
&rpmIArgs.installInterfaceFlags, (INSTALL_UPGRADE|INSTALL_INSTALL),
N_("upgrade package(s)"),
N_("<packagefile>+") },
POPT_TABLEEND
};
/*@=bitwisesigned =compmempass @*/
|