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

Generated on Wed Mar 8 18:19:34 2006 for rpm by  doxygen 1.4.6