X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git;a=blobdiff_plain;f=samples%2Fgengentooisms;fp=samples%2Fgengentooisms;h=24238e3b0ae6402528f1d6d80c1d7ae912d8a7ca;hp=03253e053397a87edec037b6624ca2fb9cda5bb8;hb=d5ec73d3500d10154218a91cab682ff97287a21d;hpb=363cb060a54409c7ae3032978b3db8eadbead176 diff --git a/samples/gengentooisms b/samples/gengentooisms index 03253e0..24238e3 100755 --- a/samples/gengentooisms +++ b/samples/gengentooisms @@ -43,15 +43,7 @@ sub p { printf $fmt, @args; } -sub timestamp { - my $tm = File::Spec->catfile(PORTAGE, 'metadata', 'timestamp.chk'); - return unless -e $tm; - open my $fh, '<', $tm; - local $/; - <$fh>; -} - -my $timestamp = timestamp(); +my $timestamp = CPANPLUS::Dist::Gentoo::Maps::get_portage_timestamp(PORTAGE); { my $ua; @@ -287,7 +279,7 @@ my $already_parsed = 0; if (-e STATE_FILE) { my $state = Storable::retrieve(STATE_FILE); - if ($state->[0] eq $timestamp) { + if ($state->[0] == $timestamp) { printf "State retrieved from %s\n", STATE_FILE; @not_on_cpan = @{ $state->[1] }; @unfindable = @{ $state->[2] }; @@ -304,7 +296,7 @@ if (-e STATE_FILE) { unless ($already_parsed) { if (-e DATA_FILE) { my $data = Storable::retrieve(DATA_FILE); - if ($data->[0] eq $timestamp) { + if ($data->[0] == $timestamp) { printf "Data retrieved from %s\n", DATA_FILE; %fetched_uri = %{ $data->[1] }; } else { @@ -383,11 +375,15 @@ open my $dst, '>', TARGET; my $max = max map length, keys %name_mismatch; SRC: while (<$src>) { - print $dst $_; - if (/^__DATA__$/) { + if (/^sub TIMESTAMP/) { + print $dst "sub TIMESTAMP () { $timestamp }\n"; + } elsif (/^__DATA__$/) { + print $dst "__DATA__\n"; printf $dst "%s%s %s\n", $_, (' ' x ($max - length)), $name_mismatch{$_} for sort keys %name_mismatch; last SRC; + } else { + print $dst $_; } }