calamares/src/modules/partition/README.md

91 lines
3.6 KiB
Markdown
Raw Normal View History

2014-08-08 13:40:09 +02:00
# Architecture
2014-08-08 16:56:33 +02:00
## Overview
The heart of the module is the PartitionCoreModule class. It holds Qt models for
the various elements and can create Calamares jobs representing the changes to
be performed at install time.
PartitionPage is the main UI class. It represents the module main page, the one
with the device combo box, partition list and action buttons. It reacts to the
buttons by creating various dialogs (the (...)Dialog classes) and tell
PartitionCoreModule what to do.
2016-01-13 17:38:48 +01:00
## Use of KPMcore
2014-08-08 16:56:33 +02:00
2016-01-13 17:38:48 +01:00
This module depends on KPMcore, the same library used by [KDE Partition Manager][kpm].
2014-08-08 16:56:33 +02:00
[kpm]: http://sourceforge.net/projects/partitionman/
2014-08-08 13:40:09 +02:00
## Partition and PartitionInfo
2014-08-08 16:56:33 +02:00
Calamares needs to store some information about partitions which is not
available in Partition Manager's Partition class.
This includes the install mount point and a boolean to mark whether an existing
partition should be formatted.
Reusing the existing `Partition::mountPoint` property was not an option because
it stores the directory where a partition is currently mounted, which is a
different concept from the directory where the user wants the partition to be
mounted on the installed system. We can't hijack this to store our install mount
point because whether the partition is currently mounted is an important
information which should be taken into account later to prevent any modification
on an installed partition.
The way this extra information is stored is a bit unusual: the functions in the
PartitionInfo namespace takes advantage of Qt dynamic properties methods to add
Calamares-specific properties to the Partition instances: setting the install
mount point is done with `PartitionInfo::setMountPoint(partition, "/")`,
retrieving it is done with `mountPoint = PartitionInfo::mountPoint(partition)`.
The rational behind this unusual design is simplicity: the alternative would
have been to keep a separate PartitionInfo object and a map linking each
Partition to its PartitionInfo instance. Such a design makes things more
complicated. It complicates memory management: if a Partition goes away, its
matching PartitionInfo must be removed. It also leads to uglier APIs: code which
needs access to extra partition information must be passed both Partition and
PartitionInfo instances or know a way to get a PartitionInfo from a Partition.
The other alternative would have been to add Calamares-specific information to
the real Partition object. This would have worked and would have made for a less
2016-01-13 17:38:48 +01:00
surprising API, but it would mean more Calamares-specific patches on KPMcore.
2014-08-08 16:56:33 +02:00
2014-08-08 13:40:09 +02:00
# Tests
The module comes with unit tests for the partition jobs. Those tests need to
2014-08-08 16:56:33 +02:00
run on storage device which does not contain any data you care about.
2014-08-08 13:40:09 +02:00
To build them:
2017-06-20 16:03:44 +02:00
cd $top_build_dir
2014-08-08 13:40:09 +02:00
make buildtests
To run them you need to define the `CALAMARES_TEST_DISK` environment variable.
It should contain the device path to the test disk. For example, assuming you
plugged a test USB stick identified as `/dev/sdb`, you would run the tests like
this:
2017-06-20 16:03:44 +02:00
sudo CALAMARES_TEST_DISK=/dev/sdb $top_build_dir/partitionjobtests
2014-08-08 13:40:09 +02:00
2014-08-08 16:56:33 +02:00
2014-08-08 13:40:09 +02:00
# TODO
2014-08-08 16:56:33 +02:00
- Support resizing extended partitions. ResizePartitionJob should already
support this but the UI prevents editing of extended partitions for now.
2014-08-09 11:51:29 +02:00
- Use os-prober to find out the installed OS. This information could then be
used in PartitionModel and in the partition views.
- PartitionBarsView
2014-08-08 13:40:09 +02:00
- Show used space
- Highlight selected partition
- Make the partitions clickable
2014-08-09 11:51:29 +02:00
- Match appearance with PartResizerWidget appearance
2014-08-08 13:40:09 +02:00
2014-08-08 16:56:33 +02:00
- Expose PartitionInfo::format in PartitionModel and add a column for it in the
tree view