From d5b2933709087e29ec10d81b5ae3cfbb1730c257 Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Fri, 17 May 2024 08:53:23 +0200 Subject: [PATCH] Replace is_rhel8 and is_rhel9 with get_platform function --- anaconda-conf.ks.in | 4 +-- anaconda-modules.ks.in | 4 +-- bindtomac-bridge-2devs-httpks.ks.in | 3 ++- bindtomac-bridge-2devs-pre.ks.in | 3 ++- bindtomac-bridge-httpks.ks.in | 3 ++- bond-ks-initramfs.ks.in | 6 +++-- bridge-2devs-httpks.ks.in | 3 ++- bridge-2devs-pre.ks.in | 3 ++- bridge-2devs.ks.in | 3 ++- bridge-httpks.ks.in | 3 ++- bridge-no-bootopts-net.ks.in | 3 ++- network-addr-gen-mode.ks.in | 3 ++- network-autoconnections-dhcpall-httpks.ks.in | 10 +++++--- network-autoconnections-httpks.ks.in | 10 +++++--- repo-install.ks.in | 4 +-- scripts-lib.sh | 26 -------------------- 16 files changed, 40 insertions(+), 51 deletions(-) diff --git a/anaconda-conf.ks.in b/anaconda-conf.ks.in index 74d3bf5f..891f45f4 100644 --- a/anaconda-conf.ks.in +++ b/anaconda-conf.ks.in @@ -22,9 +22,9 @@ fi %post --nochroot @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ || \ - is_rhel9 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ] || [ "${platform}" == "rhel9" ]; then LOG_MSG="Writing a temporary configuration loaded from" else LOG_MSG="Configuration loaded from:" diff --git a/anaconda-modules.ks.in b/anaconda-modules.ks.in index 8d11d689..184212f7 100644 --- a/anaconda-modules.ks.in +++ b/anaconda-modules.ks.in @@ -11,6 +11,7 @@ %post --nochroot @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" # Get the activated Anaconda DBus modules. cat /tmp/syslog | grep "Activating service name" | \ @@ -18,8 +19,7 @@ grep "org.fedoraproject.Anaconda.Modules" | cut -d"'" -f2 \ | sort > /tmp/generated.out # Generate the expected output. -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ || \ - is_rhel9 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ] || [ "${platform}" == "rhel9" ]; then cat > /tmp/expected.out << EOF org.fedoraproject.Anaconda.Modules.Localization org.fedoraproject.Anaconda.Modules.Network diff --git a/bindtomac-bridge-2devs-httpks.ks.in b/bindtomac-bridge-2devs-httpks.ks.in index 91c4ebee..004126b8 100644 --- a/bindtomac-bridge-2devs-httpks.ks.in +++ b/bindtomac-bridge-2devs-httpks.ks.in @@ -36,6 +36,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bridge0 bridge1 @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" # bridge0 @@ -76,7 +77,7 @@ check_device_config_value bridge1 ONBOOT yes connection autoconnect __NONE check_device_config_value bridge1_slave_1 ONBOOT yes connection autoconnect __NONE -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then # RHEL-8-FAILURE: anaconda does not create default config file for enslaved device in RHEL8 check_config_exists @KSTEST_NETDEV2@ no else diff --git a/bindtomac-bridge-2devs-pre.ks.in b/bindtomac-bridge-2devs-pre.ks.in index 1f21e8e7..11b10213 100644 --- a/bindtomac-bridge-2devs-pre.ks.in +++ b/bindtomac-bridge-2devs-pre.ks.in @@ -38,6 +38,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bridge0 bridge1 @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" # bridge0 @@ -76,7 +77,7 @@ check_device_config_value bridge1 ONBOOT yes connection autoconnect __NONE check_device_config_value bridge1_slave_1 ONBOOT yes connection autoconnect __NONE -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then # RHEL-8-FAILURE: anaconda does not create default config file for enslaved device in RHEL8 check_config_exists @KSTEST_NETDEV2@ no else diff --git a/bindtomac-bridge-httpks.ks.in b/bindtomac-bridge-httpks.ks.in index e3903a08..fffffaf7 100644 --- a/bindtomac-bridge-httpks.ks.in +++ b/bindtomac-bridge-httpks.ks.in @@ -21,10 +21,11 @@ shutdown %post --nochroot @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" @KSINCLUDE@ post-nochroot-lib-network.sh check_bridge_has_slave_nochroot bridge0 @KSTEST_NETDEV1@ yes -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then # RHEL-8-FAILURE: generic "Wired Connection" created in initramfs (ip=dhcp) # would be edited for @KSTEST_NETDEV1@ in GUI which is not ideal check_gui_configurations bridge0 diff --git a/bond-ks-initramfs.ks.in b/bond-ks-initramfs.ks.in index 420bb8e4..854e5a35 100644 --- a/bond-ks-initramfs.ks.in +++ b/bond-ks-initramfs.ks.in @@ -18,8 +18,9 @@ network --device bond0 --bootproto dhcp --bondslaves=@KSTEST_NETDEV1@,@KSTEST_NE # We will copy /root/RESULT to /mnt/sysimage/root/RESULT at the beginning of the %post (--nochroot) checks @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then # Ifcfg files for the kickstart configuration are created in initramfs check_config_exists bond0 yes check_config_exists bond0_slave_1 yes @@ -59,9 +60,10 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bond0 @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" check_device_config_value bond0 ONBOOT yes connection autoconnect __NONE -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then check_device_config_value bond0_slave_1 ONBOOT yes connection autoconnect __NONE check_device_config_value bond0_slave_1 SLAVE yes connection slave-type bond check_device_config_value bond0_slave_2 ONBOOT yes connection autoconnect __NONE diff --git a/bridge-2devs-httpks.ks.in b/bridge-2devs-httpks.ks.in index dc1a85ef..340cbfb9 100644 --- a/bridge-2devs-httpks.ks.in +++ b/bridge-2devs-httpks.ks.in @@ -36,6 +36,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bridge0 bridge1 @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" # bridge0 @@ -77,7 +78,7 @@ check_device_config_value bridge1 ONBOOT yes connection autoconnect __NONE check_device_config_value bridge1_slave_1 ONBOOT yes connection autoconnect __NONE -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then # RHEL-8-FAILURE: anaconda does not create default config file for enslaved device in RHEL8 check_config_exists @KSTEST_NETDEV2@ no else diff --git a/bridge-2devs-pre.ks.in b/bridge-2devs-pre.ks.in index 4b28300e..65756d7b 100644 --- a/bridge-2devs-pre.ks.in +++ b/bridge-2devs-pre.ks.in @@ -38,6 +38,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bridge0 bridge1 @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" # bridge0 @@ -76,7 +77,7 @@ check_device_config_value bridge1 ONBOOT yes connection autoconnect __NONE check_device_config_value bridge1_slave_1 ONBOOT yes connection autoconnect __NONE -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then # RHEL-8-FAILURE: anaconda does not create default config file for enslaved device in RHEL8 check_config_exists @KSTEST_NETDEV2@ no else diff --git a/bridge-2devs.ks.in b/bridge-2devs.ks.in index 87911608..4ba96359 100644 --- a/bridge-2devs.ks.in +++ b/bridge-2devs.ks.in @@ -36,6 +36,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ bridge0 bridge1 @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" # bridge0 @@ -75,7 +76,7 @@ check_device_config_value bridge1 ONBOOT yes connection autoconnect __NONE check_device_config_value bridge1_slave_1 ONBOOT yes connection autoconnect __NONE -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then # RHEL-8-FAILURE: anaconda does not create default config file for enslaved device in RHEL8 check_config_exists @KSTEST_NETDEV2@ no else diff --git a/bridge-httpks.ks.in b/bridge-httpks.ks.in index 4267fad3..6c4736de 100644 --- a/bridge-httpks.ks.in +++ b/bridge-httpks.ks.in @@ -21,10 +21,11 @@ shutdown %post --nochroot @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" @KSINCLUDE@ post-nochroot-lib-network.sh check_bridge_has_slave_nochroot bridge0 @KSTEST_NETDEV1@ yes -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then # RHEL-8-FAILURE: generic "Wired Connection" created in initramfs (ip=dhcp) # would be edited for @KSTEST_NETDEV1@ in GUI which is not ideal check_gui_configurations bridge0 diff --git a/bridge-no-bootopts-net.ks.in b/bridge-no-bootopts-net.ks.in index 56ff46d9..784d8ce7 100644 --- a/bridge-no-bootopts-net.ks.in +++ b/bridge-no-bootopts-net.ks.in @@ -34,11 +34,12 @@ check_gui_configurations @KSTEST_NETDEV1@ bridge0 @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" check_device_connected bridge0 yes check_device_connected @KSTEST_NETDEV1@ yes -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then # RHEL-8-FAILURE: in rhel 8 the ifcfg is generated in initramfs by Anaconda check_device_config_value bridge0_slave_1 BRIDGE bridge0 connection master bridge0 check_device_config_value bridge0_slave_1 BRIDGE bridge0 connection slave-type bridge diff --git a/network-addr-gen-mode.ks.in b/network-addr-gen-mode.ks.in index a0dd5486..97868570 100644 --- a/network-addr-gen-mode.ks.in +++ b/network-addr-gen-mode.ks.in @@ -52,11 +52,12 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ @KSTEST_NETDEV3@ @KST @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" check_device_config_value @KSTEST_NETDEV1@ IPV6_ADDR_GEN_MODE eui64 ipv6 addr-gen-mode eui64 check_connection_setting "@KSTEST_NETDEV1@" ipv6.addr-gen-mode eui64 check_device_config_value @KSTEST_NETDEV2@ IPV6_ADDR_GEN_MODE __NONE ipv6 addr-gen-mode eui64 -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then # In rhel8 ifcfg from kickstart is generated in initramfs check_connection_setting "System @KSTEST_NETDEV2@" ipv6.addr-gen-mode default-or-eui64 else diff --git a/network-autoconnections-dhcpall-httpks.ks.in b/network-autoconnections-dhcpall-httpks.ks.in index a20825e6..4c54cad2 100644 --- a/network-autoconnections-dhcpall-httpks.ks.in +++ b/network-autoconnections-dhcpall-httpks.ks.in @@ -26,9 +26,10 @@ shutdown # We will copy /root/RESULT to /mnt/sysimage/root/RESULT at the beginning of the %post (--nochroot) checks @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" check_config_exists @KSTEST_NETDEV1@ no -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then check_config_exists @KSTEST_NETDEV2@ yes else check_config_exists @KSTEST_NETDEV2@ no @@ -38,7 +39,7 @@ check_device_connected @KSTEST_NETDEV1@ yes check_device_connected @KSTEST_NETDEV2@ yes check_device_connected @KSTEST_NETDEV3@ yes -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then check_number_of_connections 2 else # includes "lo" connection @@ -47,7 +48,7 @@ fi check_connection_device "Wired Connection" @KSTEST_NETDEV1@ check_connection_device "Wired Connection" @KSTEST_NETDEV2@ -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then check_connection_device "System @KSTEST_NETDEV2@" fi check_connection_device "Wired Connection" @KSTEST_NETDEV3@ @@ -76,6 +77,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ @KSTEST_NETDEV3@ @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" check_device_config_value @KSTEST_NETDEV1@ ONBOOT yes connection autoconnect __NONE check_device_config_value @KSTEST_NETDEV2@ ONBOOT yes connection autoconnect __NONE @@ -89,7 +91,7 @@ check_device_connected @KSTEST_NETDEV3@ yes check_connection_device "Wired Connection" @KSTEST_NETDEV2@ check_connection_device @KSTEST_NETDEV2@ -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then check_number_of_connections 4 else # includes "lo" connection diff --git a/network-autoconnections-httpks.ks.in b/network-autoconnections-httpks.ks.in index 4cc897db..1a032f9f 100644 --- a/network-autoconnections-httpks.ks.in +++ b/network-autoconnections-httpks.ks.in @@ -27,11 +27,12 @@ shutdown # We will copy /root/RESULT to /mnt/sysimage/root/RESULT at the beginning of the %post (--nochroot) checks @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" # Note: up to RHEL8.2 the file was created by dracut network module # check_config_exists @KSTEST_NETDEV1@ yes check_config_exists @KSTEST_NETDEV1@ no # In RHEL8 ifcfg files are created from kickstart already in initramfs -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then check_config_exists @KSTEST_NETDEV2@ yes else check_config_exists @KSTEST_NETDEV2@ no @@ -40,7 +41,7 @@ check_config_exists @KSTEST_NETDEV3@ no check_device_connected @KSTEST_NETDEV1@ yes check_connection_device @KSTEST_NETDEV1@ @KSTEST_NETDEV1@ -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ]; then check_connection_device "System @KSTEST_NETDEV2@" fi @@ -53,7 +54,7 @@ check_connection_setting "@KSTEST_NETDEV1@" 802-3-ethernet.mac-address -- detect_nm_has_autoconnections_off nm_has_autoconnections_off=$? if [[ $nm_has_autoconnections_off -eq 0 ]]; then - if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then + if [ "${platform}" == "rhel8" ]; then check_number_of_connections 2 else # includes "lo" connection @@ -94,6 +95,7 @@ check_gui_configurations @KSTEST_NETDEV1@ @KSTEST_NETDEV2@ @KSTEST_NETDEV3@ @KSINCLUDE@ post-lib-network.sh @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" check_device_config_value @KSTEST_NETDEV1@ ONBOOT yes connection autoconnect __NONE check_device_config_value @KSTEST_NETDEV2@ ONBOOT yes connection autoconnect __NONE @@ -103,7 +105,7 @@ detect_nm_has_autoconnections_off nm_has_autoconnections_off=$? if [[ $nm_has_autoconnections_off -eq 0 ]]; then check_device_config_value @KSTEST_NETDEV3@ ONBOOT no connection autoconnect false - if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then + if [ "${platform}" == "rhel8" ]; then check_number_of_connections 3 else # includes "lo" connection diff --git a/repo-install.ks.in b/repo-install.ks.in index b28c7a6d..8e2f487d 100644 --- a/repo-install.ks.in +++ b/repo-install.ks.in @@ -15,10 +15,10 @@ repo --name=test05 --baseurl=EMPTY_REPO_URL --includepkgs=p1,p2 --excludepkgs=p3 %post @KSINCLUDE@ scripts-lib.sh +platform="$(get_platform @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@)" # Define patterns for repo options. -if is_rhel8 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ || \ - is_rhel9 @KSTEST_OS_NAME@ @KSTEST_OS_VERSION@ ; then +if [ "${platform}" == "rhel8" ] || [ "${platform}" == "rhel9" ]; then cost='^cost=25$' sslverify='^sslverify=0$' includepkgs='^includepkgs=p1,p2$' diff --git a/scripts-lib.sh b/scripts-lib.sh index 93e237f2..ff105337 100644 --- a/scripts-lib.sh +++ b/scripts-lib.sh @@ -21,29 +21,3 @@ function get_platform { echo ${platform} } - - -# is_rhel8 KSTESTS_OS_NAME KSTESTS_OS_VERSION -# Are we testing rhel 8 (based on the name and version detected from boot.iso) ? -function is_rhel8 { - local os_name=$1 - local os_version=$2 - if [ "$(get_platform ${os_name} ${os_version})" == "rhel8" ] ; then - return 0 - else - return 1 - fi -} - - -# is_rhel9 KSTESTS_OS_NAME KSTESTS_OS_VERSION -# Are we testing rhel 9 (based on the name and version detected from boot.iso) ? -function is_rhel9 { - local os_name=$1 - local os_version=$2 - if [ "$(get_platform ${os_name} ${os_version})" == "rhel9" ] ; then - return 0 - else - return 1 - fi -}