[Pkg-haskell-commits] darcs: tools: Add option to check for possible upgrades

Joachim Breitner mail at joachim-breitner.de
Thu Jul 4 14:13:01 UTC 2013


Thu Jul  4 14:07:58 UTC 2013  Joachim Breitner <mail at joachim-breitner.de>
  * Add option to check for possible upgrades

    M ./all-packages/test-packages.pl -4 +15

Thu Jul  4 14:07:58 UTC 2013  Joachim Breitner <mail at joachim-breitner.de>
  * Add option to check for possible upgrades
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-07-04 14:13:01.763044621 +0000
+++ new-tools/all-packages/test-packages.pl	2013-07-04 14:13:01.833542008 +0000
@@ -10,6 +10,7 @@
 use File::Slurp;
 use Text::Patch;
 use IPC::Run qw( run );
+use Getopt::Long;
 
 my %packages;
 my %versions;
@@ -18,6 +19,12 @@
 my %notest;
 my @flags;
 
+my $allow_upgrade = 0;
+
+GetOptions (
+	"allow-upgrade" => \$allow_upgrade,
+	) or die("Error in command line arguments\n");
+
 print "Reading packages.txt...\n";
 open PACKAGES, "<", "packages.txt" or die $!;
 while (<PACKAGES>) {
@@ -166,7 +173,7 @@
 my $comma = "";
 for my $pkg (sort keys %versions) {
 	next if (exists $comments{$pkg});
-	printf CABAL "    %s%s (== %s)\n", $comma, $pkg, $versions{$pkg};
+	printf CABAL "    %s%s (%s %s)\n", $comma, $pkg, ($allow_upgrade?">=":"=="), $versions{$pkg};
 	$comma = ", ";
 }
 close CABAL;
@@ -176,12 +183,12 @@
 
 for my $pkg (sort keys %versions) {
 	next if (exists $comments{$pkg});
-	push @params, "--constraint", sprintf "%s (== %s)", $pkg, $versions{$pkg};
+	push @params, "--constraint", sprintf "%s (%s %s)", $pkg, ($allow_upgrade?">=":"==") ,$versions{$pkg};
 }
 for my $pkg (sort keys %versions) {
 	next if (exists $comments{$pkg});
 	next if (exists $notest{$pkg});
-	push @params, sprintf "%s-%s", $pkg, $versions{$pkg};
+	push @params, sprintf "%s", $pkg;
 }
 push @params, @flags;
 
@@ -199,7 +206,11 @@
 			next
 		}
 		unless ($versions{$pkg} eq $version) {
-			printf "ERROR: %s has %s but should have %\n", $pkg, $version, $versions{$pkg};
+			if ($allow_upgrade) {
+				printf "Upgrading %s: %s -> %s\n", $pkg, $versions{$pkg}, $version;
+			} else {
+				printf "ERROR: %s has %s but should have %s\n", $pkg, $version, $versions{$pkg};
+			}
 			next
 		}
 		$count++;




More information about the Pkg-haskell-commits mailing list