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 extern int fancyPercents;
00017
00018
00019 struct rpmInstallArguments_s rpmIArgs;
00020
00021 #define POPT_RELOCATE -1016
00022 #define POPT_EXCLUDEPATH -1019
00023 #define POPT_ROLLBACK -1024
00024
00025 static void argerror(const char * desc)
00026
00027
00028 {
00029 fprintf(stderr, _("%s: %s\n"), __progname, desc);
00030 exit(EXIT_FAILURE);
00031
00032 }
00033
00036 static void installArgCallback( poptContext con,
00037 enum poptCallbackReason reason,
00038 const struct poptOption * opt, const char * arg,
00039 const void * data)
00040
00041 {
00042 struct rpmInstallArguments_s * ia = &rpmIArgs;
00043
00044 #if 0
00045 fprintf(stderr, "*** opt %s %c info 0x%x arg %p val 0x%x arg %p %s\n", opt->longName, opt->shortName, opt->argInfo, opt->arg, opt->val, arg, arg);
00046 #endif
00047
00048
00049 if (opt->arg == NULL)
00050 switch (opt->val) {
00051 case POPT_EXCLUDEPATH:
00052 if (arg == NULL || *arg != '/')
00053 argerror(_("exclude paths must begin with a /"));
00054 ia->relocations = xrealloc(ia->relocations,
00055 sizeof(*ia->relocations) * (ia->numRelocations + 1));
00056
00057 ia->relocations[ia->numRelocations].oldPath = arg;
00058
00059 ia->relocations[ia->numRelocations].newPath = NULL;
00060 ia->numRelocations++;
00061 break;
00062 case POPT_RELOCATE:
00063 { char * newPath = NULL;
00064 if (arg == NULL || *arg != '/')
00065 argerror(_("relocations must begin with a /"));
00066 if (!(newPath = strchr(arg, '=')))
00067 argerror(_("relocations must contain a ="));
00068 *newPath++ = '\0';
00069 if (*newPath != '/')
00070 argerror(_("relocations must have a / following the ="));
00071 ia->relocations = xrealloc(ia->relocations,
00072 sizeof(*ia->relocations) * (ia->numRelocations + 1));
00073
00074 ia->relocations[ia->numRelocations].oldPath = arg;
00075
00076
00077 ia->relocations[ia->numRelocations].newPath = newPath;
00078
00079 ia->numRelocations++;
00080 } break;
00081 case POPT_ROLLBACK:
00082 { time_t tid;
00083 if (arg == NULL)
00084 argerror(_("rollback takes a time/date stamp argument"));
00085 tid = get_date(arg, NULL);
00086
00087 if (tid == (time_t)-1 || tid == (time_t)0)
00088 argerror(_("malformed rollback time/date stamp argument"));
00089 ia->rbtid = tid;
00090 } break;
00091 default:
00092 break;
00093 }
00094 }
00095
00098 struct poptOption rpmInstallPoptTable[] = {
00099 { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA,
00100 installArgCallback, 0, NULL, NULL },
00101
00102 { "allfiles", '\0', POPT_BIT_SET,
00103 &rpmIArgs.transFlags, RPMTRANS_FLAG_ALLFILES,
00104 N_("install all files, even configurations which might otherwise be skipped"),
00105 NULL},
00106 { "allmatches", '\0', POPT_BIT_SET,
00107 &rpmIArgs.eraseInterfaceFlags, UNINSTALL_ALLMATCHES,
00108 N_("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"),
00109 NULL},
00110
00111 { "apply", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00112 (_noTransScripts|_noTransTriggers|
00113 RPMTRANS_FLAG_APPLYONLY|RPMTRANS_FLAG_PKGCOMMIT),
00114 N_("do not execute package scriptlet(s)"), NULL },
00115
00116 { "badreloc", '\0', POPT_BIT_SET,
00117 &rpmIArgs.probFilter, RPMPROB_FILTER_FORCERELOCATE,
00118 N_("relocate files in non-relocateable package"), NULL},
00119 { "chainsaw", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00120 &rpmIArgs.transFlags, RPMTRANS_FLAG_CHAINSAW,
00121 N_("use chainsaw dependency tree decimation when ordering"), NULL},
00122 { "dirstash", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00123 &rpmIArgs.transFlags, RPMTRANS_FLAG_DIRSTASH,
00124 N_("save erased package files by renaming into sub-directory"), NULL},
00125 { "erase", 'e', POPT_BIT_SET,
00126 &rpmIArgs.installInterfaceFlags, INSTALL_ERASE,
00127 N_("erase (uninstall) package"), N_("<package>+") },
00128 { "excludedocs", '\0', POPT_BIT_SET,
00129 &rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
00130 N_("do not install documentation"), NULL},
00131 { "excludepath", '\0', POPT_ARG_STRING, 0, POPT_EXCLUDEPATH,
00132 N_("skip files with leading component <path> "),
00133 N_("<path>") },
00134 { "force", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00135 (RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES | RPMPROB_FILTER_OLDPACKAGE),
00136 N_("short hand for --replacepkgs --replacefiles"), NULL},
00137 { "freshen", 'F', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags,
00138 (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL),
00139 N_("upgrade package(s) if already installed"),
00140 N_("<packagefile>+") },
00141 { "hash", 'h', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags, INSTALL_HASH,
00142 N_("print hash marks as package installs (good with -v)"), NULL},
00143 { "ignorearch", '\0', POPT_BIT_SET,
00144 &rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREARCH,
00145 N_("don't verify package architecture"), NULL},
00146 { "ignoreos", '\0', POPT_BIT_SET,
00147 &rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREOS,
00148 N_("don't verify package operating system"), NULL},
00149 { "ignoresize", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00150 (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES),
00151 N_("don't check disk space before installing"), NULL},
00152 { "includedocs", '\0', 0, &rpmIArgs.incldocs, 0,
00153 N_("install documentation"), NULL},
00154 { "install", '\0', POPT_BIT_SET,
00155 &rpmIArgs.installInterfaceFlags, INSTALL_INSTALL,
00156 N_("install package"), N_("<packagefile>+") },
00157 { "justdb", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_JUSTDB,
00158 N_("update the database, but do not modify the filesystem"), NULL},
00159 { "nodeps", '\0', 0, &rpmIArgs.noDeps, 0,
00160 N_("do not verify package dependencies"), NULL },
00161 { "noorder", '\0', POPT_BIT_SET,
00162 &rpmIArgs.installInterfaceFlags, INSTALL_NOORDER,
00163 N_("do not reorder package installation to satisfy dependencies"),
00164 NULL},
00165
00166 { "noscripts", '\0', POPT_BIT_SET, &rpmIArgs.transFlags,
00167 (_noTransScripts|_noTransTriggers),
00168 N_("do not execute package scriptlet(s)"), NULL },
00169 { "nopre", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00170 RPMTRANS_FLAG_NOPRE,
00171 N_("do not execute %%pre scriptlet (if any)"), NULL },
00172 { "nopost", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00173 RPMTRANS_FLAG_NOPOST,
00174 N_("do not execute %%post scriptlet (if any)"), NULL },
00175 { "nopreun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00176 RPMTRANS_FLAG_NOPREUN,
00177 N_("do not execute %%preun scriptlet (if any)"), NULL },
00178 { "nopostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00179 RPMTRANS_FLAG_NOPOSTUN,
00180 N_("do not execute %%postun scriptlet (if any)"), NULL },
00181
00182 { "notriggers", '\0', POPT_BIT_SET, &rpmIArgs.transFlags,
00183 _noTransTriggers,
00184 N_("do not execute any scriptlet(s) triggered by this package"), NULL},
00185 { "notriggerprein", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00186 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPREIN,
00187 N_("do not execute any %%triggerprein scriptlet(s)"), NULL},
00188 { "notriggerin", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00189 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERIN,
00190 N_("do not execute any %%triggerin scriptlet(s)"), NULL},
00191 { "notriggerun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00192 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERUN,
00193 N_("do not execute any %%triggerun scriptlet(s)"), NULL},
00194 { "notriggerpostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00195 &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPOSTUN,
00196 N_("do not execute any %%triggerpostun scriptlet(s)"), NULL},
00197
00198 { "oldpackage", '\0', POPT_BIT_SET,
00199 &rpmIArgs.probFilter, RPMPROB_FILTER_OLDPACKAGE,
00200 N_("upgrade to an old version of the package (--force on upgrades does this automatically)"),
00201 NULL},
00202 { "percent", '\0', POPT_BIT_SET,
00203 &rpmIArgs.installInterfaceFlags, INSTALL_PERCENT,
00204 N_("print percentages as package installs"), NULL},
00205 { "fancypercent", '\0', 0,
00206 &fancyPercents, 0,
00207 N_("print fancy percentages as package installs"), NULL},
00208 { "prefix", '\0', POPT_ARG_STRING, &rpmIArgs.prefix, 0,
00209 N_("relocate the package to <dir>, if relocatable"),
00210 N_("<dir>") },
00211 { "relocate", '\0', POPT_ARG_STRING, 0, POPT_RELOCATE,
00212 N_("relocate files from path <old> to <new>"),
00213 N_("<old>=<new>") },
00214 { "repackage", '\0', POPT_BIT_SET,
00215 &rpmIArgs.transFlags, RPMTRANS_FLAG_REPACKAGE,
00216 N_("save erased package files by repackaging"), NULL},
00217 { "replacefiles", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00218 (RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES),
00219 N_("install even if the package replaces installed files"), NULL},
00220 { "replacepkgs", '\0', POPT_BIT_SET,
00221 &rpmIArgs.probFilter, RPMPROB_FILTER_REPLACEPKG,
00222 N_("reinstall if the package is already present"), NULL},
00223 { "rollback", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_ROLLBACK,
00224 N_("deinstall new, reinstall old, package(s), back to <date>"),
00225 N_("<date>") },
00226 { "test", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_TEST,
00227 N_("don't install, but tell if it would work or not"), NULL},
00228 { "upgrade", 'U', POPT_BIT_SET,
00229 &rpmIArgs.installInterfaceFlags, (INSTALL_UPGRADE|INSTALL_INSTALL),
00230 N_("upgrade package(s)"),
00231 N_("<packagefile>+") },
00232
00233 POPT_TABLEEND
00234 };