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

Generated on Tue Dec 28 15:17:13 2004 for rpm by doxygen 1.3.6