Binary package hint: aptitude
When I tell aptitude to install a certain version of a package - and this version is not available - it outputs an error (Unable to find a version "..." for the package...) - but still returns 0(=OK).
This is a problem when automating installs using aptitude (we use puppet to do it) - as it thinks all is well, when it isn't :(
To reproduce - do this on a hardy install.
# aptitude install subversion=1.5.1dfsg1-1ubuntu2~hardy2; echo "ret:$?"
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Building tag database... Done
Unable to find a version "1.5.1dfsg1-1ubuntu2~hardy2" for the package "subversion"
Unable to find a version "1.5.1dfsg1-1ubuntu2~hardy2" for the package "subversion"
The following packages have been automatically kept back:
libpq5 linux-libc-dev sun-java6-bin
The following packages have been kept back:
bind9-host dnsutils libbind9-30 libdns35 libisc35 libisccfg30 libkrb53 liblwres30 linux-image-server linux-server nfs-common sudo sun-java6-jre tzdata
0 packages upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
Need to get 0B of archives. After unpacking 0B will be used.
Writing extended state information... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Building tag database... Done
ret:0
This rudimentary patch catches this situation where aptitude would otherwise just install the latest available version of the package - even though you requested a specific version - and with this patch applied, it aborts when it finds out this is the case, instead of installing "latest version" of the requested package.
IMHO the correct thing to do.
You probably want to stop the processing in some other way than using abort() - and the printf may or may not need to be there (it does print out the error earlier on as well).