Browse Source

2020-02-24 Fred Gleason <fredg@paravelsystems.com>

* Refactored the 'AR_GET_DISTRO()' autoconf macro to use
	'/etc/os-release'.
pull/537/head
Fred Gleason 3 years ago
parent
commit
d005913675
  1. 3
      ChangeLog
  2. 93
      get_distro.pl

3
ChangeLog

@ -19671,3 +19671,6 @@
2020-02-23 Fred Gleason <fredg@paravelsystems.com>
* Added '-lexpat' to the '--libs' output for the 'rivwebcapi'
pkg-config profile.
2020-02-24 Fred Gleason <fredg@paravelsystems.com>
* Refactored the 'AR_GET_DISTRO()' autoconf macro to use
'/etc/os-release'.

93
get_distro.pl

@ -25,83 +25,64 @@
#USAGE: get_distro.pl NAME|VERSION|MAJOR|MINOR|POINT
if($ARGV[0] eq "NAME") {
if(!system("test","-f","/etc/SuSE-release")) {
print "SuSE";
exit 0;
}
if(!system("test","-f","/etc/debian_version")) {
print "Debian";
exit 0;
}
if(!system("test","-f","/etc/redhat-release")) {
print "RedHat";
exit 0;
}
print &Extract("NAME");
exit 0;
}
if($ARGV[0] eq "VERSION") {
if(!system("test","-f","/etc/SuSE-release")) {
print &GetVersion("/etc/SuSE-release");
exit 0;
}
if(!system("test","-f","/etc/debian_version")) {
print &GetVersion("/etc/debian_version");
exit 0;
}
if(!system("test","-f","/etc/redhat-release")) {
print &GetVersion("/etc/redhat-release");
exit 0;
}
print &Extract("VERSION_ID");
exit 0;
}
if($ARGV[0] eq "MAJOR") {
if(!system("test","-f","/etc/SuSE-release")) {
print &GetMajor("/etc/SuSE-release");
exit 0;
}
if(!system("test","-f","/etc/debian_version")) {
print &GetMajor("/etc/debian_version");
exit 0;
}
if(!system("test","-f","/etc/redhat-release")) {
print &GetMajor("/etc/redhat-release");
exit 0;
}
my $ver=&Extract("VERSION_ID");
my @f0=split '\.',$ver;
print $f0[0];
exit 0;
}
if($ARGV[0] eq "MINOR") {
if(!system("test","-f","/etc/SuSE-release")) {
print &GetMinor("/etc/SuSE-release");
exit 0;
}
if(!system("test","-f","/etc/debian_version")) {
print &GetMinor("/etc/debian_version");
exit 0;
}
if(!system("test","-f","/etc/redhat-release")) {
print &GetMinor("/etc/redhat-release");
my $ver=&Extract("VERSION_ID");
my @f0=split '\.',$ver;
if(scalar(@f0)>=2) {
print $f0[1];
exit 0;
}
print "0";
exit 0;
}
if($ARGV[0] eq "POINT") {
if(!system("test","-f","/etc/SuSE-release")) {
print &GetPoint("/etc/SuSE-release");
exit 0;
}
if(!system("test","-f","/etc/debian_version")) {
print &GetPoint("/etc/debian_version");
exit 0;
}
if(!system("test","-f","/etc/redhat-release")) {
print &GetPoint("/etc/redhat-release");
my $ver=&Extract("VERSION_ID");
my @f0=split '\.',$ver;
if(scalar(@f0)>=3) {
print $f0[2];
exit 0;
}
print "0";
exit 0;
}
exit 256;
sub Extract
{
if(open RELEASE,"<","/etc/os-release") {
while(<RELEASE>) {
my @f0=split "\n",$_;
for(my $i=0;$i<@f0;$i++) {
my @f1=split "=",$f0[$i];
if($f1[0] eq $_[0]) {
return substr($f1[1],1,length($f1[1])-2);
}
}
}
}
return "";
}
sub GetVersion
{
if(open VERSION,"<",$_[0]) {

Loading…
Cancel
Save