Hi,

Here are few more patches on the top of:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=797787#15

Paths are for:
 Typo fix
 new qx feature.
 new origversion (#458777)

As for #458777
 I see some use for multitarball case etc. where all newversion needs to
 be added with suffix.

 The document request is covered by the new POD manpage.

Test script update and multi tarball patches are in progress here and
not included.  I will try to do without introducing uupdate2 but update
uupdate by merging uupdate2 into it.  Then I will mark it as version=4.

Basically for single upstream tarball case, version3->4 change requires
nothing but setting version=4 if "debian uupdate" is used or both are
missing.  (Any custom script may have some issues.)

uupdate2 is discussed on https://bugs.debian.org/797045.

Osamu

797787#15 patches are now rebased on the top of mk-origtargz changes
discussed on https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=796986#30
.  So But should no conflict.  This one is on top of 797787#15.
>From 56432ee843171e75596da9f5237025c80c61b5d8 Mon Sep 17 00:00:00 2001
From: Osamu Aoki <os...@debian.org>
Date: Fri, 4 Sep 2015 02:47:20 +0000
Subject: [PATCH 1/4] s/dsfg/dfsg/g

---
 scripts/uscan.pl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 8dd5713..714bff0 100644
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -180,14 +180,14 @@ is determined to be B<2.03+dfsg1> without the epoch and the Debian revision.
 If the B<dversionmangle> rule exists, the last upstream version is updated by
 applying this rule to it.  For example, if the last upstream version is
 B<2.03+dfsg1> indicating the source tarball is repackaged, the suffix B<+dfsg1>
-is removed by the string substitution B<s/\+dsfg\d*$//> to make the
+is removed by the string substitution B<s/\+dfsg\d*$//> to make the
 (dversionmangled) last upstream version B<2.03> and it is compared to the
 candidate upstream tarballs such as B<2.03>, B<2.04>, ... .  Thus, set this
 rule as:
 
 =over
 
-=item  B<opts="dversionmangle=s/\+dsfg\d*$//">
+=item  B<opts="dversionmangle=s/\+dfsg\d*$//">
 
 =back
 
@@ -348,7 +348,7 @@ The removal of files is required if files are not DFSG-compliant.  For such
 case, B<+dfsg1> is used as I<suffix>.
 
 So the combined per-site options are set as
-B<opts="dversionmangle=s/\+dsfg\d*$// ,repacksuffix=+dfsg1">, instead.
+B<opts="dversionmangle=s/\+dfsg\d*$// ,repacksuffix=+dfsg1">, instead.
 
 For example, the repacked upstream tarball may be:
 
-- 
2.1.4

>From c77651ea35585f7a91049a1dc1db5e433ea54823 Mon Sep 17 00:00:00 2001
From: Osamu Aoki <os...@debian.org>
Date: Sat, 5 Sep 2015 01:27:19 +0900
Subject: [PATCH 2/4] origversionmangle

---
 scripts/uscan.pl | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 714bff0..9a2d889 100644
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -147,6 +147,8 @@ B<uversionmangle=>I<rules>B<,dversionmangle=>I<rules>
 
 =item * B<filenamemangle=>I<rule> for the downloaded tarball filename string
 
+=item * B<origversionmangle=>I<rule> for the source tarball (B<.orig.tar.gz>) version strings
+
 =item * B<downloadurlmangle=>I<rule> for the candidate upstream tarball URL string
 
 =item * B<pgpsigurlmangle=>I<rule> for the candidate upstream signature file URL string
@@ -576,6 +578,16 @@ some way into one which will work automatically, for example:
   http://developer.berlios.de/project/showfiles.php?group_id=2051 \
   http://prdownload.berlios.de/softdevice/vdr-softdevice-(.+).tgz
 
+=head2 HTTP site (origversionmangle)
+
+The option B<origversionmangle> can be used to mangle the version of the source
+tarball (B<.orig.tar.gz>).  For example, B<+dfsg1> can be added to the upstream
+version as:
+
+  opts=origversionmangle=s/(.*)/$1+dfsg1/ \
+  http://example.com/~user/release/foo.html \
+  files/foo-([\d\.]*).tar.gz
+
 =head2 HTTP site (pagemangle)
 
 The option B<pagemangle> can be used to mangle the downloaded web page before
@@ -1777,6 +1789,9 @@ sub process_watchline ($$$$$$)
 		elsif ($opt =~ /^filenamemangle\s*=\s*(.+)/) {
 		    @{$options{'filenamemangle'}} = split /;/, $1;
 		}
+		elsif ($opt =~ /^origversionmangle\s*=\s*(.+)/) {
+		    @{$options{'origversionmangle'}} = split /;/, $1;
+		}
 		elsif ($opt =~ /^downloadurlmangle\s*=\s*(.+)/) {
 		    @{$options{'downloadurlmangle'}} = split /;/, $1;
 		}
@@ -2165,9 +2180,23 @@ EOF
 	    return 1;
 	}
     }
-    print STDERR "$progname debug: new version $newversion\n" if $debug;
+    foreach my $pat (@{$options{'origversionmangle'}}) {
+	if (! safe_replace(\$newversion, $pat)) {
+	    uscan_warn "$progname: In $watchfile, potentially"
+	      . " unsafe or malformed origversionmangle"
+	      . " pattern:\n  '$pat'"
+	      . " found. Skipping watchline\n"
+	      . "  $line\n";
+		return 1;
+	}
+    }
+    print STDERR "$progname debug: new origversion $newversion\n" if $debug;
+    my $repack_newversion = $newversion;
+    if (defined $options{'repacksuffix'}) {
+	$repack_newversion =. $options{'repacksuffix'};
+    }
+    print STDERR "$progname debug: repackaed origversion $repack_newversion\n" if $debug;
     print STDERR "$progname debug: new filename $newfile\n" if $debug;
-
     my $newfile_base=basename($newfile);
     if (exists $options{'filenamemangle'}) {
         $newfile_base=$newfile;
-- 
2.1.4

>From 66a641992b5617d4bab2295617f6b6bf30c72175 Mon Sep 17 00:00:00 2001
From: Osamu Aoki <os...@debian.org>
Date: Sat, 5 Sep 2015 23:19:20 +0900
Subject: [PATCH 3/4] qx/script/

---
 scripts/uscan.pl | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 9a2d889..5baf618 100644
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -2943,12 +2943,28 @@ sub safe_replace($$) {
     my ($in, $pat) = @_;
     $pat =~ s/^\s*(.*?)\s*$/$1/;
 
-    $pat =~ /^(s|tr|y)(.)/;
+    $pat =~ /^(s|tr|y|qx)(.)/;
     my ($op, $sep) = ($1, $2 || '');
     my $esc = "\Q$sep\E";
     my ($parsed_ok, $regexp, $replacement, $flags);
 
-    if ($sep eq '{' or $sep eq '(' or $sep eq '[' or $sep eq '<') {
+    if ($op eq 'qx') {
+	my $input = $$in;
+	my $output;
+	# script name: [a-zA-Z0-9][-_a-zA-Z0-9]* (any quotation dropped)
+	$pat  =~ s/^qx[^-_a-zA-Z0-9]*([a-zA-Z0-9][-_a-zA-Z0-9]*)[^-_a-zA-Z0-9]*$/debian\/$1/;
+	if ( -x $pat) {
+	    spawn(exec => $pat,
+            from_string => \$input,
+            to_string => \$output,
+            wait_child => 1);
+	    $$in = $output;
+	    return 1;
+	} else {
+	    print STDERR "$progname warning: missing executable $pat: $!\n";
+	    return 0;
+	}
+    } elsif ($sep eq '{' or $sep eq '(' or $sep eq '[' or $sep eq '<') {
 	($parsed_ok, $regexp, $replacement, $flags) = quoted_regex_parse($pat);
 
 	return 0 unless $parsed_ok;
-- 
2.1.4

>From 760f373a87a6b78db732428a650cb5be79be21dc Mon Sep 17 00:00:00 2001
From: Osamu Aoki <os...@debian.org>
Date: Sat, 5 Sep 2015 23:56:12 +0900
Subject: [PATCH 4/4] POD update for qx/script/

---
 scripts/uscan.pl | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 5baf618..92d4d97 100644
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -920,16 +920,23 @@ details.
 =item * multiple rules can be specified for a I<rule> by making a concatenated
 string of B<;> (semicolon) separated operations.
 
-=item * I<rule> may only use the B<s>, B<tr> and B<y> operations.
+=item * I<rule> may only use the B<qx> B<s>, B<tr> and B<y> operations.
 
-=item * When the B<s> operation is used, only the B<g>, B<i> and B<x> flags are
-available and rule may not contain any expressions which have the potential to
-execute code (i.e. the B<(?{})> and B<(??{})> constructs are not supported).
+=item * B<qx/>I<script>B</>
 
-=item * If the B<s> operation is used, the replacement can contain back references
-to expressions within parenthesis in the matching regex, like
-B<s/-alpha(\d*)/.a$1/>. These back references must use the B<$1> syntax, as the
-B<\1> syntax is not supported.
+Filter the target string with the F<debian/script> script.  F<debian/script>
+should be executable.
+
+=item * B<s/>I<regex>B</>I<replacement>B</>I<options>
+
+Regex pattern match and replace the target string.  Only the B<g>, B<i> and
+B<x> flags are available.  Use the B<$1> syntax for the back reference (No
+B<\1> syntax).  Code execution is not allowed (i.e. No B<(?{})> nor B<(??{})>
+constructs).
+
+=item * B<y/>I<source>B</>I<dest>B</> or B<tr/>I<source>B</>I<dest>B</>
+
+Transliterate the characters in the target string.
 
 =item * each operation can not contain B<;> (semicolon) nor B<,> (comma).
 
-- 
2.1.4

Reply via email to