2006-12-19 00:17:44 +01:00
|
|
|
Provide rpmqpack, a fast way to list all installed packages are
|
|
|
|
check if some package is installed. This is a hack.
|
|
|
|
|
2008-09-12 20:37:28 +02:00
|
|
|
Index: Makefile.am
|
|
|
|
===================================================================
|
|
|
|
--- Makefile.am.orig
|
2006-12-19 00:17:44 +01:00
|
|
|
+++ Makefile.am
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -41,7 +41,7 @@ rpmbin_PROGRAMS = rpm
|
|
|
|
bin_PROGRAMS = rpm2cpio
|
2006-12-19 00:17:44 +01:00
|
|
|
|
|
|
|
pkglibdir = @RPMCONFIGDIR@
|
|
|
|
-pkglib_PROGRAMS = rpmb rpmd rpmi rpmk rpmq
|
|
|
|
+pkglib_PROGRAMS = rpmb rpmd rpmi rpmk rpmq rpmqpack
|
|
|
|
pkglib_DATA = rpmrc rpmpopt-$(VERSION) macros
|
|
|
|
pkglib_SCRIPTS = find-provides find-requires mkinstalldirs \
|
|
|
|
config.guess config.sub config.site
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -93,6 +93,12 @@ rpm2cpio_SOURCES = $(top_srcdir)/rpm2cpi
|
2006-12-19 00:17:44 +01:00
|
|
|
rpm2cpio_LDFLAGS = $(myLDFLAGS)
|
|
|
|
rpm2cpio_LDADD = $(myLDADD) @LIBMISC@
|
|
|
|
|
|
|
|
+rpmqpack_SOURCES = rpmqpack.c
|
|
|
|
+rpmqpack_LDFLAGS = $(myLDFLAGS)
|
|
|
|
+rpmqpack_LDADD = $(top_builddir)/rpmdb/librpmdb.la \
|
|
|
|
+ $(top_builddir)/rpmio/librpmio.la \
|
|
|
|
+ $(top_builddir)/popt/libpopt.la
|
|
|
|
+
|
|
|
|
$(PROGRAMS): $(myLDADD) @WITH_APIDOCS_TARGET@
|
|
|
|
|
|
|
|
.PHONY: splint
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -138,6 +144,8 @@ install-data-local:
|
2006-12-19 00:17:44 +01:00
|
|
|
@LN_S@ ../lib/rpm/rpmv $(DESTDIR)$(bindir)/rpmverify
|
|
|
|
rm -f $(DESTDIR)$(bindir)/rpmsign
|
|
|
|
@LN_S@ ../lib/rpm/rpmk $(DESTDIR)$(bindir)/rpmsign
|
|
|
|
+ rm -f $(DESTDIR)$(bindir)/rpmqpack
|
|
|
|
+ @LN_S@ ../lib/rpm/rpmqpack $(DESTDIR)$(bindir)/rpmqpack
|
|
|
|
rm -f $(DESTDIR)$(bindir)/rpmdb ; \
|
|
|
|
@LN_S@ ../lib/rpm/rpmd $(DESTDIR)$(bindir)/rpmdb ; \
|
|
|
|
for bf in e i u ; do \
|
2008-09-12 20:37:28 +02:00
|
|
|
Index: doc/Makefile.am
|
|
|
|
===================================================================
|
|
|
|
--- doc/Makefile.am.orig
|
2006-12-19 00:17:44 +01:00
|
|
|
+++ doc/Makefile.am
|
|
|
|
@@ -2,6 +2,6 @@
|
|
|
|
|
|
|
|
SUBDIRS = manual fr ja ko pl ru sk
|
|
|
|
|
|
|
|
-man_MANS = gendiff.1 rpm.8 rpmbuild.8 rpmcache.8 rpmdeps.8 rpmgraph.8 rpm2cpio.8
|
|
|
|
+man_MANS = gendiff.1 rpm.8 rpmbuild.8 rpmcache.8 rpmdeps.8 rpmgraph.8 rpm2cpio.8 rpmqpack.8
|
|
|
|
|
|
|
|
EXTRA_DIST = $(man_MANS)
|
2008-09-12 20:37:28 +02:00
|
|
|
Index: doc/rpmqpack.8
|
|
|
|
===================================================================
|
|
|
|
--- /dev/null
|
2006-12-19 00:17:44 +01:00
|
|
|
+++ doc/rpmqpack.8
|
|
|
|
@@ -0,0 +1,25 @@
|
|
|
|
+.TH RPMQPACK 8 "Mar 2002"
|
|
|
|
+.SH NAME
|
|
|
|
+rpmqpack \- check for installed rpm packages
|
|
|
|
+
|
|
|
|
+.SH SYNOPSIS
|
|
|
|
+.B rpmqpack
|
|
|
|
+.RI [ pack1 "] [" pack2 ]...
|
|
|
|
+
|
|
|
|
+.SH DESCRIPTION
|
|
|
|
+rpmqpack checks if packages given as arguments are installed in
|
|
|
|
+the system. It prints each installed package to stdout.
|
|
|
|
+If no arguments are given all installed packages are printed.
|
|
|
|
+
|
|
|
|
+.SH EXIT STATUS
|
|
|
|
+rpmqpack returns 0 if all given packages are installed, otherwise
|
|
|
|
+1.
|
|
|
|
+
|
|
|
|
+.SH SEE ALSO
|
|
|
|
+.BR rpm (1)
|
|
|
|
+
|
|
|
|
+.SH COPYRIGHT
|
|
|
|
+2002 SuSE Linux AG Nuernberg, Germany.
|
|
|
|
+
|
|
|
|
+.SH AUTHOR
|
|
|
|
+Michael Schroeder <mls@suse.de>
|
2008-09-12 20:37:28 +02:00
|
|
|
Index: rpmqpack.c
|
|
|
|
===================================================================
|
|
|
|
--- /dev/null
|
2006-12-19 00:17:44 +01:00
|
|
|
+++ rpmqpack.c
|
|
|
|
@@ -0,0 +1,59 @@
|
|
|
|
+#include <sys/types.h>
|
|
|
|
+#include <limits.h>
|
|
|
|
+#include <fcntl.h>
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <string.h>
|
|
|
|
+
|
|
|
|
+#include <db.h>
|
|
|
|
+
|
|
|
|
+DBT key;
|
|
|
|
+DBT data;
|
|
|
|
+
|
|
|
|
+int
|
|
|
|
+main(int argc, char **argv)
|
|
|
|
+{
|
|
|
|
+ DB *db = 0;
|
|
|
|
+ DBC *dbc = 0;
|
|
|
|
+ int ret = 0;
|
|
|
|
+
|
|
|
|
+ if (db_create(&db, 0, 0))
|
|
|
|
+ {
|
|
|
|
+ perror("db_create");
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+ if (db->open(db, 0, "/var/lib/rpm/Name", 0, DB_HASH, DB_RDONLY, 0664))
|
|
|
|
+ {
|
|
|
|
+ perror("db->open");
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+ if (argc == 1)
|
|
|
|
+ {
|
|
|
|
+ if (db->cursor(db, NULL, &dbc, 0))
|
|
|
|
+ {
|
|
|
|
+ perror("db->cursor");
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+ while (dbc->c_get(dbc, &key, &data, DB_NEXT) == 0)
|
|
|
|
+ printf("%*.*s\n", (int)key.size, (int)key.size, (char *)key.data);
|
|
|
|
+ dbc->c_close(dbc);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ argc--;
|
|
|
|
+ while (argc--)
|
|
|
|
+ {
|
|
|
|
+ argv++;
|
|
|
|
+ key.data = (void *)*argv;
|
|
|
|
+ key.size = strlen(*argv);
|
|
|
|
+ data.data = NULL;
|
|
|
|
+ data.size = 0;
|
|
|
|
+ if (db->get(db, 0, &key, &data, 0) == 0)
|
|
|
|
+ printf("%s\n", *argv);
|
|
|
|
+ else
|
|
|
|
+ ret = 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ db->close(db, 0);
|
|
|
|
+ return ret;
|
|
|
|
+}
|