From a177a63ec1c6c41758d14a003409c0fb9c64e307 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 20 Aug 2019 14:16:23 -0700 Subject: [PATCH] Factor out s/metalink/mirrorlist/ into a util function We do this in quite a few places and need to do it in another, so let's just have a function for it. It takes a file glob so we can have it run on a different one for _live_build. Signed-off-by: Adam Williamson --- lib/utils.pm | 18 ++++++++++++------ tests/_live_build.pm | 2 +- tests/upgrade_boot.pm | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/utils.pm b/lib/utils.pm index d82e30f3..382cfe6c 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -7,7 +7,7 @@ use Exporter; use lockapi; use testapi; -our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type start_cockpit repo_setup gnome_initial_setup anaconda_create_user check_desktop_clean download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut lo_dismiss_tip disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile bypass_1691487 get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log click_unwanted_notifications/; +our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type start_cockpit repo_setup gnome_initial_setup anaconda_create_user check_desktop_clean download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut lo_dismiss_tip disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile bypass_1691487 get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log click_unwanted_notifications repos_mirrorlist/; sub run_with_error_check { my ($func, $error_screen) = @_; @@ -341,6 +341,16 @@ sub start_cockpit { } } +sub repos_mirrorlist { + # Use mirrorlist not metalink so we don't hit the timing issue where + # the infra repo is updated but mirrormanager metadata checksums + # have not been updated, and the infra repo is rejected as its + # metadata checksum isn't known to MM + my $files = shift; + my $files ||= "/etc/yum.repos.d/fedora*.repo"; + assert_script_run "sed -i -e 's,metalink,mirrorlist,g' ${files}"; +} + sub _repo_setup_compose { # Appropriate repo setup steps for testing a compose # disable updates-testing and updates and use the compose location @@ -370,11 +380,7 @@ sub _repo_setup_updates { # Appropriate repo setup steps for testing a Bodhi update # Check if we already ran, bail if so return unless script_run "test -f /etc/yum.repos.d/advisory.repo"; - # Use mirrorlist not metalink so we don't hit the timing issue where - # the infra repo is updated but mirrormanager metadata checksums - # have not been updated, and the infra repo is rejected as its - # metadata checksum isn't known to MM - assert_script_run "sed -i -e 's,metalink,mirrorlist,g' /etc/yum.repos.d/fedora*.repo"; + _repos_mirrorlist(); if (get_var("DEVELOPMENT")) { # Disable updates-testing so other bad updates don't break us # this will do nothing on upgrade tests as we're on a stable diff --git a/tests/_live_build.pm b/tests/_live_build.pm index 08bc8d97..d626a8ad 100644 --- a/tests/_live_build.pm +++ b/tests/_live_build.pm @@ -23,7 +23,7 @@ sub run { # now add the side repo to the config assert_script_run 'printf "[advisory]\nname=Advisory repo\nbaseurl=file:///opt/update_repo\nenabled=1\nmetadata_expire=3600\ngpgcheck=0\n\"\"\"" >> /etc/mock/openqa.cfg'; # replace metalink with mirrorlist so we don't get slow mirrors - assert_script_run "sed -i -e 's,metalink,mirrorlist,g' /etc/mock/openqa.cfg"; + repos_mirrorlist("/etc/mock/openqa.cfg"); # upload the config so we can check it's OK upload_logs "/etc/mock/openqa.cfg"; # now check out the kickstarts diff --git a/tests/upgrade_boot.pm b/tests/upgrade_boot.pm index 00e3c0cb..597dc5ae 100644 --- a/tests/upgrade_boot.pm +++ b/tests/upgrade_boot.pm @@ -22,7 +22,7 @@ sub run { script_run "setterm -blank 0"; # adjust repo files to use mirrorlist not metalink (to avoid # metalink checksum timing issue causing infra repo to be rejected) - assert_script_run "sed -i -e 's,metalink,mirrorlist,g' /etc/yum.repos.d/fedora*.repo"; + repos_mirrorlist; }