source: calamares/trunk/fuentes/src/modules/partition/README.md @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 3.6 KB
Line 
1# Architecture
2
3## Overview
4
5The heart of the module is the PartitionCoreModule class. It holds Qt models for
6the various elements and can create Calamares jobs representing the changes to
7be performed at install time.
8
9PartitionPage is the main UI class. It represents the module main page, the one
10with the device combo box, partition list and action buttons. It reacts to the
11buttons by creating various dialogs (the (...)Dialog classes) and tell
12PartitionCoreModule what to do.
13
14
15## Use of KPMcore
16
17This module depends on KPMcore, the same library used by [KDE Partition Manager][kpm].
18
19[kpm]: http://sourceforge.net/projects/partitionman/
20
21
22## Partition and PartitionInfo
23
24Calamares needs to store some information about partitions which is not
25available in Partition Manager's Partition class.
26
27This includes the install mount point and a boolean to mark whether an existing
28partition should be formatted.
29
30Reusing the existing `Partition::mountPoint` property was not an option because
31it stores the directory where a partition is currently mounted, which is a
32different concept from the directory where the user wants the partition to be
33mounted on the installed system. We can't hijack this to store our install mount
34point because whether the partition is currently mounted is an important
35information which should be taken into account later to prevent any modification
36on an installed partition.
37
38The way this extra information is stored is a bit unusual: the functions in the
39PartitionInfo namespace takes advantage of Qt dynamic properties methods to add
40Calamares-specific properties to the Partition instances: setting the install
41mount point is done with `PartitionInfo::setMountPoint(partition, "/")`,
42retrieving it is done with `mountPoint = PartitionInfo::mountPoint(partition)`.
43
44The rational behind this unusual design is simplicity: the alternative would
45have been to keep a separate PartitionInfo object and a map linking each
46Partition to its PartitionInfo instance. Such a design makes things more
47complicated. It complicates memory management: if a Partition goes away, its
48matching PartitionInfo must be removed. It also leads to uglier APIs: code which
49needs access to extra partition information must be passed both Partition and
50PartitionInfo instances or know a way to get a PartitionInfo from a Partition.
51
52The other alternative would have been to add Calamares-specific information to
53the real Partition object. This would have worked and would have made for a less
54surprising API, but it would mean more Calamares-specific patches on KPMcore.
55
56
57# Tests
58
59The module comes with unit tests for the partition jobs. Those tests need to
60run on storage device which does not contain any data you care about.
61
62To build them:
63
64    cd $top_build_dir
65    make buildtests
66
67To run them you need to define the `CALAMARES_TEST_DISK` environment variable.
68It should contain the device path to the test disk. For example, assuming you
69plugged a test USB stick identified as `/dev/sdb`, you would run the tests like
70this:
71
72    sudo CALAMARES_TEST_DISK=/dev/sdb $top_build_dir/partitionjobtests
73
74
75# TODO
76
77- Support resizing extended partitions. ResizePartitionJob should already
78  support this but the UI prevents editing of extended partitions for now.
79
80- Use os-prober to find out the installed OS. This information could then be
81  used in PartitionModel and in the partition views.
82
83- PartitionBarsView
84    - Show used space
85    - Highlight selected partition
86    - Make the partitions clickable
87    - Match appearance with PartResizerWidget appearance
88
89- Expose PartitionInfo::format in PartitionModel and add a column for it in the
90  tree view
Note: See TracBrowser for help on using the repository browser.