[Pkg-haskell-commits] darcs: tools: Recreate 00-list.tar only when needed

Joachim Breitner mail at joachim-breitner.de
Sat Jun 15 08:53:42 UTC 2013


Sat Jun 15 08:37:12 UTC 2013  Joachim Breitner <mail at joachim-breitner.de>
  * Recreate 00-list.tar only when needed

    M ./all-packages/test-packages.pl -37 +55

Sat Jun 15 08:37:12 UTC 2013  Joachim Breitner <mail at joachim-breitner.de>
  * Recreate 00-list.tar only when needed
diff -rN -u old-tools/all-packages/test-packages.pl new-tools/all-packages/test-packages.pl
--- old-tools/all-packages/test-packages.pl	2013-06-15 08:53:42.074040887 +0000
+++ new-tools/all-packages/test-packages.pl	2013-06-15 08:53:42.085540559 +0000
@@ -64,15 +64,29 @@
  	}
 }
 
-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 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";




More information about the Pkg-haskell-commits mailing list