Web lists-archives.com

Re: Debian testing - release number

On Thu, Jul 05, 2018 at 02:57:03PM -0500, Nicholas Geovanis wrote:
> I am rightly accused of relying too heavily on /etc/debian_version to
> detect my running release. But it seems clear
> to me that the "right", canonical way to detect this is to query the
> installed package base to extract a version/release
> number from a package name and/or version. So surely there is an
> "approved" tool for doing that. Hopefully OTHER THAN
> apt, aptitude, synaptic or apt-get; ideally simpler and easier to
> script than that.
> So what is that tool?

if [[ ! -r /etc/debian_version ]]; then
  echo "This script only supports Debian systems." >&2
  exit 1

read -r debver < /etc/debian_version
case $debver in
  *unstable*) : code to handle testing/unstable ;;
  1[0-9].*)   : code to handle the fuuuuture {probably just abort} ;;
  9.*)        : code to handle stretch ;;
  8.*)        : code to handle jessie ;;
  *)          : code to handle "too old" or "unknown" {probably just abort} ;;