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.
|
|
|
|
|
2011-05-16 18:07:44 +02:00
|
|
|
--- ./Makefile.am.orig 2011-05-11 14:27:32.000000000 +0000
|
|
|
|
+++ ./Makefile.am 2011-05-11 15:15:27.000000000 +0000
|
|
|
|
@@ -170,6 +170,10 @@ rpmgraph_LDADD = lib/librpm.la rpmio/lib
|
|
|
|
|
|
|
|
dist_bin_SCRIPTS = scripts/gendiff
|
2006-12-19 00:17:44 +01:00
|
|
|
|
2009-08-28 15:54:03 +02:00
|
|
|
+bin_PROGRAMS += rpmqpack
|
|
|
|
+rpmqpack_SOURCES = rpmqpack.c
|
|
|
|
+rpmqpack_LDADD = lib/librpm.la
|
2006-12-19 00:17:44 +01:00
|
|
|
+
|
2009-08-28 15:54:03 +02:00
|
|
|
rpmconfig_DATA = rpmrc
|
|
|
|
rpmrc: $(top_srcdir)/rpmrc.in
|
|
|
|
@$(SED) \
|
2011-05-16 18:07:44 +02:00
|
|
|
--- ./doc/Makefile.am.orig 2011-01-05 08:11:09.000000000 +0000
|
|
|
|
+++ ./doc/Makefile.am 2011-05-11 15:16:24.000000000 +0000
|
|
|
|
@@ -8,7 +8,7 @@ EXTRA_DIST += $(man_man1_DATA)
|
2006-12-19 00:17:44 +01:00
|
|
|
|
2009-08-28 15:54:03 +02:00
|
|
|
man_man8dir = $(mandir)/man8
|
2011-05-16 18:07:44 +02:00
|
|
|
man_man8_DATA = rpm.8 rpmbuild.8 rpmdeps.8 rpmgraph.8 rpm2cpio.8
|
|
|
|
-man_man8_DATA += rpmdb.8 rpmkeys.8 rpmsign.8 rpmspec.8
|
|
|
|
+man_man8_DATA += rpmdb.8 rpmkeys.8 rpmsign.8 rpmspec.8 rpmqpack.8
|
2009-08-28 15:54:03 +02:00
|
|
|
EXTRA_DIST += $(man_man8_DATA)
|
2006-12-19 00:17:44 +01:00
|
|
|
|
2009-08-28 15:54:03 +02:00
|
|
|
man_fr_man8dir = $(mandir)/fr/man8
|
2011-05-16 18:07:44 +02:00
|
|
|
--- ./doc/rpmqpack.8.orig 2011-05-11 15:15:27.000000000 +0000
|
|
|
|
+++ ./doc/rpmqpack.8 2011-05-11 15:15:27.000000000 +0000
|
2006-12-19 00:17:44 +01:00
|
|
|
@@ -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
|
2014-08-18 15:03:18 +02:00
|
|
|
+2002 SUSE Linux AG Nuernberg, Germany.
|
2006-12-19 00:17:44 +01:00
|
|
|
+
|
|
|
|
+.SH AUTHOR
|
|
|
|
+Michael Schroeder <mls@suse.de>
|
2011-05-16 18:07:44 +02:00
|
|
|
--- ./rpmqpack.c.orig 2011-05-11 15:15:27.000000000 +0000
|
|
|
|
+++ ./rpmqpack.c 2011-05-11 15:15:27.000000000 +0000
|
2006-12-19 00:17:44 +01:00
|
|
|
@@ -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);
|
|
|
|
+ }
|
2011-05-16 18:07:44 +02:00
|
|
|
+ if (db->open(db, 0, "/var/lib/rpm/Name", 0, DB_UNKNOWN, DB_RDONLY, 0664))
|
2006-12-19 00:17:44 +01:00
|
|
|
+ {
|
|
|
|
+ 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;
|
|
|
|
+}
|