[pkg-haskell-tools] 02/03: Add tag script
Joachim Breitner
nomeata at moszumanska.debian.org
Thu Aug 13 10:03:27 UTC 2015
This is an automated email from the git hooks/post-receive script.
nomeata pushed a commit to branch master
in repository pkg-haskell-tools.
commit 0ebfd50f5eca2790af25f16b1b254b72818c6be2
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Thu Aug 13 11:57:19 2015 +0200
Add tag script
---
debian/control | 4 ++++
debian/pkg-haskell-tools.install | 4 +++-
dht | 12 ++++++----
lib/DHT.pm | 13 ++++++++++
scripts/tag | 52 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 80 insertions(+), 5 deletions(-)
diff --git a/debian/control b/debian/control
index 35f691b..5db98bf 100644
--- a/debian/control
+++ b/debian/control
@@ -4,6 +4,7 @@ Uploaders: Joachim Breitner <nomeata at debian.org>
Priority: extra
Section: haskell
Build-Depends: debhelper (>= 9),
+ help2man,
haskell-devscripts (>= 0.9),
cdbs,
ghc,
@@ -31,6 +32,9 @@ Depends:
devscripts,
dctrl-tools,
reprepro,
+ ${perl:Depends},
+ ${haskell:Depends},
+ ${shlibs:Depends},
Description: Debian Haskell Group tools
This package provides various convenience tools used by the Debian Haskell
Group.
diff --git a/debian/pkg-haskell-tools.install b/debian/pkg-haskell-tools.install
index f96d760..8941c44 100644
--- a/debian/pkg-haskell-tools.install
+++ b/debian/pkg-haskell-tools.install
@@ -1,2 +1,4 @@
-dist-ghc/build/make-all/make-all var/lib/pkg-haskell-tools
+dist-ghc/build/make-all/make-all var/lib/pkg-haskell-tools/bin
+scripts/tag var/lib/pkg-haskell-tools/bin
+lib/* var/lib/pkg-haskell-tools/lib
dht usr/bin
diff --git a/dht b/dht
index 5f7939b..c437932 100755
--- a/dht
+++ b/dht
@@ -7,12 +7,16 @@ use warnings;
no warnings 'experimental::smartmatch';
use File::Basename;
+use FindBin qw($Bin);;
our $DHT_SCRIPT_DIR;
-if (__FILE__ eq "/usr/bin/dht") {
- $DHT_SCRIPT_DIR="/var/lib/pkg-haskell-tools";
+$ENV{PERL5LIB} = ":" unless $ENV{PERL5LIB};
+if ($Bin eq "/usr/bin") {
+ $DHT_SCRIPT_DIR="/var/lib/pkg-haskell-tools/bin";
+ $ENV{PERL5LIB} = "/var/lib/pkg-haskell-tools/lib" . $ENV{PERL5LIB};
} else {
- $DHT_SCRIPT_DIR=dirname(__FILE__)."/scripts";
+ $DHT_SCRIPT_DIR = "$Bin/scripts";
+ $ENV{PERL5LIB} = "$Bin/lib" . $ENV{PERL5LIB};
}
$ENV{DHT_SCRIPT_DIR} = $DHT_SCRIPT_DIR;
@@ -45,7 +49,7 @@ __END__
}
print "\n";
- print "Run $prog subcommand --help for more information.";
+ print "Run $prog subcommand --help for more information.\n";
exit(0);
}
diff --git a/lib/DHT.pm b/lib/DHT.pm
new file mode 100644
index 0000000..f0f71b6
--- /dev/null
+++ b/lib/DHT.pm
@@ -0,0 +1,13 @@
+
+use warnings;
+use strict;
+
+sub usage ($) {
+ my $usage = shift;
+ if ($ARGV[0] and ($ARGV[0] eq "--help" or $ARGV[0] eq "-h")) {
+ print $usage;
+ exit(1);
+ }
+}
+
+return 1;
diff --git a/scripts/tag b/scripts/tag
new file mode 100755
index 0000000..85c9756
--- /dev/null
+++ b/scripts/tag
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+
+# TODO:
+# * Check for uncommited changes before
+# * Add a dry-run mode, to be used from upload
+
+use strict;
+use warnings;
+
+use DHT;
+
+usage <<__END__;
+tag- Tag a built pakage
+
+Usage: dht tag [directory..]
+
+For all given directories, which should be Debian source packages,
+figure out the current version from debian/changeslog and create a tag, tagging
+the youngest git commit that changed this particular source package.
+__END__
+
+my @dirs = @ARGV;
+
+for my $dir (@dirs) {
+ my $changelog = "$dir/debian/changelog";
+ unless (-r $changelog) {
+ print "ERROR: Could not find $changelog\n";
+ next;
+ }
+ open CHANGELOG, '<', $changelog or die @!;
+ my $firstline = <CHANGELOG>;
+ if ($firstline =~ m/([\w-]+) \(([\w:~.+-]+)\) ([\w-]+);/) {
+ my ($source, $version, $suite) = ($1, $2, $3);
+ my $tag = sprintf "%s_v%s", $source, $version;
+ $tag =~ tr/:~/_/;
+ my $msg = sprintf "Tagging %s version %s, targetted for %s", $source, $version, $suite;
+ if ($suite eq "UNRELEASED") {
+ printf STDERR "Cannot tag UNRELEASED package %s-%s", $source, $version;
+ } else {
+ my $rev = `git log -n 1 --pretty=format:%h -- $dir`;
+ my $ret = system(qw/git tag -a -m/, $msg, $tag, $rev);
+ die (sprintf "Failed to tag %s: %d\n", $tag, $?>>8) if $ret != 0;
+ printf "Added tag %s (revision %s)\n", $tag, $rev;
+ }
+ } else {
+ printf STDERR "Cannot parse %s:\n%s", $changelog, $firstline;
+ next
+ }
+}
+
+
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/pkg-haskell-tools.git
More information about the Pkg-haskell-commits
mailing list