Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there an easy way to get the latest version number of a source package that is available?

135 views
Skip to first unread message

Tim Woodall

unread,
Jun 27, 2022, 10:40:06 AM6/27/22
to
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?


------
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.

The manpage says --no-all-versions to turn off the default -a but
that doesn't seem to work with showsrc.

apt-cache policy <package> appears to only work with .deb, not sources.

apt-cache also seems to ignore -t and the results are not ordered by
version number:

$ apt-cache -t bullseye showsrc dpkg | grep ^Version:
Version: 1.20.9
Version: 1.20.10
Version: 1.18.24
Version: 1.18.25
Version: 1.19.5
Version: 1.19.7
Version: 1.21.7
Version: 1.21.8


This is also annoying:
$ apt-get -t bullseye --print-uris --only-source source dpkg
Reading package lists... Done
Selected version '1.20.9' (bullseye) for dpkg
NOTICE: 'dpkg' packaging is maintained in the 'Git' version control system at:
https://git.dpkg.org/git/dpkg/dpkg.git
Please use:
git clone https://git.dpkg.org/git/dpkg/dpkg.git
to retrieve the latest (possibly unreleased) updates to the package.
Need to get 4957 kB of source archives.
'http://ftp.uk.debian.org/debian/pool/main/d/dpkg/dpkg_1.20.9.dsc' dpkg_1.20.9.dsc 2120 SHA256:87f21320f3165d1c57dae2314b7fd1849b49da9416fee3fb57c4b1e4192b4285
'http://ftp.uk.debian.org/debian/pool/main/d/dpkg/dpkg_1.20.9.tar.xz' dpkg_1.20.9.tar.xz 4954428 SHA256:5ce242830f213b5620f08e6c4183adb1ef4dc9da28d31988a27c87c71fe534ce


In order to get that 1.20.10 version I have to use -t bullseye-updates.


In buster you don't need to do that: (The list above of the versions was
generated without the buster/updates Suite being added)
after I add it this works:

$ apt-get -t buster --print-uris --only-source source dpkg
Reading package lists... Done
Selected version '1.19.8' (buster) for dpkg
NOTICE: 'dpkg' packaging is maintained in the 'Git' version control system at:
https://git.dpkg.org/git/dpkg/dpkg.git
Please use:
git clone https://git.dpkg.org/git/dpkg/dpkg.git
to retrieve the latest (possibly unreleased) updates to the package.
Need to get 4703 kB of source archives.
'http://security.debian.org/pool/updates/main/d/dpkg/dpkg_1.19.8.dsc' dpkg_1.19.8.dsc 2103 SHA256:3b0220b111044754f8620ce53b1ba67cad9458cab6dde39d299dbb2f27c5528d
'http://security.debian.org/pool/updates/main/d/dpkg/dpkg_1.19.8.tar.xz' dpkg_1.19.8.tar.xz 4701260 SHA256:2632c00b0cf0ea19ed7bd6700e6ec5faca93f0045af629d356dc03ad74ae6f10



(What I'm actually doing now to work around this issue is generate a
separate apt config that only contains one release and then I don't need
to use the -t at all. I run patched versions of some things and my
scripts are supposed to notice that there's a new source but they were
missing the bullseye updates until the weekend)


Tim.

The Wanderer

unread,
Jun 27, 2022, 12:10:05 PM6/27/22
to
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?

--
The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw

signature.asc

Tim Woodall

unread,
Jun 27, 2022, 1:10:05 PM6/27/22
to
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.

Roberto C. Sánchez

unread,
Jun 27, 2022, 1:50:05 PM6/27/22
to
On Mon, Jun 27, 2022 at 03:31:01PM +0100, 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?
>
If you are not opposed to installing the devscripts package, then you
can do this:

$ rmadison -u debian -a source -s unstable firefox-esr
firefox-esr | 91.10.0esr-1 | unstable | source

Regards,

-Roberto

--
Roberto C. Sánchez

Cindy Sue Causey

unread,
Jun 27, 2022, 4:50:06 PM6/27/22
to
DISCLAIMER: I do understand this is about the source packages. I've
never thought about whether or not they ever differentiate from our
debs. Having just run "apt-cache policy", I do see the difference that
can arise.

My search into this went off into a tangent that ended up at..

/usr/share/bash-completion/completions/apt-cache

That has a line that includes:

if [[ ${words[ispecial]} ==
@(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then

So next I hit up "man apt-cache" to see if man showed how to choose
src over pkg. I didn't get there because "apt-cache showsrc" popped up
first. Ran it to see its output then ended up with...

$ apt-cache showsrc firefox-esr|grep Vers
Version: 91.10.0esr-1
Standards-Version: 3.9.8.0

For the package policy based on last time a system ran "apt-get
update", it could be:

$ apt-cache policy firefox-esr|grep C
Candidate: 91.10.0esr-1

Those just happened to match. My original sample was einstein. Version
and Candidate outputs are different for him. At this second, they are
Version 2.0.dfsg.2-10 versus Candidate 2.0.dfsg.2-10+b1.

That just shows it is capable of plucking out the difference in those.
I usually miss something obvious that negates anything I typed so my
apologies in advance if and when I did here. :)

Hope that helps somehow. Maybe the output from showsrc might be fun to
look at for distraction or something....

Cindy :)
--
Talking Rock, Pickens County, Georgia, USA
* runs with birdseed *

Bob Weber

unread,
Jun 27, 2022, 5:00:05 PM6/27/22
to
On 6/27/22 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?



Tim.


I use 2 aliases that have server me well (almost daily).

Search for any pattern of package names:

alias al='apt list | grep '

Search for only installed package names:

alias ali='apt list --installed | grep '

al linux-im gives me this:


linux-image-5.10.0-8-amd64/now 5.10.46-4 amd64 [installed,local]
linux-image-5.14.0-3-amd64/now 5.14.12-1 amd64 [residual-config]
linux-image-5.15.0-2-amd64/now 5.15.5-2 amd64 [installed,local]
linux-image-5.15.0-3-amd64/now 5.15.15-2 amd64 [installed,local]
linux-image-5.18.0-2-amd64-dbg/testing,unstable 5.18.5-1 amd64
linux-image-5.18.0-2-amd64-unsigned/testing,unstable 5.18.5-1 amd64
linux-image-5.18.0-2-amd64/testing,unstable 5.18.5-1 amd64
linux-image-5.18.0-2-cloud-amd64-dbg/testing,unstable 5.18.5-1 amd64
linux-image-5.18.0-2-cloud-amd64-unsigned/testing,unstable 5.18.5-1 amd64
linux-image-5.18.0-2-cloud-amd64/testing,unstable 5.18.5-1 amd64
linux-image-5.18.0-2-rt-amd64-dbg/testing,unstable 5.18.5-1 amd64
linux-image-5.18.0-2-rt-amd64-unsigned/testing,unstable 5.18.5-1 amd64
linux-image-5.18.0-2-rt-amd64/testing,unstable 5.18.5-1 amd64
linux-image-amd64-dbg/testing,unstable 5.18.5-1 amd64
linux-image-amd64-signed-template/testing,unstable 5.18.5-1 amd64
linux-image-amd64/testing,unstable 5.18.5-1 amd64
linux-image-cloud-amd64-dbg/testing,unstable 5.18.5-1 amd64
linux-image-cloud-amd64/testing,unstable 5.18.5-1 amd64
linux-image-rt-amd64-dbg/testing,unstable 5.18.5-1 amd64
linux-image-rt-amd64/testing,unstable 5.18.5-1 amd64

and ali linux-im


linux-image-5.10.0-8-amd64/now 5.10.46-4 amd64 [installed,local]
linux-image-5.15.0-2-amd64/now 5.15.5-2 amd64 [installed,local]
linux-image-5.15.0-3-amd64/now 5.15.15-2 amd64 [installed,local]


--


...Bob

Tim Woodall

unread,
Jun 27, 2022, 5:50:04 PM6/27/22
to
Thanks! And that has given me another hint:

$ apt-cache madison openssh
openssh | 1:9.0p1-1 | http://aptmirror17.home.woodall.me.uk/local bullseye/main Sources
openssh | 1:9.0p1-1~tjw11r1 | http://aptmirror17.home.woodall.me.uk/local bullseye/main Sources
openssh | 1:8.4p1-5 | http://ftp.uk.debian.org/debian bullseye/main Sources
openssh | 1:7.9p1-10+deb10u1 | http://security.debian.org buster/updates/main Sources
openssh | 1:7.4p1-10+deb9u7 | http://ftp.uk.debian.org/debian stretch/main Sources
openssh | 1:7.9p1-10+deb10u2 | http://ftp.uk.debian.org/debian buster/main Sources
openssh | 1:8.4p1-5 | http://ftp.uk.debian.org/debian stable/main Sources
openssh | 1:8.4p1-5 | http://ftp.uk.debian.org/debian testing/main Sources
openssh | 1:9.0p1-1 | http://ftp.uk.debian.org/debian testing/main Sources
openssh | 1:8.4p1-5 | http://ftp.uk.debian.org/debian sid/main Sources
openssh | 1:9.0p1-1 | http://ftp.uk.debian.org/debian sid/main Sources

That shouldn't be too hard to parse.

I didn't know what madison was but I recalled seeing it in the manpage.

I'll need to investigate rmadison. Might be just what I need assuming it
can also support my local repo. Doesn't honour my apt proxy setting so
doesn't work out of the box for me.

Tim.

Roberto C. Sánchez

unread,
Jun 27, 2022, 7:10:05 PM6/27/22
to
The usefulness of 'apt-cache madison' versus 'rmadison' depends on what
you mean by "lastest available version". If you mean "latest available
version from the sources configured on my system", then 'apt-cache
madison' will do just that. If you mean "latest available version in
the Debian archive", then you need 'rmadison'.

Tim Woodall

unread,
Jul 8, 2022, 6:50:04 PM7/8/22
to
On Mon, 27 Jun 2022, Roberto C. S?nchez wrote:

> On Mon, Jun 27, 2022 at 10:44:25PM +0100, Tim Woodall wrote:
>> On Mon, 27 Jun 2022, Roberto C. S?nchez wrote:
>>
>>> On Mon, Jun 27, 2022 at 03:31:01PM +0100, 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?
>>>>
>>> If you are not opposed to installing the devscripts package, then you
>>> can do this:
>>>
>>> $ rmadison -u debian -a source -s unstable firefox-esr
>>> firefox-esr | 91.10.0esr-1 | unstable | source
>>>
>>
> The usefulness of 'apt-cache madison' versus 'rmadison' depends on what
> you mean by "lastest available version". If you mean "latest available
> version from the sources configured on my system", then 'apt-cache
> madison' will do just that. If you mean "latest available version in
> the Debian archive", then you need 'rmadison'.
>

This was really useful, thank you. In the end I stuck with my previous
apt-cache showsrc parsing but apt-cache madison has just made it really
easy to track down a bug where that wasn't working (because of a
copy-pasta error that meant I had Suite: bullseye configured instead of
buster but only for the debsrc (and not for security updates which was
correct)
0 new messages