aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild_archive37
-rw-r--r--gendepslist2.cc5
-rw-r--r--genhdlist_cz217
3 files changed, 45 insertions, 14 deletions
diff --git a/build_archive b/build_archive
index 27e37f5..ae8bcf0 100755
--- a/build_archive
+++ b/build_archive
@@ -48,6 +48,9 @@
#+use strict qw(subs vars refs);
+#- tempory file used for building.
+my $tmpz = "/tmp/tmp.z.$$";
+
sub toc_line {
my ($file, $data) = @_;
@@ -59,6 +62,26 @@ sub toc_line {
}
}
+sub cat_compress {
+ my ($compress, @filenames) = @_;
+ local *F;
+ open F, "| $compress >$tmpz" or die "cannot start \"$compress\"\n";
+ foreach (@filenames) {
+ my ($buf, $siz, $sz);
+ local *FILE;
+ open FILE, $_ or die "cannot open $_: $!\n";
+ $siz = -s $_;
+ while (($sz = sysread(FILE, $buf, $siz > 16384 ? 16384 : $siz))) {
+ $siz -= $sz;
+ syswrite(F, $buf);
+ last unless $siz > 0;
+ }
+ close FILE;
+ }
+ close F;
+ -s $tmpz;
+}
+
sub main {
my ($archivename, $maxsiz) = @_;
my ($compress, $uncompress, $off1, $siz1, $off2, $siz2) = ('', '', 0, 0, 0, 0);
@@ -79,7 +102,7 @@ sub main {
print STDERR "choosing compression method with \"$compress\" for archive $archivename\n";
unlink "$archivename";
- unlink "tmp.z";
+ unlink $tmpz;
foreach (<STDIN>) {
chomp;
@@ -100,12 +123,11 @@ sub main {
$data{$file} = [ 'f', -1, -1, $off2, $siz2 ];
if ($off2 + $siz2 > $maxsiz) { #- need compression.
- system "cat @filelist | $compress >tmp.z";
- $siz1 = -s "tmp.z";
+ $siz1 = cat_compress($compress, @filelist);
foreach (@filelist) { $data{$_} = [ 'f', $off1, $siz1, $data{$_}[3], $data{$_}[4] ] }
- system "cat tmp.z >>$archivename";
+ system "cat $tmpz >>$archivename";
$off1 += $siz1;
$off2 = 0; $siz2 = 0;
@filelist = ();
@@ -114,12 +136,11 @@ sub main {
}
}
if (scalar @filelist) {
- system "cat @filelist | $compress >tmp.z";
- $siz1 = -s "tmp.z";
+ $siz1 = cat_compress($compress, @filelist);
foreach (@filelist) { $data{$_} = [ 'f', $off1, $siz1, $data{$_}[3], $data{$_}[4] ] }
- system "cat tmp.z >>$archivename";
+ system "cat $tmpz >>$archivename";
$off1 += $siz1;
print STDERR "real archive size of $archivename is $off1\n";
}
@@ -172,4 +193,4 @@ sub toc_trailer {
}
main(@ARGV);
-unlink "tmp.z";
+unlink $tmpz;
diff --git a/gendepslist2.cc b/gendepslist2.cc
index 13ac4de..aed37ae 100644
--- a/gendepslist2.cc
+++ b/gendepslist2.cc
@@ -158,7 +158,7 @@ void getRequires(FD_t fd, int current_hdlist) {
string s_name = get_name(header, RPMTAG_NAME);
string name = s_name + "-" + get_name(header, RPMTAG_VERSION) + "-" + get_name(header, RPMTAG_RELEASE);
vector<string> l = get_info(header, RPMTAG_REQUIRENAME);
-
+ if (in(s_name, name2fullname)) continue;
packages.push_back(name);
name2fullname[s_name] = name;
hdlist2names[current_hdlist].insert(name);
@@ -179,11 +179,14 @@ bool notfound(const string &s) {
}
void getProvides(FD_t fd, int current_hdlist) {
+ map<string,bool> used;
Header header;
while ((header=headerRead(fd, HEADER_MAGIC_YES)))
{
string s_name = get_name(header, RPMTAG_NAME);
string name = s_name + "-" + get_name(header, RPMTAG_VERSION) + "-" + get_name(header, RPMTAG_RELEASE);
+ if (in(s_name, used)) continue;
+ used[s_name] = true;
if (in(s_name, provided_by)) provided_by[s_name].push_back(name);
diff --git a/genhdlist_cz2 b/genhdlist_cz2
index ec83e54..6a178a4 100644
--- a/genhdlist_cz2
+++ b/genhdlist_cz2
@@ -38,11 +38,18 @@ 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";
- -s $key or unlink($key), die "bad rpm $dir/$_\n";
- $keys{$key} = 1;
+ my ($key, $arch) = /(.*)\.(.*)\.rpm$/ or next;
+ system("rpm2header $dir/$_ > $_") unless -e $_;
+ $? == 0 or unlink($_), die "bad rpm $dir/$_\n";
+ -s $_ or unlink($_), die "bad rpm $dir/$_\n";
+ if ($keys{$key}) {
+ my ($name, $tail) = $key =~ /(.*)(-[^-]*-[^-]*)/;
+ $keys{"$name($keys{$key})$tail"} = $keys{$key}; unlink "$name($keys{$key})$tail"; link $_, "$name($keys{$key})$tail";
+ $keys{"$name($arch)$tail"} = $arch; unlink "$name($arch)$tail"; link $_, "$name($arch)$tail";
+ delete $keys{$key};
+ } else {
+ $keys{$key} = $arch; unlink $key; link $_, $key;
+ }
}
if (-e $depslist) {
open F, $depslist;