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

Generated on Sun Oct 26 13:01:59 2003 for rpm by doxygen1.2.18