Hello community, here is the log from the commit of package yast2-storage-ng for openSUSE:Factory checked in at 2018-03-14 19:35:02 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-storage-ng (Old) and /work/SRC/openSUSE:Factory/.yast2-storage-ng.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-storage-ng" Wed Mar 14 19:35:02 2018 rev:12 rq:586965 version:4.0.132 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-storage-ng/yast2-storage-ng.changes 2018-03-11 18:02:27.508970169 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-storage-ng.new/yast2-storage-ng.changes 2018-03-14 19:35:03.889669100 +0100 @@ -1,0 +2,21 @@ +Tue Mar 13 15:04:59 UTC 2018 - [email protected] + +- Post a warning if reusing an existing system mount point without + formatting during installation in the partitioner (bsc#1080073) +- 4.0.132 + +------------------------------------------------------------------- +Mon Mar 12 11:35:55 UTC 2018 - [email protected] + +- Add a new btrfs_read_only property to force the root filesystem + to be read-only (bsc#1079000) +- Honor the subvolumes list for the root filesystem (bsc#1077866) +- 4.0.131 + +------------------------------------------------------------------- +Mon Mar 12 08:50:40 UTC 2018 - [email protected] + +- Partitioner: always allow to edit the partition id (bsc#1077868). +- 4.0.130 + +------------------------------------------------------------------- Old: ---- yast2-storage-ng-4.0.129.tar.bz2 New: ---- yast2-storage-ng-4.0.132.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-storage-ng.spec ++++++ --- /var/tmp/diff_new_pack.TyqH4K/_old 2018-03-14 19:35:04.693640545 +0100 +++ /var/tmp/diff_new_pack.TyqH4K/_new 2018-03-14 19:35:04.697640403 +0100 @@ -17,7 +17,7 @@ Name: yast2-storage-ng -Version: 4.0.129 +Version: 4.0.132 Release: 0 BuildArch: noarch ++++++ yast2-storage-ng-4.0.129.tar.bz2 -> yast2-storage-ng-4.0.132.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/README.md new/yast2-storage-ng-4.0.132/README.md --- old/yast2-storage-ng-4.0.129/README.md 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/README.md 2018-03-14 15:20:08.000000000 +0100 @@ -35,49 +35,6 @@ for details about the wrapper classes. * Additional YaST-specific functionality. -This module is entirely unsupported. - -## Trying on Running System - -If you are brave enough to install this module in a (open)SUSE system, despite -the facts that **is not supported and can produce data loss**, you can perform -the following steps (as root): - -```bash -# Repository for Tumbleweed/Factory, adjust this line if using other distribution -zypper ar -f http://download.opensuse.org/repositories/YaST:/storage-ng/openSUSE_Tumbleweed/ libstorage-ng -zypper ref -rpm -e --nodeps libstorage7 libstorage-ruby libstorage-python libstorage-devel libstorage-testsuite -# There might be reported file conflicts between yast2-storage-ng and yast2-storage, -# it should be OK to ignore them. -zypper in yast2-storage-ng -``` - -Once the package is installed, the YaST Partitioner can be invoked running -`yast2 partitioner` or `yast2 storage`. - -It is also possible to run it with a device graph from a file via -`yast2 partitioner_testing <path to file>`. Supported formats are -the [yast2-storage-ng yml -format](https://github.com/yast/yast-storage-ng/blob/master/doc/fake-devicegraphs-yaml-format.md) -and the [libstorage xml format](https://github.com/openSUSE/libstorage-ng). - -## Trying the installation process - -There are test ISO images [available in the build -service](http://download.opensuse.org/repositories/YaST:/storage-ng/images/iso/) -that can be used to perform an openSUSE Tumbleweed installation using this -module instead of the original yast2-storage. Once again, take into account this -**is not supported and can produce data loss**. - -The installation process is the same than a regular openSUSE system. The -following things must be taken into account: - -* Not all scenarios work at this point in time (see Status below). -* Some user interfaces can be slightly different. -* The ISO image includes a relatively small selection of software, so choosing - Gnome or KDE Plasma in the "computer role" screen may not work as expected. - ## Status Check the [status](doc/status.md) of already implemented and still missing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/doc/installer-hacks.md new/yast2-storage-ng-4.0.132/doc/installer-hacks.md --- old/yast2-storage-ng-4.0.129/doc/installer-hacks.md 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/doc/installer-hacks.md 2018-03-14 15:20:08.000000000 +0100 @@ -82,13 +82,8 @@ ## Changes in yast2-bootloader -* Disabled some unit tests dealing with non-supported features (see below). - -* Various code dealing with RAID, alternative device names and crypt devices - disabled. All marked with "# storage-ng". - -* Code dealing with BIOS-ID changed to blindly assume common values. Original - code commented and marked with "storage-ng". +* Code dealing with BIOS-ID changed to assume that boot disk is one which + have /boot partition. ## Changes in autoyast2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/package/yast2-storage-ng.changes new/yast2-storage-ng-4.0.132/package/yast2-storage-ng.changes --- old/yast2-storage-ng-4.0.129/package/yast2-storage-ng.changes 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/package/yast2-storage-ng.changes 2018-03-14 15:20:08.000000000 +0100 @@ -1,4 +1,25 @@ ------------------------------------------------------------------- +Tue Mar 13 15:04:59 UTC 2018 - [email protected] + +- Post a warning if reusing an existing system mount point without + formatting during installation in the partitioner (bsc#1080073) +- 4.0.132 + +------------------------------------------------------------------- +Mon Mar 12 11:35:55 UTC 2018 - [email protected] + +- Add a new btrfs_read_only property to force the root filesystem + to be read-only (bsc#1079000) +- Honor the subvolumes list for the root filesystem (bsc#1077866) +- 4.0.131 + +------------------------------------------------------------------- +Mon Mar 12 08:50:40 UTC 2018 - [email protected] + +- Partitioner: always allow to edit the partition id (bsc#1077868). +- 4.0.130 + +------------------------------------------------------------------- Fri Mar 9 09:36:27 UTC 2018 - [email protected] - Shadowed subvolumes that are ignored in the first proposal diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/package/yast2-storage-ng.spec new/yast2-storage-ng-4.0.132/package/yast2-storage-ng.spec --- old/yast2-storage-ng-4.0.129/package/yast2-storage-ng.spec 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/package/yast2-storage-ng.spec 2018-03-14 15:20:08.000000000 +0100 @@ -16,7 +16,7 @@ # Name: yast2-storage-ng -Version: 4.0.129 +Version: 4.0.132 Release: 0 BuildArch: noarch diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/src/lib/y2partitioner/actions/controllers/filesystem.rb new/yast2-storage-ng-4.0.132/src/lib/y2partitioner/actions/controllers/filesystem.rb --- old/yast2-storage-ng-4.0.129/src/lib/y2partitioner/actions/controllers/filesystem.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/src/lib/y2partitioner/actions/controllers/filesystem.rb 2018-03-14 15:20:08.000000000 +0100 @@ -481,8 +481,7 @@ # Special handling for some mount paths ("/", "/boot/*") opt = options[:mount_options] || [] - opt = filesystem.type.special_path_fstab_options(opt, mount_point.path) - mount_point.mount_options = opt + mount_point.mount_options = add_special_mount_options_for(mount_point.path, opt) end def current_value_for(attribute) @@ -538,11 +537,10 @@ end def after_change_mount_point - # When the filesystem is btrfs and root, default proposed subvolumes are added - # in case they are not been probed. - add_proposed_subvolumes if btrfs? && root? - # When the filesystem is btrfs, the mount point of the resulting subvolumes is updated. - update_mount_points if btrfs? + if btrfs? + add_proposed_subvolumes + update_mount_points + end # Shadowing control of btrfs subvolumes is always performed. Y2Storage::Filesystems::Btrfs.refresh_subvolumes_shadowing(working_graph) end @@ -570,10 +568,9 @@ # # @see Y2Storage::Filesystems::Btrfs#add_btrfs_subvolumes def add_proposed_subvolumes - specs = Y2Storage::SubvolSpecification.from_control_file - specs = Y2Storage::SubvolSpecification.fallback_list if specs.nil? || specs.empty? - - filesystem.add_btrfs_subvolumes(specs) + spec = Y2Storage::VolumeSpecification.for(mount_point.path) + return unless spec && spec.subvolumes + filesystem.add_btrfs_subvolumes(spec.subvolumes) end # Updates subvolumes mount point @@ -679,6 +676,26 @@ def arch Y2Storage::StorageManager.instance.arch end + + # Determines whether a file system should be read-only by default + # + # @param path [String] Mount point path + # @return [Boolean] + def read_only?(path) + spec = Y2Storage::VolumeSpecification.for(path) + spec && spec.btrfs_read_only? + end + + # Adds special mount options for a given path + # + # @param path [String] Mount point path + # @param mount_options [Array<String>] Original set of options + # @return [Array<String>] Mount options including special ones + def add_special_mount_options_for(path, mount_options) + opt = filesystem.type.special_path_fstab_options(mount_options, path) + opt.push("ro") if read_only?(path) + opt + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/src/lib/y2partitioner/widgets/format_and_mount.rb new/yast2-storage-ng-4.0.132/src/lib/y2partitioner/widgets/format_and_mount.rb --- old/yast2-storage-ng-4.0.129/src/lib/y2partitioner/widgets/format_and_mount.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/src/lib/y2partitioner/widgets/format_and_mount.rb 2018-03-14 15:20:08.000000000 +0100 @@ -71,7 +71,6 @@ @encrypt_widget.enable @filesystem_widget.enable - @partition_id.disable else Yast::UI.ChangeWidget(Id(:no_format_device), :Value, true) @@ -79,7 +78,6 @@ # on the encryption value controller.filesystem ? @encrypt_widget.disable : @encrypt_widget.enable @filesystem_widget.disable - @partition_id.enable end end @@ -140,6 +138,7 @@ @partition_id ) ), + VSpacing(1), Left(@encrypt_widget) ) ) @@ -243,7 +242,8 @@ Left(RadioButton(Id(:dont_mount_device), Opt(:notify), _("Do not mount device"))) ) ), - HBox(Left(@btrfs_subvolumes_widget)) + VSpacing(1), + Left(@btrfs_subvolumes_widget) ) ) ) @@ -268,6 +268,12 @@ nil end + def validate + validate_system_mount_points && validate_mount_by_label + end + + private + # It is necessary to prevent an empty filesystem label when the option mount_by is set # to label by default. The label value is validated when the user gives one value # (by editing the fstab options), but the user could mount a device without entering @@ -278,7 +284,7 @@ # # @return [Boolean] true if the label is not required or it is required and given; false # otherwise. - def validate + def validate_mount_by_label return true if !formatted? || !mounted? || !mounted_by_label? || !empty_label? # TRANSLATORS: Error message when a device should be mounted by label but no label @@ -287,7 +293,51 @@ false end - private + # Check if a system mount point is reused without formatting the + # partition during installation and warn the user if it is. + # + # @return [Boolean] true if okay, false if not + def validate_system_mount_points + return true unless Yast::Mode.installation + return true if to_be_formatted? + return true unless mounted? + return true unless ["/", "/usr", "/boot"].include?(mount_path) + warn_unformatted_system_mount_points + end + + # Post a warning about reusing unformatted system mount points. + # + # @return [Boolean] true if the user wants to continue + def warn_unformatted_system_mount_points + log.info("warn_unformatted_system_mount_points") + # Translators: popup text + message = _( + "\n" \ + "You chose to install onto an existing partition that will not be\n" \ + "formatted. YaST cannot guarantee your installation will succeed,\n" \ + "particularly in any of the following cases:\n" + ) + + # continued popup text + _( + "- if this is an existing Btrfs partition\n" \ + "- if this partition already contains a Linux distribution that will be\n" \ + "overwritten\n" \ + "- if this partition does not yet contain a file system\n" + ) + + # continued popup text + _( + "If in doubt, better go back and mark this partition for\n" \ + "formatting, especially if it is assigned to one of the standard mount points\n" \ + "like /, /boot, /opt or /var.\n" + ) + + # continued popup text + _( + "If you decide to format the partition, all data on it will be lost.\n" \ + "\n" \ + "Really skip formatting the partition?\n" + ) + Yast::Popup.YesNo(message) + end def mount_device @mount_point_widget.enable @@ -324,6 +374,13 @@ [email protected]? end + # Whether the device will be formatted + # + # @return [Boolean] true if will be formatted; false otherwise + def to_be_formatted? + @controller.to_be_formatted? + end + # Whether the device has a mount point # # @return [Boolean] true if it has a mount point; false otherwise. @@ -732,7 +789,7 @@ # @macro seeAbstractWidget def contents if @selector - HBox(HSpacing(4), Left(@selector)) + VBox(VSpacing(1), Left(@selector)) else Empty() end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/src/lib/y2storage/planned/can_be_formatted.rb new/yast2-storage-ng-4.0.132/src/lib/y2storage/planned/can_be_formatted.rb --- old/yast2-storage-ng-4.0.129/src/lib/y2storage/planned/can_be_formatted.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/src/lib/y2storage/planned/can_be_formatted.rb 2018-03-14 15:20:08.000000000 +0100 @@ -27,6 +27,7 @@ module Planned # Mixin for planned devices that can have an associated block filesystem. # @see Planned::Device + # rubocop:disable Metrics/ModuleLength module CanBeFormatted # @return [Filesystems::Type] the type of filesystem this device should # get, like Filesystems::Type::BTRFS or Filesystems::Type::SWAP. A value of @@ -186,11 +187,24 @@ # @param mount_point [MountPoint] def setup_fstab_options(mount_point) return unless mount_point - if fstab_options - mount_point.mount_options = fstab_options - elsif filesystem_type - mount_point.mount_options = filesystem_type.default_fstab_options(mount_point.path) - end + options = fstab_options_for(mount_point) + mount_point.mount_options = options unless options.empty? + end + + # Returns fstab options for the given mount point + # + # @param mount_point [MountPoint] + def fstab_options_for(mount_point) + options = + if fstab_options + fstab_options + elsif filesystem_type + filesystem_type.default_fstab_options(mount_point.path) + else + [] + end + options.push("ro") if read_only && !options.include?("rw") + options end # Creates subvolumes in the previously created filesystem that is placed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/src/lib/y2storage/planned/can_be_mounted.rb new/yast2-storage-ng-4.0.132/src/lib/y2storage/planned/can_be_mounted.rb --- old/yast2-storage-ng-4.0.129/src/lib/y2storage/planned/can_be_mounted.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/src/lib/y2storage/planned/can_be_mounted.rb 2018-03-14 15:20:08.000000000 +0100 @@ -40,8 +40,12 @@ # @return [Array<String>] attr_accessor :fstab_options + # @return [Boolean] + attr_accessor :read_only + # Initializations of the mixin, to be called from the class constructor. def initialize_can_be_mounted + @read_only = false end # Whether the device will be mounted as root diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/src/lib/y2storage/proposal/autoinst_devices_planner.rb new/yast2-storage-ng-4.0.132/src/lib/y2storage/proposal/autoinst_devices_planner.rb --- old/yast2-storage-ng-4.0.129/src/lib/y2storage/proposal/autoinst_devices_planner.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/src/lib/y2storage/proposal/autoinst_devices_planner.rb 2018-03-14 15:20:08.000000000 +0100 @@ -27,6 +27,7 @@ require "y2storage/subvol_specification" require "y2storage/proposal_settings" require "y2storage/proposal/autoinst_size_parser" +require "y2storage/volume_specification" module Y2Storage module Proposal @@ -192,6 +193,7 @@ device.mount_by = section.type_for_mountby device.mkfs_options = section.mkfs_options device.fstab_options = section.fstab_options + device.read_only = read_only?(section.mount) end # Set device attributes related to snapshots @@ -456,10 +458,20 @@ # @param section [AutoinstProfile::PartitionSection] # @return [Filesystems::Type] Filesystem type def default_filesystem_for(section) - spec = VolumeSpecificationBuilder.new(proposal_settings).for(section.mount) + spec = VolumeSpecification.for(section.mount) return spec.fs_type if spec && spec.fs_type section.mount == "swap" ? Filesystems::Type::SWAP : Filesystems::Type::BTRFS end + + # Determine whether the filesystem for the given mount point should be read-only + # + # @param mount_point [String] Filesystem mount point + # @return [Boolean] true if it should be read-only; false otherwise. + def read_only?(mount_point) + return false unless mount_point + spec = VolumeSpecification.for(mount_point) + !!spec && spec.btrfs_read_only? + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/src/lib/y2storage/proposal/autoinst_size_parser.rb new/yast2-storage-ng-4.0.132/src/lib/y2storage/proposal/autoinst_size_parser.rb --- old/yast2-storage-ng-4.0.129/src/lib/y2storage/proposal/autoinst_size_parser.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/src/lib/y2storage/proposal/autoinst_size_parser.rb 2018-03-14 15:20:08.000000000 +0100 @@ -111,7 +111,7 @@ # @return [nil,Array<DiskSize>] def auto_sizes_for(mount_point) - spec = VolumeSpecificationBuilder.new(proposal_settings).for(mount_point) + spec = VolumeSpecification.for(mount_point, proposal_settings: proposal_settings) return nil if spec.nil? AutoinstSize.new( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/src/lib/y2storage/proposal/devices_planner_strategies/ng.rb new/yast2-storage-ng-4.0.132/src/lib/y2storage/proposal/devices_planner_strategies/ng.rb --- old/yast2-storage-ng-4.0.129/src/lib/y2storage/proposal/devices_planner_strategies/ng.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/src/lib/y2storage/proposal/devices_planner_strategies/ng.rb 2018-03-14 15:20:08.000000000 +0100 @@ -125,6 +125,7 @@ planned_device.default_subvolume = volume.btrfs_default_subvolume || "" planned_device.subvolumes = volume.subvolumes planned_device.snapshots = volume.snapshots + planned_device.read_only = volume.btrfs_read_only? adjust_btrfs_sizes(planned_device, volume) if planned_device.snapshots? end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/src/lib/y2storage/subvol_specification.rb new/yast2-storage-ng-4.0.132/src/lib/y2storage/subvol_specification.rb --- old/yast2-storage-ng-4.0.129/src/lib/y2storage/subvol_specification.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/src/lib/y2storage/subvol_specification.rb 2018-03-14 15:20:08.000000000 +0100 @@ -151,10 +151,13 @@ # @note The new subvolume is set as 'can be auto deleted'. # # @param filesystem [Filesystems::Btrfs] - # @return [BtrfsSubvolume] + # @return [BtrfsSubvolume,nil] New BtrfsSubvolume; nil if the subvolume could not + # be created. + # @see FileSystems::Btrfs#create_btrfs_subvolume def create_btrfs_subvolume(filesystem) subvolume_path = filesystem.btrfs_subvolume_path(path) subvolume = filesystem.create_btrfs_subvolume(subvolume_path, !copy_on_write) + return if subvolume.nil? subvolume.can_be_auto_deleted = true subvolume end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/src/lib/y2storage/volume_specification.rb new/yast2-storage-ng-4.0.132/src/lib/y2storage/volume_specification.rb --- old/yast2-storage-ng-4.0.129/src/lib/y2storage/volume_specification.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/src/lib/y2storage/volume_specification.rb 2018-03-14 15:20:08.000000000 +0100 @@ -22,6 +22,7 @@ require "yast" require "y2storage/partitioning_features" require "y2storage/subvol_specification" +require "y2storage/volume_specification" module Y2Storage # Helper class to represent a volume specification as defined in control.xml @@ -109,6 +110,9 @@ # @return [String] default btrfs subvolume path attr_accessor :btrfs_default_subvolume + # @return [Boolean] whether the volume should be mounted as read-only + attr_accessor :btrfs_read_only + # @return [Numeric] order to disable volumes if needed to make the initial proposal attr_accessor :disable_order @@ -118,6 +122,29 @@ alias_method :adjust_by_ram_configurable?, :adjust_by_ram_configurable alias_method :snapshots?, :snapshots alias_method :snapshots_configurable?, :snapshots_configurable + alias_method :btrfs_read_only?, :btrfs_read_only + + class << self + # Returns the volume specification for the given mount point + # + # This method keeps a cache of already calculated volume specifications. + # Call {.clear_cache} method in order to clear it. Beware that the cache + # does not take into account that different proposal settings are being + # used. + # + # @param mount_point [String] Volume's mount point + # @param proposal_settings [ProposalSettings] Proposal settings + # @return [VolumeSpecification,nil] Volume specification or nil if not found + def for(mount_point, proposal_settings: nil) + clear_cache unless @cache + @cache[mount_point] ||= VolumeSpecificationBuilder.new(proposal_settings).for(mount_point) + end + + # Clear volume specifications cache + def clear_cache + @cache = {} + end + end # Constructor # @param volume_features [Hash] features for a volume @@ -194,6 +221,7 @@ snapshots: :boolean, snapshots_configurable: :boolean, btrfs_default_subvolume: :string, + btrfs_read_only: :boolean, desired_size: :size, min_size: :size, max_size: :size, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/test/y2partitioner/actions/controllers/filesystem_test.rb new/yast2-storage-ng-4.0.132/test/y2partitioner/actions/controllers/filesystem_test.rb --- old/yast2-storage-ng-4.0.129/test/y2partitioner/actions/controllers/filesystem_test.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/test/y2partitioner/actions/controllers/filesystem_test.rb 2018-03-14 15:20:08.000000000 +0100 @@ -26,6 +26,9 @@ describe Y2Partitioner::Actions::Controllers::Filesystem do before do devicegraph_stub(scenario) + allow(Y2Storage::VolumeSpecification).to receive(:for).and_call_original + allow(Y2Storage::VolumeSpecification).to receive(:for).with("/") + .and_return(volume_spec) end let(:scenario) { "mixed_disks_btrfs" } @@ -38,6 +41,14 @@ let(:dev_name) { "/dev/sda2" } + let(:volume_spec) do + instance_double( + Y2Storage::VolumeSpecification, subvolumes: subvolumes, btrfs_read_only?: false + ) + end + + let(:subvolumes) { Y2Storage::SubvolSpecification.fallback_list } + describe "#blk_device" do it "returns a Y2Storage::BlkDevice" do expect(subject.blk_device).to be_a(Y2Storage::BlkDevice) @@ -601,35 +612,47 @@ end end - context "and the new mount point is root" do - let(:mount_path) { "/" } + describe "subvolumes handling" do + let(:mount_path) { "/foo" } + let(:subvolumes) { Y2Storage::SubvolSpecification.fallback_list } + let(:volume_spec) do + instance_double( + Y2Storage::VolumeSpecification, subvolumes: subvolumes, btrfs_read_only?: false + ) + end before do - # Make sure there is no other mount points - all_filesystems = Y2Storage::MountPoint.all(devicegraph).map(&:filesystem) - other_filesystems = all_filesystems - [filesystem] - other_filesystems.each(&:remove_descendants) + allow(Y2Storage::VolumeSpecification).to receive(:for).with(mount_path) + .and_return(volume_spec) end - it "adds the proposed subvolumes that do not exist" do - specs = Y2Storage::SubvolSpecification.fallback_list - arch_specs = Y2Storage::SubvolSpecification.for_current_arch(specs) - paths = arch_specs.map { |s| filesystem.btrfs_subvolume_path(s.path) } + context "and there are subvolumes defined for the given mount point" do + before do + # Make sure there is no other mount points + all_filesystems = Y2Storage::MountPoint.all(devicegraph).map(&:filesystem) + other_filesystems = all_filesystems - [filesystem] + other_filesystems.each(&:remove_descendants) + end + + it "adds the proposed subvolumes that do not exist" do + arch_specs = Y2Storage::SubvolSpecification.for_current_arch(subvolumes) + paths = arch_specs.map { |s| filesystem.btrfs_subvolume_path(s.path) } - subject.public_send(testing_method, mount_path, mount_point_options) + subject.public_send(testing_method, mount_path, mount_point_options) - expect(paths.any? { |p| filesystem.find_btrfs_subvolume_by_path(p).nil? }).to be(false) + expect(paths.any? { |p| filesystem.find_btrfs_subvolume_by_path(p).nil? }).to be(false) + end end - end - context "and the new mount point is not root" do - let(:mount_path) { "/foo" } + context "and there are no subvolumes defined for the given mount point" do + let(:subvolumes) { nil } - it "does not add new subvolumes" do - paths = filesystem.btrfs_subvolumes.map(&:path) - subject.public_send(testing_method, mount_path, mount_point_options) + it "does not add any subvolume" do + paths = filesystem.btrfs_subvolumes.map(&:path) + subject.public_send(testing_method, mount_path, mount_point_options) - expect(filesystem.btrfs_subvolumes.map(&:path) - paths).to be_empty + expect(filesystem.btrfs_subvolumes.map(&:path) - paths).to be_empty + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/test/y2storage/planned/can_be_formatted_test.rb new/yast2-storage-ng-4.0.132/test/y2storage/planned/can_be_formatted_test.rb --- old/yast2-storage-ng-4.0.129/test/y2storage/planned/can_be_formatted_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/test/y2storage/planned/can_be_formatted_test.rb 2018-03-14 15:20:08.000000000 +0100 @@ -0,0 +1,91 @@ +#!/usr/bin/env rspec +# encoding: utf-8 + +# Copyright (c) [2018] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "../spec_helper" +require "y2storage" + +describe Y2Storage::Planned::CanBeFormatted do + using Y2Storage::Refinements::SizeCasts + + # Dummy class to test the mixing + class FormattableDevice < Y2Storage::Planned::Device + include Y2Storage::Planned::CanBeMounted + include Y2Storage::Planned::CanBeFormatted + + def initialize + super + initialize_can_be_formatted + initialize_can_be_mounted + end + end + + subject(:planned) { FormattableDevice.new } + + describe "#format!" do + let(:filesystem_type) { Y2Storage::Filesystems::Type::BTRFS } + let(:blk_device) { Y2Storage::BlkDevice.find_by_name(fake_devicegraph, device_name) } + let(:device_name) { "/dev/sda2" } + let(:mount_point) { "/" } + + before do + fake_scenario("windows-linux-free-pc") + planned.filesystem_type = filesystem_type + planned.mount_point = mount_point + end + + it "creates a filesystem of the given type" do + planned.format!(blk_device) + expect(blk_device.filesystem.type).to eq(filesystem_type) + end + + context "when filesystem type is not defined" do + let(:filesystem_type) { nil } + + it "does not format the device" do + planned.format!(blk_device) + expect(blk_device.filesystem.type).to eq(Y2Storage::Filesystems::Type::SWAP) + end + end + + context "when filesystem is set as read-only" do + before do + planned.read_only = true + end + + it "sets the 'ro' option" do + planned.format!(blk_device) + expect(blk_device.filesystem.mount_options).to include("ro") + end + + context "but fstab options include the 'rw' flag" do + before do + planned.fstab_options = ["rw"] + end + + it "does not set the 'ro' option" do + planned.format!(blk_device) + expect(blk_device.filesystem.mount_options).to_not include("ro") + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/test/y2storage/proposal/autoinst_devices_planner_test.rb new/yast2-storage-ng-4.0.132/test/y2storage/proposal/autoinst_devices_planner_test.rb --- old/yast2-storage-ng-4.0.129/test/y2storage/proposal/autoinst_devices_planner_test.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/test/y2storage/proposal/autoinst_devices_planner_test.rb 2018-03-14 15:20:08.000000000 +0100 @@ -65,6 +65,7 @@ allow(Yast::Arch).to receive(:i386).and_return(architecture == :i386) allow(Yast::Arch).to receive(:ppc).and_return(architecture == :ppc) allow(Yast::Arch).to receive(:s390).and_return(architecture == :s390) + Y2Storage::VolumeSpecification.clear_cache end describe "#planned_devices" do @@ -506,6 +507,22 @@ expect(home.snapshots?).to eq false end end + + context "when root volume is supposed to be read-only" do + let(:root_volume_spec) do + instance_double(Y2Storage::VolumeSpecification, btrfs_read_only?: true) + end + + before do + allow(Y2Storage::VolumeSpecification).to receive(:for).and_return(nil) + allow(Y2Storage::VolumeSpecification).to receive(:for).with("/") + .and_return(root_volume_spec) + end + + it "sets root partition as read-only" do + expect(root.read_only).to eq(true) + end + end end context "using LVM" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/test/y2storage/proposal/autoinst_size_parser_test.rb new/yast2-storage-ng-4.0.132/test/y2storage/proposal/autoinst_size_parser_test.rb --- old/yast2-storage-ng-4.0.129/test/y2storage/proposal/autoinst_size_parser_test.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/test/y2storage/proposal/autoinst_size_parser_test.rb 2018-03-14 15:20:08.000000000 +0100 @@ -43,6 +43,10 @@ MIN = Y2Storage::DiskSize.parse("512MB").freeze MAX = Y2Storage::DiskSize.parse("2GB").freeze + before do + Y2Storage::VolumeSpecification.clear_cache + end + describe "#parse" do context "when size is empty" do it "sets min_value to the given minimal value" do @@ -81,7 +85,7 @@ let(:volumes) { [] } it "returns nil" do - expect(parser.parse("auto", "/", MIN, MAX)).to be_nil + expect(parser.parse("auto", "/srv", MIN, MAX)).to be_nil end context "and mount point is 'swap'" do @@ -97,7 +101,7 @@ let(:subvolumes) { [] } it "sets min and max values to nil" do - expect(parser.parse("auto", "/", MIN, MAX)).to be_nil + expect(parser.parse("auto", "/srv", MIN, MAX)).to be_nil end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/test/y2storage/proposal/devices_planner_strategies/ng_test.rb new/yast2-storage-ng-4.0.132/test/y2storage/proposal/devices_planner_strategies/ng_test.rb --- old/yast2-storage-ng-4.0.129/test/y2storage/proposal/devices_planner_strategies/ng_test.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/test/y2storage/proposal/devices_planner_strategies/ng_test.rb 2018-03-14 15:20:08.000000000 +0100 @@ -56,15 +56,16 @@ let(:volume) do { - "proposed" => proposed, - "mount_point" => mount_point, - "fs_type" => fs_type, - "desired_size" => desired_size.to_s, - "min_size" => min_size.to_s, - "max_size" => max_size.to_s, - "weight" => weight, - "max_size_lvm" => max_size_lvm.to_s, - "adjust_by_ram" => adjust_by_ram + "proposed" => proposed, + "mount_point" => mount_point, + "fs_type" => fs_type, + "desired_size" => desired_size.to_s, + "min_size" => min_size.to_s, + "max_size" => max_size.to_s, + "weight" => weight, + "max_size_lvm" => max_size_lvm.to_s, + "adjust_by_ram" => adjust_by_ram, + "btrfs_read_only" => btrfs_read_only } end @@ -88,6 +89,8 @@ let(:adjust_by_ram) { nil } + let(:btrfs_read_only) { false } + describe "#planned_devices" do let(:target) { :desired } @@ -639,6 +642,37 @@ end end end + + context "and the volume is set as read only" do + let(:volume_spec) { volume.merge("btrfs_read_only" => true) } + let(:volumes) { [volume_spec] } + + context "and it is a btrfs filesystem" do + let(:fs_type) { :btrfs } + + it "is set as read only" do + expect(planned_device.read_only).to eq(true) + end + end + + context "but it is not a btrfs filesystem" do + let(:fs_type) { :ext4 } + + it "is not set as read only" do + expect(planned_device.read_only).to eq(false) + end + end + end + + context "and the volume is not set as read only" do + let(:volume_spec) { volume.merge("btrfs_read_only" => false) } + let(:fs_type) { :btrfs } + let(:volumes) { [volume_spec] } + + it "is not set as read only" do + expect(planned_device.read_only).to eq(false) + end + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.0.129/test/y2storage/volume_specification_test.rb new/yast2-storage-ng-4.0.132/test/y2storage/volume_specification_test.rb --- old/yast2-storage-ng-4.0.129/test/y2storage/volume_specification_test.rb 2018-03-09 11:12:51.000000000 +0100 +++ new/yast2-storage-ng-4.0.132/test/y2storage/volume_specification_test.rb 2018-03-14 15:20:08.000000000 +0100 @@ -28,6 +28,52 @@ subject(:volume) { described_class.new(volume_features) } + describe ".for" do + let(:spec_builder) { instance_double(Y2Storage::VolumeSpecificationBuilder, for: volume_spec) } + let(:volume_spec) { instance_double(Y2Storage::VolumeSpecification) } + + before do + allow(Y2Storage::VolumeSpecificationBuilder).to receive(:new) + .and_return(spec_builder) + described_class.clear_cache + end + + it "returns the volume specification" do + expect(described_class.for("/")).to eq(volume_spec) + end + + context "when no specification is defined for the given mount point" do + let(:volume_spec) { nil } + + it "returns nil" do + expect(described_class.for("/")).to be_nil + end + end + + context "when a volume specification was already calculated" do + before do + described_class.for("/") + end + + it "retrieves the value from the internal cache" do + expect(Y2Storage::VolumeSpecificationBuilder).to_not receive(:new) + described_class.for("/") + end + end + end + + describe "#clear_cache" do + before do + described_class.for("/") + end + + it "clears the cache and forces to build the specification again when required" do + described_class.clear_cache + expect(Y2Storage::VolumeSpecificationBuilder).to receive(:new).and_call_original + described_class.for("/") + end + end + describe "#initialize" do let(:volume_features) do {
