[devscripts] 03/12: uscan: new oversionmangle rule

Osamu Aoki osamu at moszumanska.debian.org
Wed Sep 23 16:43:29 UTC 2015


This is an automated email from the git hooks/post-receive script.

osamu pushed a commit to branch multitar
in repository devscripts.

commit 3bcf112707b008bacbdd32fcaea486b13d2db783
Author: Osamu Aoki <osamu at debian.org>
Date:   Wed Sep 23 21:59:42 2015 +0900

    uscan: new oversionmangle rule
    
    oversionmangle:
        the further mangling of uversionmangled version to the pristine
        tarball version
    
    test_uscan_mangle: enable test for oversionmangle
    
    Use case:
    If you wish to match the downloaded <file>-<version>.tar.gz to be the
    same as the actual upstream, uversionmangle can not be used to prefix
    version number such as 20010101 with prefix 0. for
    <packagename>_<version>.orig.tar.gz.  (This trick enables to avoid epoch
    in future)
    
    Also for the multi upstream tarball (MUT) case, conditional suffix does
    not work since all repackaged and non-repackaged packages needs to carry
    the same suffix.  Also the last version may use +dfsg1, +dfsg2, or ...
    so, you need to have dversionmangle to remove it for comparison with the
    downloaded file.  There is a need to readd suffix for all tarballs..
    
    similar feature origverrsionmangle was discussed as:
     https://bugs.debian.org/458777
---
 scripts/uscan.pl | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 411f467..c84efb4 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -834,6 +834,9 @@ sub process_watchline ($$$$$$)
 		elsif ($opt =~ /^\s*filenamemangle\s*=\s*(.+?)\s*$/) {
 		    @{$options{'filenamemangle'}} = split /;/, $1;
 		}
+		elsif ($opt =~ /^\s*oversionmangle\s*=\s*(.+?)\s*$/) {
+		    @{$options{'oversionmangle'}} = split /;/, $1;
+		}
 		elsif ($opt =~ /^\s*downloadurlmangle\s*=\s*(.+?)\s*$/) {
 		    @{$options{'downloadurlmangle'}} = split /;/, $1;
 		}
@@ -1277,7 +1280,22 @@ EOF
 	    $newfile_base = "$pkg-$newversion.download";
 	}
     }
-    print STDERR "$progname debug: filenamemangled new filename $newfile_base\n" if $debug;
+    print STDERR "$progname debug: new filename selected for download (filenamemangled): $newfile_base\n" if $debug;
+
+    my $mangled_newversion = $newversion;
+    foreach my $pat (@{$options{'oversionmangle'}}) {
+	print STDERR "$progname debug: Oversionmangle rule: $pat\n" if $debug;
+	if (! safe_replace(\$mangled_newversion, $pat)) {
+	    uscan_warn "$progname: In $watchfile, potentially"
+	      . " unsafe or malformed oversionmangle"
+	      . " pattern:\n  '$pat'"
+	      . " found. Skipping watchline\n"
+	      . "  $line\n";
+		return 1;
+	}
+    }
+    # $mangled_newversion = version used for the new orig.tar.gz (a.k.a oversion)
+    print STDERR "$progname debug: new orig.tar.gz tarball version (oversionmangled): $mangled_newversion\n" if $debug;
 
     # So what have we got to report now?
     my $upstream_url;
@@ -1564,7 +1582,7 @@ EOF
     unless ($symlink eq "no") {
 	my @cmd = ("mk-origtargz");
 	push @cmd, "--package", $pkg;
-	push @cmd, "--version", $newversion;
+	push @cmd, "--version", $mangled_newversion;
 	push @cmd, '--repack-suffix', $options{repacksuffix} if defined $options{repacksuffix};
 	push @cmd, "--rename" if $symlink eq "rename";
 	push @cmd, "--copy"   if $symlink eq "copy";
@@ -1584,7 +1602,7 @@ EOF
 	$path = $1 if $mk_origtargz_out =~ /Successfully .* (?:to|as) ([^,]+)(?:,.*)?\.$/;
 	$path = $1 if $mk_origtargz_out =~ /Leaving (.*) where it is/;
 	$target = basename($path);
-	$newversion = $1 if $target =~ m/[^_]+_(.+)\.orig\.tar\.(?:gz|bz2|lzma|xz)$/;
+	$mangled_newversion = $1 if $target =~ m/[^_]+_(.+)\.orig\.tar\.(?:gz|bz2|lzma|xz)$/;
     }
 
     if ($dehs) {
@@ -1620,9 +1638,9 @@ EOF
 	}
 
 	if ($watch_version > 1) {
-	    push @cmd, "--upstream-version", $newversion, $path;
+	    push @cmd, "--upstream-version", $mangled_newversion, $path;
 	} else {
-	    push @cmd, $path, $newversion;
+	    push @cmd, $path, $mangled_newversion;
 	}
 	my $actioncmd = join(" ", @cmd);
 	print "-- Executing user specified script\n     $actioncmd\n" if $verbose;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list