aboutsummaryrefslogtreecommitdiffstats
path: root/hdlist2prereq.cc
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-03-07 23:37:35 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-03-07 23:37:35 +0000
commitecad1562e7ef9070a2ecce05c05e0b431dc2045a (patch)
tree508a3dfefe74d74703174e4f3e7167aa494034db /hdlist2prereq.cc
parent18a2943fdceb9c1197cdc2b2253db52a94437747 (diff)
downloadrpmtools-ecad1562e7ef9070a2ecce05c05e0b431dc2045a.tar
rpmtools-ecad1562e7ef9070a2ecce05c05e0b431dc2045a.tar.gz
rpmtools-ecad1562e7ef9070a2ecce05c05e0b431dc2045a.tar.bz2
rpmtools-ecad1562e7ef9070a2ecce05c05e0b431dc2045a.tar.xz
rpmtools-ecad1562e7ef9070a2ecce05c05e0b431dc2045a.zip
no_comment
Diffstat (limited to 'hdlist2prereq.cc')
-rw-r--r--hdlist2prereq.cc53
1 files changed, 53 insertions, 0 deletions
diff --git a/hdlist2prereq.cc b/hdlist2prereq.cc
new file mode 100644
index 0000000..68434f0
--- /dev/null
+++ b/hdlist2prereq.cc
@@ -0,0 +1,53 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <rpm/rpmlib.h>
+#include <rpm/header.h>
+#include <iostream>
+
+
+char *get_name(Header header, int_32 tag) {
+ int_32 type, count;
+ char *name;
+
+ headerGetEntry(header, tag, &type, (void **) &name, &count);
+ return name;
+}
+
+int get_int(Header header, int_32 tag) {
+ int_32 type, count;
+ int *i;
+
+ headerGetEntry(header, tag, &type, (void **) &i, &count);
+ return *i;
+}
+
+int main(int argc, char **argv)
+{
+ if (argc <= 1) {
+ cerr << "usage: hdlist2prereq <hdlist> [<hdlists...>]\n";
+ exit(1);
+ }
+ for (int i = 1; i < argc; i++) {
+ FD_t fd = strcmp(argv[i], "-") == 0 ? fdDup(STDIN_FILENO) : fdOpen(argv[i], O_RDONLY, 0);
+ if (fdFileno(fd) < 0) cerr << "rpmpackdeps: cannot open file " << argv[i] << "\n";
+ else {
+ Header header;
+ int_32 type, count;
+ char **list;
+ int *flags;
+
+ while ((header=headerRead(fd, HEADER_MAGIC_YES))) {
+ char *name = get_name(header, RPMTAG_NAME);
+
+ headerGetEntry(header, RPMTAG_REQUIRENAME, &type, (void **) &list, &count);
+ headerGetEntry(header, RPMTAG_REQUIREFLAGS, &type, (void **) &flags, &count);
+
+ if (flags && list)
+ for(i = 0; i < count; i++)
+ if (flags[i] & RPMSENSE_PREREQ) printf("%s:%s\n", name, list[i]);
+ }
+ }
+ fdClose(fd);
+ }
+}