develooper Front page | perl.perl5.porters | Postings from October 1999

Re: Detecting RedHat distribution version

From:
Paul Schinder
Date:
October 26, 1999 16:45
Subject:
Re: Detecting RedHat distribution version
Message ID:
v04205500b43bece16257@[168.143.5.160]
At 10:03 PM +0100 10/26/99, Matt Sergeant wrote:
>On Tue, 26 Oct 1999, Chip Turner wrote:
> > Matt Sergeant <matt@sergeant.org> writes:
> >
> > > On Tue, 26 Oct 1999, Andy Dougherty wrote:
> > > > I'm currently trying to patch Configure to tell you the Linux
> > > > distribution (RedHat, SuSE, Debian, others as folks supply the
> > > > information), and I'm unsure of how to best parse RedHat's
> > > > /etc/redhat-release file. I have the following 1 example:
> > > >
> > > > 	Red Hat Linux release 6.1 (Cartman)
> > > >
> > > > I'm guessing that the '6.1' is what would be most useful. 
>Does anyone have
> > > > a variety of Red Hat systems around or enough familiarity 
>with Red Hat to
> > > > say how stable that format is or give me other examples?
> > >
> > > Mandrake 6.0 gives:
> > >
> > > $ cat /etc/redhat-release
> > > Linux Mandrake release 6.0 (Venus)
> >
> > Great.  Mandrake would just HAVE to pretend to be redhat.  Of course,
> > it's based on redhat and is nearly identical at the level we care, but
> > it's still irksome.
> >
> > For Configure...
> >
> > if $test -f /etc/redhat-release
> >   if $grep "Mandrake" /etc/redhat-release > /dev/null
> >   then
> >     osvers="Mandrake Linux"
> >   else
> >     osvers="Red Hat Linux"
> >   fi
> >   if $test "$osvers" != "Generic Linux"
> >   then
> >     tmp=`$sed 's/.*release \([0-9]*\.[0-9]*\).*/\1/' /etc/redhat-release`
> >     osvers="$osvers $tmp"
> >   fi
> > fi
> >
> > (Hope that helps the maintainer.  I've tested it on the oddball
> > redhat's we have here and it works).
>
>or just:
>
>if (-e '/etc/redhat-release') {
>	my $release = `rpm -qf /etc/redhat-release';
>	# Do something with $release
>}
>
>On a real redhat system you get "redhat-release-<version>" and on mandrake
>you get "mandrake-release-<version>". However, as I discussed with Andy
>privately - probably the best (albeit slightly wrong) thing to do is make
>it so that mandrake == redhat for config - since all the system files are
>all in the same place with both distros.


On Yellow Dog Linux, a PPC distribution that has nothing to do with 
RedHat except it's modeled after it:

linux% cat /etc/redhat-release
Yellow Dog Linux (CS-1.1)

linux% rpm -qf /etc/redhat-release
yellowdog-release-CS_1.1-1

So don't go making too many assumptions just because 
/etc/redhat-release exists.  In this case, it's a symbolic link to 
/etc/yellowdog-release.

>
>--
><Matt/>
>
>Details: FastNet Software Ltd - XML, Perl, Databases.
>Tagline: High Performance Web Solutions
>Web Sites: http://come.to/fastnet http://sergeant.org
>Available for Consultancy, Contracts and Training.

--
Paul Schinder
schinder@pobox.com



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About