distro id updates

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

140
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,76 +31578,69 @@ 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);
} }
$id = 'Debian'; return if !$file_value && !$codename;
return if !$debian_version && !$codename; if ($type eq 'debian'){
# note, 3.0, woody, 3.1, sarge, but after it's integer per version $id = 'Debian';
my %debians = ( # note, 3.0, woody, 3.1, sarge, but after it's integer per version
'4' => 'etch', %releases = (
'5' => 'lenny', '4' => 'etch',
'6' => 'squeeze', '5' => 'lenny',
'7' => 'wheezy', '6' => 'squeeze',
'8' => 'jessie', '7' => 'wheezy',
'9' => 'stretch', '8' => 'jessie',
'10' => 'buster', '9' => 'stretch',
'11' => 'bullseye', '10' => 'buster',
'12' => 'bookworm', '11' => 'bullseye',
'13' => 'trixie', '12' => 'bookworm',
'14' => 'forky', '13' => 'trixie',
); '14' => 'forky',
if (main::is_numeric($debian_version)){ );
$id .= " $debian_version " . $debians{int($debian_version)};
} }
elsif ($codename){ else {
my %by_value = reverse %debians; $id = 'Devuan';
my $version = (main::is_numeric($debian_version)) ? "$debian_version $codename": $debian_version; %releases = (
$id .= " $version"; '1' => 'jesse', # jesse
'2' => 'ascii', # stretch
'3' => 'beowolf', # buster
'4' => 'chimaera', # bullseye
'5' => 'daedalus', # bookworm
'6' => 'excalibur',# trixie
'7' => 'freia', # forky
# '' => 'ceres/daedalus', # sid/unstable
);
} }
# like buster/sid # debian often numeric, devuan usually not
elsif ($debian_version){ # like trixie/sid; daedalus; ceres/daedalus; 12.0
$id .= " $debian_version"; if (main::is_numeric($file_value)){
$version = $file_value . ' ' . $releases{int($file_value)};
} }
eval $end if $b_log; else {
return $id; my %releases_r = reverse %releases;
} if ($codename){
$version = ($releases_r{$codename}) ? "$releases_r{$codename} $codename": $codename;
# args: 0: optional: debian codename }
sub devuan_id { elsif ($releases_r{$file_value}) {
my ($codename) = @_; $version = "$releases_r{$file_value} $file_value";
my ($devuan_version,$id); }
if (-r '/etc/devuan_version'){ else {
$devuan_version = main::reader('/etc/devuan_version','strip',0); $version = $file_value;
}
} }
$id = 'Devuan'; if ($version){
return if !$devuan_version && !$codename; my @temp = split(/\s*[\/\s]\s*/, $version);
my %devuans = ( foreach (@temp){
'1' => 'jesse', # jesse if ($distro !~ /\b$_\b/i){
'2' => 'ascii', # stretch $id .= " $_";
'3' => 'beowolf', # buster }
'4' => 'chimaera', # bullseye }
'5' => 'daedalus', # bookworm
'6' => 'excalibur',# trixie
'7' => 'freia', # forky
# '' => 'ceres', # sid/unstable
);
if (main::is_numeric($devuan_version)){
$id .= " $devuan_version " . $devuans{int($devuan_version)};
}
elsif ($codename){
my %by_value = reverse %devuans;
my $version = (main::is_numeric($devuan_version)) ? "$devuan_version $codename": $devuan_version;
$id .= " $version";
}
# like ceres/unstable
elsif ($devuan_version){
$id .= " $devuan_version";
} }
eval $end if $b_log; eval $end if $b_log;
return $id; return $id;