[Pkg-haskell-commits] [package-plan] 116/457: Allow applying patches to cabal files before running cabal-install on it
Joachim Breitner
nomeata at moszumanska.debian.org
Mon Apr 14 20:05:16 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 f6ae5deb90e2f3fae0752e9e9bf9761fd96cb7df
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Fri Jun 14 22:08:35 2013 +0000
Allow applying patches to cabal files before running cabal-install on it
---
test-packages.pl | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/test-packages.pl b/test-packages.pl
index 62f544e..ff237c5 100644
--- a/test-packages.pl
+++ b/test-packages.pl
@@ -6,6 +6,9 @@ use warnings;
use Dpkg::Version;
use Cwd;
use File::Copy;
+use Archive::Tar;
+use File::Slurp;
+use Text::Patch;
my %packages;
my %versions;
@@ -64,6 +67,7 @@ for my $pkg (sort keys %packages) {
print "Creating local hackage \"repository\"...\n";
system("rm -rf cabal-sandbox");
my $sandboxdir = cwd() . "/cabal-sandbox";
+my $tarpath = "$sandboxdir/packages/debian/00-index.tar";
mkdir "$sandboxdir" or die $!;
mkdir "$sandboxdir/packages" or die $!;
mkdir "$sandboxdir/packages/debian" or die $!;
@@ -79,7 +83,38 @@ install-dirs global
prefix: /does-not-exist
__END__
close CABALCONFIG or die $!;
-copy($ENV{HOME}."/.cabal/packages/hackage.haskell.org/00-index.tar", "$sandboxdir/packages/debian/00-index.tar") 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
+ }
+ 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;
+}
+$tar->write($tarpath);
print "Creating all-packages.cabal...\n";
@@ -120,3 +155,6 @@ for my $pkg (sort keys %versions) {
print "Running cabal-install...\n";
(system @params) == 0 or die "cabal install failed: $?";
+
+
+system("rm -rf cabal-sandbox");
--
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