Casey Bralla on 29 Mar 2009 14:18:12 -0700


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

Re: [PLUG] Determining Debian/Ubuntu distro and release?


Not a solution, and you probably already knew this, but "uname -a" will give 
you kernel info.


On Sunday 29 March 2009 5:12:14 pm JP Vossen wrote:
> Does anyone have a better method for determining the distro and release
> for Debian/Ubuntu?  /etc/issue isn't always consistent,
> /etc/debian-release doesn't help for Ubuntu, /etc/lsb-release isn't
> always there.
>
> So far I have:
>
> # Release code name (should be 5 lines)
> codename=$(perl -ne 'print qq($1\n) if
> m!^deb.*?(?:debian|ubuntu)/\s+(\w+)\s+main!;' /etc/apt/sources.list)
> [ -n "$codename" ] || {
>      echo "Release codename not set, 'export codename=name' before
> running..."
>      exit 2
> }
>
> # Debian or Ubuntu
>      if   grep -q 'debian.org' /etc/apt/sources.list; then
>          # Do something
>      elif grep -q 'ubuntu.com' /etc/apt/sources.list; then
>          # Do something
>      else
>          echo "/etc/apt/sources.list doesn't look like Debian or Ubuntu,
> skipping..."
>          exit 3
>      fi
>
-- 


Casey Bralla
Chief Nerd in Residence
The NerdWorld Organisation
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug