1 /** \ingroup rpmcli
2 * \file lib/poptI.c
3 * Popt tables for install modes.
4 */
5
6 #include "system.h"
7
8 #include <rpm/rpmcli.h>
9
10 #include "debug.h"
11
12 struct rpmInstallArguments_s rpmIArgs = {
13 0, /* transFlags */
14 0, /* probFilter */
15 0, /* installInterfaceFlags */
16 0, /* numRelocations */
17 0, /* noDeps */
18 0, /* incldocs */
19 NULL, /* relocations */
20 NULL, /* prefix */
21 };
22
23 #define POPT_RELOCATE -1021
24 #define POPT_EXCLUDEPATH -1022
25
26 RPM_GNUC_NORETURN
argerror(const char * desc)27 static void argerror(const char * desc)
28 {
29 fprintf(stderr, "%s: %s\n", xgetprogname(), desc);
30 exit(EXIT_FAILURE);
31 }
32
33 /**
34 */
installArgCallback(poptContext con,enum poptCallbackReason reason,const struct poptOption * opt,const char * arg,const void * data)35 static void installArgCallback( poptContext con,
36 enum poptCallbackReason reason,
37 const struct poptOption * opt, const char * arg,
38 const void * data)
39 {
40 struct rpmInstallArguments_s * ia = &rpmIArgs;
41
42 /* XXX avoid accidental collisions with POPT_BIT_SET for flags */
43 if (opt->arg == NULL)
44 switch (opt->val) {
45
46 case 'i':
47 ia->installInterfaceFlags |= INSTALL_INSTALL;
48 break;
49
50 case POPT_EXCLUDEPATH:
51 if (arg == NULL || *arg != '/')
52 argerror(_("exclude paths must begin with a /"));
53 ia->relocations = xrealloc(ia->relocations,
54 sizeof(*ia->relocations) * (ia->numRelocations + 1));
55 ia->relocations[ia->numRelocations].oldPath = xstrdup(arg);
56 ia->relocations[ia->numRelocations].newPath = NULL;
57 ia->numRelocations++;
58 break;
59 case POPT_RELOCATE:
60 { char * oldPath = NULL;
61 char * newPath = NULL;
62
63 if (arg == NULL || *arg != '/')
64 argerror(_("relocations must begin with a /"));
65 oldPath = xstrdup(arg);
66 if (!(newPath = strchr(oldPath, '=')))
67 argerror(_("relocations must contain a ="));
68 *newPath++ = '\0';
69 if (*newPath != '/')
70 argerror(_("relocations must have a / following the ="));
71 ia->relocations = xrealloc(ia->relocations,
72 sizeof(*ia->relocations) * (ia->numRelocations + 1));
73 ia->relocations[ia->numRelocations].oldPath = oldPath;
74 ia->relocations[ia->numRelocations].newPath = newPath;
75 ia->numRelocations++;
76 } break;
77
78 case RPMCLI_POPT_NODEPS:
79 ia->noDeps = 1;
80 break;
81
82 case RPMCLI_POPT_NOFILEDIGEST:
83 ia->transFlags |= RPMTRANS_FLAG_NOFILEDIGEST;
84 break;
85
86 case RPMCLI_POPT_NOCONTEXTS:
87 ia->transFlags |= RPMTRANS_FLAG_NOCONTEXTS;
88 break;
89
90 case RPMCLI_POPT_NOCAPS:
91 ia->transFlags |= RPMTRANS_FLAG_NOCAPS;
92 break;
93
94 case RPMCLI_POPT_FORCE:
95 ia->probFilter |=
96 ( RPMPROB_FILTER_REPLACEPKG
97 | RPMPROB_FILTER_REPLACEOLDFILES
98 | RPMPROB_FILTER_REPLACENEWFILES
99 | RPMPROB_FILTER_OLDPACKAGE );
100 break;
101
102 case RPMCLI_POPT_NOSCRIPTS:
103 ia->transFlags |= (_noTransScripts | _noTransTriggers);
104 break;
105
106 }
107 }
108
109 /**
110 */
111 struct poptOption rpmInstallPoptTable[] = {
112 /* FIX: cast? */
113 { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
114 installArgCallback, 0, NULL, NULL },
115
116 { "allfiles", '\0', POPT_BIT_SET,
117 &rpmIArgs.transFlags, RPMTRANS_FLAG_ALLFILES,
118 N_("install all files, even configurations which might otherwise be skipped"),
119 NULL},
120 { "allmatches", '\0', POPT_BIT_SET,
121 &rpmIArgs.installInterfaceFlags, UNINSTALL_ALLMATCHES,
122 N_("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"),
123 NULL},
124
125 { "badreloc", '\0', POPT_BIT_SET,
126 &rpmIArgs.probFilter, RPMPROB_FILTER_FORCERELOCATE,
127 N_("relocate files in non-relocatable package"), NULL},
128
129 { "deploops", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
130 &rpmIArgs.transFlags, RPMTRANS_FLAG_DEPLOOPS,
131 N_("print dependency loops as warning"), NULL},
132
133 { "erase", 'e', POPT_BIT_SET,
134 &rpmIArgs.installInterfaceFlags, INSTALL_ERASE,
135 N_("erase (uninstall) package"), N_("<package>+") },
136 { "excludeartifacts", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
137 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOARTIFACTS,
138 N_("do not install artifacts"), NULL},
139 { "excludeconfigs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
140 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOCONFIGS,
141 N_("do not install configuration files"), NULL},
142 { "excludedocs", '\0', POPT_BIT_SET,
143 &rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
144 N_("do not install documentation"), NULL},
145 { "excludepath", '\0', POPT_ARG_STRING, 0, POPT_EXCLUDEPATH,
146 N_("skip files with leading component <path> "),
147 N_("<path>") },
148
149 { "force", '\0', 0, NULL, RPMCLI_POPT_FORCE,
150 N_("short hand for --replacepkgs --replacefiles"), NULL},
151
152 { "freshen", 'F', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags,
153 (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL),
154 N_("upgrade package(s) if already installed"),
155 N_("<packagefile>+") },
156 { "hash", 'h', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags, INSTALL_HASH,
157 N_("print hash marks as package installs (good with -v)"), NULL},
158 { "ignorearch", '\0', POPT_BIT_SET,
159 &rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREARCH,
160 N_("don't verify package architecture"), NULL},
161 { "ignoreos", '\0', POPT_BIT_SET,
162 &rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREOS,
163 N_("don't verify package operating system"), NULL},
164 { "ignoresize", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
165 (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES),
166 N_("don't check disk space before installing"), NULL},
167 { "noverify", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
168 (RPMPROB_FILTER_VERIFY),
169 N_("short hand for --ignorepayload --ignoresignature"), NULL},
170 { "includedocs", '\0', POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.incldocs, 0,
171 N_("install documentation"), NULL},
172
173 { "install", 'i', 0, NULL, 'i',
174 N_("install package(s)"), N_("<packagefile>+") },
175
176 { "justdb", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_JUSTDB,
177 N_("update the database, but do not modify the filesystem"), NULL},
178
179 { "noconfigs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
180 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOCONFIGS,
181 N_("do not install configuration files"), NULL},
182 { "nodeps", '\0', 0, NULL, RPMCLI_POPT_NODEPS,
183 N_("do not verify package dependencies"), NULL },
184 { "nodocs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
185 &rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
186 N_("do not install documentation"), NULL},
187
188 { "nofiledigest", '\0', 0, NULL, RPMCLI_POPT_NOFILEDIGEST,
189 N_("don't verify digest of files"), NULL },
190 { "nomd5", '\0', POPT_ARGFLAG_DOC_HIDDEN, NULL, RPMCLI_POPT_NOFILEDIGEST,
191 N_("don't verify digest of files (obsolete)"), NULL },
192 { "nocontexts", '\0',0, NULL, RPMCLI_POPT_NOCONTEXTS,
193 N_("don't install file security contexts"), NULL},
194 { "nocaps", '\0',0, NULL, RPMCLI_POPT_NOCAPS,
195 N_("don't install file capabilities"), NULL},
196
197 { "noorder", '\0', POPT_BIT_SET,
198 &rpmIArgs.installInterfaceFlags, INSTALL_NOORDER,
199 N_("do not reorder package installation to satisfy dependencies"),
200 NULL},
201
202 { "noscripts", '\0', 0, NULL, RPMCLI_POPT_NOSCRIPTS,
203 N_("do not execute package scriptlet(s)"), NULL },
204
205 { "nopre", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
206 RPMTRANS_FLAG_NOPRE,
207 N_("do not execute %%pre scriptlet (if any)"), NULL },
208 { "nopost", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
209 RPMTRANS_FLAG_NOPOST,
210 N_("do not execute %%post scriptlet (if any)"), NULL },
211 { "nopreun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
212 RPMTRANS_FLAG_NOPREUN,
213 N_("do not execute %%preun scriptlet (if any)"), NULL },
214 { "nopostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
215 RPMTRANS_FLAG_NOPOSTUN,
216 N_("do not execute %%postun scriptlet (if any)"), NULL },
217 { "nopretrans", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
218 RPMTRANS_FLAG_NOPRETRANS,
219 N_("do not execute %%pretrans scriptlet (if any)"), NULL },
220 { "noposttrans", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
221 RPMTRANS_FLAG_NOPOSTTRANS,
222 N_("do not execute %%posttrans scriptlet (if any)"), NULL },
223
224 { "notriggers", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, _noTransTriggers,
225 N_("do not execute any scriptlet(s) triggered by this package"), NULL},
226 { "notriggerprein", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
227 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPREIN,
228 N_("do not execute any %%triggerprein scriptlet(s)"), NULL},
229 { "notriggerin", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
230 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERIN,
231 N_("do not execute any %%triggerin scriptlet(s)"), NULL},
232 { "notriggerun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
233 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERUN,
234 N_("do not execute any %%triggerun scriptlet(s)"), NULL},
235 { "notriggerpostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
236 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPOSTUN,
237 N_("do not execute any %%triggerpostun scriptlet(s)"), NULL},
238
239 { "oldpackage", '\0', POPT_BIT_SET,
240 &rpmIArgs.probFilter, RPMPROB_FILTER_OLDPACKAGE,
241 N_("upgrade to an old version of the package (--force on upgrades does this automatically)"),
242 NULL},
243 { "percent", '\0', POPT_BIT_SET,
244 &rpmIArgs.installInterfaceFlags, INSTALL_PERCENT,
245 N_("print percentages as package installs"), NULL},
246 { "prefix", '\0', POPT_ARG_STRING, &rpmIArgs.prefix, 0,
247 N_("relocate the package to <dir>, if relocatable"),
248 N_("<dir>") },
249 { "relocate", '\0', POPT_ARG_STRING, 0, POPT_RELOCATE,
250 N_("relocate files from path <old> to <new>"),
251 N_("<old>=<new>") },
252 { "replacefiles", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
253 (RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES),
254 N_("ignore file conflicts between packages"), NULL},
255 { "replacepkgs", '\0', POPT_BIT_SET,
256 &rpmIArgs.probFilter, RPMPROB_FILTER_REPLACEPKG,
257 N_("reinstall if the package is already present"), NULL},
258 { "test", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_TEST,
259 N_("don't install, but tell if it would work or not"), NULL},
260 { "upgrade", 'U', POPT_BIT_SET,
261 &rpmIArgs.installInterfaceFlags, (INSTALL_UPGRADE|INSTALL_INSTALL),
262 N_("upgrade package(s)"),
263 N_("<packagefile>+") },
264 { "reinstall", '\0', POPT_BIT_SET,
265 &rpmIArgs.installInterfaceFlags, (INSTALL_REINSTALL|INSTALL_INSTALL),
266 N_("reinstall package(s)"),
267 N_("<packagefile>+") },
268
269 POPT_TABLEEND
270 };
271