sean finney on 29 Mar 2009 14:21:34 -0700

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

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


On Sun, Mar 29, 2009 at 05:12:14PM -0400, JP Vossen wrote:
> 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
> }

btw, this will get interesting results if you have a system that has
sources.list entries referencing both (for example i have deb-src entries
for ubuntu on my debian system for various reasons).

but i can suggest something a bit easier anyway :)

rangda[/home/sean] lsb_release --short --id                                  :)
rangda[/home/sean] lsb_release --short --description                         :)
Debian GNU/Linux 5.0 (lenny)
rangda[/home/sean] lsb_release --short --release                             :)
rangda[/home/sean] lsb_release --short --codename                            :)

note that this might not be 100% accurate (i.e. above it says lenny but
my system is squeeze/sid), but that's the best "vendor supported way" afaik.


Attachment: signature.asc
Description: Digital signature

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --