summaryrefslogtreecommitdiffstats
path: root/autoirpm.update-all.cc
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-12-17 00:21:09 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-12-17 00:21:09 +0000
commit2b6d115da4ba39a0b30eb6e014684d82101f3265 (patch)
tree7ead586efca6413473c0b880d976f3dc5d7f2849 /autoirpm.update-all.cc
parent8bc2804dffe993ded66f55ec4a6d13d9e8ed0bd7 (diff)
downloadurpmi-2b6d115da4ba39a0b30eb6e014684d82101f3265.tar
urpmi-2b6d115da4ba39a0b30eb6e014684d82101f3265.tar.gz
urpmi-2b6d115da4ba39a0b30eb6e014684d82101f3265.tar.bz2
urpmi-2b6d115da4ba39a0b30eb6e014684d82101f3265.tar.xz
urpmi-2b6d115da4ba39a0b30eb6e014684d82101f3265.zip
no_comment
Diffstat (limited to 'autoirpm.update-all.cc')
-rw-r--r--autoirpm.update-all.cc72
1 files changed, 72 insertions, 0 deletions
diff --git a/autoirpm.update-all.cc b/autoirpm.update-all.cc
new file mode 100644
index 00000000..db2ee5a2
--- /dev/null
+++ b/autoirpm.update-all.cc
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <rpmlib.h>
+#include <string>
+#include <set>
+#include <fstream>
+
+
+typedef set<string>::difference_type diff_type;
+
+set<string> *read_set(const char *file) {
+ ifstream input(file);
+ if (input) {
+ set<string> *myset = new set<string>;
+ istream_iterator<string,diff_type> input_set(input),eos;
+ copy(input_set, eos, inserter(*myset, myset->begin()));
+ return myset;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ if (argc <= 3) {
+ cerr << "usage: " << argv[0] << " <allow progs file> <deny progs file> <hdlist> [<hdlist> ...]\n";
+ exit(1);
+ }
+
+ set<string> *allow = read_set(argv[1]);
+ set<string> *deny = read_set(argv[2]);
+
+ for (int i = 3; i < argc; i++) {
+ Header header;
+ FD_t fd = fdOpen(argv[i], O_RDONLY, 0);
+ if (fdFileno(fd) < 0) {
+ fprintf(stderr, "%s: cannot open file %s\n", argv[0], argv[i]);
+ exit(1);
+ }
+
+ while ((header=headerRead(fd, HEADER_MAGIC_YES))) {
+ int_32 type, count;
+ unsigned short *p;
+ char **f, *name, *s;
+ int printed = 0;
+
+ headerGetEntry(header, RPMTAG_NAME, &type, (void **) &name, &count);
+ headerGetEntry(header, RPMTAG_FILEMODES, &type, (void **) &p, &count);
+ headerGetEntry(header, RPMTAG_FILENAMES, &type, (void **) &f, &count);
+ for (; count--; *p++, *f++)
+ if ((*p & 040111) == 0111 &&
+ (s = strrchr(*f, '/')) &&
+ s - 3 >= *f &&
+ strncmp(s - 3, "bin", 3) == 0 &&
+ (!allow || allow->count(s + 1)) &&
+ (!deny || !deny->count(s + 1))) {
+
+ if (!printed) {
+ printed = 1;
+ cout << name;
+ }
+ cout << " " << *f;
+ }
+ if (printed) cout << "\n";
+ }
+ fdClose(fd);
+ }
+ return 0;
+}