Skip to content

Commit

Permalink
Enable POM structure and libyui for firstboot
Browse files Browse the repository at this point in the history
  • Loading branch information
JRivrain committed Apr 9, 2021
1 parent 31a042d commit 6ee97cb
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 6 deletions.
35 changes: 35 additions & 0 deletions data/autoyast_opensuse/autoyast_firstboot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,39 @@
<timeout config:type="integer">0</timeout>
</yesno_messages>
</report>
<scripts>
<chroot-scripts config:type="list">
<script>
<chrooted config:type="boolean">true</chrooted>
<source>
<![CDATA[#!/bin/bash
# Enable libyui-rest-api in firstboot (requires an init script).
for i in YUI_HTTP_PORT={{YUI_PORT}} YUI_HTTP_REMOTE=1 YUI_REUSE_PORT=1 Y2DEBUG=1; do
echo "export $i" >> /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
done
chmod +x /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
]]>
</source>
</script>
</chroot-scripts>
<post-scripts config:type="list">
<script>
<filename>install_libyui.sh</filename>
<interpreter>shell</interpreter>
<location/>
<feedback config:type="boolean">false</feedback>
<source><![CDATA[#!/bin/sh
# Regarding rpm lock see Q9@ https://documentation.suse.com/de-de/sles/15-SP1/html/SLES-all/app-ay-faq.html
# quote : "during the post-script phase, YaST still has an exclusive lock on the RPM database."
# the package cannot be installed the autoyast way, because of the package name (eg libyui-rest-api15)
# only zypper allows to install "by capability".
mv /var/run/zypp.pid /var/run/zypp.sav
zypper ar https://openqa.opensuse.org/assets/repo/openSUSE-Tumbleweed-oss-i586-x86_64-Snapshot{{BUILD}} tumb
zypper -n in libyui-rest-api
mv /var/run/zypp.sav /var/run/zypp.pid
systemctl disable firewalld
]]></source>
</script>
</post-scripts>
</scripts>
</profile>
35 changes: 35 additions & 0 deletions data/autoyast_opensuse/autoyast_firstboot_leap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,39 @@
<timeout config:type="integer">0</timeout>
</yesno_messages>
</report>
<scripts>
<chroot-scripts config:type="list">
<script>
<chrooted config:type="boolean">true</chrooted>
<source>
<![CDATA[#!/bin/bash
# Enable libyui-rest-api in firstboot (requires an init script).
for i in YUI_HTTP_PORT={{YUI_PORT}} YUI_HTTP_REMOTE=1 YUI_REUSE_PORT=1 Y2DEBUG=1; do
echo "export $i" >> /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
done
chmod +x /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
]]>
</source>
</script>
</chroot-scripts>
<post-scripts config:type="list">
<script>
<filename>install_libyui.sh</filename>
<interpreter>shell</interpreter>
<location/>
<feedback config:type="boolean">false</feedback>
<source><![CDATA[#!/bin/sh
# Regarding rpm lock see Q9@ https://documentation.suse.com/de-de/sles/15-SP1/html/SLES-all/app-ay-faq.html
# quote : "during the post-script phase, YaST still has an exclusive lock on the RPM database."
# the package cannot be installed the autoyast way, because of the package name (eg libyui-rest-api15)
# only zypper allows to install "by capability".
mv /var/run/zypp.pid /var/run/zypp.sav
zypper ar http://openqa.opensuse.org/assets/repo/openSUSE-Leap-{{VERSION}}-oss-Build{{BUILD}} leap
zypper -n in libyui-rest-api
mv /var/run/zypp.sav /var/run/zypp.pid
systemctl disable firewalld
]]></source>
</script>
</post-scripts>
</scripts>
</profile>
55 changes: 55 additions & 0 deletions data/autoyast_sle15/autoyast_firstboot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<version>{{VERSION}}</version>
<arch>{{ARCH}}</arch>
</addon>
<addon>
<name>sle-module-development-tools</name>
<version>{{VERSION}}</version>
<arch>{{ARCH}}</arch>
</addon>
<addon>
<name>sle-module-desktop-applications</name>
<version>{{VERSION}}</version>
Expand All @@ -34,6 +39,23 @@
<networking>
<keep_install_network config:type="boolean">true</keep_install_network>
</networking>
<firewall>
<zones config:type="list">
<zone>
<name>external</name>
<services config:type="list">
<service>http</service>
<service>https</service>
</services>
<ports config:type="list">
<port>{{YUI_PORT}}/tcp</port>
</ports>
</zone>
</zones>
<log_denied_packets>off</log_denied_packets>
<enable_firewall config:type="boolean">false</enable_firewall>
<start_firewall config:type="boolean">false</start_firewall>
</firewall>
<software>
<products config:type="list">
<product>SLES</product>
Expand Down Expand Up @@ -95,4 +117,37 @@
<timeout config:type="integer">0</timeout>
</yesno_messages>
</report>
<scripts>
<chroot-scripts config:type="list">
<script>
<chrooted config:type="boolean">true</chrooted>
<source>
<![CDATA[#!/bin/bash
# Enable libyui-rest-api in firstboot (requires an init script).
for i in YUI_HTTP_PORT={{YUI_PORT}} YUI_HTTP_REMOTE=1 YUI_REUSE_PORT=1 Y2DEBUG=1; do
echo "export $i" >> /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
done
chmod +x /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
]]>
</source>
</script>
</chroot-scripts>
<post-scripts config:type="list">
<script>
<filename>install_libyui.sh</filename>
<interpreter>shell</interpreter>
<location/>
<feedback config:type="boolean">false</feedback>
<source><![CDATA[#!/bin/sh
# Regarding rpm lock see Q9@ https://documentation.suse.com/de-de/sles/15-SP1/html/SLES-all/app-ay-faq.html
# quote : "during the post-script phase, YaST still has an exclusive lock on the RPM database."
# the package cannot be installed the autoyast way, because of the package name (eg libyui-rest-api15)
# only zypper allows to install "by capability".
mv /var/run/zypp.pid /var/run/zypp.sav
zypper -n in libyui-rest-api
mv /var/run/zypp.sav /var/run/zypp.pid
]]></source>
</script>
</post-scripts>
</scripts>
</profile>
5 changes: 5 additions & 0 deletions lib/Distribution/Opensuse/Tumbleweed.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use Installation::Partitioner::LibstorageNG::v4_3::ExpertPartitionerController;
use YaST::NetworkSettings::v4_3::NetworkSettingsController;
use Installation::SystemRole::SystemRoleController;
use YaST::SystemSettings::SystemSettingsController;
use YaST::Firstboot::FirstbootController;

sub get_partitioner {
return Installation::Partitioner::LibstorageNG::GuidedSetupController->new();
Expand Down Expand Up @@ -52,4 +53,8 @@ sub get_suggested_partitioning() {
return Installation::Partitioner::LibstorageNG::v4_3::SuggestedPartitioningController->new();
}

sub get_firstboot {
return YaST::Firstboot::FirstbootController->new();
}

1;
41 changes: 41 additions & 0 deletions lib/YaST/Firstboot/FirstbootController.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SUSE's openQA tests
#
# Copyright © 2021 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

# Summary: Controller for firstboot wizard.
# Maintainer: QE YaST <qa-sle-yast@suse.de>

package YaST::Firstboot::FirstbootController;
use strict;
use warnings;
use YuiRestClient;
use YaST::Firstboot::GenericPage;

sub new {
my ($class, $args) = @_;
my $self = bless {}, $class;
return $self->init($args);
}

sub init {
my ($self, $args) = @_;
$self->{GenericPage} = YaST::Firstboot::GenericPage->new({app => YuiRestClient::get_app()});
return $self;
}

sub get_generic_page {
my ($self) = @_;
$self->{GenericPage};
}

sub press_next {
my ($self) = @_;
$self->get_generic_page->press_next();
}

1;
36 changes: 36 additions & 0 deletions lib/YaST/Firstboot/GenericPage.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SUSE's openQA tests
#
# Copyright © 2021 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

# Summary: Handle common parts in all firstboot pages.
# Maintainer: QE YaST <qa-sle-yast@suse.de>

package YaST::Firstboot::GenericPage;
use strict;
use warnings;

sub new {
my ($class, $args) = @_;
my $self = bless {
app => $args->{app}
}, $class;
return $self->init();
}

sub init {
my ($self) = @_;
$self->{btn_next} = $self->{app}->button({id => 'next'});
return $self;
}

sub press_next {
my ($self) = @_;
return $self->{btn_next}->click();
}

1;
11 changes: 11 additions & 0 deletions lib/YuiRestClient.pm
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,15 @@ sub set_libyui_backend_vars {
set_var('YUI_SERVER', $server);
}

sub setup_libyui_firstboot {
my $port = get_var('YUI_PORT');
record_info("YUIPORT", "Port that will be used by libyui_rest_api:" . get_var('YUI_PORT'));
zypper_call('in libyui-rest-api');
assert_script_run "firewall-cmd --zone=public --add-port=$port/tcp --permanent";
foreach my $export ("YUI_HTTP_PORT=$port", "YUI_HTTP_REMOTE=1", "YUI_REUSE_PORT=1", "Y2DEBUG=1") {
assert_script_run "echo export $export >> /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api";
}
assert_script_run "chmod +x /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api";
}

1;
1 change: 1 addition & 0 deletions schedule/yast/firstboot/autoyast_y2_firstboot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ schedule:
- autoyast/prepare_profile
- installation/isosize
- installation/bootloader_start
- installation/setup_libyui
- autoyast/installation
- installation/yast2_firstboot
- installation/first_boot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ schedule:
- autoyast/prepare_profile
- installation/isosize
- installation/bootloader_start
- installation/setup_libyui
- autoyast/installation
- installation/yast2_firstboot
- installation/first_boot
Expand Down
1 change: 1 addition & 0 deletions schedule/yast/firstboot/yast2_firstboot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ schedule:
- console/consoletest_setup
- console/hostname
- installation/enable_y2_firstboot
- installation/setup_libyui_firstboot
- autoyast/autoyast_reboot
- installation/grub_test
- installation/yast2_firstboot
Expand Down
2 changes: 2 additions & 0 deletions schedule/yast/firstboot/yast2_firstboot_custom-opensuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ schedule:
- console/consoletest_setup
- console/hostname
- installation/enable_y2_firstboot
- installation/setup_libyui_firstboot
- autoyast/autoyast_reboot
- installation/grub_test
- installation/yast2_firstboot
Expand All @@ -25,5 +26,6 @@ test_data:
- firstboot_hostname
- firstboot_timezone
- firstboot_user
- firstboot_finish
custom_control_file: "firstboot_custom-opensuse.xml"
sysconfig_firstboot: "sysconfig_firstboot"
2 changes: 2 additions & 0 deletions schedule/yast/firstboot/yast2_firstboot_custom-sle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ schedule:
- console/consoletest_setup
- console/hostname
- installation/enable_y2_firstboot
- installation/setup_libyui_firstboot
- autoyast/autoyast_reboot
- installation/grub_test
- installation/yast2_firstboot
Expand All @@ -25,5 +26,6 @@ test_data:
- firstboot_hostname
- firstboot_timezone
- firstboot_user
- firstboot_finish
custom_control_file: "firstboot_custom-sle.xml"
sysconfig_firstboot: "sysconfig_firstboot"
1 change: 1 addition & 0 deletions test_data/yast/firstboot/yast2_firstboot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ clients:
- firstboot_timezone
- firstboot_user
- firstboot_root
- firstboot_finish
1 change: 1 addition & 0 deletions test_data/yast/firstboot/yast2_firstboot_sle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ clients:
- firstboot_user
- firstboot_root
- firstboot_registration
- firstboot_finish
32 changes: 32 additions & 0 deletions tests/installation/setup_libyui_firstboot.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright © 2020 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.

# Summary: Enable libyui for firstboot. Temporary module until
# https://progress.opensuse.org/issues/90368 is done.

# Maintainer: QA SLE YaST team <qa-sle-yast@suse.de>

use strict;
use warnings;
use base "installbasetest";
use registration "add_suseconnect_product";
use version_utils "is_sle";

sub run {
add_suseconnect_product('sle-module-development-tools') if is_sle;
YuiRestClient::setup_libyui_firstboot();
}

1;
Loading

0 comments on commit 6ee97cb

Please sign in to comment.