Handle Windows 11 version numbers.

This commit is contained in:
László Valkó 2025-09-29 04:37:17 +02:00
parent 898cb3c39a
commit c34c3c70a5
2 changed files with 22 additions and 3 deletions

View file

@ -23,6 +23,7 @@ require Exporter;
set_current_pkg_name
get_win_major
get_win_version
get_real_win_version
get_default_vars
set_datetime_vars
compare_versions
@ -207,6 +208,15 @@ sub get_win_version ()
return $osmajor.'.'.$osminor;
}
sub get_real_win_version ()
{
my ($osver, $osmajor, $osminor, $osbuild) = Win32::GetOSVersion();
$osmajor = 11 if $osmajor == 10 && $osbuild >= 20000;
return $osmajor.'.'.$osminor;
}
sub get_default_vars (;$)
{
my ($config) = @_;
@ -229,15 +239,24 @@ sub get_default_vars (;$)
my ($osver, $osmajor, $osminor, $osbuild) = Win32::GetOSVersion();
if ($osmajor == 5 && $osminor == 1) {
$$vars{os} = 'xp';
$$vars{osfixed} = 'xp';
}
elsif ($osmajor == 6 && $osminor == 1) {
$$vars{os} = '7';
$$vars{osfixed} = '7';
}
elsif ($osmajor == 10) {
$$vars{os} = '10';
if (int($osbuild) < 20000) {
$$vars{osfixed} = '10';
}
else {
$$vars{osfixed} = '11';
}
}
else {
$$vars{os} = 'unknown';
$$vars{osfixed} = 'unknown';
}
$$vars{osversion} = $osmajor.'.'.$osminor;
$$vars{osmajor} = $osmajor;

View file

@ -2530,9 +2530,9 @@ sub scan_package_dirs ($$)
return undef unless defined $filename && defined $dirs;
$maxdepth = 1 unless defined $maxdepth;
print_log('global', INFO, 'Scanning package directories');
my $vars = get_default_vars($config);
print_log('global', INFO, 'OS version: %s.%s.%s OS major: %s OS major fixed: %s', $$vars{osmajor}, $$vars{osminor}, $$vars{osbuild}, $$vars{os}, $$vars{osfixed});
print_log('global', INFO, 'Scanning package directories');
foreach my $dir (@$dirs) {
my $scandir = substitute_variables($vars, $dir, 1, $basedir, 'global');
my $error = scan_package_dir($config, $scandir, $maxdepth, $filename);
@ -2806,7 +2806,7 @@ sub get_patch_vars ($$$$$)
$$vars{patchkbnum} = $kbnum;
$$vars{patchnum} = $number;
$$vars{patchextra} = $extra;
$$vars{patchprefix} = defined $$patchdef{prefix} ? $$patchdef{prefix} : 'Windows'.get_win_version().'-';
$$vars{patchprefix} = defined $$patchdef{prefix} ? $$patchdef{prefix} : 'Windows'.get_real_win_version().'-';
$$vars{patchkbname} = defined $$patchdef{kbname} ? $$patchdef{kbname} : 'KB';
$$vars{patchedition} = defined $$patchdef{edition} ? $$patchdef{edition} : '';
$$vars{patcharch} = defined $$patchdef{arch} ? $$patchdef{arch} : '-'.$$vars{xarch};