Merge "Fixed incorrect writting host_os to platform/macros for uClibc" into tizen
[platform/upstream/rpm.git] / rpmqv.c
diff --git a/rpmqv.c b/rpmqv.c
index 325449d..da5f2ca 100644 (file)
--- a/rpmqv.c
+++ b/rpmqv.c
@@ -3,9 +3,7 @@ const char *__progname;
 
 #include <rpm/rpmcli.h>
 #include <rpm/rpmlib.h>                        /* RPMSIGTAG, rpmReadPackageFile .. */
-#include <rpm/rpmbuild.h>
 #include <rpm/rpmlog.h>
-#include <rpm/rpmdb.h>
 #include <rpm/rpmps.h>
 #include <rpm/rpmts.h>
 
@@ -13,6 +11,10 @@ const char *__progname;
 
 #include "debug.h"
 
+#if defined(IAM_RPMQ) || defined(IAM_RPMV)
+#define IAM_RPMQV
+#endif
+
 enum modes {
 
     MODE_QUERY         = (1 <<  0),
@@ -26,10 +28,8 @@ enum modes {
     MODE_UNKNOWN       = 0
 };
 
-#define        MODES_FOR_DBPATH        (MODES_IE | MODES_QV)
 #define        MODES_FOR_NODEPS        (MODES_IE | MODE_VERIFY)
 #define        MODES_FOR_TEST          (MODES_IE)
-#define        MODES_FOR_ROOT          (MODES_IE | MODES_QV)
 
 static int quiet;
 
@@ -40,13 +40,17 @@ static struct poptOption optionsTable[] = {
  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQVSourcePoptTable, 0,
         N_("Query/Verify package selection options:"),
         NULL },
+#endif
+#ifdef IAM_RPMQ
  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQueryPoptTable, 0,
        N_("Query options (with -q or --query):"),
        NULL },
+#endif
+#ifdef IAM_RPMV
  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmVerifyPoptTable, 0,
        N_("Verify options (with -V or --verify):"),
        NULL },
-#endif /* IAM_RPMQV */
+#endif
 
 #ifdef IAM_RPMEIU
  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmInstallPoptTable, 0,
@@ -113,7 +117,7 @@ int main(int argc, char *argv[])
     }
 
     if (qva->qva_sourceCount) {
-       if (qva->qva_sourceCount > 2)
+       if (qva->qva_sourceCount > 1)
            argerror(_("one type of query/verify may be performed at a "
                        "time"));
     }
@@ -146,7 +150,7 @@ int main(int argc, char *argv[])
 #if defined(IAM_RPMEIU)
     if (!( bigMode == MODE_INSTALL ) &&
 (ia->probFilter & (RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_OLDPACKAGE)))
-       argerror(_("only installation, upgrading, rmsource and rmspec may be forced"));
+       argerror(_("only installation and upgrading may be forced"));
     if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_FORCERELOCATE))
        argerror(_("files may only be relocated during package installation"));
 
@@ -162,13 +166,13 @@ int main(int argc, char *argv[])
     if (ia->prefix && ia->prefix[0] != '/') 
        argerror(_("arguments to --prefix must begin with a /"));
 
-    if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_HASH))
+    if (!(bigMode & MODES_IE) && (ia->installInterfaceFlags & INSTALL_HASH))
        argerror(_("--hash (-h) may only be specified during package "
-                       "installation"));
+                       "installation and erasure"));
 
-    if (bigMode != MODE_INSTALL && (ia->installInterfaceFlags & INSTALL_PERCENT))
+    if (!(bigMode & MODES_IE) && (ia->installInterfaceFlags & INSTALL_PERCENT))
        argerror(_("--percent may only be specified during package "
-                       "installation"));
+                       "installation and erasure"));
 
     if (bigMode != MODE_INSTALL && (ia->probFilter & RPMPROB_FILTER_REPLACEPKG))
        argerror(_("--replacepkgs may only be specified during package "
@@ -224,19 +228,13 @@ int main(int argc, char *argv[])
 
     if (ia->noDeps & (bigMode & ~MODES_FOR_NODEPS))
        argerror(_("--nodeps may only be specified during package "
-                  "building, rebuilding, recompilation, installation,"
-                  "erasure, and verification"));
+                  "installation, erasure, and verification"));
 
     if ((ia->transFlags & RPMTRANS_FLAG_TEST) && (bigMode & ~MODES_FOR_TEST))
-       argerror(_("--test may only be specified during package installation, "
-                "erasure, and building"));
+       argerror(_("--test may only be specified during package installation "
+                "and erasure"));
 #endif /* IAM_RPMEIU */
 
-    if (rpmcliRootDir && rpmcliRootDir[1] && (bigMode & ~MODES_FOR_ROOT))
-       argerror(_("--root (-r) may only be specified during "
-                "installation, erasure, querying, and "
-                "database rebuilds"));
-
     if (rpmcliRootDir && rpmcliRootDir[0] != '/') {
        argerror(_("arguments to --root (-r) must begin with a /"));
     }
@@ -303,9 +301,7 @@ int main(int argc, char *argv[])
        if (!poptPeekArg(optCon) && !(qva->qva_source == RPMQV_ALL))
            argerror(_("no arguments given for query"));
 
-       qva->qva_specQuery = rpmspecQuery;
        ec = rpmcliQuery(ts, qva, (ARGV_const_t) poptGetArgs(optCon));
-       qva->qva_specQuery = NULL;
        break;
 
     case MODE_VERIFY:
@@ -336,18 +332,20 @@ int main(int argc, char *argv[])
        break;
     }
 
-    ts = rpmtsFree(ts);
-    finishPipe();
+    rpmtsFree(ts);
+    if (finishPipe())
+       ec = EXIT_FAILURE;
 
 #ifdef IAM_RPMQV
-    qva->qva_queryFormat = _free(qva->qva_queryFormat);
+    free(qva->qva_queryFormat);
 #endif
 
 #ifdef IAM_RPMEIU
-    if (ia->relocations != NULL)
-    for (i = 0; i < ia->numRelocations; i++)
-       ia->relocations[i].oldPath = _free(ia->relocations[i].oldPath);
-    ia->relocations = _free(ia->relocations);
+    if (ia->relocations != NULL) {
+       for (i = 0; i < ia->numRelocations; i++)
+           free(ia->relocations[i].oldPath);
+       free(ia->relocations);
+    }
 #endif
 
     rpmcliFini(optCon);