From 437a5be8ad0d6f33d94fc5cefe769bb7f94c41ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Wed, 25 Apr 2018 14:53:41 +0200 Subject: [PATCH] Inject the /etc/resolv.conf file, sort the restore scripts --- src/modules/RootPart.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/modules/RootPart.rb b/src/modules/RootPart.rb index b8f24fa6..0b8e72a6 100644 --- a/src/modules/RootPart.rb +++ b/src/modules/RootPart.rb @@ -31,6 +31,8 @@ require "yast2/fs_snapshot_store" require "y2storage" +require "fileutils" + module Yast class RootPartClass < Module include Logger @@ -1675,11 +1677,14 @@ def MountPartitions(root_device_current) end Update.clean_backup create_backup + inject_resolv_conf end success end + RESOLV_CONF = "/etc/resolv.conf".freeze + # known configuration files that are changed during update, so we need to # backup them to restore if something goes wrong (bnc#882039) BACKUP_DIRS = { @@ -1689,14 +1694,28 @@ def MountPartitions(root_device_current) "/etc/zypp/repos.d", "/etc/zypp/services.d", "/etc/zypp/credentials.d" + ], + # this should be restored as the very last one, after restoring the original + # resolv.conf the network might not work properly in the chroot + "0999-resolv_conf" => [ + RESOLV_CONF ] } + def create_backup BACKUP_DIRS.each_pair do |name, paths| Update.create_backup(name, paths) end end + # inject the /etc/resolv.conf from the inst-sys to the chroot so + # the network connection works for the chrooted scripts + # the original file is backed up and restored later + def inject_resolv_conf + return unless File.exist?(RESOLV_CONF) + ::FileUtils.cp(RESOLV_CONF, File.join(Installation.destdir, RESOLV_CONF)) + end + # Get architecture of an elf file. def GetArchOfELF(filename) bash_out = Convert.to_map(