#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>
#include "debug.h"
+#if defined(IAM_RPMQ) || defined(IAM_RPMV)
+#define IAM_RPMQV
+#endif
+
enum modes {
MODE_QUERY = (1 << 0),
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;
{ 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,
}
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"));
}
#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"));
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 "
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 /"));
}
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:
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);