# poptQV.c

Go to the documentation of this file.

    00001
    00006 #include "system.h"
    00007
    00008 #include <rpmcli.h>
    00009 #include <rpmbuild.h>
    00010
    00011 #include "debug.h"
    00012
    00013 /*@unchecked@*/
    00014 struct rpmQVArguments_s rpmQVArgs;
    00015
    00016 /*@unchecked@*/
    00017 int specedit = 0;
    00018
    00019 #define POPT_QUERYFORMAT        -1000
    00020 #define POPT_WHATREQUIRES       -1001
    00021 #define POPT_WHATPROVIDES       -1002
    00022 #define POPT_QUERYBYNUMBER      -1003
    00023 #define POPT_TRIGGEREDBY        -1004
    00024 #define POPT_DUMP               -1005
    00025 #define POPT_SPECFILE           -1006
    00026 #define POPT_QUERYBYPKGID       -1007
    00027 #define POPT_QUERYBYHDRID       -1008
    00028 #define POPT_QUERYBYFILEID      -1009
    00029 #define POPT_QUERYBYTID         -1010
    00030
    00031 /* ========== Query/Verify source popt args */
    00032 static void rpmQVSourceArgCallback( /*@unused@*/ poptContext con,
    00033                 /*@unused@*/ enum poptCallbackReason reason,
    00034                 const struct poptOption * opt, /*@unused@*/ const char * arg,
    00035                 /*@unused@*/ const void * data)
    00036         /*@modifies rpmQVArgs @*/
    00037 {
    00038     QVA_t qva = &rpmQVArgs;
    00039
    00040     switch (opt->val) {
    00041     case 'q':
    00042     case 'Q':
    00043     case 'V':
    00044         if (qva->qva_mode == ' ') {
    00045             qva->qva_mode = opt->val;
    00046             qva->qva_char = ' ';
    00047         }
    00048         break;
    00049     case 'a': qva->qva_source |= RPMQV_ALL; qva->qva_sourceCount++; break;
    00050     case 'f': qva->qva_source |= RPMQV_PATH; qva->qva_sourceCount++; break;
    00051     case 'g': qva->qva_source |= RPMQV_GROUP; qva->qva_sourceCount++; break;
    00052     case 'p': qva->qva_source |= RPMQV_RPM; qva->qva_sourceCount++; break;
    00053     case POPT_WHATPROVIDES: qva->qva_source |= RPMQV_WHATPROVIDES;
    00054                               qva->qva_sourceCount++; break;
    00055     case POPT_WHATREQUIRES: qva->qva_source |= RPMQV_WHATREQUIRES;
    00056                               qva->qva_sourceCount++; break;
    00057     case POPT_TRIGGEREDBY: qva->qva_source |= RPMQV_TRIGGEREDBY;
    00058                               qva->qva_sourceCount++; break;
    00059     case POPT_QUERYBYPKGID: qva->qva_source |= RPMQV_PKGID;
    00060                               qva->qva_sourceCount++; break;
    00061     case POPT_QUERYBYHDRID: qva->qva_source |= RPMQV_HDRID;
    00062                               qva->qva_sourceCount++; break;
    00063     case POPT_QUERYBYFILEID: qva->qva_source |= RPMQV_FILEID;
    00064                               qva->qva_sourceCount++; break;
    00065     case POPT_QUERYBYTID: qva->qva_source |= RPMQV_TID;
    00066                               qva->qva_sourceCount++; break;
    00067
    00068 /* XXX SPECFILE is not verify sources */
    00069     case POPT_SPECFILE:
    00070         qva->qva_source |= RPMQV_SPECFILE;
    00071         qva->qva_sourceCount++;
    00072         break;
    00073     case POPT_QUERYBYNUMBER:
    00074         qva->qva_source |= RPMQV_DBOFFSET;
    00075         qva->qva_sourceCount++;
    00076         break;
    00077     }
    00078 }
    00079
    00083 /*@unchecked@*/
    00084 struct poptOption rpmQVSourcePoptTable[] = {
    00085  { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA,
    00086         rpmQVSourceArgCallback, 0, NULL, NULL },
    00087  { "all", 'a', 0, 0, 'a',
    00088         N_("query/verify all packages"), NULL },
    00089  { "file", 'f', 0, 0, 'f',
    00090         N_("query/verify package(s) owning file"), "FILE" },
    00091  { "fileid", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_QUERYBYFILEID,
    00092         N_("query/verify package(s) with file identifier"), "MD5" },
    00093  { "group", 'g', 0, 0, 'g',
    00094         N_("query/verify package(s) in group"), "GROUP" },
    00095  { "hdrid", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_QUERYBYHDRID,
    00096         N_("query/verify package(s) with header identifier"), "SHA1" },
    00097  { "package", 'p', 0, 0, 'p',
    00098         N_("query/verify a package file (i.e. a binary *.rpm file)"), NULL },
    00099  { "pkgid", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_QUERYBYPKGID,
    00100         N_("query/verify package(s) with package identifier"), "MD5" },
    00101  { "query", 'q', POPT_ARGFLAG_DOC_HIDDEN, NULL, 'q',
    00102         N_("rpm query mode"), NULL },
    00103  { "querybynumber", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0,
    00104         POPT_QUERYBYNUMBER, NULL, NULL },
    00105  { "querytags", '\0', 0, 0, 'Q',
    00106         N_("display known query tags"), NULL },
    00107  { "specfile", '\0', 0, 0, POPT_SPECFILE,
    00108         N_("query a spec file"), N_("<spec>") },
    00109  { "tid", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_QUERYBYTID,
    00110         N_("query/verify package(s) from install transaction"), "TID" },
    00111  { "triggeredby", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_TRIGGEREDBY,
    00112         N_("query the package(s) triggered by the package"), "PACKAGE" },
    00113  { "verify", 'V', POPT_ARGFLAG_DOC_HIDDEN, NULL, 'V',
    00114         N_("rpm verify mode"), NULL },
    00115  { NULL, 'y',  POPT_ARGFLAG_DOC_HIDDEN, NULL, 'V',
    00116         N_("rpm verify mode (legacy)"), NULL },
    00117  { "whatrequires", '\0', 0, 0, POPT_WHATREQUIRES,
    00118         N_("query/verify the package(s) which require a dependency"), "CAPABILITY" },
    00119  { "whatprovides", '\0', 0, 0, POPT_WHATPROVIDES,
    00120         N_("query/verify the package(s) which provide a dependency"), "CAPABILITY" },
    00121    POPT_TABLEEND
    00122 };
    00123
    00124 /* ========== Query specific popt args */
    00125
    00126 static void queryArgCallback(/*@unused@*/poptContext con,
    00127                 /*@unused@*/enum poptCallbackReason reason,
    00128                 const struct poptOption * opt, const char * arg,
    00129                 /*@unused@*/ const void * data)
    00130         /*@modifies rpmQVArgs @*/
    00131 {
    00132     QVA_t qva = &rpmQVArgs;
    00133
    00134     switch (opt->val) {
    00135     case 'c': qva->qva_flags |= QUERY_FOR_CONFIG | QUERY_FOR_LIST; break;
    00136     case 'd': qva->qva_flags |= QUERY_FOR_DOCS | QUERY_FOR_LIST; break;
    00137     case 'l': qva->qva_flags |= QUERY_FOR_LIST; break;
    00138     case 's': qva->qva_flags |= QUERY_FOR_STATE | QUERY_FOR_LIST;
    00139         break;
    00140     case POPT_DUMP: qva->qva_flags |= QUERY_FOR_DUMPFILES | QUERY_FOR_LIST;
    00141         break;
    00142     case 'v': rpmIncreaseVerbosity();    break;
    00143
    00144     case POPT_QUERYFORMAT:
    00145         if (arg) {
    00146             char * qf = (char *)qva->qva_queryFormat;
    00147             if (qf) {
    00148                 int len = strlen(qf) + strlen(arg) + 1;
    00149                 qf = xrealloc(qf, len);
    00150                 strcat(qf, arg);
    00151             } else {
    00152                 qf = xmalloc(strlen(arg) + 1);
    00153                 strcpy(qf, arg);
    00154             }
    00155             qva->qva_queryFormat = qf;
    00156         }
    00157         break;
    00158     }
    00159 }
    00160
    00164 /*@unchecked@*/
    00165 struct poptOption rpmQueryPoptTable[] = {
    00166  { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA,
    00167         queryArgCallback, 0, NULL, NULL },
    00168  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQVSourcePoptTable, 0,
    00169         NULL, NULL },
    00170  { "configfiles", 'c', 0, 0, 'c',
    00171         N_("list all configuration files"), NULL },
    00172  { "docfiles", 'd', 0, 0, 'd',
    00173         N_("list all documentation files"), NULL },
    00174  { "dump", '\0', 0, 0, POPT_DUMP,
    00175         N_("dump basic file information"), NULL },
    00176  { "list", 'l', 0, 0, 'l',
    00177         N_("list files in package"), NULL },
    00178
    00179  /* Duplicate file attr flags from packages into command line options. */
    00180  { "noghost", '\0', POPT_BIT_CLR|POPT_ARGFLAG_DOC_HIDDEN,
    00181         &rpmQVArgs.qva_fflags, RPMFILE_GHOST,
    00182         N_("skip %%ghost files"), NULL },
    00183 #ifdef  NOTEVER         /* XXX there's hardly a need for these */
    00184  { "nolicense", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00185         &rpmQVArgs.qva_fflags, RPMFILE_LICENSE,
    00186         N_("skip %%license files"), NULL },
    00187  { "noreadme", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00188         &rpmQVArgs.qva_fflags, RPMFILE_README,
    00189         N_("skip %%readme files"), NULL },
    00190 #endif
    00191
    00192  { "qf", '\0', POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN, 0,
    00193         POPT_QUERYFORMAT, NULL, NULL },
    00194  { "queryformat", '\0', POPT_ARG_STRING, 0, POPT_QUERYFORMAT,
    00195         N_("use the following query format"), "QUERYFORMAT" },
    00196  { "specedit", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &specedit, -1,
    00197         N_("substitute i18n sections into spec file"), NULL },
    00198  { "state", 's', 0, 0, 's',
    00199         N_("display the states of the listed files"), NULL },
    00200  { "verbose", 'v', 0, 0, 'v',
    00201         N_("display a verbose file listing"), NULL },
    00202    POPT_TABLEEND
    00203 };
    00204
    00208 /*@unchecked@*/
    00209 struct poptOption rpmVerifyPoptTable[] = {
    00210 #ifdef  DYING
    00211  { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA,
    00212         verifyArgCallback, 0, NULL, NULL },
    00213 #endif  /* DYING */
    00214  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQVSourcePoptTable, 0,
    00215         NULL, NULL },
    00216
    00217  /* Duplicate file verify flags from packages into command line options. */
    00218  { "nomd5", '\0', POPT_BIT_SET, &rpmQVArgs.qva_flags, VERIFY_MD5,
    00219         N_("don't verify MD5 digest of files"), NULL },
    00220  { "nosize", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00221         &rpmQVArgs.qva_flags, VERIFY_SIZE,
    00222         N_("don't verify size of files"), NULL },
    00223  { "nolinkto", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00224         &rpmQVArgs.qva_flags, VERIFY_LINKTO,
    00225         N_("don't verify symlink path of files"), NULL },
    00226  { "nouser", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00227         &rpmQVArgs.qva_flags, VERIFY_USER,
    00228         N_("don't verify owner of files"), NULL },
    00229  { "nogroup", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00230         &rpmQVArgs.qva_flags, VERIFY_GROUP,
    00231         N_("don't verify group of files"), NULL },
    00232  { "nomtime", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00233         &rpmQVArgs.qva_flags, VERIFY_MTIME,
    00234         N_("don't verify modification time of files"), NULL },
    00235  { "nomode", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00236         &rpmQVArgs.qva_flags, VERIFY_MODE,
    00237         N_("don't verify mode of files"), NULL },
    00238  { "nordev", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00239         &rpmQVArgs.qva_flags, VERIFY_RDEV,
    00240         N_("don't verify mode of files"), NULL },
    00241
    00242  { "nofiles", '\0', POPT_BIT_SET, &rpmQVArgs.qva_flags, VERIFY_FILES,
    00243         N_("don't verify files in package"), NULL},
    00244  { "nodeps", '\0', POPT_BIT_SET, &rpmQVArgs.qva_flags, VERIFY_DEPS,
    00245         N_("don't verify package dependencies"), NULL },
    00246  { "noscript", '\0', POPT_BIT_SET,&rpmQVArgs.qva_flags, VERIFY_SCRIPT,
    00247         N_("don't execute %verifyscript (if any)"), NULL },
    00248  /* XXX legacy had a trailing s on --noscript */
    00249  { "noscripts", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00250         &rpmQVArgs.qva_flags, VERIFY_SCRIPT,
    00251         N_("don't execute %verifyscript (if any)"), NULL },
    00252  { "nodigest", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
    00253         &rpmQVArgs.qva_flags, VERIFY_DIGEST,
    00254         N_("don't verify header SHA1 digest"), NULL },
    00255
    00256     POPT_TABLEEND
    00257 };