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_FORCE:
00137 ia->probFilter |=
00138 ( RPMPROB_FILTER_REPLACEPKG
00139 | RPMPROB_FILTER_REPLACEOLDFILES
00140 | RPMPROB_FILTER_REPLACENEWFILES
00141 | RPMPROB_FILTER_OLDPACKAGE );
00142 break;
00143
00144 case RPMCLI_POPT_NOSCRIPTS:
00145 ia->transFlags |= (_noTransScripts | _noTransTriggers);
00146 break;
00147
00148 }
00149
00150 }
00151
00152
00155
00156
00157 struct poptOption rpmInstallPoptTable[] = {
00158
00159 { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
00160 installArgCallback, 0, NULL, NULL },
00161
00162
00163 { "aid", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_ADDINDEPS,
00164 N_("add suggested packages to transaction"), NULL },
00165
00166 { "allfiles", '\0', POPT_BIT_SET,
00167 &rpmIArgs.transFlags, RPMTRANS_FLAG_ALLFILES,
00168 N_("install all files, even configurations which might otherwise be skipped"),
00169 NULL},
00170 { "allmatches", '\0', POPT_BIT_SET,
00171 &rpmIArgs.eraseInterfaceFlags, UNINSTALL_ALLMATCHES,
00172 N_("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"),
00173 NULL},
00174
00175 { "anaconda", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00176 &rpmIArgs.transFlags, RPMTRANS_FLAG_ANACONDA,
00177 N_("use anaconda \"presentation order\""), NULL},
00178
00179 { "apply", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00180 (_noTransScripts|_noTransTriggers|
00181 RPMTRANS_FLAG_APPLYONLY|RPMTRANS_FLAG_PKGCOMMIT),
00182 N_("do not execute package scriptlet(s)"), NULL },
00183
00184 { "badreloc", '\0', POPT_BIT_SET,
00185 &rpmIArgs.probFilter, RPMPROB_FILTER_FORCERELOCATE,
00186 N_("relocate files in non-relocatable package"), NULL},
00187 { "dirstash", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00188 &rpmIArgs.transFlags, RPMTRANS_FLAG_DIRSTASH,
00189 N_("save erased package files by renaming into sub-directory"), NULL},
00190 { "erase", 'e', POPT_BIT_SET,
00191 &rpmIArgs.installInterfaceFlags, INSTALL_ERASE,
00192 N_("erase (uninstall) package"), N_("<package>+") },
00193 { "excludeconfigs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00194 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOCONFIGS,
00195 N_("do not install configuration files"), NULL},
00196 { "excludedocs", '\0', POPT_BIT_SET,
00197 &rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
00198 N_("do not install documentation"), NULL},
00199 { "excludepath", '\0', POPT_ARG_STRING, 0, POPT_EXCLUDEPATH,
00200 N_("skip files with leading component <path> "),
00201 N_("<path>") },
00202
00203 { "fileconflicts", '\0', POPT_BIT_CLR, &rpmIArgs.probFilter,
00204 (RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES),
00205 N_("detect file conflicts between packages"), NULL},
00206 { "force", '\0', 0, NULL, RPMCLI_POPT_FORCE,
00207 N_("short hand for --replacepkgs --replacefiles"), NULL},
00208
00209 { "freshen", 'F', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags,
00210 (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL),
00211 N_("upgrade package(s) if already installed"),
00212 N_("<packagefile>+") },
00213 { "hash", 'h', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags, INSTALL_HASH,
00214 N_("print hash marks as package installs (good with -v)"), NULL},
00215 { "ignorearch", '\0', POPT_BIT_SET,
00216 &rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREARCH,
00217 N_("don't verify package architecture"), NULL},
00218 { "ignoreos", '\0', POPT_BIT_SET,
00219 &rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREOS,
00220 N_("don't verify package operating system"), NULL},
00221 { "ignoresize", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00222 (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES),
00223 N_("don't check disk space before installing/uninstalling"), NULL},
00224 { "includedocs", '\0', POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.incldocs, 0,
00225 N_("install documentation"), NULL},
00226
00227 { "install", 'i', 0, NULL, 'i',
00228 N_("install package(s)"), N_("<packagefile>+") },
00229
00230 { "justdb", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_JUSTDB,
00231 N_("update the database, but do not modify the filesystem"), NULL},
00232
00233 { "noconfigs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00234 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOCONFIGS,
00235 N_("do not install configuration files"), NULL},
00236 { "nodeps", '\0', 0, NULL, RPMCLI_POPT_NODEPS,
00237 N_("do not verify package dependencies"), NULL },
00238 { "nodocs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00239 &rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
00240 N_("do not install documentation"), NULL},
00241
00242 { "nomd5", '\0', 0, NULL, RPMCLI_POPT_NOMD5,
00243 N_("don't verify MD5 digest of files"), NULL },
00244 { "noorder", '\0', POPT_BIT_SET,
00245 &rpmIArgs.installInterfaceFlags, INSTALL_NOORDER,
00246 N_("do not reorder package installation to satisfy dependencies"),
00247 NULL},
00248
00249 { "nosuggest", '\0', POPT_BIT_SET, &rpmIArgs.transFlags,
00250 RPMTRANS_FLAG_NOSUGGEST,
00251 N_("do not suggest missing dependency resolution(s)"), NULL},
00252
00253 { "noscripts", '\0', 0, NULL, RPMCLI_POPT_NOSCRIPTS,
00254 N_("do not execute package scriptlet(s)"), NULL },
00255
00256 { "nopre", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00257 RPMTRANS_FLAG_NOPRE,
00258 N_("do not execute %%pre scriptlet (if any)"), NULL },
00259 { "nopost", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00260 RPMTRANS_FLAG_NOPOST,
00261 N_("do not execute %%post scriptlet (if any)"), NULL },
00262 { "nopreun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00263 RPMTRANS_FLAG_NOPREUN,
00264 N_("do not execute %%preun scriptlet (if any)"), NULL },
00265 { "nopostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00266 RPMTRANS_FLAG_NOPOSTUN,
00267 N_("do not execute %%postun scriptlet (if any)"), NULL },
00268
00269 { "nodigest", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NODIGEST,
00270 N_("don't verify package digest(s)"), NULL },
00271 { "nohdrchk", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOHDRCHK,
00272 N_("don't verify database header(s) when retrieved"), NULL },
00273 { "nosignature", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOSIGNATURE,
00274 N_("don't verify package signature(s)"), NULL },
00275
00276 { "notriggers", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, _noTransTriggers,
00277 N_("do not execute any scriptlet(s) triggered by this package"), NULL},
00278 { "notriggerprein", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00279 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPREIN,
00280 N_("do not execute any %%triggerprein scriptlet(s)"), NULL},
00281 { "notriggerin", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00282 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERIN,
00283 N_("do not execute any %%triggerin scriptlet(s)"), NULL},
00284 { "notriggerun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00285 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERUN,
00286 N_("do not execute any %%triggerun scriptlet(s)"), NULL},
00287 { "notriggerpostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00288 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPOSTUN,
00289 N_("do not execute any %%triggerpostun scriptlet(s)"), NULL},
00290
00291 { "oldpackage", '\0', POPT_BIT_SET,
00292 &rpmIArgs.probFilter, RPMPROB_FILTER_OLDPACKAGE,
00293 N_("upgrade to an old version of the package (--force on upgrades does this automatically)"),
00294 NULL},
00295 { "percent", '\0', POPT_BIT_SET,
00296 &rpmIArgs.installInterfaceFlags, INSTALL_PERCENT,
00297 N_("print percentages as package installs"), NULL},
00298 { "prefix", '\0', POPT_ARG_STRING, &rpmIArgs.prefix, 0,
00299 N_("relocate the package to <dir>, if relocatable"),
00300 N_("<dir>") },
00301 { "relocate", '\0', POPT_ARG_STRING, 0, POPT_RELOCATE,
00302 N_("relocate files from path <old> to <new>"),
00303 N_("<old>=<new>") },
00304 { "repackage", '\0', POPT_BIT_SET,
00305 &rpmIArgs.transFlags, RPMTRANS_FLAG_REPACKAGE,
00306 N_("save erased package files by repackaging"), NULL},
00307 { "replacefiles", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00308 (RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES),
00309 N_("ignore file conflicts between packages"), NULL},
00310 { "replacepkgs", '\0', POPT_BIT_SET,
00311 &rpmIArgs.probFilter, RPMPROB_FILTER_REPLACEPKG,
00312 N_("reinstall if the package is already present"), NULL},
00313 { "rollback", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_ROLLBACK,
00314 N_("deinstall new, reinstall old, package(s), back to <date>"),
00315 N_("<date>") },
00316 { "test", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_TEST,
00317 N_("don't install, but tell if it would work or not"), NULL},
00318 { "upgrade", 'U', POPT_BIT_SET,
00319 &rpmIArgs.installInterfaceFlags, (INSTALL_UPGRADE|INSTALL_INSTALL),
00320 N_("upgrade package(s)"),
00321 N_("<packagefile>+") },
00322
00323 POPT_TABLEEND
00324 };
00325