aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2006-08-25 02:42:39 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2006-08-25 02:42:39 +0000
commit97de88969a686cb7d92586df43a64f280dee9765 (patch)
tree64676416a780e6603c6c2896f99139be2f363255
parente118ad0ec8d6e0d33401eb7183260183d4038c9c (diff)
downloadrpmtools-97de88969a686cb7d92586df43a64f280dee9765.tar
rpmtools-97de88969a686cb7d92586df43a64f280dee9765.tar.gz
rpmtools-97de88969a686cb7d92586df43a64f280dee9765.tar.bz2
rpmtools-97de88969a686cb7d92586df43a64f280dee9765.tar.xz
rpmtools-97de88969a686cb7d92586df43a64f280dee9765.zip
- add media size computation
-rwxr-xr-xgendistrib63
1 files changed, 43 insertions, 20 deletions
diff --git a/gendistrib b/gendistrib
index 9582c31..9800f1f 100755
--- a/gendistrib
+++ b/gendistrib
@@ -134,40 +134,40 @@ EOF
my @hdlists;
my @media_missing_dirs;
-foreach ($distrib->listmedia) {
- $distrib->getvalue($_, 'askmedia') || $distrib->getvalue($_, 'suppl') and next;
+foreach my $m ($distrib->listmedia) {
+ $distrib->getvalue($m, 'askmedia') || $distrib->getvalue($m, 'suppl') and next;
- if (!-d $distrib->getfullpath($_, 'path')) {
+ if (!-d $distrib->getfullpath($m, 'path')) {
next; # this has been checked earlier
}
push @hdlists, {
- media => $_,
+ media => $m,
synthesis2 => $destdir ?
- $destdir . '/' . $distrib->getpath($_, 'synthesis') :
- $distrib->getfullpath($_, 'synthesis'),
+ $destdir . '/' . $distrib->getpath($m, 'synthesis') :
+ $distrib->getfullpath($m, 'synthesis'),
hdlist2 => $destdir ?
- $destdir . '/' .$distrib->getpath($_, 'hdlist') :
- $distrib->getfullpath($_, 'hdlist'),
- dir => $distrib->getpath($_, 'path'),
- descr => $distrib->getvalue($_, 'name'),
+ $destdir . '/' .$distrib->getpath($m, 'hdlist') :
+ $distrib->getfullpath($m, 'hdlist'),
+ dir => $distrib->getpath($m, 'path'),
+ descr => $distrib->getvalue($m, 'name'),
mediainfo => $destdir ?
$destdir . '/' . $distrib->getpath(undef, 'infodir') :
$distrib->getfullpath(undef, 'infodir'),
thismediainfo => ($destdir ?
- $destdir . '/' . $distrib->getpath($_, 'path') :
- $distrib->getfullpath($_, 'path')) . "/media_info",
+ $destdir . '/' . $distrib->getpath($m, 'path') :
+ $distrib->getfullpath($m, 'path')) . "/media_info",
synthesis => ($destdir ?
- $destdir . '/' . $distrib->getpath($_, 'path') :
- $distrib->getfullpath($_, 'path')) . "/media_info/synthesis.hdlist.cz",
+ $destdir . '/' . $distrib->getpath($m, 'path') :
+ $distrib->getfullpath($m, 'path')) . "/media_info/synthesis.hdlist.cz",
hdlist => ($destdir ?
- $destdir . '/' . $distrib->getpath($_, 'path') :
- $distrib->getfullpath($_, 'path')) . "/media_info/hdlist.cz",
+ $destdir . '/' . $distrib->getpath($m, 'path') :
+ $distrib->getfullpath($m, 'path')) . "/media_info/hdlist.cz",
md5sum => ($destdir ?
- $destdir . '/' . $distrib->getpath($_, 'path') :
- $distrib->getfullpath($_, 'path')) . "/media_info/MD5SUM",
- noneedrebuild => $blind ? 0 : $distrib->check_index_sync($_, 'formedia'),
- noneedredomd5 => $distrib->check_media_md5($_),
+ $destdir . '/' . $distrib->getpath($m, 'path') :
+ $distrib->getfullpath($m, 'path')) . "/media_info/MD5SUM",
+ noneedrebuild => $blind ? 0 : $distrib->check_index_sync($m, 'formedia'),
+ noneedredomd5 => $distrib->check_media_md5($m),
};
}
@@ -383,6 +383,29 @@ if (grep { ! ($_->{noneedrebuild} && $_->{noneedredomd5}) } @hdlists) {
}
}
+ print STDERR "Calculating size of medias\n" unless $nooutput;
+ foreach my $e (@hdlists) {
+ my $size = 0;
+ foreach (@{$e->{files} || []}) {
+ $size += (stat($_))[7];
+ }
+ my $blk = 1;
+ my $showsize = $size;
+ my @unit = (' ', qw(k m g));
+ while (@unit) {
+ my $u = shift(@unit);
+ if ($size / $blk < 1) {
+ last;
+ }
+ $showsize = sprintf('%d%s', $size / $blk, $u);
+ $blk *= 1024;
+ }
+ $distrib->setvalue($e->{media}, 'size', $showsize);
+ }
+
+ print STDERR "Rewriting media.cfg file\n" unless $nooutput;
+ $distrib->write_mediacfg($urpmfiles{mediacfg});
+
print STDERR "Building version file\n" unless $nooutput;
$distrib->write_version($urpmfiles{version});
}