distro id updates

This commit is contained in:
Harald Hope 2023-11-18 13:02:40 -08:00
parent f1fdbd0d60
commit 2e8be3da88

96
pinxi
View file

@ -50,8 +50,8 @@ use POSIX qw(ceil uname strftime ttyname);
## INXI INFO ## ## INXI INFO ##
my $self_name='pinxi'; my $self_name='pinxi';
my $self_version='3.3.31'; my $self_version='3.3.31';
my $self_date='2023-11-17'; my $self_date='2023-11-18';
my $self_patch='11'; my $self_patch='12';
## END INXI INFO ## ## END INXI INFO ##
my ($b_pledge,@pledges); my ($b_pledge,@pledges);
@ -31300,10 +31300,10 @@ sub system_base {
} }
# must go before base_osr_arch,ubuntu tests. For steamos, use fallback arch # must go before base_osr_arch,ubuntu tests. For steamos, use fallback arch
elsif (grep {/($base_osr_debian_version)/i} @osr){ elsif (grep {/($base_osr_debian_version)/i} @osr){
$system_base = debian_id(); $system_base = debian_id('debian');
} }
elsif (grep {/($base_osr_devuan_version)/i} @osr){ elsif (grep {/($base_osr_devuan_version)/i} @osr){
$system_base = devuan_id(); $system_base = debian_id('devuan');
} }
elsif (grep {/($base_osr_redhat)/i} @osr){ elsif (grep {/($base_osr_redhat)/i} @osr){
$base_type = 'rhel'; $base_type = 'rhel';
@ -31322,7 +31322,7 @@ sub system_base {
} }
if (!$system_base && @distro_files && if (!$system_base && @distro_files &&
(grep {/($base_file_debian_version)/i} @distro_files)){ (grep {/($base_file_debian_version)/i} @distro_files)){
$system_base = debian_id(); $system_base = debian_id('debian');
} }
if (!$system_base && $lc_issue && $lc_issue =~ /($base_manual)/){ if (!$system_base && $lc_issue && $lc_issue =~ /($base_manual)/){
my $id = $1; my $id = $1;
@ -31494,7 +31494,12 @@ sub get_os_release {
} }
} }
if ($version_codename && $distro_osr !~ /$version_codename/i){ if ($version_codename && $distro_osr !~ /$version_codename/i){
$distro_osr .= " $version_codename"; my @temp = split(/\s*[\/\s]\s*/, $version_codename);
foreach (@temp){
if ($distro_osr !~ /\b$_\b/i){
$distro_osr .= " $_";
}
}
} }
} }
# note: mint has varying formats here, some have ubuntu as name, 17 and earlier # note: mint has varying formats here, some have ubuntu as name, 17 and earlier
@ -31528,10 +31533,10 @@ sub get_os_release {
$distro_osr = ($name && $version_name) ? "$name $version_name": $name_pretty; $distro_osr = ($name && $version_name) ? "$name $version_name": $name_pretty;
} }
elsif ($base_type eq 'debian' && $base_version){ elsif ($base_type eq 'debian' && $base_version){
$distro_osr = debian_id($base_version); $distro_osr = debian_id('debian',$base_version);
} }
elsif ($base_type eq 'devuan' && $base_version){ elsif ($base_type eq 'devuan' && $base_version){
$distro_osr = devuan_id($base_version); $distro_osr = debian_id('devuan',$base_version);
} }
} }
eval $end if $b_log; eval $end if $b_log;
@ -31573,18 +31578,19 @@ sub distro_spin {
return $name; return $name;
} }
# args: 0: optional: debian codename # args: 0: $type [debian|devuan]; 1: optional: debian codename
sub debian_id { sub debian_id {
eval $start if $b_log; eval $start if $b_log;
my ($codename) = @_; my ($type,$codename) = @_;
my ($debian_version,$id); my ($id,$file_value,%releases,$version);
if (-r '/etc/debian_version'){ if (-r "/etc/${type}_version"){
$debian_version = main::reader('/etc/debian_version','strip',0); $file_value = main::reader("/etc/${type}_version",'strip',0);
} }
return if !$file_value && !$codename;
if ($type eq 'debian'){
$id = 'Debian'; $id = 'Debian';
return if !$debian_version && !$codename;
# note, 3.0, woody, 3.1, sarge, but after it's integer per version # note, 3.0, woody, 3.1, sarge, but after it's integer per version
my %debians = ( %releases = (
'4' => 'etch', '4' => 'etch',
'5' => 'lenny', '5' => 'lenny',
'6' => 'squeeze', '6' => 'squeeze',
@ -31597,32 +31603,10 @@ sub debian_id {
'13' => 'trixie', '13' => 'trixie',
'14' => 'forky', '14' => 'forky',
); );
if (main::is_numeric($debian_version)){
$id .= " $debian_version " . $debians{int($debian_version)};
}
elsif ($codename){
my %by_value = reverse %debians;
my $version = (main::is_numeric($debian_version)) ? "$debian_version $codename": $debian_version;
$id .= " $version";
}
# like buster/sid
elsif ($debian_version){
$id .= " $debian_version";
}
eval $end if $b_log;
return $id;
}
# args: 0: optional: debian codename
sub devuan_id {
my ($codename) = @_;
my ($devuan_version,$id);
if (-r '/etc/devuan_version'){
$devuan_version = main::reader('/etc/devuan_version','strip',0);
} }
else {
$id = 'Devuan'; $id = 'Devuan';
return if !$devuan_version && !$codename; %releases = (
my %devuans = (
'1' => 'jesse', # jesse '1' => 'jesse', # jesse
'2' => 'ascii', # stretch '2' => 'ascii', # stretch
'3' => 'beowolf', # buster '3' => 'beowolf', # buster
@ -31630,19 +31614,33 @@ sub devuan_id {
'5' => 'daedalus', # bookworm '5' => 'daedalus', # bookworm
'6' => 'excalibur',# trixie '6' => 'excalibur',# trixie
'7' => 'freia', # forky '7' => 'freia', # forky
# '' => 'ceres', # sid/unstable # '' => 'ceres/daedalus', # sid/unstable
); );
if (main::is_numeric($devuan_version)){
$id .= " $devuan_version " . $devuans{int($devuan_version)};
} }
elsif ($codename){ # debian often numeric, devuan usually not
my %by_value = reverse %devuans; # like trixie/sid; daedalus; ceres/daedalus; 12.0
my $version = (main::is_numeric($devuan_version)) ? "$devuan_version $codename": $devuan_version; if (main::is_numeric($file_value)){
$id .= " $version"; $version = $file_value . ' ' . $releases{int($file_value)};
}
else {
my %releases_r = reverse %releases;
if ($codename){
$version = ($releases_r{$codename}) ? "$releases_r{$codename} $codename": $codename;
}
elsif ($releases_r{$file_value}) {
$version = "$releases_r{$file_value} $file_value";
}
else {
$version = $file_value;
}
}
if ($version){
my @temp = split(/\s*[\/\s]\s*/, $version);
foreach (@temp){
if ($distro !~ /\b$_\b/i){
$id .= " $_";
}
} }
# like ceres/unstable
elsif ($devuan_version){
$id .= " $devuan_version";
} }
eval $end if $b_log; eval $end if $b_log;
return $id; return $id;