54 Commits (f03ae06deb42c593a0fa9ad524305e28d55e0d31)

Author SHA1 Message Date
Gaël PORTAY f03ae06deb [partition] Rename execute to createPartitions 4 years ago
Gaël PORTAY 2007335865 [partition] Rename the KPMCore Partition local to part 4 years ago
Gaël PORTAY 32c1f81fbf [partition] Rename iterator in for loop to entry 4 years ago
Gaël PORTAY 3016b93c8f [partition] Simplify the method execute
- Rename the "size" locals using "sectors" in their name. Size may be
  confusing or not enough specific as it can be interpreted a size in
  Byte.
    partSizeMap -> partSectorsMap,
    totalSize -> totalSectors,
    availablesize -> availableSectors,
    size -> sectors,
    minSize -> minSectors
    maxSize -> maxSectors
- Create a the new local currentSector to iterate over the sectors;
  instead of using the parameter firstSector.
- Remove the variable end that does not help much; too many variable
  already. Expand its expression instead.
4 years ago
Gaël PORTAY 81bec68b3d [partition] Introduce new constructors for PartitionEntry
- Introduces new constructors for PartitionEntry: copy constructory and
  constructor with all attributes.
- Use the new constructor in method addEntry().
4 years ago
Gaël PORTAY 3f2dd516d3 [partition] Simplify the retrieval of the size attributes
- The variant helper toString() takes a default value since commit
  c9f942ad6 ([libcalamares] Add default value to variant helpers).
- Set the default value to 0 and simplify the retreival of size values
  by calling the helper toString() and removing the temporary variables.
4 years ago
Gaël PORTAY db7cf74034 [partition] Remove the call the method contains
- The variant helper getString() calls contains() already.
4 years ago
Gaël PORTAY d6ea30b23e [partition] Move initLayout logic to object PartitionLayout
- The logic of the method initLayout belongs to the object
  PartitionLayout. Move logic to that object.
- Use a single method initLayout in object PartitionCoreModule.
- Member m_partLayout in object PartitionCoreModule is no longer
  allocated.
4 years ago
Gaël PORTAY eae1e90dce [partition] Remove unused PartitionLayout constructor
- The constructor PartitionLayout with PartitionEntry appears to be
  unused since its always. Drop it!
4 years ago
Gaël PORTAY f2960366c8 [partition] Remove unused addEntry method
- The method addEntry with PartitionEntry appears to be unused since its
  always. Drop it!
4 years ago
Adriaan de Groot 9910b23152 [partition] Avoid uninitialized variable
- if the partition size is invalid, then warn about it but do
  not print the (uninitialized) size of the partition.
- shuffle code to continue earlier, allowing the "good path"
  code to be out-dented.
5 years ago
Adriaan de Groot 687a795b71 [partition] Warnings-- by initialization order 5 years ago
Adriaan de Groot 44a11bd93b [partition] Initialize in the initializer list, if possible 5 years ago
Adriaan de Groot 77e2701365 [partition] Coding style
- various clang-format versions battle for supremacy
5 years ago
Adriaan de Groot b4cbf73e2d Merge branch 'calamares' into issues-1166 5 years ago
Corentin Noël 0293015b09 [partition] Fix regression in partition size assignment
In some cases, the partition size was set to zero as the maxSize isn't always defined.
5 years ago
Adriaan de Groot 010526ee2a [partition] Coding style 5 years ago
Corentin Noël 75fd1dd114 [partition] Correctly handle percentage-define partitions
* Use the minSize when the target storage is smaller than the sum of sizes
 * Percentage-defined partitions should be computed after setting hard-defined ones

This fixes issues when 0 byte partitions were created when the disk is too small.
Also fixes an issue with percent-defined partitions being forced to be defined at the end of the disk.
5 years ago
Adriaan de Groot 1cd9b93a22 REUSE: Giant boilerplate cleanup
- point to main Calamares site in the 'part of' headers instead
  of to github (this is the "this file is part of Calamares"
  opening line for most files).
- remove boilerplate from all source files, CMake modules and completions,
  this is the 3-paragraph summary of the GPL-3.0-or-later, which has
  a meaning entirely covered by the SPDX tag.
5 years ago
Adriaan de Groot 30a85668b7 REUSE: (GPL-3.0-or-later) C++ modules 5 years ago
Gaël PORTAY 4974d86932 [partition] Fix missing initialization of the attribute partAttributes
- Initialize the attribute partAttributes to 0; it is a primitive type
  and it is not initialized in some constructors.
  Fixes commit c1b5426c6 ([partition] Add support for partition attributes).
- Move implementation of default constructor to cpp.
5 years ago
Adriaan de Groot e3b8570d61 Merge remote-tracking branch 'origin/master' into calamares
Pick up some older MRs that apply to the older branch.
5 years ago
Gaël PORTAY c1b5426c66 [partition] Add support for partition attributes 5 years ago
Gaël PORTAY da6f728cd4 [partition] Add support for partition uuid 5 years ago
Adriaan de Groot 8b41a71668 [partition] Apply coding style to core/ 5 years ago
Adriaan de Groot 1718f7a8a8
Merge branch 'master' into partition-type 5 years ago
Adriaan de Groot 377a78a405
Merge pull request #1347 from gportay/partition-name
[partition] Name partition using filesystem label
5 years ago
Gaël PORTAY 15cce29a51 [partition] Add support for filesystem-specific features 5 years ago
Gaël PORTAY c5ebe13aeb [partition] Add support for partition type 5 years ago
Gaël PORTAY cba4d2e93b [partition] Name partition using filesystem label 5 years ago
Adriaan de Groot 7f295d9565 [partition] Apply coding style to core/ subdir
Because this is a giant code change, with no functional effect,
I've been saving this until the end of the kpmcore-manager branch.
5 years ago
Adriaan de Groot 34ffc7a20a [libcalamares] Consistent namespace usage in partition service
- The sub-directories under libcalamares (e.g. Utils, ..)
   all live in namespace CalamaresUtils (well, except for Logger).
   The services (e.g. subdirs other than utils/) live in their
   own nested namespace, so partitioning should go into
   CalamaresUtils::Partition for consistency.
6 years ago
Adriaan de Groot fd4bc4bb17 [partition] Avoid UB by initializing size everywhere 6 years ago
Arnaud Ferraris 80fd3d3353 [partition] Switch to using the generic PartitionSize class
Instead of relying on a module-specific implementation, use the new
PartitionSize class for storing partition sizes.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Arnaud Ferraris 123222c0a8 Add global checks for partition layout
This commit adds several checks while reading the configuration of the
`partition` module, in case the partition layout configuration is
misformed. If an error is encountered, an message is printed to the
console and the module reverts to the default partition layout.

Checks are also added when implementing the partition layout, in case a
problem occurs that couldn't be anticipated (for example, when a
partition size is in %, checking its absolute value require knowing the
total device size, which is not the case when the configuration is
being read).

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Arnaud Ferraris d32733bf59 Switch to using PartSize class for partition sizes
Every call of `ParseStringSize` is replaced by using an instance of the
`PartUtils::PartSize` class.

This commit also removes the now-unused previous size parsing functions.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Adriaan de Groot d2404851cd [partition] Reduce warnings (shadow, ;, types) 6 years ago
Adriaan de Groot 547dc7d334
Merge pull request #1117 from a-wai/partition-layout-add-maxsize
[partition] Add max size parameter
6 years ago
Arnaud Ferraris 5358e2314d [partition] Add max size parameter
When using a custom partition layout with partition sizes in %, it can
be useful to set an upper limit to the partition size.

For instance, using a 20% size for the `/` partition will create a 24G
partition on a 120GB drive, but a 200GB partition on a 1TB drive, which
is not useful, and could be avoided by setting a maximum partition size.

This commit adds the `maxSize` parameter (with a default value of 100%).

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Adriaan de Groot 2a2795c54c [partition] Avoid KPMCore warnings
- Get ready for KPMCore post-3.3.0, which deprecates a bunch of
   Flag<foo> and State<foo> in preparation of enum classes.
6 years ago
Arnaud Ferraris a5258f07a1 [partition] move bytesToSectors() and sizeToSectors() to PartUtils
In order to allow the use of these functions across the whole partition
module and keep all partition size-related functions in the same
namespace, this commit moves them to PartUtils.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Arnaud Ferraris 90eb6afd52 [partition] move parseSizeString() function to PartUtils
In order to be able to parse partition size strings using the same
functions across the partition module, the parseSizeString() function is
exported to the PartUtils namespace.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Arnaud Ferraris 74ead4c7ba [partition] improve filesystem search operation
Due to changes to the FileSsytem::typeForName() function, more
processing is needed to deal with locales and different cases.
This is done by refactoring the findFS() function, initially located in
the PartitionViewStep class, and making it available to the whole module.

Additionnally, more checks have been implemented regarding the use of
global storage in the PartitionLayout class, and the filesystem types
now use the correct FileSystem::Type, as requested.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Arnaud Ferraris 5084c44b54 [partition] fix naming of PartitionLayout class member variables
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Arnaud Ferraris 586cb63ef5 [partition] use configured default filesystem type instead of ext4
When using the default partition layout (only a `/` partition), the
filesystem used was ext4, ignoring the `defaultFileSystemType`
configuration option.

This commit fixes this bug, so that any supported filesystem can now be
used for the default partitioning scheme.

Fixes #1093

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Adriaan de Groot a6edb3ed34 [partition] Refactor PartitionEntry
- add a constructor that parses size and min
 - minor reduction in code duplication
6 years ago
Adriaan de Groot 5863300f67 [partition] Use const QString&
- minor code-layout and idiomatic-C++
6 years ago
Arnaud Ferraris cf45d55b32 [partition] Fix parsing of partition size in partition layout
When setting the size of a partition without indicating the unit, two
problems occur:

- the size is parsed as an integer, not as a string, hence the
configuration parsing fails
- the size parser doesn't recognize the fact that the size has no units
and defaults to 100%

This patch fixes the configuration parsing as well as the size string
parsing.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Arnaud Ferraris 18bb71aceb [partition] Fix minimum size parsing in partition layout
When a partition doesn't have a minimum size in the partition layout
configuration, it defaults to using 100% of the available space.

This patch fixes this error by setting the minimum partition size to 0
when the attribute has been omitted.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago
Arnaud Ferraris 921f70d3bb [partition] Fix size and last sector computation
Due to a computation error when calculating the total drive space and
each partition's last sector, the last partition's last sector was out
of boundaries, leading to an error creating this partition.

This patch fixes the computation algorithm to get rid of this error.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
6 years ago