00001
00006 #include "system.h"
00007
00008 #include <rpmcli.h>
00009
00010 #include "debug.h"
00011
00012
00013 extern time_t get_date(const char * p, void * now);
00014
00015
00016
00017 struct rpmInstallArguments_s rpmIArgs = {
00018 0,
00019 0,
00020 0,
00021 0,
00022 0,
00023 0,
00024 0,
00025 0,
00026 0,
00027 NULL,
00028 NULL,
00029 NULL
00030 };
00031
00032 #define POPT_RELOCATE -1021
00033 #define POPT_EXCLUDEPATH -1022
00034 #define POPT_ROLLBACK -1023
00035
00036
00037 static void argerror(const char * desc)
00038
00039
00040 {
00041
00042 fprintf(stderr, _("%s: %s\n"), __progname, desc);
00043
00044 exit(EXIT_FAILURE);
00045 }
00046
00049
00050 static void installArgCallback( poptContext con,
00051 enum poptCallbackReason reason,
00052 const struct poptOption * opt, const char * arg,
00053 const void * data)
00054
00055
00056 {
00057 struct rpmInstallArguments_s * ia = &rpmIArgs;
00058
00059
00060
00061 if (opt->arg == NULL)
00062 switch (opt->val) {
00063
00064 case 'i':
00065 ia->installInterfaceFlags |= INSTALL_INSTALL;
00066 break;
00067
00068 case POPT_EXCLUDEPATH:
00069 if (arg == NULL || *arg != '/')
00070 argerror(_("exclude paths must begin with a /"));
00071 ia->relocations = xrealloc(ia->relocations,
00072 sizeof(*ia->relocations) * (ia->numRelocations + 1));
00073
00074 ia->relocations[ia->numRelocations].oldPath = xstrdup(arg);
00075
00076 ia->relocations[ia->numRelocations].newPath = NULL;
00077 ia->numRelocations++;
00078 break;
00079 case POPT_RELOCATE:
00080 { char * oldPath = NULL;
00081 char * newPath = NULL;
00082
00083 if (arg == NULL || *arg != '/')
00084 argerror(_("relocations must begin with a /"));
00085 oldPath = xstrdup(arg);
00086 if (!(newPath = strchr(oldPath, '=')))
00087 argerror(_("relocations must contain a ="));
00088 *newPath++ = '\0';
00089 if (*newPath != '/')
00090 argerror(_("relocations must have a / following the ="));
00091 ia->relocations = xrealloc(ia->relocations,
00092 sizeof(*ia->relocations) * (ia->numRelocations + 1));
00093
00094 ia->relocations[ia->numRelocations].oldPath = oldPath;
00095
00096
00097 ia->relocations[ia->numRelocations].newPath = newPath;
00098
00099 ia->numRelocations++;
00100 } break;
00101
00102 case POPT_ROLLBACK:
00103 { time_t tid;
00104 if (arg == NULL)
00105 argerror(_("rollback takes a time/date stamp argument"));
00106
00107
00108 tid = get_date(arg, NULL);
00109
00110
00111 if (tid == (time_t)-1 || tid == (time_t)0)
00112 argerror(_("malformed rollback time/date stamp argument"));
00113 ia->rbtid = tid;
00114 } break;
00115
00116 case RPMCLI_POPT_NODIGEST:
00117 ia->qva_flags |= VERIFY_DIGEST;
00118 break;
00119
00120 case RPMCLI_POPT_NOSIGNATURE:
00121 ia->qva_flags |= VERIFY_SIGNATURE;
00122 break;
00123
00124 case RPMCLI_POPT_NOHDRCHK:
00125 ia->qva_flags |= VERIFY_HDRCHK;
00126 break;
00127
00128 case RPMCLI_POPT_NODEPS:
00129 ia->noDeps = 1;
00130 break;
00131
00132 case RPMCLI_POPT_NOMD5:
00133 ia->transFlags |= RPMTRANS_FLAG_NOMD5;
00134 break;
00135
00136 case RPMCLI_POPT_NOCONTEXTS:
00137 ia->transFlags |= RPMTRANS_FLAG_NOCONTEXTS;
00138 break;
00139
00140 case RPMCLI_POPT_FORCE:
00141 ia->probFilter |=
00142 ( RPMPROB_FILTER_REPLACEPKG
00143 | RPMPROB_FILTER_REPLACEOLDFILES
00144 | RPMPROB_FILTER_REPLACENEWFILES
00145 | RPMPROB_FILTER_OLDPACKAGE );
00146 break;
00147
00148 case RPMCLI_POPT_NOSCRIPTS:
00149 ia->transFlags |= (_noTransScripts | _noTransTriggers);
00150 break;
00151
00152 }
00153
00154 }
00155
00156
00159
00160
00161 struct poptOption rpmInstallPoptTable[] = {
00162
00163 { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
00164 installArgCallback, 0, NULL, NULL },
00165
00166
00167 { "aid", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_ADDINDEPS,
00168 N_("add suggested packages to transaction"), NULL },
00169
00170 { "allfiles", '\0', POPT_BIT_SET,
00171 &rpmIArgs.transFlags, RPMTRANS_FLAG_ALLFILES,
00172 N_("install all files, even configurations which might otherwise be skipped"),
00173 NULL},
00174 { "allmatches", '\0', POPT_BIT_SET,
00175 &rpmIArgs.eraseInterfaceFlags, UNINSTALL_ALLMATCHES,
00176 N_("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"),
00177 NULL},
00178
00179 { "anaconda", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00180 &rpmIArgs.transFlags, RPMTRANS_FLAG_ANACONDA|RPMTRANS_FLAG_DEPLOOPS,
00181 N_("use anaconda \"presentation order\""), NULL},
00182
00183 { "apply", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00184 (_noTransScripts|_noTransTriggers|
00185 RPMTRANS_FLAG_APPLYONLY|RPMTRANS_FLAG_PKGCOMMIT),
00186 N_("do not execute package scriptlet(s)"), NULL },
00187
00188 { "badreloc", '\0', POPT_BIT_SET,
00189 &rpmIArgs.probFilter, RPMPROB_FILTER_FORCERELOCATE,
00190 N_("relocate files in non-relocatable package"), NULL},
00191
00192 { "deploops", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00193 &rpmIArgs.transFlags, RPMTRANS_FLAG_DEPLOOPS,
00194 N_("print dependency loops as warning"), NULL},
00195
00196 { "dirstash", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00197 &rpmIArgs.transFlags, RPMTRANS_FLAG_DIRSTASH,
00198 N_("save erased package files by renaming into sub-directory"), NULL},
00199 { "erase", 'e', POPT_BIT_SET,
00200 &rpmIArgs.installInterfaceFlags, INSTALL_ERASE,
00201 N_("erase (uninstall) package"), N_("<package>+") },
00202 { "excludeconfigs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00203 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOCONFIGS,
00204 N_("do not install configuration files"), NULL},
00205 { "excludedocs", '\0', POPT_BIT_SET,
00206 &rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
00207 N_("do not install documentation"), NULL},
00208 { "excludepath", '\0', POPT_ARG_STRING, 0, POPT_EXCLUDEPATH,
00209 N_("skip files with leading component <path> "),
00210 N_("<path>") },
00211
00212 { "fileconflicts", '\0', POPT_BIT_CLR, &rpmIArgs.probFilter,
00213 (RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES),
00214 N_("detect file conflicts between packages"), NULL},
00215 { "force", '\0', 0, NULL, RPMCLI_POPT_FORCE,
00216 N_("short hand for --replacepkgs --replacefiles"), NULL},
00217
00218 { "freshen", 'F', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags,
00219 (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL),
00220 N_("upgrade package(s) if already installed"),
00221 N_("<packagefile>+") },
00222 { "hash", 'h', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags, INSTALL_HASH,
00223 N_("print hash marks as package installs (good with -v)"), NULL},
00224 { "ignorearch", '\0', POPT_BIT_SET,
00225 &rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREARCH,
00226 N_("don't verify package architecture"), NULL},
00227 { "ignoreos", '\0', POPT_BIT_SET,
00228 &rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREOS,
00229 N_("don't verify package operating system"), NULL},
00230 { "ignoresize", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00231 (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES),
00232 N_("don't check disk space before installing"), NULL},
00233 { "includedocs", '\0', POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.incldocs, 0,
00234 N_("install documentation"), NULL},
00235
00236 { "install", 'i', 0, NULL, 'i',
00237 N_("install package(s)"), N_("<packagefile>+") },
00238
00239 { "justdb", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_JUSTDB,
00240 N_("update the database, but do not modify the filesystem"), NULL},
00241
00242 { "noconfigs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00243 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOCONFIGS,
00244 N_("do not install configuration files"), NULL},
00245 { "nodeps", '\0', 0, NULL, RPMCLI_POPT_NODEPS,
00246 N_("do not verify package dependencies"), NULL },
00247 { "nodocs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00248 &rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
00249 N_("do not install documentation"), NULL},
00250
00251 { "nomd5", '\0', 0, NULL, RPMCLI_POPT_NOMD5,
00252 N_("don't verify MD5 digest of files"), NULL },
00253 { "nocontexts", '\0',0, NULL, RPMCLI_POPT_NOCONTEXTS,
00254 N_("don't install file security contexts"), NULL},
00255
00256 { "noorder", '\0', POPT_BIT_SET,
00257 &rpmIArgs.installInterfaceFlags, INSTALL_NOORDER,
00258 N_("do not reorder package installation to satisfy dependencies"),
00259 NULL},
00260
00261 { "nosuggest", '\0', POPT_BIT_SET, &rpmIArgs.transFlags,
00262 RPMTRANS_FLAG_NOSUGGEST,
00263 N_("do not suggest missing dependency resolution(s)"), NULL},
00264
00265 { "noscripts", '\0', 0, NULL, RPMCLI_POPT_NOSCRIPTS,
00266 N_("do not execute package scriptlet(s)"), NULL },
00267
00268 { "nopre", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00269 RPMTRANS_FLAG_NOPRE,
00270 N_("do not execute %%pre scriptlet (if any)"), NULL },
00271 { "nopost", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00272 RPMTRANS_FLAG_NOPOST,
00273 N_("do not execute %%post scriptlet (if any)"), NULL },
00274 { "nopreun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00275 RPMTRANS_FLAG_NOPREUN,
00276 N_("do not execute %%preun scriptlet (if any)"), NULL },
00277 { "nopostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00278 RPMTRANS_FLAG_NOPOSTUN,
00279 N_("do not execute %%postun scriptlet (if any)"), NULL },
00280
00281 { "nodigest", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NODIGEST,
00282 N_("don't verify package digest(s)"), NULL },
00283 { "nohdrchk", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOHDRCHK,
00284 N_("don't verify database header(s) when retrieved"), NULL },
00285 { "nosignature", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOSIGNATURE,
00286 N_("don't verify package signature(s)"), NULL },
00287
00288 { "notriggers", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, _noTransTriggers,
00289 N_("do not execute any scriptlet(s) triggered by this package"), NULL},
00290 { "notriggerprein", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00291 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPREIN,
00292 N_("do not execute any %%triggerprein scriptlet(s)"), NULL},
00293 { "notriggerin", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00294 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERIN,
00295 N_("do not execute any %%triggerin scriptlet(s)"), NULL},
00296 { "notriggerun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00297 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERUN,
00298 N_("do not execute any %%triggerun scriptlet(s)"), NULL},
00299 { "notriggerpostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00300 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPOSTUN,
00301 N_("do not execute any %%triggerpostun scriptlet(s)"), NULL},
00302
00303 { "oldpackage", '\0', POPT_BIT_SET,
00304 &rpmIArgs.probFilter, RPMPROB_FILTER_OLDPACKAGE,
00305 N_("upgrade to an old version of the package (--force on upgrades does this automatically)"),
00306 NULL},
00307 { "percent", '\0', POPT_BIT_SET,
00308 &rpmIArgs.installInterfaceFlags, INSTALL_PERCENT,
00309 N_("print percentages as package installs"), NULL},
00310 { "prefix", '\0', POPT_ARG_STRING, &rpmIArgs.prefix, 0,
00311 N_("relocate the package to <dir>, if relocatable"),
00312 N_("<dir>") },
00313 { "relocate", '\0', POPT_ARG_STRING, 0, POPT_RELOCATE,
00314 N_("relocate files from path <old> to <new>"),
00315 N_("<old>=<new>") },
00316 { "repackage", '\0', POPT_BIT_SET,
00317 &rpmIArgs.transFlags, RPMTRANS_FLAG_REPACKAGE,
00318 N_("save erased package files by repackaging"), NULL},
00319 { "replacefiles", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00320 (RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES),
00321 N_("ignore file conflicts between packages"), NULL},
00322 { "replacepkgs", '\0', POPT_BIT_SET,
00323 &rpmIArgs.probFilter, RPMPROB_FILTER_REPLACEPKG,
00324 N_("reinstall if the package is already present"), NULL},
00325 { "rollback", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_ROLLBACK,
00326 N_("deinstall new, reinstall old, package(s), back to <date>"),
00327 N_("<date>") },
00328 { "test", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_TEST,
00329 N_("don't install, but tell if it would work or not"), NULL},
00330 { "upgrade", 'U', POPT_BIT_SET,
00331 &rpmIArgs.installInterfaceFlags, (INSTALL_UPGRADE|INSTALL_INSTALL),
00332 N_("upgrade package(s)"),
00333 N_("<packagefile>+") },
00334
00335 POPT_TABLEEND
00336 };
00337