[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: preinst: get new pkg version to check for downgrade



Hi!

On Wed, 2014-12-24 at 19:43:47 +0200, Andrey Utkin wrote:
> When preinst is called with $1 = "upgrade", $2 is set with old
> version. How should I get programmatically the new version (the one
> being currently installed), to compare with "dpkg --compare-versions".

The new version is always implicitly known at package build time, so
if you really need to have a varying version you can replace it then.
But usually you compare against a known version that introduced
something and then you have logic like:

case "$1" in
upgrade)
  if dpkg --compare-versions "$2" lt KNOWN-VERSION; then
    : # do some actions, or deny or accept the downgrade
  fi
  ;;
esac

Thanks,
Guillem


Reply to: