Bug#458789: uscan: framework for using external scripts: qx/script/
Osamu Aoki
osamu at debian.org
Sat Sep 5 14:13:39 UTC 2015
Hi,
Let me propose a new generic mangle rule: qx/script/
This mangles by feeding the target $string into the STDIN of script in
the debian directory and reading its STDOUT back into the target
$string.
This works somewhat like a Perl command thus I used qx as the initiating
command.
$script = qx"debian/script";
This is applicable to all mangle rules :-) including pagemangle I
proposed in https://bugs.debian.org/797787 Message #15. (Disregard the
old patch in Message #5 and #10) The exact patch will be posted there
later.
At least this and pagemangle facilitate users to setup a watch file for
the following bug reports:
#451051 Please support parsing .lsm files
#458789 Please allow framework for using external scripts
#614802 watch file syntax for taking version from timestamp
==> The last one needs a new mangling rule after the download.
This is a very generic tool to address many random feature requests
which devscripts maintainer can not be keeping up with.
I just made a proof of concept code snippet which changes the start of
uscan safe_replace($$) as follows:
---------
sub safe_replace($$) {
my ($in, $pat) = @_;
$pat =~ s/^\s*(.*?)\s*$/$1/;
$pat =~ /^(s|tr|y|qx)(.)/;
my ($op, $sep) = ($1, $2 || '');
my $esc = "\Q$sep\E";
my ($parsed_ok, $regexp, $replacement, $flags);
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 '<') {
...
---------
So we can use this as:
opts="pagemangle=qx/script/;suffix=+dfsg1;dversionmangle=s/+dfsg\d*$//" ...
There are relatively strict limitations to the script name for the safe
operation.
This uses Dpkg::IPC and I tested the above code in a mock code
environment and works nicely.
Regards,
Osamu
More information about the devscripts-devel
mailing list