aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-03-23 12:20:51 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-03-23 12:20:51 +0000
commita898762b524ce1e92a2396f36c02aa475c4314f8 (patch)
tree9eb71ad491489b1e2f225f1f85500c2e0c6c9eef
parent116f5db5c2339c9526735df960b4dbc52ee78568 (diff)
downloadrpmtools-a898762b524ce1e92a2396f36c02aa475c4314f8.tar
rpmtools-a898762b524ce1e92a2396f36c02aa475c4314f8.tar.gz
rpmtools-a898762b524ce1e92a2396f36c02aa475c4314f8.tar.bz2
rpmtools-a898762b524ce1e92a2396f36c02aa475c4314f8.tar.xz
rpmtools-a898762b524ce1e92a2396f36c02aa475c4314f8.zip
no_comment
-rw-r--r--Makefile13
-rw-r--r--gendepslist2.cc94
-rw-r--r--genhdlist_cz212
-rw-r--r--rpmtools.spec17
4 files changed, 97 insertions, 39 deletions
diff --git a/Makefile b/Makefile
index b9f409c..e4d8b2d 100644
--- a/Makefile
+++ b/Makefile
@@ -2,9 +2,12 @@ VERSION = 1.1
NAME = rpmtools
FROMC = rpm2header #rpm-find-leaves
FROMCC = gendepslist2 hdlist2names hdlist2files hdlist2prereq
+FROMC_STATIC = $(FROMC:%=%_static)
+FROMCC_STATIC = $(FROMCC:%=%_static)
ALL = $(FROMC) $(FROMCC)
+ALL_STATIC = $(FROMC_STATIC) $(FROMCC_STATIC)
CFLAGS = -Wall -g
-LIBRPM = /usr/lib/librpm.so.0 -ldb1 -lz -I/usr/include/rpm -lpopt
+LIBRPM = -lrpm -ldb1 -lz -lbz2 -I/usr/include/rpm -lpopt
all: $(ALL)
@@ -16,11 +19,17 @@ install: $(ALL)
$(FROMCC): %: %.cc
$(CXX) $(CFLAGS) $< $(LIBRPM) -o $@
+$(FROMCC_STATIC): %_static: %.cc
+ $(CXX) -s -static $(CFLAGS) $< $(LIBRPM) -o $@
+
$(FROMC): %: %.c
$(CC) $(CFLAGS) $< $(LIBRPM) -o $@
+$(FROMC_STATIC): %_static: %.c
+ $(CC) -s -static $(CFLAGS) $< $(LIBRPM) -o $@
+
clean:
- rm -rf *~ $(ALL)
+ rm -rf *~ $(ALL) $(ALL_STATIC)
dis: clean
rm -rf $(NAME)-$(VERSION) ../$(NAME)-$(VERSION).tar*
diff --git a/gendepslist2.cc b/gendepslist2.cc
index 1520c48..57a421f 100644
--- a/gendepslist2.cc
+++ b/gendepslist2.cc
@@ -12,8 +12,6 @@
#define COMPATIBILITY
-string put_first = "setup filesystem";
-
/********************************************************************************/
/* C++ template functions *******************************************************/
@@ -32,7 +30,7 @@ vector<string> split(char sep, const string &l) {
vector<string> r;
for (int pos = 0, pos2 = 0; pos2 >= 0;) {
pos2 = l.find(sep, pos);
- r.push_back(l.substr(pos, pos2));
+ r.push_back(l.substr(pos, pos2 - pos));
pos = pos2 + 1;
}
return r;
@@ -151,7 +149,7 @@ map<string, string> name2fullname;
map<string, vector<string> > requires, frequires;
map<string, vector<string> > provided_by, fprovided_by;
-void getRequires(FD_t fd) {
+void getRequires(FD_t fd, int) {
set<string> all_requires, all_frequires;
Header header;
@@ -272,43 +270,60 @@ void printDepslist(ofstream *out1, ofstream *out2) {
map<string, set<string> > closed = closure(names);
for (ITms p = closed.begin(); p != closed.end(); p++) p->second.erase(p->first);
-
names = closed;
- map<string,int> length;
- for (ITms p = names.begin(); p != names.end(); p++) {
- int l = p->second.size();
- for (ITs q = p->second.begin(); q != p->second.end(); q++) if (q->find('|') != string::npos) l += 1000;
- length[p->first] = l;
- }
- vector<string> put_first_ = split(' ', put_first);
vector<string> packages;
+ set<string> list = hdlist2names[0];
int nb2hdlist[names.size()];
- for (int i = 0; i < nb_hdlists; i++) {
- set<string> list = hdlist2names[i];
- while (list.begin() != list.end()) {
- string n;
- unsigned int l_best = 9999;
+ int i = 0;
+ string n;
+
+ map<string,int> nb_deps_done;
+ for (ITms p = names.begin(); p != names.end(); p++) nb_deps_done[p->first] = 0;
- for (ITv p = put_first_.begin(); p != put_first_.end(); p++)
- if (in(name2fullname[*p], list)) { n = name2fullname[*p]; goto found; }
- for (ITs p = list.begin(); p != list.end(); p++)
- if (names[*p].size() < l_best) {
- l_best = names[*p].size();
+
+ for (int i = -1, nb = 0; i < nb_hdlists; i++, nb++) {
+ set<string> list;
+
+ if (i == -1) {
+ list = names[name2fullname["basesystem"]];
+ list.insert(name2fullname["basesystem"]);
+ for (ITs p = list.begin(); p != list.end(); p++) {
+ if (p->find('|') != string::npos) {
+ list.erase(*p);
+ vector<string> l = split('|', *p);
+ for (ITv k = l.begin(); k != l.end(); k++) {
+ list.insert(*k);
+ add(list, names[*k]);
+ }
+ }
+ }
+ for (ITs p = list.begin(); p != list.end(); p++) hdlist2names[0].erase(*p);
+ } else {
+ list = hdlist2names[i];
+ }
+ while (list.begin() != list.end()) {
+ int l_best = 9999;
+
+ for (ITs p = list.begin(); p != list.end(); p++) {
+ int lo = names[*p].size() - nb_deps_done[*p];
+ if (lo < l_best) {
+ l_best = lo;
n = *p;
- if (l_best == 0) break;
+ if (l_best == -1) break;
}
- found:
+ }
names.erase(n);
list.erase(n);
- nb2hdlist[packages.size()] = i;
+ nb2hdlist[nb++] = i;
packages.push_back(n);
for (ITms p = names.begin(); p != names.end(); p++) p->second.erase(n);
}
}
+ cerr << "ordering done\n";
- int i = 0;
+ i = 0;
map<string,int> where;
for (ITv p = packages.begin(); p != packages.end(); p++, i++) where[*p] = i;
@@ -319,9 +334,19 @@ void printDepslist(ofstream *out1, ofstream *out2) {
for (ITs q = dep.begin(); q != dep.end(); q++) {
if (q->find('|') != string::npos) {
vector<string> l = split('|', *q);
+
+ int skip = 0;
+ for (ITv k = l.begin(); k != l.end(); k++) if (*p == *k) { skip = 1; break; }
+ if (skip) continue;
+
+ *out2 << " ";
+ int previous = 0;
for (ITv k = l.begin(); k != l.end(); k++) {
+ if (previous) *out2 << "|";
+ previous = 1;
+
verif(nb2hdlist[i], nb2hdlist[where[*k]], *p, *k);
- *out2 << " " << where[*k];
+ *out2 << where[*k];
}
} else if (q->compare("NOTFOUND_") > 1) {
*out2 << " " << *q;
@@ -334,8 +359,15 @@ void printDepslist(ofstream *out1, ofstream *out2) {
}
}
-FD_t hdlists(const char *hdlist) {
- return fdDup(fileno(popen(((string) "bzip2 -dc " + hdlist + " 2>/dev/null").c_str(), "r")));
+void hdlists(void (*f)(FD_t, int), const char *hdlist, int current_hdlist) {
+ FILE *pipe = popen(((string) "bzip2 -d <" + hdlist + " 2>/dev/null").c_str(), "r");
+
+ f(fdDup(fileno(pipe)), current_hdlist);
+
+ if (fclose(pipe) != 0) {
+ cerr << "bad hdlist " << hdlist << "\n";
+ exit(1);
+ }
}
int main(int argc, char **argv)
@@ -355,10 +387,10 @@ int main(int argc, char **argv)
nb_hdlists = argc - 1;
- for (int i = 1; i < argc; i++) getRequires(hdlists(argv[i]));
+ for (int i = 1; i < argc; i++) hdlists(getRequires, argv[i], i - 1);
cerr << "getRequires done\n";
- for (int i = 1; i < argc; i++) getProvides(hdlists(argv[i]), i - 1);
+ for (int i = 1; i < argc; i++) hdlists(getProvides, argv[i], i - 1);
cerr << "getProvides done\n";
printDepslist(out1, out2);
diff --git a/genhdlist_cz2 b/genhdlist_cz2
index 7512d68..de3e317 100644
--- a/genhdlist_cz2
+++ b/genhdlist_cz2
@@ -10,15 +10,21 @@ $hdlist && @ARGV == 1 || $root && @ARGV == 0 or die
or genhdlist_cz2 [--noclean] --distrib <root distrib>
";
+chop($pwd = `pwd`);
+
if ($root) {
+ $root = "$pwd/$root" if $root !~ m|^/|;
$depslist = "$root/Mandrake/base/depslist.ordered";
- $hdlist = "$root/Mandrake/base/hdlist.cz2";
- $dir = "$root/Mandrake/RPMS";
+ $hdlist = "$root/Mandrake/base/hdlist.cz2";
+ $dir = "$root/Mandrake/RPMS";
$ENV{PATH} = "$ENV{PATH}:$root/misc";
} else {
($dir) = @ARGV;
}
+$depslist = "$pwd/$depslist" if $depslist !~ m|^/|;
+$hdlist = "$pwd/$hdlist" if $hdlist !~ m|^/|;
+$dir = "$pwd/$dir" if $dir !~ m|^/|;
$work_dir = "/tmp/.build_hdlist";
@@ -44,7 +50,7 @@ if (-e $depslist) {
@keys = grep { delete $keys{$_} } @keys;
open B, "| build_archive $hdlist 400000";
-print B "$_\n" foreach @keys, keys %keys;
+foreach (@keys, keys %keys) { print B "$_\n" }
close B or die "build_archive failed\n";
system("rm -rf $work_dir") unless $noclean;
diff --git a/rpmtools.spec b/rpmtools.spec
index 14f66a8..703f342 100644
--- a/rpmtools.spec
+++ b/rpmtools.spec
@@ -1,5 +1,5 @@
%define name rpmtools
-%define release 3mdk
+%define release 8mdk
# do not modify here, see Makefile in the CVS
%define version 1.1
@@ -16,7 +16,7 @@ Group: System/Configuration/Packaging
BuildRoot: %{_tmppath}/%{name}-buildroot
Prefix: %{_prefix}
BuildRequires: rpm-devel >= 3.0.4
-Requires: /usr/bin/perl
+Requires: /usr/bin/perl rpm >= 3.0.4
%description
Various rpmtools.
@@ -31,7 +31,7 @@ Various devel rpm tools.
%setup
%build
-make
+make CFLAGS="$RPM_OPT_FLAGS"
%install
make install PREFIX=$RPM_BUILD_ROOT
@@ -56,6 +56,17 @@ rm -rf $RPM_BUILD_ROOT
/usr/bin/genhdlists
%changelog
+* Thu Mar 23 2000 Pixel <pixel@mandrakesoft.com> 1.1-8mdk
+- gendepslist2 now handles virtual basesystem requires
+
+* Wed Mar 22 2000 Pixel <pixel@mandrakesoft.com> 1.1-7mdk
+- add require rpm >= 3.0.4
+- gendepslist2 now puts basesystem first in depslist.ordered
+- gendepslist2 orders better
+
+* Mon Mar 20 2000 Pixel <pixel@mandrakesoft.com> 1.1-5mdk
+- fix a bug in gendepslist2 (in case of choices)
+
* Tue Mar 7 2000 Pixel <pixel@mandrakesoft.com> 1.1-1mdk
- new version (gendepslist2 instead of gendepslist, hdlist2prereq)
- host build_archive/extract_archive until francois put them somewhere else :)