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 /*@-fullinitblock@*/
00017 /*@unchecked@*/
00018 struct rpmQVKArguments_s rpmIArgs = {
00019     .probFilter = 0,
00020 };
00021 /*@=fullinitblock@*/
00022 
00023 #define POPT_RELOCATE           -1021
00024 #define POPT_EXCLUDEPATH        -1022
00025 #define POPT_ROLLBACK           -1023
00026 #define POPT_ROLLBACK_EXCLUDE   -1024
00027 /* -1025 thrugh -1033 are common in rpmcli.h. */
00028 #define POPT_AUTOROLLBACK_GOAL  -1036
00029 
00030 #define alloca_strdup(_s)       strcpy(alloca(strlen(_s)+1), (_s))
00031 
00037 /*@exits@*/
00038 static void argerror(const char * desc)
00039         /*@globals stderr, fileSystem @*/
00040         /*@modifies stderr, fileSystem @*/
00041 {
00042     /*@-modfilesys -globs @*/
00043     fprintf(stderr, _("%s: %s\n"), __progname, desc);
00044     /*@=modfilesys =globs @*/
00045     exit(EXIT_FAILURE);
00046 }
00047 
00050 /*@-bounds@*/
00051 static void installArgCallback( /*@unused@*/ poptContext con,
00052                 /*@unused@*/ enum poptCallbackReason reason,
00053                 const struct poptOption * opt, const char * arg,
00054                 /*@unused@*/ const void * data)
00055         /*@globals rpmIArgs, stderr, fileSystem @*/
00056         /*@modifies rpmIArgs, stderr, fileSystem @*/
00057 {
00058     QVA_t ia = &rpmIArgs;
00059 
00060     /* XXX avoid accidental collisions with POPT_BIT_SET for flags */
00061     /*@-branchstate@*/
00062     if (opt->arg == NULL)
00063     switch (opt->val) {
00064 
00065     case 'i':
00066         ia->installInterfaceFlags |= INSTALL_INSTALL;
00067         break;
00068 
00069     case POPT_EXCLUDEPATH:
00070         if (arg == NULL || *arg != '/') 
00071             argerror(_("exclude paths must begin with a /"));
00072         ia->relocations = xrealloc(ia->relocations, 
00073                         sizeof(*ia->relocations) * (ia->numRelocations + 1));
00074 /*@-temptrans@*/
00075         ia->relocations[ia->numRelocations].oldPath = xstrdup(arg);
00076 /*@=temptrans@*/
00077         ia->relocations[ia->numRelocations].newPath = NULL;
00078         ia->numRelocations++;
00079         break;
00080     case POPT_RELOCATE:
00081       { char * oldPath = NULL;
00082         char * newPath = NULL;
00083         
00084         if (arg == NULL) 
00085             argerror(_("Option --relocate needs /old/path=/new/path argument"));
00086         if (*arg != '/') 
00087             argerror(_("relocations must begin with a /"));
00088         oldPath = xstrdup(arg);
00089         if (!(newPath = strchr(oldPath, '=')))
00090             argerror(_("relocations must contain a ="));
00091         *newPath++ = '\0';
00092         if (*newPath != '/') 
00093             argerror(_("relocations must have a / following the ="));
00094         ia->relocations = xrealloc(ia->relocations, 
00095                         sizeof(*ia->relocations) * (ia->numRelocations + 1));
00096 /*@-temptrans@*/
00097         ia->relocations[ia->numRelocations].oldPath = oldPath;
00098 /*@=temptrans@*/
00099 /*@-kepttrans -usereleased @*/
00100         ia->relocations[ia->numRelocations].newPath = newPath;
00101 /*@=kepttrans =usereleased @*/
00102         ia->numRelocations++;
00103       } break;
00104 
00105     case POPT_ROLLBACK_EXCLUDE:
00106     {   int_32 tid;
00107         char *t, *te;
00108 
00109         /* Make sure we were given the proper number of args */
00110         if (arg == NULL)
00111             argerror(_("Option --rbexclude needs transaction id argument(s)"));
00112 
00113         te = alloca_strdup(arg);
00114         while (*te != '\0' && strchr(" \t\n,", *te) != NULL)
00115             *te++ = '\0';
00116         while ((t = te++) != NULL && *t != '\0') {
00117             /* Find next tid. */
00118             while (*te != '\0' && strchr(" \t\n,", *te) == NULL)
00119                 te++;
00120             while (*te != '\0' && strchr(" \t\n,", *te) != NULL)
00121                 *te++ = '\0';
00122 
00123             /* Convert arg to TID which happens to be time_t */
00124             /* XXX: Need check for arg to be an integer      */
00125             tid = (int_32) strtol(t, NULL, 0);
00126 
00127             /* Allocate space for new exclude tid */
00128             ia->rbtidExcludes = xrealloc(ia->rbtidExcludes, 
00129                 sizeof(*ia->rbtidExcludes) * (ia->numrbtidExcludes + 1));
00130 
00131             /* Add it to the list and iterate count*/
00132 /*@-temptrans@*/
00133             ia->rbtidExcludes[ia->numrbtidExcludes] = tid;
00134 /*@=temptrans@*/
00135             ia->numrbtidExcludes++;
00136         }
00137     } break;
00138 
00139     case POPT_ROLLBACK:
00140       { time_t tid;
00141         if (arg == NULL)
00142             argerror(_("Option --rollback needs a time/date stamp argument"));
00143 
00144         /*@-moduncon@*/
00145         tid = get_date(arg, NULL);
00146         rpmMessage(RPMMESS_VERBOSE, _("Rollback goal:  %-24.24s (0x%08x)\n"), ctime(&tid), (int)tid);
00147         /*@=moduncon@*/
00148 
00149         if (tid == (time_t)-1 || tid == (time_t)0)
00150             argerror(_("malformed rollback time/date stamp argument"));
00151         ia->rbtid = tid;
00152       } break;
00153     
00154     case POPT_AUTOROLLBACK_GOAL:
00155       { time_t tid;
00156         if (arg == NULL)
00157             argerror(_("arbgoal takes a time/date stamp argument"));
00158 
00159         /*@-moduncon@*/
00160         tid = get_date(arg, NULL);
00161         /*@=moduncon@*/
00162 
00163         if (tid == (time_t)-1 || tid == (time_t)0)
00164             argerror(_("malformed arbgoal time/date stamp argument"));
00165         ia->arbtid = tid;
00166       } break;
00167 
00168     case RPMCLI_POPT_NODIGEST:
00169         ia->qva_flags |= VERIFY_DIGEST;
00170         break;
00171 
00172     case RPMCLI_POPT_NOSIGNATURE:
00173         ia->qva_flags |= VERIFY_SIGNATURE;
00174         break;
00175 
00176     case RPMCLI_POPT_NOHDRCHK:
00177         ia->qva_flags |= VERIFY_HDRCHK;
00178         break;
00179 
00180     case RPMCLI_POPT_NODEPS:
00181         ia->noDeps = 1;
00182         break;
00183 
00184     case RPMCLI_POPT_NOFDIGESTS:
00185         ia->transFlags |= RPMTRANS_FLAG_NOFDIGESTS;
00186         break;
00187 
00188     case RPMCLI_POPT_NOCONTEXTS:
00189         ia->transFlags |= RPMTRANS_FLAG_NOCONTEXTS;
00190         break;
00191 
00192     case RPMCLI_POPT_FORCE:
00193         ia->probFilter |=
00194                 ( RPMPROB_FILTER_REPLACEPKG
00195                 | RPMPROB_FILTER_REPLACEOLDFILES
00196                 | RPMPROB_FILTER_REPLACENEWFILES
00197                 | RPMPROB_FILTER_OLDPACKAGE );
00198         break;
00199 
00200     case RPMCLI_POPT_NOSCRIPTS:
00201         ia->transFlags |= (_noTransScripts | _noTransTriggers);
00202         break;
00203 
00204     }
00205     /*@=branchstate@*/
00206 }
00207 /*@=bounds@*/
00208 
00211 /*@-bitwisesigned -compmempass @*/
00212 /*@unchecked@*/
00213 struct poptOption rpmInstallPoptTable[] = {
00214 /*@-type@*/ /* FIX: cast? */
00215  { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
00216         installArgCallback, 0, NULL, NULL },
00217 /*@=type@*/
00218 
00219  { "allfiles", '\0', POPT_BIT_SET,
00220         &rpmIArgs.transFlags, RPMTRANS_FLAG_ALLFILES,
00221   N_("install all files, even configurations which might otherwise be skipped"),
00222         NULL},
00223  { "allmatches", '\0', POPT_BIT_SET,
00224         &rpmIArgs.installInterfaceFlags, INSTALL_ALLMATCHES,
00225         N_("remove all packages which match <package> (normally an error is generated if <package> specified multiple packages)"),
00226         NULL},
00227 
00228  { "apply", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00229         (_noTransScripts|_noTransTriggers|
00230                 RPMTRANS_FLAG_APPLYONLY|RPMTRANS_FLAG_PKGCOMMIT),
00231         N_("do not execute package scriptlet(s)"), NULL },
00232 
00233  { "badreloc", '\0', POPT_BIT_SET,
00234         &rpmIArgs.probFilter, RPMPROB_FILTER_FORCERELOCATE,
00235         N_("relocate files in non-relocatable package"), NULL},
00236 
00237  { "dirstash", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00238         &rpmIArgs.transFlags, RPMTRANS_FLAG_DIRSTASH,
00239         N_("save erased package files by renaming into sub-directory"), NULL},
00240  { "erase", 'e', POPT_BIT_SET,
00241         &rpmIArgs.installInterfaceFlags, INSTALL_ERASE,
00242         N_("erase (uninstall) package"), N_("<package>+") },
00243  { "excludeconfigs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00244         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOCONFIGS,
00245         N_("do not install configuration files"), NULL},
00246  { "excludedocs", '\0', POPT_BIT_SET,
00247         &rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
00248         N_("do not install documentation"), NULL},
00249  { "excludepath", '\0', POPT_ARG_STRING, 0, POPT_EXCLUDEPATH,
00250         N_("skip files with leading component <path> "),
00251         N_("<path>") },
00252 
00253  { "force", '\0', 0, NULL, RPMCLI_POPT_FORCE,
00254         N_("short hand for --replacepkgs --replacefiles"), NULL},
00255 
00256  { "freshen", 'F', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags,
00257         (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL),
00258         N_("upgrade package(s) if already installed"),
00259         N_("<packagefile>+") },
00260  { "hash", 'h', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags, INSTALL_HASH,
00261         N_("print hash marks as package installs (good with -v)"), NULL},
00262 #ifndef DIEDIEDIE
00263  { "ignorearch", '\0', POPT_BIT_SET,
00264         &rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREARCH,
00265         N_("don't verify package architecture"), NULL},
00266  { "ignoreos", '\0', POPT_BIT_SET,
00267         &rpmIArgs.probFilter, RPMPROB_FILTER_IGNOREOS,
00268         N_("don't verify package operating system"), NULL},
00269 #endif
00270  { "ignoresize", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00271         (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES),
00272         N_("don't check disk space before installing"), NULL},
00273  { "includedocs", '\0', POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.incldocs, 0,
00274         N_("install documentation"), NULL},
00275 
00276  { "install", 'i', 0, NULL, 'i',
00277         N_("install package(s)"), N_("<packagefile>+") },
00278 
00279  { "justdb", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_JUSTDB,
00280         N_("update the database, but do not modify the filesystem"), NULL},
00281 
00282  { "noconfigs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00283         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOCONFIGS,
00284         N_("do not install configuration files"), NULL},
00285  { "nodeps", '\0', 0, NULL, RPMCLI_POPT_NODEPS,
00286         N_("do not verify package dependencies"), NULL },
00287  { "nodocs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00288         &rpmIArgs.transFlags, RPMTRANS_FLAG_NODOCS,
00289         N_("do not install documentation"), NULL},
00290 
00291  { "nomd5", '\0', POPT_ARGFLAG_DOC_HIDDEN, NULL, RPMCLI_POPT_NOFDIGESTS,
00292         N_("don't verify file digests"), NULL },
00293  { "nofdigests", '\0', 0, NULL, RPMCLI_POPT_NOFDIGESTS,
00294         N_("don't verify file digests"), NULL },
00295  { "nocontexts", '\0',0,  NULL, RPMCLI_POPT_NOCONTEXTS,
00296         N_("don't install file security contexts"), NULL},
00297 
00298  { "noorder", '\0', POPT_BIT_SET,
00299         &rpmIArgs.installInterfaceFlags, INSTALL_NOORDER,
00300         N_("do not reorder package installation to satisfy dependencies"),
00301         NULL},
00302 
00303  { "noscripts", '\0', 0, NULL, RPMCLI_POPT_NOSCRIPTS,
00304         N_("do not execute package scriptlet(s)"), NULL },
00305 
00306  { "nopretrans", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00307         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOPRETRANS,
00308         N_("do not execute %%pretrans scriptlet (if any)"), NULL },
00309 
00310  { "nopre", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00311         RPMTRANS_FLAG_NOPRE,
00312         N_("do not execute %%pre scriptlet (if any)"), NULL },
00313  { "nopost", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00314         RPMTRANS_FLAG_NOPOST,
00315         N_("do not execute %%post scriptlet (if any)"), NULL },
00316  { "nopreun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00317         RPMTRANS_FLAG_NOPREUN,
00318         N_("do not execute %%preun scriptlet (if any)"), NULL },
00319  { "nopostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.transFlags,
00320         RPMTRANS_FLAG_NOPOSTUN,
00321         N_("do not execute %%postun scriptlet (if any)"), NULL },
00322  { "noposttrans", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00323         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOPOSTTRANS,
00324         N_("do not execute %%postrans scriptlet (if any)"), NULL },
00325 
00326  { "nodigest", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NODIGEST,
00327         N_("don't verify package digest(s)"), NULL },
00328  { "nohdrchk", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOHDRCHK,
00329         N_("don't verify database header(s) when retrieved"), NULL },
00330  { "nosignature", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, RPMCLI_POPT_NOSIGNATURE,
00331         N_("don't verify package signature(s)"), NULL },
00332 
00333  { "notriggers", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, _noTransTriggers,
00334         N_("do not execute any scriptlet(s) triggered by this package"), NULL},
00335  { "notriggerprein", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00336         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPREIN,
00337         N_("do not execute any %%triggerprein scriptlet(s)"), NULL},
00338  { "notriggerin", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00339         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERIN,
00340         N_("do not execute any %%triggerin scriptlet(s)"), NULL},
00341  { "notriggerun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00342         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERUN,
00343         N_("do not execute any %%triggerun scriptlet(s)"), NULL},
00344  { "notriggerpostun", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
00345         &rpmIArgs.transFlags, RPMTRANS_FLAG_NOTRIGGERPOSTUN,
00346         N_("do not execute any %%triggerpostun scriptlet(s)"), NULL},
00347 
00348  { "oldpackage", '\0', POPT_BIT_SET,
00349         &rpmIArgs.probFilter, RPMPROB_FILTER_OLDPACKAGE,
00350         N_("upgrade to an old version of the package (--force on upgrades does this automatically)"),
00351         NULL},
00352  { "percent", '\0', POPT_BIT_SET,
00353         &rpmIArgs.installInterfaceFlags, INSTALL_PERCENT,
00354         N_("print percentages as package installs"), NULL},
00355  { "prefix", '\0', POPT_ARG_STRING, &rpmIArgs.qva_prefix, 0,
00356         N_("relocate the package to <dir>, if relocatable"),
00357         N_("<dir>") },
00358  { "relocate", '\0', POPT_ARG_STRING, 0, POPT_RELOCATE,
00359         N_("relocate files from path <old> to <new>"),
00360         N_("<old>=<new>") },
00361  { "repackage", '\0', POPT_BIT_SET,
00362         &rpmIArgs.transFlags, RPMTRANS_FLAG_REPACKAGE,
00363         N_("save erased package files by repackaging"), NULL},
00364  { "replacefiles", '\0', POPT_BIT_SET, &rpmIArgs.probFilter,
00365         (RPMPROB_FILTER_REPLACEOLDFILES | RPMPROB_FILTER_REPLACENEWFILES),
00366         N_("ignore file conflicts between packages"), NULL},
00367  { "replacepkgs", '\0', POPT_BIT_SET,
00368         &rpmIArgs.probFilter, RPMPROB_FILTER_REPLACEPKG,
00369         N_("reinstall if the package is already present"), NULL},
00370  { "rollback", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_ROLLBACK,
00371         N_("deinstall new, reinstall old, package(s), back to <date>"),
00372         N_("<date>") },
00373  { "arbgoal", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_AUTOROLLBACK_GOAL,
00374         N_("If transaction fails rollback to <date>"),
00375         N_("<date>") },
00376  { "rbexclude", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_ROLLBACK_EXCLUDE,
00377         N_("Exclude Transaction I.D. from rollback"),
00378         N_("<tid>") },
00379  { "test", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_TEST,
00380         N_("don't install, but tell if it would work or not"), NULL},
00381  { "upgrade", 'U', POPT_BIT_SET,
00382         &rpmIArgs.installInterfaceFlags, (INSTALL_UPGRADE|INSTALL_INSTALL),
00383         N_("upgrade package(s)"),
00384         N_("<packagefile>+") },
00385 
00386    POPT_TABLEEND
00387 };
00388 /*@=bitwisesigned =compmempass @*/

Generated on Tue Dec 27 22:41:14 2016 for rpm by  doxygen 1.4.4