[dh-make-perl] 03/05: Code-deduplication by splitting up guess_tarball()
Axel Beckert
abe at deuxchevaux.org
Sun Jan 19 16:37:28 UTC 2014
This is an automated email from the git hooks/post-receive script.
abe pushed a commit to branch master
in repository dh-make-perl.
commit 19d87805db74f0c93cc622a0b34d1ca71a41b7e5
Author: Axel Beckert <abe at deuxchevaux.org>
Date: Sun Jan 19 14:43:56 2014 +0100
Code-deduplication by splitting up guess_tarball()
The same guessing of tar ball names was done in guess_tarball() as
well as in setup_dir(). The common parts are now in guess_tarball()
which needs a prefix (i.e. everything without .tar.gz) as parameter.
The original use of guess_tarball() in execute() has been replaced by
guess_debian_tarball() which just computes the proper prefix and then
calls guess_tarball() on it.
This facilitates later changes on the algorithm to guess tarballs.
---
debian/changelog | 3 +++
lib/DhMakePerl/Command/make.pm | 33 ++++++++++++++++++---------------
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index cb621c0..287d9d2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -32,6 +32,9 @@ dh-make-perl (0.81-1) UNRELEASED; urgency=medium
* Apply wrap-and-sort.
* Untangle checks for pristine-tar and upstream tarball in
git_add_debian() (Closes: #735968)
+ * Code-deduplication by splitting up guess_tarball() into
+ guess_tarball($prefix) and guess_debian_tarball() and then using
+ guess_tarball() also in setup_dir().
-- Dima Kogan <dima at secretsauce.net> Wed, 25 Dec 2013 17:08:35 +0100
diff --git a/lib/DhMakePerl/Command/make.pm b/lib/DhMakePerl/Command/make.pm
index 55f3174..5e9b9b4 100644
--- a/lib/DhMakePerl/Command/make.pm
+++ b/lib/DhMakePerl/Command/make.pm
@@ -81,7 +81,7 @@ sub execute {
$self->extract_basic();
- $tarball //= $self->guess_tarball if $self->cfg->{vcs} eq 'git';
+ $tarball //= $self->guess_debian_tarball if $self->cfg->{vcs} eq 'git';
unless ( defined $self->cfg->version ) {
$self->pkgversion( $self->version . '-1' );
@@ -255,13 +255,23 @@ sub execute {
return(0);
}
+sub guess_debian_tarball {
+ my $self = shift;
+
+ my $prefix = catfile( $self->main_dir, '..',
+ $self->control->source->Source . '_'
+ . $self->version
+ . '.orig' );
+ $self->guess_tarball($prefix);
+}
+
sub guess_tarball {
my $self = shift;
+ my $prefix = shift;
+ die "guess_tarball(): Needs everything except the file type suffix as parameter"
+ unless defined $prefix;
- my $try = catfile( $self->main_dir, '..',
- $self->control->source->Source . '_'
- . $self->version
- . '.orig.tar.gz' );
+ my $try = "$prefix.tar.gz";
print "Trying $try...";
if ( -f $try ) {
@@ -366,17 +376,10 @@ sub setup_dir {
my $maindir = shift(@ARGV) || '.';
$maindir =~ s/\/$//;
$self->main_dir($maindir);
- my $guessed_tarball = catfile( $self->main_dir, "..",
- basename( $self->main_dir ) . ".tar.gz" );
+ my $guessed_tarball_prefix = catfile( $self->main_dir, "..",
+ basename( $self->main_dir ) );
- print "Trying $guessed_tarball...";
- if ( -f $guessed_tarball ) {
- $tarball = $guessed_tarball;
- print " found.\n";
- }
- else {
- print " not found.\n";
- }
+ $tarball = $self->guess_tarball($guessed_tarball_prefix);
}
return $tarball;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/dh-make-perl.git
More information about the Pkg-perl-cvs-commits
mailing list