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