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