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|POPT_ARGFLAG_DOC_HIDDEN,
00151         &rpmIArgs.transFlags, RPMTRANS_FLAG_ADDINDEPS,
00152         N_("add suggested packages to transaction"), NULL },
00153 
00154  { "allfiles", '\0', POPT_BIT_SET,
00155         &rpmIArgs.transFlags, RPMTRANS_FLAG_ALLFILES,
00156   N_("install all files, even configurations which might otherwise be skipped"),
00157         NULL},
00158  { "allmatches", '\0', POPT_BIT_SET,
00159         &rpmIArgs.eraseInterfaceFlags, UNINSTALL_ALLMATCHES,
00160         N_("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"),
00161         NULL},
00162 
00163  { "apply", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00164         (_noTransScripts|_noTransTriggers|
00165                 RPMTRANS_FLAG_APPLYONLY|RPMTRANS_FLAG_PKGCOMMIT),
00166         N_("do not execute package scriptlet(s)"), NULL },
00167 
00168  { "badreloc", '\0', POPT_BIT_SET,
00169         &rpmIArgs.probFilter, RPMPROB_FILTER_FORCERELOCATE,
00170         N_("relocate files in non-relocateable package"), NULL},
00171  { "dirstash", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00172         &rpmIArgs.transFlags, RPMTRANS_FLAG_DIRSTASH,
00173         N_("save erased package files by renaming into sub-directory"), NULL},
00174  { "erase", 'e', POPT_BIT_SET,
00175         &rpmIArgs.installInterfaceFlags, INSTALL_ERASE,
00176         N_("erase (uninstall) package"), N_("<package>+") },
00177  { "excludedocs", '\0', POPT_BIT_SET,
00178         &rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
00179         N_("do not install documentation"), NULL},
00180  { "excludepath", '\0', POPT_ARG_STRING, 0, POPT_EXCLUDEPATH,
00181         N_("skip files with leading component <path> "),
00182         N_("<path>") },
00183 
00184 #ifdef  DYING
00185  { "force", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00186         (RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES | RPMPROB_FILTER_OLDPACKAGE),
00187         N_("short hand for --replacepkgs --replacefiles"), NULL},
00188 #else
00189  { "force", '\0', 0, NULL, RPMCLI_POPT_FORCE,
00190         N_("short hand for --replacepkgs --replacefiles"), NULL},
00191 #endif
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 #ifdef  DYING
00212  { "install", '\0', POPT_BIT_SET,
00213         &rpmIArgs.installInterfaceFlags, INSTALL_INSTALL,
00214         N_("install package(s)"), N_("<packagefile>+") },
00215 #else
00216  { "install", 'i', 0, NULL, 'i',
00217         N_("install package(s)"), N_("<packagefile>+") },
00218 #endif
00219 
00220  { "justdb", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_JUSTDB,
00221         N_("update the database, but do not modify the filesystem"), NULL},
00222 
00223 #ifdef  DYING
00224  { "nodeps", '\0', 0, &rpmIArgs.noDeps, 0,
00225         N_("do not verify package dependencies"), NULL },
00226 #else
00227  { "nodeps", '\0', 0, NULL, RPMCLI_POPT_NODEPS,
00228         N_("do not verify package dependencies"), NULL },
00229 #endif
00230 
00231  { "nomd5", '\0', 0, NULL, RPMCLI_POPT_NOMD5,
00232         N_("don't verify MD5 digest of files"), NULL },
00233  { "noorder", '\0', POPT_BIT_SET,
00234         &rpmIArgs.installInterfaceFlags, INSTALL_NOORDER,
00235         N_("do not reorder package installation to satisfy dependencies"),
00236         NULL},
00237 
00238  { "nosuggest", '\0', POPT_BIT_SET, &rpmIArgs.transFlags,
00239         RPMTRANS_FLAG_NOSUGGEST,
00240         N_("do not suggest missing dependency resolution(s)"), NULL},
00241 
00242 #ifdef  DYING
00243  { "noscripts", '\0', POPT_BIT_SET, &rpmIArgs.transFlags,
00244         (_noTransScripts|_noTransTriggers),
00245         N_("do not execute package scriptlet(s)"), NULL },
00246 #else
00247  { "noscripts", '\0', 0, NULL, RPMCLI_POPT_NOSCRIPTS,
00248         N_("do not execute package scriptlet(s)"), NULL },
00249 #endif
00250  { "nopre", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00251         RPMTRANS_FLAG_NOPRE,
00252         N_("do not execute %%pre scriptlet (if any)"), NULL },
00253  { "nopost", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00254         RPMTRANS_FLAG_NOPOST,
00255         N_("do not execute %%post scriptlet (if any)"), NULL },
00256  { "nopreun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00257         RPMTRANS_FLAG_NOPREUN,
00258         N_("do not execute %%preun scriptlet (if any)"), NULL },
00259  { "nopostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00260         RPMTRANS_FLAG_NOPOSTUN,
00261         N_("do not execute %%postun scriptlet (if any)"), NULL },
00262 
00263 #ifdef  DYING
00264  { "nodigest", '\0', POPT_BIT_SET, &rpmIArgs.qva_flags, VERIFY_DIGEST,
00265         N_("don't verify package digest(s)"), NULL },
00266  { "nohdrchk", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.qva_flags, VERIFY_HDRCHK,
00267         N_("don't verify database header(s) when retrieved"), NULL },
00268  { "nosignature", '\0', POPT_BIT_SET, &rpmIArgs.qva_flags, VERIFY_SIGNATURE,
00269         N_("don't verify package signature(s)"), NULL },
00270 #else
00271  { "nodigest", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NODIGEST,
00272         N_("don't verify package digest(s)"), NULL },
00273  { "nohdrchk", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOHDRCHK,
00274         N_("don't verify database header(s) when retrieved"), NULL },
00275  { "nosignature", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOSIGNATURE,
00276         N_("don't verify package signature(s)"), NULL },
00277 #endif
00278 
00279  { "notriggers", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, _noTransTriggers,
00280         N_("do not execute any scriptlet(s) triggered by this package"), NULL},
00281  { "notriggerprein", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00282         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPREIN,
00283         N_("do not execute any %%triggerprein scriptlet(s)"), NULL},
00284  { "notriggerin", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00285         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERIN,
00286         N_("do not execute any %%triggerin scriptlet(s)"), NULL},
00287  { "notriggerun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00288         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERUN,
00289         N_("do not execute any %%triggerun scriptlet(s)"), NULL},
00290  { "notriggerpostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00291         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPOSTUN,
00292         N_("do not execute any %%triggerpostun scriptlet(s)"), NULL},
00293 
00294  { "oldpackage", '\0', POPT_BIT_SET,
00295         &rpmIArgs.probFilter, RPMPROB_FILTER_OLDPACKAGE,
00296         N_("upgrade to an old version of the package (--force on upgrades does this automatically)"),
00297         NULL},
00298  { "percent", '\0', POPT_BIT_SET,
00299         &rpmIArgs.installInterfaceFlags, INSTALL_PERCENT,
00300         N_("print percentages as package installs"), NULL},
00301  { "prefix", '\0', POPT_ARG_STRING, &rpmIArgs.prefix, 0,
00302         N_("relocate the package to <dir>, if relocatable"),
00303         N_("<dir>") },
00304  { "relocate", '\0', POPT_ARG_STRING, 0, POPT_RELOCATE,
00305         N_("relocate files from path <old> to <new>"),
00306         N_("<old>=<new>") },
00307  { "repackage", '\0', POPT_BIT_SET,
00308         &rpmIArgs.transFlags, RPMTRANS_FLAG_REPACKAGE,
00309         N_("save erased package files by repackaging"), NULL},
00310  { "replacefiles", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00311         (RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES),
00312         N_("install even if the package replaces installed files"), NULL},
00313  { "replacepkgs", '\0', POPT_BIT_SET,
00314         &rpmIArgs.probFilter, RPMPROB_FILTER_REPLACEPKG,
00315         N_("reinstall if the package is already present"), NULL},
00316  { "rollback", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_ROLLBACK,
00317         N_("deinstall new, reinstall old, package(s), back to <date>"),
00318         N_("<date>") },
00319  { "test", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_TEST,
00320         N_("don't install, but tell if it would work or not"), NULL},
00321  { "upgrade", 'U', POPT_BIT_SET,
00322         &rpmIArgs.installInterfaceFlags, (INSTALL_UPGRADE|INSTALL_INSTALL),
00323         N_("upgrade package(s)"),
00324         N_("<packagefile>+") },
00325 
00326    POPT_TABLEEND
00327 };
00328 /*@=bitwisesigned =compmempass @*/

Generated on Tue Sep 17 15:59:49 2002 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002