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

* Refactored the 'AR_GET_DISTRO()' autoconf macro to use
	'/etc/os-release'.
This commit is contained in:
Fred Gleason 2020-02-24 18:20:38 -05:00
parent 7c055a19a3
commit d005913675
2 changed files with 40 additions and 56 deletions

View File

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

View File

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