Skip to content

Commit

Permalink
Ignore the partitions mounted before the installer is started (bsc#10…
Browse files Browse the repository at this point in the history
…73696)

Ignore the HDD installation source or the user mounts for remote logging.

- 4.0.27
  • Loading branch information
lslezak committed Jan 9, 2018
1 parent ab38bbe commit 35ee573
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
8 changes: 8 additions & 0 deletions package/yast2-packager.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Jan 9 14:48:08 UTC 2018 - lslezak@suse.cz

- Space check: ignore the partitions mounted before the installer
is started, e.g. ignore the HDD installation source or the user
mounts for remote logging (bsc#1073696)
- 4.0.27

-------------------------------------------------------------------
Mon Jan 8 13:17:00 UTC 2018 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-packager.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-packager
Version: 4.0.26
Version: 4.0.27
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
18 changes: 17 additions & 1 deletion src/modules/SpaceCalculation.rb
Expand Up @@ -1052,7 +1052,23 @@ def size_from_string(size_str)
# @return [Array<Storage::Filesystem>]
def target_filesystems
filesystems = Y2Storage::Filesystems::BlkFilesystem.all(staging_devicegraph)
filesystems.select! { |fs| fs.mountpoint && fs.mountpoint.start_with?("/") }
filesystems.select! do |fs|
# Ignore the devices mounted before starting the installer (e.g. the
# installation repository mounted by linuxrc when installing from HDD or
# the user mounted devices like for remote logging). Such devices will
# not be saved in the final /etc/fstab therefore check that flag.
# Check this only in the initial installation (as the non-fstab values
# will be missing in "/mnt"), in installed system they will stay available
# at "/".
# TODO: use a better API when provided by the libstorage-ng wrapper
if fs.mountpoint
log.debug("#{fs.mountpoint.inspect} in fstab: " \
"#{fs.to_storage_value.mount_point.in_etc_fstab?}")
end

fs.mountpoint && fs.mountpoint.start_with?("/") &&
(!Stage.initial || fs.to_storage_value.mount_point.in_etc_fstab?)
end
filesystems.reject! { |fs| TARGET_FS_TYPES_TO_IGNORE.include?(fs.type) }
filesystems
end
Expand Down
17 changes: 17 additions & 0 deletions test/space_calculation_test.rb
Expand Up @@ -23,6 +23,10 @@ def expect_to_execute(command)
expect(Yast::SCR).to receive(:Execute).with(SCR_BASH_PATH, command)
end

def expect_to_not_execute(command)
expect(Yast::SCR).to_not receive(:Execute).with(SCR_BASH_PATH, command)
end

def filesystem(size_k: 0, block_size: 4096, type: :ext2, tune_options: "")
disk_size = Y2Storage::DiskSize.KiB(size_k)
region = Y2Storage::Region.create(0, disk_size.to_i, Y2Storage::DiskSize.B(block_size))
Expand Down Expand Up @@ -128,6 +132,19 @@ def filesystem(size_k: 0, block_size: 4096, type: :ext2, tune_options: "")
Yast::SpaceCalculation.get_partition_info
end
end

context "on non-fstab device" do
let(:target_map) { "xfs" }
let(:with_options) { false }

it "skips non-fstab devices" do
# for simplicity simulate nothing in fstab
allow_any_instance_of(Storage::MountPoint).to receive(:in_etc_fstab?).and_return(false)
# ensure nothing is mounted
expect_to_not_execute(/mount/)
Yast::SpaceCalculation.get_partition_info
end
end
end
end

Expand Down

0 comments on commit 35ee573

Please sign in to comment.