Skip to content

Commit

Permalink
Extract prepare_wsl to the Windows instalation testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Herranz Ramírez committed Jan 16, 2025
1 parent f31bb42 commit 635618d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
1 change: 1 addition & 0 deletions schedule/wsl/install/create_windows_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ schedule:
- wsl/install/ms_win_installation
- '{{unattended_install}}'
- wsl/update_windows
- wsl/prepare_wsl
1 change: 0 additions & 1 deletion schedule/wsl/wsl_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ conditional_schedule:

schedule:
- wsl/boot_windows
- wsl/prepare_wsl
- wsl/install_wsl
- wsl/firstrun
- '{{enable_systemd}}'
Expand Down
25 changes: 1 addition & 24 deletions tests/wsl/install_wsl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,6 @@ use testapi;
use version_utils;
use Utils::Architectures 'is_aarch64';

sub install_certificates {
my ($self) = @_;
my $certs = {
opensuse => 'wsl/openSUSE-UEFI-CA-Certificate.crt',
sle => 'wsl/SLES-UEFI-CA-Certificate.crt'
};
my $ms_cert_store = 'cert:\\LocalMachine\\Root';
my $cert_file_path = 'C:\Users\Public\image-ca.cert';
# The certificates should be downloaded from the web
$self->run_in_powershell(
cmd => 'Invoke-WebRequest -Uri "' . data_url($certs->{get_required_var('DISTRI')}) . '" -O "' . $cert_file_path . '" -UseBasicParsing',
);
$self->run_in_powershell(
cmd => 'Import-Certificate -FilePath "' . $cert_file_path . '" -CertStoreLocation ' . $ms_cert_store . ' -Verbose',
timeout => 120
);
}

sub run {
my ($self) = @_;
assert_screen 'windows-desktop';
Expand All @@ -54,19 +36,14 @@ sub run {
if ($install_from eq 'build') {
my $wsl_appx_filename = (split /\//, get_required_var('ASSET_1'))[-1];
my $wsl_appx_uri = "\\\\10.0.2.4\\qemu\\$wsl_appx_filename";
# Enable the 'developer mode' in Windows
$self->run_in_powershell(
cmd => 'New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name AllowDevelopmentWithoutDevLicense -PropertyType DWORD -Value 1'
);

# On Win 11 for Arm Build 25931, smb transfers don't work (poo#126083)
$wsl_appx_uri = data_url('ASSET_1') if is_aarch64;
$self->run_in_powershell(
cmd => "Start-BitsTransfer -Source $wsl_appx_uri -Destination C:\\\\$wsl_appx_filename",
timeout => 60
);

$self->install_certificates;

$self->run_in_powershell(
cmd => "Add-AppxPackage -Path C:\\$wsl_appx_filename",
timeout => 60
Expand Down
24 changes: 24 additions & 0 deletions tests/wsl/prepare_wsl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ use Utils::Architectures qw(is_aarch64);
use testapi;
use version_utils qw(is_sle is_opensuse);

sub install_certificates {
my ($self) = @_;
my $certs = {
opensuse => 'wsl/openSUSE-UEFI-CA-Certificate.crt',
sle => 'wsl/SLES-UEFI-CA-Certificate.crt'
};
my $ms_cert_store = 'cert:\\LocalMachine\\Root';
my $cert_file_path = 'C:\Users\Public\image-ca.cert';
# The certificates should be downloaded from the web
$self->run_in_powershell(
cmd => 'Invoke-WebRequest -Uri "' . data_url($certs->{get_required_var('DISTRI')}) . '" -O "' . $cert_file_path . '" -UseBasicParsing',
);
$self->run_in_powershell(
cmd => 'Import-Certificate -FilePath "' . $cert_file_path . '" -CertStoreLocation ' . $ms_cert_store . ' -Verbose',
timeout => 120
);
}

sub run {
my ($self) = @_;

Expand Down Expand Up @@ -57,6 +75,12 @@ sub run {
) if get_var('HDD_1') =~ /24H2/;
}

# Enable the 'developer mode' in Windows
$self->run_in_powershell(
cmd => 'New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name AllowDevelopmentWithoutDevLicense -PropertyType DWORD -Value 1'
);
$self->install_certificates;

$self->reboot_or_shutdown(is_reboot => 1);
$self->wait_boot_windows;
}
Expand Down
3 changes: 0 additions & 3 deletions tests/wsl/update_windows.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ sub run {
bmwqemu::diag("Applying updates while shutting down the machine...");
}
$self->wait_boot_windows;

# Shutdown
$self->reboot_or_shutdown;
}

1;

0 comments on commit 635618d

Please sign in to comment.