Lift specfile query out of main rpm(query) into separate binary
- Avoids having to link /bin/rpm with librpmbuild and everything it might bring in (eg libmagic) which are not needed for core operation. - Minimally preserve backwards compatibility with popt exec alias
This commit is contained in:
parent
e188767e3e
commit
e8a1f5da3e
10
Makefile.am
10
Makefile.am
|
@ -88,7 +88,7 @@ pkginclude_HEADERS += build/rpmspec.h
|
|||
rpmbindir = `echo $(bindir) | $(SED) -e s,usr/bin,bin,`
|
||||
rpmbin_PROGRAMS = rpm
|
||||
|
||||
bin_PROGRAMS = rpm2cpio rpmbuild rpmdb rpmkeys rpmsign
|
||||
bin_PROGRAMS = rpm2cpio rpmbuild rpmdb rpmkeys rpmsign rpmspec
|
||||
|
||||
rpmlibexec_PROGRAMS =
|
||||
rpmconfig_SCRIPTS = find-provides find-requires mkinstalldirs \
|
||||
|
@ -105,7 +105,7 @@ libcliutils_la_LIBADD += @WITH_POPT_LIB@
|
|||
rpm_SOURCES = rpmqv.c debug.h system.h
|
||||
rpm_CPPFLAGS = $(AM_CPPFLAGS) -DIAM_RPMEIU -DIAM_RPMQV
|
||||
rpm_LDADD = libcliutils.la
|
||||
rpm_LDADD += build/librpmbuild.la lib/librpm.la rpmio/librpmio.la
|
||||
rpm_LDADD += lib/librpm.la rpmio/librpmio.la
|
||||
rpm_LDADD += @WITH_NSS_LIB@ @WITH_POPT_LIB@ @WITH_ZLIB_LIB@
|
||||
|
||||
rpmdb_SOURCES = rpmdb.c debug.h system.h
|
||||
|
@ -132,6 +132,12 @@ rpmbuild_LDADD = libcliutils.la
|
|||
rpmbuild_LDADD += build/librpmbuild.la lib/librpm.la rpmio/librpmio.la
|
||||
rpmbuild_LDADD += @WITH_NSS_LIB@ @WITH_POPT_LIB@ @WITH_ZLIB_LIB@
|
||||
|
||||
rpmspec_SOURCES = rpmspec.c debug.h system.h
|
||||
rpmspec_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
rpmspec_LDADD = libcliutils.la
|
||||
rpmspec_LDADD += build/librpmbuild.la lib/librpm.la rpmio/librpmio.la
|
||||
rpmspec_LDADD += @WITH_NSS_LIB@ @WITH_POPT_LIB@ @WITH_ZLIB_LIB@
|
||||
|
||||
rpm2cpio_SOURCES = rpm2cpio.c debug.h system.h
|
||||
rpm2cpio_LDADD = lib/librpm.la rpmio/librpmio.la
|
||||
rpm2cpio_LDADD += @WITH_NSS_LIB@ @WITH_POPT_LIB@ @WITH_ZLIB_LIB@
|
||||
|
|
|
@ -18,7 +18,6 @@ struct rpmQVKArguments_s rpmQVKArgs;
|
|||
#define POPT_QUERYBYNUMBER -1003
|
||||
#define POPT_TRIGGEREDBY -1004
|
||||
#define POPT_DUMP -1005
|
||||
#define POPT_SPECFILE -1006
|
||||
#define POPT_QUERYBYPKGID -1007
|
||||
#define POPT_QUERYBYHDRID -1008
|
||||
#define POPT_QUERYBYFILEID -1009
|
||||
|
@ -59,11 +58,6 @@ static void rpmQVSourceArgCallback( poptContext con,
|
|||
case POPT_QUERYBYTID: qva->qva_source |= RPMQV_TID;
|
||||
qva->qva_sourceCount++; break;
|
||||
|
||||
/* XXX SPECFILE is not verify sources */
|
||||
case POPT_SPECFILE:
|
||||
qva->qva_source |= RPMQV_SPECFILE;
|
||||
qva->qva_sourceCount++;
|
||||
break;
|
||||
case POPT_QUERYBYNUMBER:
|
||||
qva->qva_source |= RPMQV_DBOFFSET;
|
||||
qva->qva_sourceCount++;
|
||||
|
@ -100,8 +94,6 @@ struct poptOption rpmQVSourcePoptTable[] = {
|
|||
N_("rpm query mode"), NULL },
|
||||
{ "querybynumber", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_QUERYBYNUMBER,
|
||||
N_("query/verify a header instance"), "HDRNUM" },
|
||||
{ "specfile", '\0', 0, 0, POPT_SPECFILE,
|
||||
N_("query a spec file"), N_("<spec>") },
|
||||
{ "tid", '\0', POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_QUERYBYTID,
|
||||
N_("query/verify package(s) from install transaction"), "TID" },
|
||||
{ "triggeredby", '\0', 0, 0, POPT_TRIGGEREDBY,
|
||||
|
|
|
@ -168,6 +168,7 @@ rpm exec --import @BINDIR@/rpmkeys --import
|
|||
rpm exec --initdb @BINDIR@/rpmdb --initdb
|
||||
rpm exec --rebuilddb @BINDIR@/rpmdb --rebuilddb
|
||||
rpm exec --verifydb @BINDIR@/rpmdb --verifydb
|
||||
rpm exec --specfile @BINDIR@/rpmspec -q
|
||||
|
||||
#==============================================================================
|
||||
rpmbuild alias --dbpath --define '_dbpath !#:+' \
|
||||
|
|
2
rpmqv.c
2
rpmqv.c
|
@ -303,9 +303,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:
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#include "system.h"
|
||||
const char *__progname;
|
||||
|
||||
#include <rpm/rpmcli.h>
|
||||
#include <rpm/rpmbuild.h>
|
||||
#include <rpm/rpmlog.h>
|
||||
#include <rpm/rpmts.h>
|
||||
|
||||
#include "cliutils.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
enum modes {
|
||||
MODE_UNKNOWN = 0,
|
||||
MODE_QUERY = (1 << 0),
|
||||
};
|
||||
|
||||
static int mode = MODE_UNKNOWN;
|
||||
|
||||
/* the structure describing the options we take and the defaults */
|
||||
static struct poptOption optionsTable[] = {
|
||||
{ "query", 'q', POPT_ARG_VAL, &mode, MODE_QUERY,
|
||||
N_("Query spec file(s)"), NULL },
|
||||
|
||||
/* XXX FIXME: only queryformat is relevant for spec queries */
|
||||
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmQueryPoptTable, 0,
|
||||
N_("Query options (with -q or --query):"), NULL },
|
||||
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
|
||||
N_("Common options for all rpm modes and executables:"), NULL },
|
||||
|
||||
POPT_AUTOALIAS
|
||||
POPT_AUTOHELP
|
||||
POPT_TABLEEND
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
rpmts ts = NULL;
|
||||
QVA_t qva = &rpmQVKArgs;
|
||||
|
||||
poptContext optCon;
|
||||
int ec = 0;
|
||||
|
||||
optCon = rpmcliInit(argc, argv, optionsTable);
|
||||
|
||||
if (rpmcliPipeOutput && initPipe())
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
ts = rpmtsCreate();
|
||||
switch (mode) {
|
||||
|
||||
case MODE_QUERY:
|
||||
if (!poptPeekArg(optCon))
|
||||
argerror(_("no arguments given for query"));
|
||||
|
||||
qva->qva_source = RPMQV_SPECFILE;
|
||||
qva->qva_specQuery = rpmspecQuery;
|
||||
ec = rpmcliQuery(ts, qva, (ARGV_const_t) poptGetArgs(optCon));
|
||||
break;
|
||||
|
||||
case MODE_UNKNOWN:
|
||||
if (poptPeekArg(optCon) != NULL || argc <= 1 || rpmIsVerbose()) {
|
||||
printUsage(optCon, stderr, 0);
|
||||
ec = argc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ts = rpmtsFree(ts);
|
||||
finishPipe();
|
||||
|
||||
qva->qva_queryFormat = _free(qva->qva_queryFormat);
|
||||
|
||||
rpmcliFini(optCon);
|
||||
|
||||
return RETVAL(ec);
|
||||
}
|
|
@ -62,11 +62,11 @@ hello.spec
|
|||
AT_CLEANUP
|
||||
|
||||
# ------------------------------
|
||||
AT_SETUP([rpm -q --specfile])
|
||||
AT_SETUP([rpmspec -q])
|
||||
AT_KEYWORDS([query])
|
||||
AT_CHECK([
|
||||
run rpm \
|
||||
-q --specfile --qf "%{name}" "${abs_srcdir}"/data/SPECS/hello.spec
|
||||
run rpmspec \
|
||||
-q --qf "%{name}" "${abs_srcdir}"/data/SPECS/hello.spec
|
||||
],
|
||||
[0],
|
||||
[hello],
|
||||
|
|
Loading…
Reference in New Issue