[Pkg-haskell-commits] [package-plan] 119/457: Recreate 00-list.tar only when needed

Joachim Breitner nomeata at moszumanska.debian.org
Mon Apr 14 20:05:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

nomeata pushed a commit to branch master
in repository package-plan.

commit c56ff322afd06d300ecb88bd658d5a2c8e13aaad
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Sat Jun 15 08:37:12 2013 +0000

    Recreate 00-list.tar only when needed
---
 test-packages.pl | 94 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 56 insertions(+), 38 deletions(-)

diff --git a/test-packages.pl b/test-packages.pl
index ff237c5..1a888d4 100644
--- a/test-packages.pl
+++ b/test-packages.pl
@@ -64,15 +64,29 @@ for my $pkg (sort keys %packages) {
  	}
 }
 
-print "Creating local hackage \"repository\"...\n";
-system("rm -rf cabal-sandbox");
 my $sandboxdir = cwd() . "/cabal-sandbox";
+my $originaltarpath = $ENV{HOME}."/.cabal/packages/hackage.haskell.org/00-index.tar";
 my $tarpath = "$sandboxdir/packages/debian/00-index.tar";
-mkdir "$sandboxdir" or die $!;
-mkdir "$sandboxdir/packages" or die $!;
-mkdir "$sandboxdir/packages/debian" or die $!;
-open CABALCONFIG, ">", "cabal-sandbox/config" or die $!;
-print CABALCONFIG <<__END__;
+my $createsandbox = 0;
+if (-e $tarpath) {
+	$createsandbox++ if (-M $originaltarpath < -M $tarpath);
+	$createsandbox++ if (-M "./patches" < -M $tarpath);
+	for my $patchfile (<./patches/*>) {
+		$createsandbox++ if (-M $patchfile < -M $tarpath);
+	}
+} else {
+	$createsandbox++;
+}
+
+
+if ($createsandbox) {
+	print "(Re-)Creating local hackage \"repository\"...\n";
+	system("rm","-rf",$sandboxdir);
+	mkdir "$sandboxdir" or die $!;
+	mkdir "$sandboxdir/packages" or die $!;
+	mkdir "$sandboxdir/packages/debian" or die $!;
+	open CABALCONFIG, ">", "cabal-sandbox/config" or die $!;
+	print CABALCONFIG <<__END__;
 remote-repo: debian:http://does-not-exist.example/packages/archive
 remote-repo-cache: $sandboxdir/packages
 world-file: $sandboxdir/world
@@ -82,39 +96,43 @@ install-dirs user
 install-dirs global
   prefix: /does-not-exist
 __END__
-close CABALCONFIG or die $!;
-copy($ENV{HOME}."/.cabal/packages/hackage.haskell.org/00-index.tar",$tarpath) or die $!;
-
-print "Applying patches to repository .cabal files...\n";
-my $tar = Archive::Tar->new($tarpath);
-for my $patchfile (<./patches/*>) {
-	unless ($patchfile =~ m!^./patches/(.*)-(.*?).patch$!) {
-		printf "Ignoring $patchfile, does not match naming scheme <pkg>-<version>.patch\n";
-		next
-	}
-	my $pkg = $1;
-	my $version = $2;
-	unless (exists $versions{$pkg}) {
-		printf "Ignoring patch for %s-%s, not listed in all-packages.txt\n", $pkg ,$version;
-		next
-	}
-	unless ($version eq $versions{$pkg}) {
-		printf "Ignoring patch for %s-%s, version does not match %s in all-packages.txt\n", $pkg ,$version, $versions{$pkg};
-		next
-	}
-	my $cabalpath = sprintf "%s/%s/%s.cabal", $pkg, $version, $pkg;
-	unless ($tar->contains_file($cabalpath)) {
-		printf "File %s not found in 00-index.tar", $cabalpath;
-		next
+
+	close CABALCONFIG or die $!;
+
+	print "Reading 00-list.tar...\n";
+	my $tar = Archive::Tar->new($originaltarpath);
+	print "Applying patches to repository .cabal files...\n";
+	for my $patchfile (<./patches/*>) {
+		next if $patchfile eq "./patches/series";
+		unless ($patchfile =~ m!^./patches/(.*)-(.*?).patch$!) {
+			printf "Ignoring $patchfile, does not match naming scheme <pkg>-<version>.patch\n";
+			next
+		}
+		my $pkg = $1;
+		my $version = $2;
+		unless (exists $versions{$pkg}) {
+			printf "Ignoring patch for %s-%s, not listed in all-packages.txt\n", $pkg ,$version;
+			next
+		}
+		unless ($version eq $versions{$pkg}) {
+			printf "Ignoring patch for %s-%s, version does not match %s in all-packages.txt\n", $pkg ,$version, $versions{$pkg};
+			next
+		}
+		my $cabalpath = sprintf "%s/%s/%s.cabal", $pkg, $version, $pkg;
+		unless ($tar->contains_file($cabalpath)) {
+			printf "File %s not found in 00-index.tar", $cabalpath;
+			next
+		}
+		my ($tarfile) = $tar->get_files($cabalpath);
+		printf "Patching %s.cabal (version %s)\n", $pkg, $version;
+		my $old = $tarfile->get_content();
+		my $patch = read_file($patchfile);
+		my $new = patch($old, $patch, STYLE => "Unified");
+		$tarfile->replace_content($new) or die;
 	}
-	my ($tarfile) = $tar->get_files($cabalpath);
-	printf "Patching %s.cabal (version %s)\n", $pkg, $version;
-	my $old = $tarfile->get_content();
-	my $patch = read_file($patchfile);
-	my $new = patch($old, $patch, STYLE => "Unified");
-	$tarfile->replace_content($new) or die;
+	print "Writing 00-list.tar...\n";
+	$tar->write($tarpath);
 }
-$tar->write($tarpath);
 
 
 print "Creating all-packages.cabal...\n";

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/package-plan.git



More information about the Pkg-haskell-commits mailing list