Package: devscripts
Version: 2.21.3+deb11u1
Severity: wishlist
Tags: patch
Dear Maintainer,
I'm maintaining a package for which things are bit unusual. I would like that
on tracker.debian.org & qa.debian.org which rely on
https://qa.debian.org/cgi-bin/watch report if there is a new upstream version
available.
In my case, I need to get the latest version from an XML file.
This files contains a date/time which is used to determine the version of the
package in debian in the format of a timestamp.
In the usptream XML there is:
<!--Generated on 2023-06-08 14:28:41.521115 with ADRT.-->
The debian package version would be
1686227321
Now concerning uscan, I would need the ability to convert
from "2023-06-08 14:28:41.521115" to "1686227321"
I tried with `uversionmangle="s///e"` (ie with 'e' flag), something like this
`'s/(.*)/({ eval "date --date$1 +%s"})/ee'` but this returns: 'flags must
consist of "gix"'.
And maybe this would be some security issue to support that "e" flag.
Maybe it would be safer to support a "date" operation in mangle formulas.
You can find attached a patch which would add support for:
`uversionmangle=date//%s/`
It converts the input to the format given in parameter (here %s) and run date
--date='input' +%d
You may update/fix/improve that patch, perl is rather foreign to me. I just
wanted to check if that would be possible.
That feature may also be useful for those having to convert date/time between
upstream format & debian format. For example like:
YYYY-MM-DD → YYYYMMDD
DD-MM-YYYY → YYYYMMDD
DDMMYYYY → YYYYMMDD
YYYY-MM-DD → TIMESTAMP
TIMESTAMP → YYYYMMDD
...
Regards
Fab
-- Package-specific info:
--- /etc/devscripts.conf ---
Empty.
--- ~/.devscripts ---
Empty.
-- System Information:
Debian Release: 11.7
APT prefers oldstable-updates
APT policy: (991, 'oldstable-updates'), (991, 'oldstable-security'), (991,
'oldstable'), (990, 'oldstable-proposed-updates'), (380, 'oldoldstable'),
(379, 'oldoldstable-updates'), (370, 'oldoldstable'), (95, 'testing'), (93,
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.10.0-23-amd64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8),
LANGUAGE=fr:en_US
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages devscripts depends on:
ii dpkg-dev 1.20.12
ii fakeroot 1.25.3-1.1
ii file 1:5.39-3
ii gnupg 2.2.27-2+deb11u2
ii gpgv 2.2.27-2+deb11u2
ii libc6 2.31-13+deb11u6
ii libfile-dirlist-perl 0.05-2
ii libfile-homedir-perl 1.006-1
ii libfile-touch-perl 0.11-1
ii libfile-which-perl 1.23-1
ii libipc-run-perl 20200505.0-1
ii libmoo-perl 2.004004-1
ii libwww-perl 6.52-1
ii patchutils 0.4.2-1
ii perl 5.32.1-4+deb11u2
ii python3 3.9.2-3
ii sensible-utils 0.0.14
ii wdiff 1.2.2-2+b1
Versions of packages devscripts recommends:
ii apt 2.2.4
ii curl 7.74.0-1.3+deb11u7
ii dctrl-tools 2.24-3+b1
ii debian-keyring 2021.07.26
ii dput 1.1.0
ii equivs 2.3.1
ii libdistro-info-perl 1.0
ii libdpkg-perl 1.20.12
ii libencode-locale-perl 1.05-1.1
ii libgit-wrapper-perl 0.048-1
ii libgitlab-api-v4-perl 0.26-1
ii liblist-compare-perl 0.55-1
ii liblwp-protocol-https-perl 6.10-1
ii libsoap-lite-perl 1.27-1
ii libstring-shellquote-perl 1.04-1
ii libtry-tiny-perl 0.30-1
ii liburi-perl 5.08-1
ii licensecheck 3.1.1-2
ii lintian 2.104.0
ii man-db 2.9.4-2
ii patch 2.7.6-7
ii pristine-tar 1.49
ii python3-apt 2.2.1
ii python3-debian 0.1.39
ii python3-magic 2:0.4.20-3
ii python3-requests 2.25.1+dfsg-2
ii python3-unidiff 0.5.5-2
ii python3-xdg 0.27-2
ii strace 5.10-1
ii unzip 6.0-26+deb11u1
ii wget 1.21-1+deb11u1
ii xz-utils 5.2.5-2.1~deb11u1
Versions of packages devscripts suggests:
pn adequate <none>
pn at <none>
ii autopkgtest 5.16
pn bls-standalone <none>
ii build-essential 12.9
pn check-all-the-things <none>
pn cvs-buildpackage <none>
ii debhelper 13.3.4
pn devscripts-el <none>
pn diffoscope <none>
pn disorderfs <none>
pn dose-extra <none>
pn duck <none>
pn faketime <none>
pn gnuplot <none>
pn how-can-i-help <none>
ii libauthen-sasl-perl 2.1600-1.1
pn libdbd-pg-perl <none>
ii libfile-desktopentry-perl 0.22-2
pn libnet-smtps-perl <none>
pn libterm-size-perl <none>
ii libtimedate-perl 2.3300-2
pn libyaml-syck-perl <none>
ii mailutils [mailx] 1:3.10-3+b1
pn mmdebstrap <none>
pn mozilla-devscripts <none>
pn mutt <none>
ii openssh-client [ssh-client] 1:8.4p1-5+deb11u1
pn piuparts <none>
ii postgresql-client-13 [postgresql-client] 13.11-0+deb11u1
pn pristine-lfs <none>
ii quilt 0.66-2.1
pn ratt <none>
pn reprotest <none>
pn svn-buildpackage <none>
pn w3m <none>
-- no debconf information
--- a/lib/Devscripts/Uscan/Utils.pm
+++ b/lib/Devscripts/Uscan/Utils.pm
@@ -259,7 +259,7 @@
eval "uscan_debug \"safe_replace input=\\\"\$\$in\\\"\\n\"";
$pat =~ s/^\s*(.*?)\s*$/$1/;
- $pat =~ /^(s|tr|y)(.)/;
+ $pat =~ /^(s|tr|y|date)(.)/;
my ($op, $sep) = ($1, $2 || '');
my $esc = "\Q$sep\E";
my ($parsed_ok, $regexp, $replacement, $flags);
@@ -273,7 +273,7 @@
return 0;
}
} elsif ($pat
- !~ /^(?:s|tr|y)$esc((?:\\.|[^\\$esc])*)$esc((?:\\.|[^\\$esc])*)$esc([a-z]*)$/
+ !~ /^(?:s|tr|y|date)$esc((?:\\.|[^\\$esc])*)$esc((?:\\.|[^\\$esc])*)$esc([a-z]*)$/
) {
$sep = "/" if $sep eq '';
uscan_warn "stop mangling: rule=\"$pat\"\n"
@@ -309,6 +309,20 @@
} else {
return 1;
}
+ } elsif ($op eq 'date') {
+ uscan_debug "Converting date '$$in' to format: '$replacement'";
+ my $formatted_date = `date --date='$$in' +$replacement`;
+
+ if ($formatted_date == "") {
+ uscan_warn "error getting formatted date. Check input or format";
+ return 0;
+ }
+
+ $formatted_date =~ s/\n//;
+ uscan_debug "Formatted date $formatted_date.";
+
+ $$in = $formatted_date;
+ return 1;
} else {
$safeflags =~ tr/gix//cd;
if ($safeflags ne $flags) {