Skip to content

Commit

Permalink
check for inst sys
Browse files Browse the repository at this point in the history
  • Loading branch information
shundhammer committed Dec 22, 2015
1 parent 672578b commit ed3c7ae
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
47 changes: 47 additions & 0 deletions src/lib/storage/space_maker.rb
Expand Up @@ -22,6 +22,7 @@
# find current contact information at www.suse.com.

require "yast"
require "fileutils"
require_relative "./proposal_volume"
require_relative "./disk_size"
require "pp"
Expand Down Expand Up @@ -78,6 +79,52 @@ def windows_partition?
def resize_windows_partition
# TO DO
end

# Check if a disk is our installation disk - the medium we just booted
# and started the installation from. This will check all filesystems on
# that disk.
#
def installation_disk?(disk)
log.info("Checking #{disk}")
begin
disk.partition_table.partitions.each do |partition|
return true if installation_filesystem?(partition)
end
rescue # No partition table or nofilesystem on this partition (maybe an "Extended" partition)
end

# Check if there is a filesystem directly on the disk (without partition table).
# This is very common for installation media such as USB sticks.
begin
filesystem = disk.filesystem
return installation_filsystem?(filesystem) if filesystem
rescue # Not a filesystem
end
false
end

# Check if a partition is our installation medium - the medium we just
# booted and started the installation from.
#
def installation_filesystem?(partition)
# check if we have a filesystem
log.info("Checking #{partition.name}")
mount_point = "/mnt" # FIXME
# FIXME use libstorage function when available
cmd = "/usr/bin/mount -r #{partition.name} #{mount_point}"
log.info("Trying to mount: #{cmd}")
return false unless system(cmd) # mount failed

log.info("Checking if partition #{partition} is installation partition")
return false unless File.exist?(mount_point + "/control.xml")
result = FileUtils.identical?("/control.xml", mount_point + "/control.xml")
log.info("#{partition} is installation medium") if result

# FIXME use libstorage function when available
system("/usr/bin/umount #{partition.name}")

result
end
end
end
end
7 changes: 6 additions & 1 deletion src/lib/storage/storage_proposal.rb
Expand Up @@ -66,9 +66,14 @@ def propose
boot_requirements_checker = BootRequirementsChecker.new(@settings)
@volumes = boot_requirements_checker.needed_partitions
@volumes += standard_volumes
pp @volumes
# pp @volumes

space_maker = SpaceMaker.new(@volumes, @settings)
disks = ::Storage::Disk.all(storage.probed)
disks.each do |disk|
print("Found disk #{disk}\n")
print("#{disk} is current installation medium\n") if space_maker.installation_disk?(disk)
end
end

def proposal_text
Expand Down

0 comments on commit ed3c7ae

Please sign in to comment.