Skip to content

Commit

Permalink
Merge pull request #99 from joseivanlopez/merge_to_master
Browse files Browse the repository at this point in the history
Merge SLE-15-GA to master
  • Loading branch information
joseivanlopez committed Jun 6, 2018
2 parents aafe29e + e09a744 commit 75eaa6d
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 8 deletions.
17 changes: 17 additions & 0 deletions package/yast2-update.changes
@@ -1,3 +1,20 @@
-------------------------------------------------------------------
Wed May 9 10:20:03 UTC 2018 - lslezak@suse.cz

- Fixed unmounting /mnt/dev when going back to the partition
selection dialog (fix up for the bsc#1089643)
- 4.0.14

-------------------------------------------------------------------
Fri Apr 27 13:45:41 UTC 2018 - lslezak@suse.cz

- Copy the resolv.conf and bind mount /dev directory to the target
root, sort the restore scripts to run them in the expected
order (bsc#1089643)
- The bind mount also fixes the libzypp plugin service refresh
(bsc#1080693)
- 4.0.13

-------------------------------------------------------------------
Mon Mar 19 16:24:35 UTC 2018 - ancor@suse.com

Expand Down
6 changes: 3 additions & 3 deletions package/yast2-update.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-update
Version: 4.0.12
Version: 4.0.14
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down Expand Up @@ -49,8 +49,8 @@ Requires: yast2-storage-ng >= 4.0.137
Requires: yast2 >= 3.1.126
Requires: yast2-installation

# Packages#proposal_for_update
Requires: yast2-packager >= 3.2.13
# handle bind mount at /mnt/dev
Requires: yast2-packager >= 4.0.61

# Pkg.TargetInitializeOptions()
Requires: yast2-pkg-bindings >= 3.1.14
Expand Down
30 changes: 28 additions & 2 deletions src/modules/RootPart.rb
Expand Up @@ -31,10 +31,12 @@
require "yast2/fs_snapshot_store"
require "y2storage"

require "fileutils"

module Yast
class RootPartClass < Module
include Logger
NON_MODULAR_FS = ["proc", "sysfs"]
NON_MODULAR_FS = ["devtmpfs", "proc", "sysfs"]

def main
Yast.import "UI"
Expand Down Expand Up @@ -1095,6 +1097,13 @@ def MountFSTab(fstab, message)
)
end

# to have devices like /dev/cdrom and /dev/urandom in the chroot
if MountPartition("/dev", "devtmpfs", "devtmpfs") == nil
AddMountedPartition(
{ :type => "mount", :device => "devtmpfs", :mntpt => "/dev" }
)
end

success = true

Builtins.foreach(fstab) do |mounts|
Expand Down Expand Up @@ -1675,27 +1684,44 @@ def MountPartitions(root_device_current)
end
Update.clean_backup
create_backup
inject_intsys_files
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 = {
"sw_mgmt" => [
# use a number prefix to set the execution order
"0100-sw_mgmt" => [
"/var/lib/rpm",
"/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 required files from the inst-sys to the chroot so
# the network connection works for the chrooted scripts
def inject_intsys_files
# the original file is backed up and restored later
::FileUtils.cp(RESOLV_CONF, File.join(Installation.destdir, RESOLV_CONF)) if File.exist?(RESOLV_CONF)
end

# Get architecture of an elf file.
def GetArchOfELF(filename)
bash_out = Convert.to_map(
Expand Down
8 changes: 5 additions & 3 deletions src/modules/Update.rb
Expand Up @@ -775,11 +775,12 @@ def installed_product
BACKUP_DIR = "var/adm/backup/system-upgrade"
# Creates backup with name based on `name` contaings everything
# matching globs in `paths`.
# @param name[String] name for backup file. Use bash friendly name ;)
# @param name[String] name for backup file. Use a number prefix to run
# the restore scripts in the expected order. Use a bash friendly name ;)
# @note Can be called only after target root is mounted.
#
# @example to store repos file and credentials directory
# Update.create_backup("repos", ["/etc/zypp/repos.d/*", "/etc/zypp/credentials"])
# Update.create_backup("0100-repos", ["/etc/zypp/repos.d/*", "/etc/zypp/credentials"])
def create_backup(name, paths)
log.info "Creating tarball for #{name} including #{paths}"
mounted_root = Installation.destdir
Expand All @@ -805,7 +806,8 @@ def restore_backup
log.info "Restoring backup"
mounted_root = Installation.destdir
script_glob = File.join(mounted_root, BACKUP_DIR,"restore-*.sh")
::Dir.glob(script_glob).each do |path|
# sort the scripts to execute them in the expected order
::Dir.glob(script_glob).sort.each do |path|
cmd = "sh #{path} #{File.join("/", mounted_root)}"
res = SCR.Execute(path(".target.bash_output"), cmd)
log.info "Restoring with script #{cmd} result: #{res}"
Expand Down
14 changes: 14 additions & 0 deletions test/root_part_test.rb
Expand Up @@ -234,4 +234,18 @@
end
end
end

describe "#MountFSTab" do
it "mounts /dev, /proc and /sys" do
allow(subject).to receive(:AddMountedPartition)

["/dev", "/proc", "/sys"].each do |d|
expect(subject).to receive(:MountPartition).with(d, anything, anything)
end

# call with empty list to only test the /dev, /proc and /sys mounting
fstab = []
subject.MountFSTab(fstab, "")
end
end
end

0 comments on commit 75eaa6d

Please sign in to comment.