On Mon, 27 Jun 2022, The Wanderer wrote:
On 2022-06-27 at 10:31, Tim Woodall wrote:
Hi,
apt-get --only-source --download-only source <package>
will download the latest version of the source package.
Is there a one liner that will give me the version of the package
(including the epoch) without downloading the package and parsing
the dsc?
I'm not aware of one, just offhand; it'd be easy enough, except for the
problem that version number comparison gets complicated in corner cases
such as '+' and '~', and I'm not aware of a way to ensure that the
version number comparison is done correctly without making it no longer
a one-liner.
(Well, short of putting the more complicated logic into a script and
just running that script, but if you want a one-liner I assume that's
not an option.)
------
Everything below here is what I've tried and problems I've
encountered - feel free to comment on this but the above is the
question that I'm particularly interested in whether there's a simple
answer to.
The filename doesn't include the epoch so I can't parse the output
of --print-uris.
apt-cache showsrc <package> lists all of the versions available. I
can (and am) parsing that to find the highest version number.
So... what is it that still needs to be done?
I was putting together a possibly-kludgy easy-enough solution, and was
running into the wall of needing to do pairwise comparisons (with 'dpkg
--compare-versions') of the versions produced by 'apt-cache showsrc
--only-source <package>', since any other comparison method isn't
guaranteed to produce the same highest-version result as dpkg would use
- but if you're already doing this, that looks like it solves the
problem, for me.
Is it just that your parsing makes this no longer a one-liner?
Yes, I'm doing that - but I first have to create a new apt config,
apt-get update in that sandbox, apt-cache show-src, and then dpg
--compare-versions.
I was hoping for something simpler. I now have a script 'get-source.sh'
which takes a distribution and a package and gives me the version (and
downloads the source) but it's several hundred lines of bash.
I guess I could wget the dsc from apt-get --print-uri source (but with
the annoyance I'd have to try -t $dist-updates first and if that fails
-t $dist.) That might actually make sense! I was being bitten by some
large sources where all I wanted to do was check if a newer version
existed.