aboutsummaryrefslogtreecommitdiffstats
path: root/genhdlist_cz2
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 /genhdlist_cz2
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 'genhdlist_cz2')
-rw-r--r--genhdlist_cz250
1 files changed, 50 insertions, 0 deletions
diff --git a/genhdlist_cz2 b/genhdlist_cz2
new file mode 100644
index 0000000..7512d68
--- /dev/null
+++ b/genhdlist_cz2
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+
+($noclean, @ARGV) = @ARGV if $ARGV[0] eq "--noclean";
+(undef, $depslist, @ARGV) = @ARGV if $ARGV[0] eq "--ordered-depslist";
+(undef, $hdlist, @ARGV) = @ARGV if $ARGV[0] eq "-o";
+(undef, $root, @ARGV) = @ARGV if $ARGV[0] eq "--distrib";
+
+$hdlist && @ARGV == 1 || $root && @ARGV == 0 or die
+"usage: genhdlist_cz2 [--noclean] [--ordered-depslist <depslist>] -o <hdlist_cz2> <rpm dir>
+ or genhdlist_cz2 [--noclean] --distrib <root distrib>
+";
+
+if ($root) {
+ $depslist = "$root/Mandrake/base/depslist.ordered";
+ $hdlist = "$root/Mandrake/base/hdlist.cz2";
+ $dir = "$root/Mandrake/RPMS";
+ $ENV{PATH} = "$ENV{PATH}:$root/misc";
+} else {
+ ($dir) = @ARGV;
+}
+
+
+$work_dir = "/tmp/.build_hdlist";
+
+
+-e $work_dir && !-d $work_dir and unlink($work_dir) || die "cannot use $work_dir as a working directory";
+chmod 0755, $work_dir or system("rm -rf $work_dir");
+-d $work_dir or mkdir $work_dir, 0755 or die "cannot create working directory $work_dir\n";
+chdir $work_dir;
+
+my (%keys, @keys);
+
+opendir DIR, $dir or die "unable to opendir $dir: $!\n";
+while ($_ = readdir DIR) {
+ my ($key) = /(.*)\..*\.rpm$/ or next;
+ system("rpm2header $dir/$_ > $key") unless -e $key;
+ $? == 0 or unlink($key), die "bad rpm $dir/$_\n";
+ $keys{$key} = 1;
+}
+if (-e $depslist) {
+ open F, $depslist;
+ @keys = map { (split)[0] } <F>;
+}
+@keys = grep { delete $keys{$_} } @keys;
+
+open B, "| build_archive $hdlist 400000";
+print B "$_\n" foreach @keys, keys %keys;
+close B or die "build_archive failed\n";
+
+system("rm -rf $work_dir") unless $noclean;