#1037986 uscan: support date/time conversion in *versionmangle

Package:
devscripts
Source:
devscripts
Description:
scripts to make the life of a Debian Package maintainer easier
Submitter:
Fab Stz
Date:
2023-06-15 08:03:05 UTC
Severity:
normal
Tags:
#1037986#5
Date:
2023-06-15 07:34:01 UTC
From:
To:
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
--- /etc/devscripts.conf ---
Empty.
--- ~/.devscripts --- Empty.
#1037986#10
Date:
2023-06-15 07:59:34 UTC
From:
To:
Hi,

if "e" flag in 's///e' were supported, I could use:

uversionmangle=s/(.*)/`date --date='$1' +%s`/e

With a perl call from shell it would be:

echo "2023-06-08 14:28:41.521115" | perl -p -e 's/(.*)/`date --date="$1" +%s`/
e'


Full watch file for information (with s///e)
version=4
opts="searchmode=plain, \
    uversionmangle=s/(.*)/`date --date='$1' +%s`/e, \
    downloadurlmangle=s#.*#https://dl.google.com/android/repository/
repository2-1.xml#, \
    filenamemangle=s#.*#repository2-1.xml#" \
https://dl.google.com/android/repository/repository2-1.xml Generated\son\s(.*)
\swith\sADRT


Full watch file for information (with date)
version=4
opts="searchmode=plain, \
    uversionmangle=date//%s/, \
    downloadurlmangle=s#.*#https://dl.google.com/android/repository/
repository2-1.xml#, \
    filenamemangle=s#.*#repository2-1.xml#" \
https://dl.google.com/android/repository/repository2-1.xml Generated\son\s(.*)
\swith\sADRT



Regards
Fab