aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--gendepslist.cc240
-rw-r--r--hdlist2files.cc2
-rw-r--r--rpmtools.spec27
4 files changed, 28 insertions, 248 deletions
diff --git a/Makefile b/Makefile
index bcb65b5..d8a77d6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,16 @@
-VERSION = 1.0
+VERSION = 1.1
NAME = rpmtools
FROMC = rpm2header #rpm-find-leaves
-FROMCC = gendepslist hdlist2names hdlist2files
+FROMCC = gendepslist2 hdlist2names hdlist2files hdlist2prereq
ALL = $(FROMC) $(FROMCC)
+CFLAGS = -Wall -g
LIBRPM = /usr/lib/librpm.so.0 -ldb1 -lz -I/usr/include/rpm -lpopt
all: $(ALL)
install: $(ALL)
install -d $(PREFIX)/usr/bin
- install -s $(ALL) $(PREFIX)/usr/bin
+ install -s $(ALL) genhdlist_cz2 $(PREFIX)/usr/bin
$(FROMCC): %: %.cc
$(CXX) $(CFLAGS) $< $(LIBRPM) -o $@
diff --git a/gendepslist.cc b/gendepslist.cc
deleted file mode 100644
index 53ded8d..0000000
--- a/gendepslist.cc
+++ /dev/null
@@ -1,240 +0,0 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <rpm/rpmlib.h>
-#include <rpm/header.h>
-#include <string>
-#include <vector>
-#include <map>
-#include <set>
-#include <fstream>
-#include <algorithm>
-
-
-string get_name(Header header, int_32 tag) {
- int_32 type, count;
- char *name;
-
- headerGetEntry(header, tag, &type, (void **) &name, &count);
- return string(name);
-}
-
-int get_int(Header header, int_32 tag) {
- int_32 type, count;
- int *i;
-
- headerGetEntry(header, tag, &type, (void **) &i, &count);
- return *i;
-}
-
-vector<string> get_info(Header header, int_32 tag) {
- int_32 type, count, i;
- vector<string> r;
- char **list;
-
- headerGetEntry(header, tag, &type, (void **) &list, &count);
- if (list) {
- r.reserve(count);
- for (i = 0; i < count; i++) r.push_back(list[i]);
- }
- return r;
-}
-
-vector<string> get_files(Header header) {
- int_32 type, count, i;
- vector<string> r;
- char **list;
- char ** baseNames, ** dirNames;
- int_32 * dirIndexes;
-
- headerGetEntry(header, RPMTAG_BASENAMES, &type, (void **) &baseNames,
- &count);
- headerGetEntry(header, RPMTAG_DIRINDEXES, &type, (void **) &dirIndexes,
- NULL);
- headerGetEntry(header, RPMTAG_DIRNAMES, &type, (void **) &dirNames, NULL);
-
- if (baseNames && dirNames && dirIndexes) {
- r.reserve(count);
- for(i = 0; i < count; i++) {
- string s(dirNames[dirIndexes[i]]);
- s += baseNames[i];
- r.push_back(s);
- }
- }
- return r;
-}
-
-template<class V, class C> C sum(const V &v, const C &join = C()) {
- typename V::const_iterator p, q;
- C s = C();
- if (v.begin() != v.end()) {
- for (p = q = v.begin(), q++; q != v.end(); p = q, q++) s += *p + join;
- s += *p;
- }
- return s;
-}
-
-template<class A, class B> void map_insert(map<A, set<B> > &m, const A &a, const B &b) {
- if (m.find(a) == m.end()) m[a] = *(new set<B>);
- m[a].insert(b);
-}
-
-template<class A> bool in(const A &a, const vector<A> &v) {
- vector<A>::const_iterator p;
- for (p = v.begin(); p != v.end(); p++) if (*p == a) return 1;
- return 0;
-}
-
-typedef vector<string>::iterator IT;
-
-#define myerror(e) { checknberrors(); e; return; }
-
-struct pack {
- int nberrors;
- static const int max_errors = 20;
- ofstream html, text;
- vector<string> packages;
- map<string, string> short_name;
- map<string, int> size;
- map<string, vector<string> > requires;
- map<string, set<string> > provides;
- map<string, set<set<string> > > pack_requires;
-
- pack(string name) : nberrors(0), html((name + ".html").c_str()), text(name.c_str()) {
- if (!html || !text) {
- cerr << "rpmpackdeps: can't output files\n";
- exit(1);
- }
- }
-
- void checknberrors() {
- if (nberrors++ == max_errors) {
- cerr << "rpmpackdeps: too many errors, leaving!\n";
- exit(1);
- }
- }
-
- int get_package_info(Header header) {
-
- string s_name = get_name(header, RPMTAG_NAME);
- string name = s_name + "-" + get_name(header, RPMTAG_VERSION) + "-" + get_name(header, RPMTAG_RELEASE);
-
- packages.push_back(name);
- short_name[name] = s_name;
- requires[name] = get_info(header, RPMTAG_REQUIRENAME);
- size[name] = get_int(header, RPMTAG_SIZE);
- map_insert(provides, s_name, name);
-
- vector<string> provide = get_info(header, RPMTAG_PROVIDES);
- vector<string> files = get_info(header, RPMTAG_OLDFILENAMES);
- for (IT p = provide.begin(); p != provide.end(); p++) map_insert(provides, *p, name);
- for (IT p = files.begin(); p != files.end(); p++) map_insert(provides, *p, name);
-
- vector<string> newfiles = get_files(header);
- for (IT p = newfiles.begin(); p != newfiles.end(); p++) map_insert(provides, *p, name);
-
- headerFree(header);
- return 1;
- }
-
- void sort() {
- std::sort(packages.begin(), packages.end());
- }
-
- set<set<string> > closure(const string &package) {
- if (pack_requires.find(package) != pack_requires.end()) return pack_requires[package];
-
- set<set<string> > l;
- pack_requires[package] = l; // to avoid circular graphs
-
- for (IT q = requires[package].begin(); q != requires[package].end(); q++) {
- set<string> s;
- if (provides.find(*q) == provides.end()) {
- cerr << package << " requires " << *q << " but no package provide it\n";
- s.insert("NOTFOUND_" + *q);
- } else {
- for (set<string>::const_iterator p = provides[*q].begin(); p != provides[*q].end(); p++) {
- if (*p == package) { s.clear(); break; }
- s.insert(*p);
- }
-
- if (provides[*q].size() == 1) {
-#ifdef CLOSURE
- set<set<string> > c = closure(st);
- l.insert(c.begin(), c.end());
-#endif
- }
- }
- l.insert(s);
- }
- return pack_requires[package] = l;
- }
-
- void print_deps() {
- html << "<html><dl>\n";
- for (IT package = packages.begin(); package != packages.end(); package++) {
- set<set<string> > l = closure(*package);
-
- text << *package << " " << size[*package] << " ";
- html << "<dt>" << *package << "<dd>";
- for (set<set<string> >::const_iterator p = l.begin(); p != l.end(); p++) {
- text << sum(*p, string("|")) << " ";
- html << sum(*p, string(" or ")) << "<br>";
- }
- text << "\n";
- html << "\n";
- }
- html << "</dl></html>\n";
- }
-};
-
-void printHelp(char * name)
-{
- cerr << "usage: \n" << name << " -h name hdlists...\n" << name << " -f name rpms...\n";
-}
-
-int main(int argc, char **argv)
-{
- if (argc > 3) {
- if (!strcmp(argv[1],"-h")) { //Mode Hdlist
- pack p(argv[2]);
- for (int i = 3; 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;
- while ((header=headerRead(fd, HEADER_MAGIC_YES))) p.get_package_info(header);
- }
- fdClose(fd);
- }
- p.sort();
- p.print_deps();
- return 0;
- }
- else {
- int i=2;
- if (!strcmp(argv[1],"-f")) i++;
- //Mode rpm
- pack p(argv[2]);
- for (int i = 3; i < argc; i++)
- {
- FD_t fd = fdOpen(argv[i], O_RDONLY, 0);
- if (fdFileno(fd) < 0) cerr << argv[0] << ": cannot open file " << argv[i] << "\n";
- Header header;
- if (rpmReadPackageInfo(fd, NULL, &header)) cerr << argv[0] <<" : " << argv[i] << " does not appear to be a RPM package\n";
- else p.get_package_info(header);
- fdClose(fd);
- }
- p.sort();
- p.print_deps();
- return 0;
- }
- }
- else
- {
- printHelp(argv[0]);
- return 1;
- }
-}
-
diff --git a/hdlist2files.cc b/hdlist2files.cc
index fe905b9..c439f2f 100644
--- a/hdlist2files.cc
+++ b/hdlist2files.cc
@@ -55,7 +55,7 @@ int main(int argc, char **argv)
if (baseNames && dirNames && dirIndexes) {
for(i = 0; i < count; i++) {
- printf("%s:%s\n", name, dirNames[dirIndexes[i]], baseNames[i]);
+ printf("%s:%s%s\n", name, dirNames[dirIndexes[i]], baseNames[i]);
}
}
}
diff --git a/rpmtools.spec b/rpmtools.spec
index f7016e0..0202a27 100644
--- a/rpmtools.spec
+++ b/rpmtools.spec
@@ -1,6 +1,8 @@
%define name rpmtools
-%define version 1.0
-%define release 9mdk
+%define release 1mdk
+
+# do not modify here, see Makefile in the CVS
+%define version 1.1
Summary: contains various rpm command-line tools
Name: %{name}
@@ -10,14 +12,21 @@ Release: %{release}
# http://www.linuxmandrake.com/en/cvs.php3)
Source0: %{name}-%{version}.tar.bz2
Copyright: GPL
-Group: System Environment/Base
+Group: System/Configuration/Packaging
BuildRoot: %{_tmppath}/%{name}-buildroot
Prefix: %{_prefix}
BuildRequires: rpm-devel >= 3.0.4
+Requires: /usr/bin/perl
%description
Various rpmtools.
+%package devel
+Summary: contains various rpm command-line tools for development
+Group: Development/System
+%description devel
+Various devel rpm tools.
+
%prep
%setup
@@ -33,10 +42,20 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
-/usr/bin/*
+/usr/bin/gendepslist2
+/usr/bin/hdlist2files
+/usr/bin/hdlist2names
+/usr/bin/rpm2header
+/usr/bin/genhdlist_cz2
+%files devel
+%defattr(-,root,root)
+/usr/bin/hdlist2prereq
%changelog
+* Tue Mar 7 2000 Pixel <pixel@mandrakesoft.com> 1.1-1mdk
+- new version (gendepslist2 instead of gendepslist, hdlist2prereq)
+
* Fri Feb 18 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 1.0-9mdk
- Really fix with rpm-3.0.4 (Fredl).