Skip to content

Commit

Permalink
Inject the /etc/resolv.conf file, sort the restore scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Apr 26, 2018
1 parent f18b21b commit 437a5be
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/modules/RootPart.rb
Expand Up @@ -31,6 +31,8 @@
require "yast2/fs_snapshot_store"
require "y2storage"

require "fileutils"

module Yast
class RootPartClass < Module
include Logger
Expand Down Expand Up @@ -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 = {
Expand All @@ -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(
Expand Down

0 comments on commit 437a5be

Please sign in to comment.