summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhang Qiang <qiang.z.zhang@intel.com>2012-08-28 15:40:05 +0800
committerMichael Schroeder <mls@suse.de>2012-09-27 18:35:13 +0200
commit7891d30e70838a7032b839a05c02bf2c6e293f0e (patch)
tree7db05149c255292afd11fb66567d5062b03cab89
parent3954961663486e61498d7c313d1a870936807937 (diff)
downloadobs-build-7891d30e70838a7032b839a05c02bf2c6e293f0e.tar.gz
obs-build-7891d30e70838a7032b839a05c02bf2c6e293f0e.tar.bz2
obs-build-7891d30e70838a7032b839a05c02bf2c6e293f0e.zip
reused cached repo data file to speed up building
checksum and size is checked before trying to resuse it.
-rwxr-xr-xcreaterepomddeps30
1 files changed, 28 insertions, 2 deletions
diff --git a/createrepomddeps b/createrepomddeps
index b3d8593..cc9b2b0 100755
--- a/createrepomddeps
+++ b/createrepomddeps
@@ -34,9 +34,13 @@ my $repomdparser = {
repomd => {
data => {
_start => \&repomd_handle_data_start,
+ _end => \&repomd_handle_data_end,
location => {
_start => \&repomd_handle_location,
},
+ size => {
+ _text => \&repomd_handle_size,
+ },
},
},
};
@@ -72,6 +76,7 @@ my $primaryparser = {
# [ [tag, \%], ... ]
my @cursor = ();
+my %datafile;
sub repomd_handle_data_start
{
my $p = shift;
@@ -83,6 +88,14 @@ sub repomd_handle_data_start
}
}
+sub repomd_handle_data_end
+{
+ my $p = shift;
+ my $el = shift;
+ push @primaryfiles, {%datafile};
+}
+
+
sub repomd_handle_location
{
my $p = shift;
@@ -90,9 +103,16 @@ sub repomd_handle_location
my $attr = map_attrs(@_);
if(exists $attr->{'href'}) {
- push @primaryfiles, { location => $attr->{'href'} };
+ $datafile{location} = $attr->{'href'};
}
}
+sub repomd_handle_size
+{
+ my $p = shift;
+ my $el = shift;
+ $datafile{size} = $el;
+}
+
sub generic_handle_start
{
@@ -421,7 +441,13 @@ for my $url (@ARGV) {
@cursor = ([undef, $primaryparser]);
my $u = $dir . $f->{'location'};
- if ($url =~ /^http[s]?:\/\/([^\/]*)\/?/) {
+ my $size = 0;
+ my $cached = 0;
+ if ( -e $u ) {
+ $size = (stat($u))[7];
+ $cached = 1 if ($f->{'size'} == $size);
+ }
+ if ($url =~ /^http[s]?:\/\/([^\/]*)\/?/ and !$cached) {
if (system($INC[0].'/download', $dir . "repodata/", $baseurl . "repodata/" . basename($u))) {
die("download failed\n");
}