From 9e771836253d72c0e2a9f813a4ed79d2e7df3f22 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 27 Feb 2012 21:58:14 +0000 Subject: (get_filesize_from_synthesis) read back real filesizes from synthesis (filter_existing_hdlist) readd back real filesizes read from synthesis else, since hdlist no more have filesizes since 2008, URPM will put a bogus estimation in newly generated synthesis --- NEWS | 2 ++ genhdlist2 | 30 ++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index fcf7aa6..46adfbc 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +- keep real filesizes in synthesis + Version 6.1 - 09 September 2011, by Thierry Vignaud - force locale to be C (mga#95, Pascal Terjan) diff --git a/genhdlist2 b/genhdlist2 index 325456f..a77e510 100644 --- a/genhdlist2 +++ b/genhdlist2 @@ -115,7 +115,7 @@ sub do_it { } my @xml_media_info = $options{xml_info} ? ('info', 'files', 'changelog') : (); - build($urpm, \%rpms_todo, $media_info_dir, $rpms_dir, \@xml_media_info, $options{no_incremental}, $options{no_hdlist}, $xml_info_suffix, $xml_info_filter); + build($urpm, \%rpms_todo, $media_info_dir, $rpms_dir, \@xml_media_info, $options{no_incremental}, $options{no_hdlist}, $xml_info_suffix, $xml_info_filter, $synthesis); build_synthesis($urpm, "$synthesis.tmp", $synthesis_filter); if (1) { @@ -162,7 +162,7 @@ sub read_file_deps { } sub build { - my ($urpm, $rpms_todo, $media_info_dir, $rpms_dir, $xml_media_info, $b_no_incremental, $b_no_hdlist, $xml_info_suffix, $xml_info_filter) = @_; + my ($urpm, $rpms_todo, $media_info_dir, $rpms_dir, $xml_media_info, $b_no_incremental, $b_no_hdlist, $xml_info_suffix, $xml_info_filter, $synthesis) = @_; my $hdlist = "$media_info_dir/hdlist.cz"; @@ -181,9 +181,13 @@ sub build { map { $_ => open_xml_filter("$media_info_dir/$_.xml${xml_info_suffix}.tmp", $xml_info_filter) } @$xml_media_info }; + # keep real filesizes from synthesis since hdlist no more have filesizes since 2008 + # else URPM will put a bogus estimation: + my $sizes = get_filesize_from_synthesis($urpm, $rpms_todo, $synthesis); + if (-e $hdlist && !$b_no_incremental) { print "filtering $hdlist into hdlist.cz.tmp\n" if $verbose >= 0; - filter_existing_hdlist($urpm, $rpms_todo, $hdlist, $out); + filter_existing_hdlist($urpm, $rpms_todo, $hdlist, $out, $sizes); } add_new_rpms_to_hdlist($urpm, $rpms_todo, $out, $rpms_dir); @@ -191,8 +195,23 @@ sub build { close_xml($out->{$_}) foreach @$xml_media_info; } +sub get_filesize_from_synthesis { + my ($urpm, $rpms_todo, $synthesis) = @_; + + return {} if !-r $synthesis; + + my %sizes; + $urpm->parse_synthesis($synthesis, packing => 1, callback => sub { + my (undef, $pkg) = @_; + my $fullname = $pkg->fullname; + $sizes{$fullname} = $pkg->filesize if $rpms_todo->{$fullname}; + 0; # don't keep in memory + }); + \%sizes; +} + sub filter_existing_hdlist { - my ($urpm, $rpms_todo, $in_hdlist, $out) = @_; + my ($urpm, $rpms_todo, $in_hdlist, $out, $sizes) = @_; if ($urpm->parse_hdlist($in_hdlist, packing => 1, callback => sub { my (undef, $pkg) = @_; @@ -200,6 +219,9 @@ sub filter_existing_hdlist { if (delete $rpms_todo->{$fullname}) { print "keeping $fullname\n" if $verbose > 1; add_pkg($out, $pkg); + # readd back real filesize from synthesis since hdlist no more have filesizes since 2008 + # else URPM will put a bogus estimation: + $pkg->set_filesize($sizes->{$fullname}) if $sizes->{$fullname}; 1; # do keep in memory } else { print "removing $fullname\n" if $verbose > 0; -- cgit v1.2.1