Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

lib/poptI.c

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

Generated on Wed Mar 13 15:34:47 2002 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002