Merge ~seb128/ubiquity:remove-zfs-option into ubiquity:master

Proposed by Sebastien Bacher
Status: Rejected
Rejected by: Sebastien Bacher
Proposed branch: ~seb128/ubiquity:remove-zfs-option
Merge into: ubiquity:master
Diff against target: 1376 lines (+97/-1055)
8 files modified
debian/ubiquity.templates (+0/-61)
dev/null (+0/-625)
gui/gtk/stepPartAsk.ui (+82/-208)
gui/gtk/ubiquity.ui (+0/-1)
scripts/plugininstall.py (+0/-9)
tests/test_gtkui.py (+0/-3)
ubiquity/frontend/gtk_ui.py (+0/-11)
ubiquity/plugins/ubi-partman.py (+15/-137)
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement Pending
Ubuntu Installer Team Pending
Review via email: mp+417752@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

closing for now, seems we want to consider the change a bit more before pushing forward

Unmerged commits

9f08a3f... by Sebastien Bacher

Remove the experimental zfs option

Due to priority changes zsys hasn't gotten much work over the recent cycles
and we that's not an option we want to advertise for the incoming LTS

And go back to the old layout listing directly the lvm and encryption
checkboxes on the mainpage instead of in a separate dialog.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/ubiquity.templates b/debian/ubiquity.templates
index 16ee032..ec9423d 100644
--- a/debian/ubiquity.templates
+++ b/debian/ubiquity.templates
@@ -1473,58 +1473,6 @@ Type: text
1473_Description:1473_Description:
1474 This will set up Logical Volume Management. It allows taking snapshots and easier partition resizing.1474 This will set up Logical Volume Management. It allows taking snapshots and easier partition resizing.
14751475
1476Template: ubiquity/text/use_zfs
1477Type: text
1478_Description:
1479 Erase disk and use ZFS
1480
1481Template: ubiquity/text/use_zfs_desc
1482Type: text
1483_Description:
1484 <span foreground="darkred">Warning:</span> This will delete all your files on all operating systems.
1485
1486Template: ubiquity/use_zfs
1487Type: boolean
1488Default: false
1489Description: for internal use; can be preseeded
1490 This will set up ZFS and configure it for zsys.
1491
1492Template: ubiquity/text/advanced_features_dialog
1493Type: text
1494_Description: Advanced Features
1495
1496Template: ubiquity/text/advanced_features_radio_none
1497Type: text
1498_Description: None
1499
1500Template: ubiquity/text/advanced_features_desc
1501Type: text
1502_Description: None selected
1503
1504Template: ubiquity/text/advanced_features_selected
1505Type: text
1506_Description: Advanced features...
1507
1508Template: ubiquity/text/advanced_features_none_selected
1509Type: text
1510_Description: None selected
1511
1512Template: ubiquity/text/advanced_features_lvm_selected
1513Type: text
1514_Description: LVM selected
1515
1516Template: ubiquity/text/advanced_features_lvm_crypto_selected
1517Type: text
1518_Description: LVM and encryption selected
1519
1520Template: ubiquity/text/advanced_features_zfs_selected
1521Type: text
1522_Description: ZFS selected
1523
1524Template: ubiquity/text/advanced_features_zfs_crypto_selected
1525Type: text
1526_Description: ZFS and encryption selected
1527
1528Template: ubiquity/text/verified_crypto_label1476Template: ubiquity/text/verified_crypto_label
1529Type: text1477Type: text
1530_Description:1478_Description:
@@ -1642,15 +1590,6 @@ Template: ubiquity/secureboot_key
1642Type: password1590Type: password
1643_Description: SecureBoot key for MokPW1591_Description: SecureBoot key for MokPW
16441592
1645Template: ubiquity/text/partman_confirm_zfs
1646Type: text
1647_Description:
1648 partition #%(partid)s as %(parttype)s used for %(partusage)s
1649
1650Template: ubiquity/zfs_keystore_key
1651Type: password
1652_Description: Key to secure the keystore on ZFS installations
1653
1654Template: ubiquity/login_use_directory1593Template: ubiquity/login_use_directory
1655Type: text1594Type: text
1656_Description: Authenticate against a directory1595_Description: Authenticate against a directory
diff --git a/gui/gtk/stepPartAsk.ui b/gui/gtk/stepPartAsk.ui
index 8159d06..93a405e 100644
--- a/gui/gtk/stepPartAsk.ui
+++ b/gui/gtk/stepPartAsk.ui
@@ -1,168 +1,6 @@
1<?xml version="1.0" encoding="UTF-8"?>1<?xml version="1.0" encoding="UTF-8"?>
2<interface>2<interface>
3 <!-- interface-requires gtk+ 3.0 -->3 <!-- interface-requires gtk+ 3.0 -->
4 <object class="GtkDialog" id="advanced_features_dialog">
5 <property name="can_focus">False</property>
6 <property name="title" translatable="yes">Advanced Features</property>
7 <property name="resizable">False</property>
8 <property name="modal">True</property>
9 <property name="window_position">center-on-parent</property>
10 <property name="type_hint">dialog</property>
11 <child internal-child="vbox">
12 <object class="GtkBox" id="advanced_features_box1">
13 <property name="can_focus">False</property>
14 <property name="orientation">vertical</property>
15 <property name="spacing">24</property>
16 <child internal-child="action_area">
17 <object class="GtkButtonBox" id="advanced_features_buttonbox">
18 <property name="can_focus">False</property>
19 <property name="layout_style">end</property>
20 <child>
21 <object class="GtkButton" id="advanced_features_cancelbutton">
22 <property name="label">_Cancel</property>
23 <property name="use_action_appearance">False</property>
24 <property name="visible">True</property>
25 <property name="can_focus">True</property>
26 <property name="can_default">True</property>
27 <property name="receives_default">True</property>
28 <property name="use_underline">True</property>
29 </object>
30 <packing>
31 <property name="expand">False</property>
32 <property name="fill">False</property>
33 <property name="position">0</property>
34 </packing>
35 </child>
36 <child>
37 <object class="GtkButton" id="advanced_features_okbutton">
38 <property name="label">_OK</property>
39 <property name="use_action_appearance">False</property>
40 <property name="visible">True</property>
41 <property name="can_focus">True</property>
42 <property name="can_default">True</property>
43 <property name="has_default">True</property>
44 <property name="receives_default">True</property>
45 <property name="use_underline">True</property>
46 </object>
47 <packing>
48 <property name="expand">False</property>
49 <property name="fill">False</property>
50 <property name="position">1</property>
51 </packing>
52 </child>
53 </object>
54 <packing>
55 <property name="expand">False</property>
56 <property name="fill">False</property>
57 <property name="position">0</property>
58 </packing>
59 </child>
60 <child>
61 <object class="GtkBox" id="advanced_features_box2">
62 <property name="visible">True</property>
63 <property name="can_focus">False</property>
64 <property name="orientation">vertical</property>
65 <child>
66 <object class="GtkRadioButton" id="advanced_features_radio_none">
67 <property name="label" translatable="yes">None</property>
68 <property name="visible">True</property>
69 <property name="can_focus">True</property>
70 <property name="receives_default">True</property>
71 <property name="active">True</property>
72 <property name="draw_indicator">True</property>
73 <property name="margin_top">9</property>
74 <signal name="clicked" handler="advanced_features_option_changed" swapped="no"/>
75 </object>
76 <packing>
77 <property name="expand">False</property>
78 <property name="fill">True</property>
79 <property name="position">0</property>
80 </packing>
81 </child>
82 <child>
83 <object class="GtkRadioButton" id="use_lvm">
84 <property name="label" translatable="yes">Set up the system as an LVM volume group</property>
85 <property name="visible">True</property>
86 <property name="can_focus">True</property>
87 <property name="receives_default">False</property>
88 <property name="active">True</property>
89 <property name="draw_indicator">True</property>
90 <property name="margin_top">9</property>
91 <property name="group">advanced_features_radio_none</property>
92 <signal name="clicked" handler="advanced_features_option_changed" swapped="no"/>
93 </object>
94 <packing>
95 <property name="expand">False</property>
96 <property name="fill">True</property>
97 <property name="position">1</property>
98 </packing>
99 </child>
100 <child>
101 <object class="GtkRadioButton" id="use_zfs">
102 <property name="label" translatable="yes">Use ZFS</property>
103 <property name="visible">True</property>
104 <property name="can_focus">True</property>
105 <property name="receives_default">False</property>
106 <property name="active">True</property>
107 <property name="draw_indicator">True</property>
108 <property name="margin_top">9</property>
109 <property name="group">advanced_features_radio_none</property>
110 <signal name="clicked" handler="advanced_features_option_changed" swapped="no"/>
111 </object>
112 <packing>
113 <property name="expand">False</property>
114 <property name="fill">True</property>
115 <property name="position">2</property>
116 </packing>
117 </child>
118 <child>
119 <object class="GtkCheckButton" id="use_crypto">
120 <property name="label" translatable="yes">Encrypt the volume group for security</property>
121 <property name="visible">True</property>
122 <property name="sensitive">False</property>
123 <property name="can_focus">True</property>
124 <property name="receives_default">False</property>
125 <property name="margin_top">9</property>
126 <property name="draw_indicator">True</property>
127 </object>
128 <packing>
129 <property name="expand">False</property>
130 <property name="fill">True</property>
131 <property name="position">3</property>
132 </packing>
133 </child>
134 <child>
135 <object class="GtkLabel" id="use_crypto_desc">
136 <property name="visible">True</property>
137 <property name="sensitive">False</property>
138 <property name="can_focus">False</property>
139 <property name="xalign">0</property>
140 <property name="yalign">0</property>
141 <property name="use_markup">True</property>
142 <property name="wrap">True</property>
143 <property name="label" translatable="yes">&lt;span size="small"&gt;You'll choose a security key in the next step&lt;/span&gt;</property>
144 </object>
145 <packing>
146 <property name="expand">False</property>
147 <property name="fill">True</property>
148 <property name="position">4</property>
149 </packing>
150 </child>
151 </object>
152 <packing>
153 <property name="expand">False</property>
154 <property name="fill">True</property>
155 <property name="position">1</property>
156 </packing>
157 </child>
158 </object>
159 </child>
160 <action-widgets>
161 <action-widget response="-6">advanced_features_cancelbutton</action-widget>
162 <action-widget response="-5">advanced_features_okbutton</action-widget>
163 </action-widgets>
164 </object>
165
166 <object class="GtkAlignment" id="stepPartAsk">4 <object class="GtkAlignment" id="stepPartAsk">
167 <property name="visible">True</property>5 <property name="visible">True</property>
168 <property name="can_focus">False</property>6 <property name="can_focus">False</property>
@@ -347,63 +185,99 @@
347 <property name="height">1</property>185 <property name="height">1</property>
348 </packing>186 </packing>
349 </child>187 </child>
350
351 <child>188 <child>
352 <object class="GtkBox" id="gtkbox1">189 <object class="GtkLabel" id="use_crypto_desc">
353 <property name="visible">True</property>190 <property name="visible">True</property>
354 <property name="can_focus">False</property>191 <property name="can_focus">False</property>
192 <property name="margin_left">24</property>
193 <property name="xalign">0</property>
194 <property name="yalign">0</property>
195 <property name="label" translatable="yes">&lt;span size="small"&gt;You’ll choose a security key in the next step.&lt;/span&gt;</property>
196 <property name="use_markup">True</property>
197 <property name="wrap">True</property>
198 </object>
199 <packing>
200 <property name="left_attach">0</property>
201 <property name="top_attach">9</property>
202 <property name="width">1</property>
203 <property name="height">1</property>
204 </packing>
205 </child>
206 <child>
207 <object class="GtkCheckButton" id="use_crypto">
208 <property name="label" translatable="yes">Encrypt the new Ubuntu installation for security</property>
209 <property name="visible">True</property>
210 <property name="can_focus">True</property>
211 <property name="receives_default">False</property>
212 <property name="margin_top">21</property>
213 <property name="xalign">0</property>
214 <property name="draw_indicator">True</property>
215 <signal name="clicked" handler="on_crypto_lvm_toggled" swapped="no"/>
216 </object>
217 <packing>
218 <property name="left_attach">0</property>
219 <property name="top_attach">8</property>
220 <property name="width">1</property>
221 <property name="height">1</property>
222 </packing>
223 </child>
224 <child>
225 <object class="GtkLabel" id="use_lvm_desc">
226 <property name="visible">True</property>
227 <property name="can_focus">False</property>
228 <property name="margin_left">24</property>
229 <property name="xalign">0</property>
230 <property name="yalign">0</property>
231 <property name="label" translatable="yes">&lt;span size="small"&gt;This will set up Logical Volume Management. It allows taking snapshots and easier partition resizing.&lt;/span&gt;</property>
232 <property name="use_markup">True</property>
233 <property name="wrap">True</property>
234 </object>
235 <packing>
236 <property name="left_attach">0</property>
237 <property name="top_attach">11</property>
238 <property name="width">1</property>
239 <property name="height">1</property>
240 </packing>
241 </child>
242 <child>
243 <object class="GtkCheckButton" id="use_lvm">
244 <property name="label" translatable="yes">Use LVM with the new Ubuntu installation</property>
245 <property name="visible">True</property>
246 <property name="can_focus">True</property>
247 <property name="receives_default">False</property>
248 <property name="margin_top">9</property>
249 <property name="xalign">0</property>
250 <property name="draw_indicator">True</property>
251 <signal name="clicked" handler="on_crypto_lvm_toggled" swapped="no"/>
252 </object>
253 <packing>
254 <property name="left_attach">0</property>
255 <property name="top_attach">10</property>
256 <property name="width">1</property>
257 <property name="height">1</property>
258 </packing>
259 </child>
260 <child>
261 <object class="GtkAlignment" id="alignment2">
262 <property name="visible">True</property>
263 <property name="can_focus">False</property>
264 <property name="margin_top">15</property>
265 <property name="left_padding">25</property>
266 <property name="right_padding">25</property>
355 <child>267 <child>
356 <object class="GtkButton" id="advanced_features_button">268 <object class="GtkHSeparator" id="hseparator1">
357 <property name="visible">True</property>
358 <property name="can_focus">True</property>
359 <property name="margin_left">24</property>
360 <property name="receives_default">False</property>
361 <property name="xalign">0</property>
362 <signal name="clicked" handler="on_advanced_features_clicked" swapped="no"/>
363 <child>
364 <object class="GtkLabel" id="advanced_features_selected">
365 <property name="visible">True</property>
366 <property name="can_focus">False</property>
367 <property name="label" translatable="yes">Advanced features...</property>
368 <property name="use_markup">True</property>
369 </object>
370 </child>
371 </object>
372 <packing>
373 <property name="expand">False</property>
374 <property name="fill">True</property>
375 <property name="position">1</property>
376 <property name="left_attach">0</property>
377 <property name="width">1</property>
378 <property name="height">1</property>
379 </packing>
380 </child>
381 <child>
382 <object class="GtkLabel" id="advanced_features_desc">
383 <property name="visible">True</property>269 <property name="visible">True</property>
384 <property name="can_focus">False</property>270 <property name="can_focus">False</property>
385 <property name="label" translatable="yes">None selected</property>
386 <property name="margin_left">9</property>
387 </object>271 </object>
388 <packing>
389 <property name="expand">False</property>
390 <property name="fill">True</property>
391 <property name="position">1</property>
392 <property name="width">1</property>
393 <property name="height">1</property>
394 </packing>
395 </child>272 </child>
396 </object>273 </object>
397 <packing>274 <packing>
398 <property name="expand">False</property>
399 <property name="fill">True</property>
400 <property name="position">2</property>
401 <property name="left_attach">0</property>275 <property name="left_attach">0</property>
402 <property name="top_attach">8</property>276 <property name="top_attach">12</property>
403277 <property name="width">1</property>
278 <property name="height">1</property>
404 </packing>279 </packing>
405 </child>280 </child>
406
407 <child>281 <child>
408 <object class="GtkLabel" id="custom_partitioning_desc">282 <object class="GtkLabel" id="custom_partitioning_desc">
409 <property name="visible">True</property>283 <property name="visible">True</property>
@@ -417,7 +291,7 @@
417 </object>291 </object>
418 <packing>292 <packing>
419 <property name="left_attach">0</property>293 <property name="left_attach">0</property>
420 <property name="top_attach">10</property>294 <property name="top_attach">14</property>
421 <property name="width">1</property>295 <property name="width">1</property>
422 <property name="height">1</property>296 <property name="height">1</property>
423 </packing>297 </packing>
@@ -437,7 +311,7 @@
437 </object>311 </object>
438 <packing>312 <packing>
439 <property name="left_attach">0</property>313 <property name="left_attach">0</property>
440 <property name="top_attach">9</property>314 <property name="top_attach">13</property>
441 <property name="width">1</property>315 <property name="width">1</property>
442 <property name="height">1</property>316 <property name="height">1</property>
443 </packing>317 </packing>
diff --git a/gui/gtk/ubiquity.ui b/gui/gtk/ubiquity.ui
index 552a1e9..bbdbae8 100644
--- a/gui/gtk/ubiquity.ui
+++ b/gui/gtk/ubiquity.ui
@@ -591,7 +591,6 @@
591 <property name="ypad">6</property>591 <property name="ypad">6</property>
592 <property name="label" translatable="yes">Installation is complete. You need to restart the computer in order to use the new installation. You can continue to use this live CD, although any changes you make or documents you save will not be preserved.</property>592 <property name="label" translatable="yes">Installation is complete. You need to restart the computer in order to use the new installation. You can continue to use this live CD, although any changes you make or documents you save will not be preserved.</property>
593 <property name="wrap">True</property>593 <property name="wrap">True</property>
594 <property name="max-width-chars">50</property>
595 </object>594 </object>
596 </child>595 </child>
597 </object>596 </object>
diff --git a/scripts/plugininstall.py b/scripts/plugininstall.py
index d4452a1..17f44fc 100755
--- a/scripts/plugininstall.py
+++ b/scripts/plugininstall.py
@@ -223,9 +223,6 @@ class Install(install_misc.InstallBase):
223 else:223 else:
224 self.install_extras()224 self.install_extras()
225225
226 # Configure zsys
227 self.configure_zsys()
228
229 self.next_region()226 self.next_region()
230 self.db.progress('INFO', 'ubiquity/install/activedirectory')227 self.db.progress('INFO', 'ubiquity/install/activedirectory')
231 self.configure_active_directory()228 self.configure_active_directory()
@@ -1004,12 +1001,6 @@ class Install(install_misc.InstallBase):
1004 for bind in binds:1001 for bind in binds:
1005 misc.execute('umount', '-f', self.target + bind)1002 misc.execute('umount', '-f', self.target + bind)
10061003
1007 def configure_zsys(self):
1008 """ Configure zsys """
1009 use_zfs = self.db.get('ubiquity/use_zfs')
1010 if use_zfs:
1011 misc.execute_root('/usr/share/ubiquity/zsys-setup', 'finalize')
1012
1013 def configure_active_directory(self):1004 def configure_active_directory(self):
1014 """ Join Active Directory domain and enable pam_mkhomedir """1005 """ Join Active Directory domain and enable pam_mkhomedir """
1015 use_directory = self.db.get('ubiquity/login_use_directory')1006 use_directory = self.db.get('ubiquity/login_use_directory')
diff --git a/scripts/zsys-setup b/scripts/zsys-setup
1016deleted file mode 1007551007deleted file mode 100755
index e10cf94..0000000
--- a/scripts/zsys-setup
+++ /dev/null
@@ -1,625 +0,0 @@
1#!/bin/sh
2
3#
4# This script creates ZFS pools and dataset compatible with zsys
5#
6
7# Layout:
8# bpool/BOOT/ubuntu_${UUID}
9# rpool/ROOT/ubuntu_${UUID}
10# rpool/ROOT/ubuntu_${UUID}/var -o canmount=off
11# rpool/ROOT/ubuntu_${UUID}/var/games
12# rpool/ROOT/ubuntu_${UUID}/var/lib
13# rpool/ROOT/ubuntu_${UUID}/var/lib/AccountsService
14# rpool/ROOT/ubuntu_${UUID}/var/lib/apt
15# rpool/ROOT/ubuntu_${UUID}/var/lib/dpkg
16# rpool/ROOT/ubuntu_${UUID}/var/log
17# rpool/ROOT/ubuntu_${UUID}/var/mail
18# rpool/ROOT/ubuntu_${UUID}/var/snap
19# rpool/ROOT/ubuntu_${UUID}/var/spool
20# rpool/ROOT/ubuntu_${UUID}/var/www
21# rpool/ROOT/ubuntu_${UUID}/var/lib/NetworkManager
22# rpool/ROOT/ubuntu_${UUID}/srv
23# rpool/ROOT/ubuntu_${UUID}/usr -o canmount=off
24# rpool/ROOT/ubuntu_${UUID}/usr/local
25# rpool/USERDATA/$user_$UUID2
26# rpool/USERDATA/root_$UUID2
27# rpool/keystore
28#
29# Steps:
30# - Verify that /target is mounted
31# - Retrieve fstab
32# - unmount /target
33# - delete all the partitions but the ESP
34# - Create p1 ext4 size 100MB
35# - Create p2 zfs bpool 1GB
36# - Create p3 zfs rbool 100% remaining
37# - Create datasets
38# - Create /swapfile on /target
39#
40# After setup is done leave it mounted to let Ubiquity proceed with installation
41
42set -eu
43
44REQUIREDPKGS="zfsutils-linux"
45TARGET="/target"
46ESP="${TARGET}/boot/efi"
47ZSYSTMP="/tmp/$(basename $0)"
48INIT_FLAG="${ZSYSTMP}/init.done"
49FSTAB_PARTMAN="${ZSYSTMP}/fstab.partman"
50PARTITION_LAYOUT="${ZSYSTMP}/layout"
51KEYSTORE_ROOT="/run/keystore/rpool"
52KEYSTORE_SIZE="500M"
53
54mkdir -p "${ZSYSTMP}"
55
56usage() {
57 # Display script usage
58 cat<<EOF
59Usage: $(basename "$0") [COMMAND] [OPTIONS...]
60 Prepares a zsys compatible ZFS system.
61
62Commands:
63 layout Get layout to display before formatting to ubiquity. Give the chosen disk as argument
64 init Initialize the pools and datasets
65 finalize Finalize the installation after the system has been installed
66Options:
67 -h, --help This help
68 -d, --debug Enable debug mode
69EOF
70 exit
71}
72
73SHORTOPTS="hd"
74LONGOPTS="help,debug"
75
76TEMP=$(getopt -o $SHORTOPTS --long $LONGOPTS -- "$@")
77eval set -- "$TEMP"
78
79while true ; do
80 case "$1" in
81 -h|--help)
82 usage;;
83 -d|--debug)
84 set -x
85 shift;;
86 --)
87 shift;
88 break;;
89 *)
90 usage;;
91 esac
92done
93
94COMMAND=$( echo $1 | tr '[:upper:]' '[:lower:]' )
95EXTRAARG=""
96if [ $# -gt 1 ]; then
97 EXTRAARG="${2}"
98fi
99
100ENCRYPTION=0
101ZFS_KS_KEY=${ZFS_KS_KEY:-}
102if [ -n "${ZFS_KS_KEY}" ]; then
103 ENCRYPTION=1
104fi
105
106check_prerequisites() {
107 # Check and set requirements to run this script
108 #
109 # Check and set the requirements to run this test. If any of the
110 # requirement is missing the programs exit with error
111 #
112 # Args:
113 # $@: List of required packages
114 #
115 # Returns
116 # Exit program is a requirement is not met
117 echo "I: Checking system requirements"
118
119 if [ $(id -u) -ne 0 ]; then
120 echo "E: Script must be executed as root. Exiting!"
121 exit 1
122 fi
123
124 for pkg in $@; do
125 if ! dpkg-query -W -f'${Status}' "${pkg}"|grep -q "install ok installed" 2>/dev/null; then
126 echo "E: $pkg is required and not installed on this system. Exiting!"
127 exit 1
128 fi
129 done
130
131}
132
133prepare_target() {
134 target="$1"
135
136 if ! grep -qE "\s${target}\s" /proc/mounts; then
137 echo "E: $target is not mounted. Exiting!"
138 exit 1
139 fi
140
141 # Save fstab generated by partman
142 if [ -f "${target}/etc/fstab" ]; then
143 echo "I: Saving existing fstab"
144 cp "${target}/etc/fstab" "${FSTAB_PARTMAN}"
145 else
146 echo "W: ${target}/etc/fstab doesn't exist"
147 fi
148
149 # umount /target
150 # It may fail to umount because the swap is being created by partman and not finished when we reach this point.
151 # Give it some time and retry with a sleep between tries.
152 iter=0
153 maxiter=10
154
155 for mountpoint in "${ESP}" "${target}"; do
156 if [ ! -d "${mountpoint}" ]; then
157 continue
158 fi
159
160 echo "I: umounting ${mountpoint}"
161 while :; do
162 # Do not make it quiet. We want to know why it failed.
163 if ! sudo umount "${mountpoint}"; then
164 iter=$(( iter + 1 ))
165 echo "W: Try ${iter}. Failed to umount ${mountpoint}."
166 if [ ${iter} -eq ${maxiter} ]; then
167 echo "E: Failed to umount ${mountpoint}. Exiting!"
168 exit 1
169 fi
170 sleep 3
171 else
172 break
173 fi
174 done
175 done
176}
177
178get_layout() {
179 # Returns disk, base name of the partition and partition numbers to create
180 target="$1"
181 disk="$2"
182
183 if [ -z "${disk}" ]; then
184 # The entire disk has been formatted with use_device
185 # There is either one ext4 partition or one ext4 and one ESP
186 part="$(grep -E "\s${target}\s" /proc/mounts | awk '{print $1}')"
187 partbase=""
188
189 if [ -n "${part}" ]; then
190 disk="$(lsblk -lns -o TYPE,PATH ${part}| grep disk| awk '{print $2}')"
191 if [ -z "${disk}" ]; then
192 echo "E: Couldn't identify disk for partition ${part}. Exiting!"
193 exit 1
194 fi
195 # Some disks have letters in the partition number like /dev/nvme0n1p1
196 # In this case we want to retrieve 'p' so we deal only with partition number
197 # in the rest of the script and prepend the base.
198 partbase="$(echo ${part} | sed -e 's/[0-9]*$//' | sed -e "s#${disk}##")"
199 fi
200 else
201 # The only purpose of this code is to display a friendly message in ubiquity to show the user
202 # what partitioning will be performed. However, on first call, the disk is not yet partitioned
203 # and collecting the information about disk partitioning would require to query partman. But we
204 # don't want to add this extra complexity just to display a message. Instead we hardcode the
205 # extension of the partition name depending on the type of disk, basically it's 'p' for anything
206 # else than standard drives (eg nvme01pX)
207 case "${disk}" in
208 /dev/sd*|/dev/hd*|/dev/vd*)
209 partbase=""
210 ;;
211 *)
212 partbase="p"
213 esac
214 fi
215
216 if [ -d /sys/firmware/efi/efivars ]; then
217 # No extended partition on EFI + GPT
218 # The layout is
219 # 1: ESP
220 # 2: swap
221 # 3: bpool
222 # 4: rpool
223 partesp=1
224 partswap=2
225 partbpool=3
226 partrpool=4
227
228 # As partman forces now gpt for any installation, we consider that not having efivar equals gpt with BiosBoot (LP: #1796260)
229 else
230 # The layout is:
231 # 1: BiosBoot
232 # 2: ESP
233 # 3: swap
234 # 4: bpool
235 # 5: rpool
236 partesp=2
237 partswap=3
238 partbpool=4
239 partrpool=5
240 fi
241
242 echo "OK|${disk}|${partbase}|${partesp}|${partswap}|${partbpool}|${partrpool}"
243}
244
245format_disk() {
246 disk="$1"
247 partbase="$2"
248 partesp="$3"
249 partbpool="$4"
250 partrpool="$5"
251 ss="$6"
252 partswap=$(( partbpool - 1 ))
253 partprefix="${disk}${partbase}"
254
255 sfdisktmp="${ZSYSTMP}/sfdisk.cfg"
256 rm -f "${sfdisktmp}"
257
258 echo "I: Formatting disk $disk with partitions swap:${partswap} bpool:${partbpool} rpool:${partrpool}"
259
260 # bpool size: 500M < 5% of ZFS allocated space < 2G
261 # srcpath is the system partition on initial layout.
262 srcpath=$(lsblk -ln -o PATH ${disk}|tail -1)
263 partsrc=${srcpath##*${partprefix}}
264 size_percent=$(expr \( $(blockdev --getsize64 ${srcpath}) / 1024 / 1024 \) \* 5 / 100)
265 bpool_size=500
266 [ ${size_percent} -gt ${bpool_size} ] && bpool_size=${size_percent}
267 [ ${bpool_size} -gt 2048 ] && bpool_size=2048
268
269 # Improvement: Delete all the partitions but the ESP
270 # There should be only 1 or 2 partitions but it can be made generic
271 if ! esp_exists "${disk}"; then
272 start=$(sfdisk -l "${disk}"|grep "^${partprefix}${partesp}"|awk '{print $2}')
273 cat > "${sfdisktmp}" <<EOF
274${partprefix}${partesp} : start= ${start}, size= 512M, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, bootable
275EOF
276 else
277 sfdisk --delete "${disk}" ${partsrc}
278 fi
279
280 cat >> "${sfdisktmp}" <<EOF
281${partprefix}${partswap} : size= ${ss}M, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
282${partprefix}${partbpool} : size= ${bpool_size}M, type=6A82CB45-1DD2-11B2-99A6-080020736631
283${partprefix}${partrpool} : type=6A85CF4D-1DD2-11B2-99A6-080020736631
284EOF
285
286 cat "${sfdisktmp}" | sfdisk --append --no-reread "${disk}"
287
288 # Force a re-read of the partition table
289 echo "I: Re-reading partition table"
290 partx --add "${disk}" 2>/dev/null || true
291 partx --show "${disk}"
292}
293
294init_keystore() {
295 keystore_dev="$1"
296 echo "I: Initializing Key Store"
297
298 if [ ${ENCRYPTION} -eq 1 ]; then
299 mkdir -p "${KEYSTORE_ROOT}"
300 printf "%s" "${ZFS_KS_KEY}" | cryptsetup luksFormat /dev/zvol/${keystore_dev} -
301 printf "%s" "${ZFS_KS_KEY}" | cryptsetup luksOpen /dev/zvol/${keystore_dev} keystore-rpool -
302 mke2fs -t ext4 /dev/mapper/keystore-rpool -L keystore-rpool
303 mount /dev/mapper/keystore-rpool "${KEYSTORE_ROOT}"
304 fi
305}
306
307init_zfs() {
308 target="$1"
309 partbpool="$2"
310 partrpool="$3"
311
312 echo "I: Initializing ZFS"
313 # Now we can create the pools and dataset
314 UUID_ORIG=$(head -100 /dev/urandom | tr -dc 'a-z0-9' |head -c6)
315
316 # Use stable uuid for partition when available as device name can change
317 # Let udev finish its job before proceeding with zpool creation
318 udevadm settle
319 bpooluuid=$(blkid -s PARTUUID -o value $partbpool)
320 [ -n "$bpooluuid" -a -e "/dev/disk/by-partuuid/$bpooluuid" ] && partbpool=/dev/disk/by-partuuid/$bpooluuid
321 rpooluuid=$(blkid -s PARTUUID -o value $partrpool)
322 [ -n "$rpooluuid" -a -e "/dev/disk/by-partuuid/$rpooluuid" ] && partrpool=/dev/disk/by-partuuid/$rpooluuid
323
324 # Pools
325 encrypt_args=""
326 if [ ${ENCRYPTION} -eq 1 ]; then
327 # Creation of the encryption key
328 local ks_system_key="${KEYSTORE_ROOT}/system.key"
329 local ks_system_key_tmp="${ZSYSTMP}/$(basename "${ks_system_key}")"
330 head -c 32 /dev/urandom > "${ks_system_key_tmp}"
331 encrypt_args="-O encryption=on -O keylocation=file://${ks_system_key_tmp} -O keyformat=raw"
332 fi
333
334 # rpool
335 zpool create -f \
336 -o ashift=12 \
337 -o autotrim=on \
338 -O compression=lz4 \
339 -O acltype=posixacl \
340 -O xattr=sa \
341 -O relatime=on \
342 -O normalization=formD \
343 -O mountpoint=/ \
344 -O canmount=off \
345 -O dnodesize=auto \
346 -O sync=disabled \
347 ${encrypt_args} \
348 -O mountpoint=/ -R "${target}" rpool "${partrpool}"
349
350 # bpool
351 # The version of bpool is set to the default version to prevent users from upgrading
352 # Then only features supported by grub are enabled.
353 zpool create -f \
354 -o ashift=12 \
355 -o autotrim=on \
356 -d \
357 -o feature@async_destroy=enabled \
358 -o feature@bookmarks=enabled \
359 -o feature@embedded_data=enabled \
360 -o feature@empty_bpobj=enabled \
361 -o feature@enabled_txg=enabled \
362 -o feature@extensible_dataset=enabled \
363 -o feature@filesystem_limits=enabled \
364 -o feature@hole_birth=enabled \
365 -o feature@large_blocks=enabled \
366 -o feature@lz4_compress=enabled \
367 -o feature@spacemap_histogram=enabled \
368 -O compression=lz4 \
369 -O acltype=posixacl \
370 -O xattr=sa \
371 -O relatime=on \
372 -O normalization=formD \
373 -O canmount=off \
374 -O devices=off \
375 -O mountpoint=/boot -R "${target}" bpool "${partbpool}"
376
377 if [ ${ENCRYPTION} -eq 1 ]; then
378 # Creation of the encryption keystore on the pool directly
379 # and point to the system ZFS decryption key path
380 local keystore_dev="rpool/keystore"
381 zfs create -o encryption=off -V ${KEYSTORE_SIZE} "${keystore_dev}"
382 init_keystore "${keystore_dev}"
383 mv "${ks_system_key_tmp}" "${ks_system_key}"
384 chmod 600 "${ks_system_key}"
385 zfs set keylocation=file://"${ks_system_key}" rpool
386 fi
387
388 # Root and boot dataset
389 zfs create rpool/ROOT -o canmount=off -o mountpoint=none
390 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}" -o mountpoint=/
391 zfs create bpool/BOOT -o canmount=off -o mountpoint=none
392 zfs create "bpool/BOOT/ubuntu_${UUID_ORIG}" -o mountpoint=/boot
393
394 # System dataset
395 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var" -o canmount=off
396 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/lib"
397 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/lib/AccountsService"
398 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/lib/apt"
399 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/lib/dpkg"
400 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/lib/NetworkManager"
401
402 # Desktop specific system dataset
403 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/srv"
404 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/usr" -o canmount=off
405 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/usr/local"
406 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/games"
407 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/log"
408 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/mail"
409 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/snap"
410 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/spool"
411 zfs create "rpool/ROOT/ubuntu_${UUID_ORIG}/var/www"
412
413 # USERDATA datasets
414 # Dataset associated to the user are created by the installer.
415 zfs create rpool/USERDATA -o canmount=off -o mountpoint=/
416
417 # Set zsys properties
418 zfs set com.ubuntu.zsys:bootfs='yes' "rpool/ROOT/ubuntu_${UUID_ORIG}"
419 zfs set com.ubuntu.zsys:last-used=$(date +%s) "rpool/ROOT/ubuntu_${UUID_ORIG}"
420 zfs set com.ubuntu.zsys:bootfs='no' "rpool/ROOT/ubuntu_${UUID_ORIG}/srv"
421 zfs set com.ubuntu.zsys:bootfs='no' "rpool/ROOT/ubuntu_${UUID_ORIG}/usr"
422 zfs set com.ubuntu.zsys:bootfs='no' "rpool/ROOT/ubuntu_${UUID_ORIG}/var"
423}
424
425move_user () {
426 target="$1"
427 user="$2"
428 userhome="$3"
429 uuid="$4"
430
431 echo "I: Creating user $user with home $userhome"
432 mv "${target}/${userhome}" "${target}/tmp/home/${user}"
433 zfs create "rpool/USERDATA/${user}_${uuid}" -o canmount=on -o mountpoint=${userhome}
434 chown $(chroot "${target}" id -u ${user}):$(chroot ${target} id -g ${user}) "${target}/${userhome}"
435 rsync -a "${target}/tmp/home/${user}/" "${target}/${userhome}"
436 bootfsdataset=$(grep "\s${target}\s" /proc/mounts | awk '{ print $1 }')
437 zfs set com.ubuntu.zsys:bootfs-datasets="${bootfsdataset}" rpool/USERDATA/${user}_${UUID_ORIG}
438}
439
440init_system_partitions() {
441 target="$1"
442 partefi="$2"
443
444 # ESP
445 mkdir -p "${target}/boot/efi"
446 mount -t vfat "${partefi}" "${target}/boot/efi"
447 mkdir -p "${target}/boot/efi/grub"
448
449 echo "I: Mount grub directory"
450 # Finalize grub directory
451 mkdir -p "${target}/boot/grub"
452 mount -o bind "${target}/boot/efi/grub" "${target}/boot/grub"
453}
454
455esp_exists() {
456 parttype="C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
457 sfdisk -d "${1}" | grep -q "type=${parttype}"
458}
459
460check_prerequisites ${REQUIREDPKGS}
461
462echo "I: Running $(basename "$0") ${COMMAND}"
463
464if [ -z "${COMMAND}" ]; then
465 echo "E: ${COMMAND} is mandatory. Exiting!"
466 exit 1
467elif [ "${COMMAND}" = "layout" ]; then
468 # Just displays de layout that will be created without any change to the disk.
469 # At this stage we don't know yet the size of the partition that will be created.
470 IFS="|" read ERR DISK PARTBASE PARTESP PARTSWAP PARTBPOOL PARTRPOOL<<EOF
471$(get_layout ${TARGET} "${EXTRAARG}")
472EOF
473
474 if [ "${ERR}" != "OK" ]; then
475 echo "${ERR}"
476 exit 1
477 fi
478
479 cat > "${PARTITION_LAYOUT}" <<EOF
480disk:${DISK}
481EOF
482 if ! esp_exists "${DISK}"; then
483 cat >> "${PARTITION_LAYOUT}" <<EOF
484part:vfat:ESP:${DISK}${PARTBASE}${PARTESP}
485EOF
486 fi
487
488 cat >> "${PARTITION_LAYOUT}" <<EOF
489part:swap:swap:${DISK}${PARTBASE}${PARTSWAP}
490part:zfs:bpool:${DISK}${PARTBASE}${PARTBPOOL}
491part:zfs:rpool:${DISK}${PARTBASE}${PARTRPOOL}
492EOF
493
494elif [ "${COMMAND}" = "init" ]; then
495 rm -f "${INIT_FLAG}"
496
497 IFS="|" read ERR DISK PARTBASE PARTESP PARTSWAP PARTBPOOL PARTRPOOL<<EOF
498$(get_layout ${TARGET} "")
499EOF
500
501 if [ "${ERR}" != "OK" ]; then
502 echo "${ERR}"
503 exit 1
504 fi
505
506 echo "I: Partition table before init of ZFS"
507 partx --show "${DISK}"
508
509 # Swap files are not supported on ZFS, we use a swap partition instead:
510 SWAPFILE="$(grep "^${TARGET}" /proc/swaps | awk '{print $1}')"
511 # Give us a minimum swap partition size of 4MB in case we decide on
512 # no swap, just to keep the partition layout stable:
513 SWAPSIZE=4194304
514
515 # Disable swap and get the swap volume size:
516 if [ -n "${SWAPFILE}" ]; then
517 SWAPSIZE=$(stat -c%s "${SWAPFILE}")
518 echo "I: Found swapfile with size ${SWAPSIZE}. Disabling"
519 swapoff "${SWAPFILE}"
520 fi
521 # Convert to MiB to align the size on the size of a block
522 SWAPVOLSIZE=$(( SWAPSIZE / 1024 / 1024 ))
523
524 prepare_target "${TARGET}"
525 format_disk "${DISK}" "${PARTBASE}" "${PARTESP}" "${PARTBPOOL}" "${PARTRPOOL}" "${SWAPVOLSIZE}"
526 init_zfs "${TARGET}" "${DISK}${PARTBASE}${PARTBPOOL}" "${DISK}${PARTBASE}${PARTRPOOL}"
527 init_system_partitions "${TARGET}" "${DISK}${PARTBASE}${PARTESP}"
528
529 # Generate fstab
530 # $TARGET/etc has been destroyed by the creation of the zfs partitition
531 # Recreate it
532 mkdir -p "${TARGET}/etc"
533 if [ -f "${FSTAB_PARTMAN}" ]; then
534 echo "I: Creating fstab"
535 grep -Ev '\s/\s|/swapfile' "${FSTAB_PARTMAN}" > "${TARGET}/etc/fstab"
536 fi
537
538 if ! grep -q "boot/efi" "${TARGET}/etc/fstab"; then
539 espuuid=$(blkid -s UUID -o value "${DISK}${PARTBASE}${PARTESP}")
540 echo "UUID=${espuuid}\t/boot/efi\tvfat\tumask=0022,fmask=0022,dmask=0022\t0\t1" >> "${TARGET}/etc/fstab"
541 fi
542
543 # Bind mount grub from ESP to the expected location
544 echo "/boot/efi/grub\t/boot/grub\tnone\tdefaults,bind\t0\t0" >> "${TARGET}/etc/fstab"
545
546 if [ -n "${SWAPFILE}" ]; then
547 swap_device="${DISK}${PARTBASE}${PARTSWAP}"
548 if [ ${ENCRYPTION} -eq 1 ]; then
549 # Format swap as Luks
550 swap_name="cryptoswap"
551 touch ${ZSYSTMP}/swap.keyfile
552 cryptsetup -q --key-file=${ZSYSTMP}/swap.keyfile luksFormat "${swap_device}"
553 cryptsetup -q --key-file=${ZSYSTMP}/swap.keyfile luksOpen "${swap_device}" "${swap_name}"
554 udevadm settle
555 orig_swap_device="${swap_device}"
556 swap_device="/dev/mapper/${swap_name}"
557
558 # Update crypttab
559 printf "${swap_name}\t${orig_swap_device}\t/dev/urandom\tswap,initramfs" >> "${TARGET}/etc/crypttab"
560 swap_dev_fstab="${swap_device}"
561 fi
562 mkswap -f "${swap_device}"
563 if [ ${ENCRYPTION} -eq 0 ]; then
564 # for unencrypted swap, this has to be after mkswap to read the right device id
565 swap_dev_fstab="UUID=$(blkid -s UUID -o value "${swap_device}")"
566 fi
567 printf "${swap_dev_fstab}\tnone\tswap\tsw\t0\t0\n" >> "${TARGET}/etc/fstab"
568 swapon -v "${swap_device}"
569 fi
570 # Make /boot/{grub,efi} world readable
571 sed -i 's#\(.*boot/efi.*\)umask=0077\(.*\)#\1umask=0022,fmask=0022,dmask=0022\2#' "${TARGET}/etc/fstab"
572
573 echo "I: Marking ZFS utilities to be kept in the target system"
574 apt-install zfsutils-linux 2>/dev/null
575 apt-install zfs-initramfs 2>/dev/null
576 apt-install zsys 2>/dev/null
577 apt-install cryptsetup 2>/dev/null
578 apt-install cryptsetup-initramfs 2>/dev/null
579
580 touch "$INIT_FLAG"
581elif [ "${COMMAND}" = "finalize" ]; then
582 if [ ! -f "$INIT_FLAG" ]; then
583 echo "W: zsys init didn't succeed. Not proceeding with command: ${COMMAND}. Aborting!"
584 exit 1
585 fi
586
587 # Activate zfs generator.
588 # After enabling the generator we should run zfs set canmount=on DATASET
589 # in the chroot for one dataset of each pool to refresh the zfs cache.
590 echo "I: Activating zfs generator"
591
592 # Create zpool cache
593 zpool set cachefile= bpool
594 zpool set cachefile= rpool
595 cp /etc/zfs/zpool.cache "${TARGET}/etc/zfs/"
596 mkdir -p "${TARGET}/etc/zfs/zfs-list.cache"
597 touch "${TARGET}/etc/zfs/zfs-list.cache/bpool" "${TARGET}/etc/zfs/zfs-list.cache/rpool"
598
599 # Handle userdata
600 UUID_ORIG=$(head -100 /dev/urandom | tr -dc 'a-z0-9' |head -c6)
601 mkdir -p "${TARGET}/tmp/home"
602 for user in ${TARGET}/home/*; do
603 if [ -d "${user}" ]; then
604 user="$(basename $user)"
605 move_user "${TARGET}" "${user}" "/home/${user}" "${UUID_ORIG}"
606 fi
607 done
608
609 move_user "${TARGET}" root /root "${UUID_ORIG}"
610
611 echo "I: Changing sync mode of rpool to standard"
612 zfs set sync=standard rpool
613
614 # Disable resumable device
615 if [ -b /dev/mapper/cryptoswap ]; then
616 mkdir -p "${TARGET}/etc/initramfs-tools/conf.d"
617 echo "RESUME=none" > "${TARGET}/etc/initramfs-tools/conf.d/resume"
618 chroot "${TARGET}" update-initramfs -u
619 fi
620
621 echo "I: ZFS setup complete"
622else
623 echo "E: Unknown command: $COMMAND"
624 exit 1
625fi
diff --git a/tests/test_gtkui.py b/tests/test_gtkui.py
index a33829d..9516746 100644
--- a/tests/test_gtkui.py
+++ b/tests/test_gtkui.py
@@ -104,8 +104,6 @@ class TestFrontend(unittest.TestCase):
104 'cancelbutton2', 'okbutton2', 'okbutton3',104 'cancelbutton2', 'okbutton2', 'okbutton3',
105 'partition_dialog_okbutton', 'cancelbutton3',105 'partition_dialog_okbutton', 'cancelbutton3',
106 'grub_fail_okbutton',106 'grub_fail_okbutton',
107 'advanced_features_cancelbutton',
108 'advanced_features_okbutton',
109 # These are calculated and set as the partitioning options are107 # These are calculated and set as the partitioning options are
110 # being calculated.108 # being calculated.
111 'reuse_partition_desc', 'reuse_partition',109 'reuse_partition_desc', 'reuse_partition',
@@ -113,7 +111,6 @@ class TestFrontend(unittest.TestCase):
113 'resize_use_free_desc', 'resize_use_free',111 'resize_use_free_desc', 'resize_use_free',
114 'use_device_desc', 'use_device', 'part_ask_heading',112 'use_device_desc', 'use_device', 'part_ask_heading',
115 'custom_partitioning_desc', 'custom_partitioning',113 'custom_partitioning_desc', 'custom_partitioning',
116 'advanced_features_selected',
117 # Pulled straight from debconf when the installation medium is114 # Pulled straight from debconf when the installation medium is
118 # already mounted.115 # already mounted.
119 'part_advanced_warning_message',116 'part_advanced_warning_message',
diff --git a/ubiquity/frontend/gtk_ui.py b/ubiquity/frontend/gtk_ui.py
index 77e0cde..7695f04 100644
--- a/ubiquity/frontend/gtk_ui.py
+++ b/ubiquity/frontend/gtk_ui.py
@@ -1752,17 +1752,6 @@ class Wizard(BaseFrontend):
1752 (self.partitioned, self.timezone_set))1752 (self.partitioned, self.timezone_set))
1753 return1753 return
17541754
1755 # Setup zfs layout
1756 use_zfs = self.db.get('ubiquity/use_zfs')
1757 if use_zfs == 'true':
1758 env = os.environ.copy()
1759 zfs_keystore_key = self.db.get('ubiquity/zfs_keystore_key')
1760 if zfs_keystore_key:
1761 os.environ['ZFS_KS_KEY'] = zfs_keystore_key
1762 misc.execute_root('/usr/share/ubiquity/zsys-setup', 'init')
1763 os.environ.clear()
1764 os.environ.update(env)
1765
1766 syslog.syslog('Starting the installation')1755 syslog.syslog('Starting the installation')
17671756
1768 from ubiquity.debconfcommunicator import DebconfCommunicator1757 from ubiquity.debconfcommunicator import DebconfCommunicator
diff --git a/ubiquity/plugins/ubi-partman.py b/ubiquity/plugins/ubi-partman.py
index b9f3d9e..10b783a 100644
--- a/ubiquity/plugins/ubi-partman.py
+++ b/ubiquity/plugins/ubi-partman.py
@@ -324,46 +324,6 @@ class PageGtk(PageBase):
324 self.recovery_key.set_text(key)324 self.recovery_key.set_text(key)
325 self.verified_recovery_key.set_text(key)325 self.verified_recovery_key.set_text(key)
326326
327 def on_advanced_features_clicked(self, widget):
328 from gi.repository import Gtk
329
330 # Save current state of advanced features
331 selected = None
332 crypto_selected = self.use_crypto.get_active()
333 for w in (self.advanced_features_radio_none,
334 self.use_lvm, self.use_zfs):
335 if w.get_active():
336 selected = w
337 break
338
339 # Only show zfs when available
340 zpool_exists = os.path.exists('/sbin/zpool')
341 self.use_zfs.set_visible(zpool_exists)
342
343 dlg = self.advanced_features_dialog
344 dlg.show()
345 response = dlg.run()
346 dlg.hide()
347
348 if response == Gtk.ResponseType.OK:
349 label = ""
350 if self.advanced_features_radio_none.get_active():
351 label = self.controller.get_string('advanced_features_none_selected')
352 elif self.use_lvm.get_active():
353 label = self.controller.get_string('advanced_features_lvm_selected')
354 if self.use_crypto.get_active():
355 label = self.controller.get_string('advanced_features_lvm_crypto_selected')
356 elif self.use_zfs.get_active():
357 label = self.controller.get_string('advanced_features_zfs_selected')
358 if self.use_crypto.get_active():
359 label = self.controller.get_string('advanced_features_zfs_crypto_selected')
360 self.advanced_features_desc.set_text(label)
361 else:
362 # Restore previous selection
363 if selected:
364 selected.set_active(True)
365 self.use_crypto.set_active(crypto_selected)
366
367 def on_recovery_key_button_clicked(self, widget):327 def on_recovery_key_button_clicked(self, widget):
368 from gi.repository import Gtk328 from gi.repository import Gtk
369 label = self.controller.get_string('recovery_key_filename')329 label = self.controller.get_string('recovery_key_filename')
@@ -444,9 +404,7 @@ class PageGtk(PageBase):
444 replace = self.replace_partition.get_active()404 replace = self.replace_partition.get_active()
445 resize = self.resize_use_free.get_active()405 resize = self.resize_use_free.get_active()
446 custom = self.custom_partitioning.get_active()406 custom = self.custom_partitioning.get_active()
447 use_zfs = self.use_zfs.get_active()407 use_device = self.use_device.get_active()
448 # ZFS is installed on entire drive.
449 use_device = self.use_device.get_active() or use_zfs
450 biggest_free = 'biggest_free' in self.extra_options408 biggest_free = 'biggest_free' in self.extra_options
451 crypto = self.use_crypto.get_active()409 crypto = self.use_crypto.get_active()
452 disks = self.extra_options.get('use_device', [])410 disks = self.extra_options.get('use_device', [])
@@ -640,7 +598,7 @@ class PageGtk(PageBase):
640 elif (self.resize_use_free.get_active() and598 elif (self.resize_use_free.get_active() and
641 'biggest_free' in self.extra_options):599 'biggest_free' in self.extra_options):
642 return True600 return True
643 elif ((self.use_device.get_active() or self.use_zfs.get_active()) and601 elif (self.use_device.get_active() and
644 len(self.extra_options['use_device'][1]) == 1):602 len(self.extra_options['use_device'][1]) == 1):
645 return True603 return True
646 else:604 else:
@@ -659,20 +617,12 @@ class PageGtk(PageBase):
659 self.controller.toggle_next_button()617 self.controller.toggle_next_button()
660 self.plugin_is_install = about_to_install618 self.plugin_is_install = about_to_install
661619
662 # Advanced features in new installs only for now620 # Supporting crypto and lvm in new installs only for now
663 use_device = self.use_device.get_active()621 use_device = self.use_device.get_active()
664 self.advanced_features_button.set_sensitive(use_device)622 self.use_lvm.set_sensitive(use_device)
665 self.advanced_features_selected.set_sensitive(use_device)623 self.use_crypto.set_sensitive(use_device)
666624 self.use_lvm_desc.set_sensitive(use_device)
667 def advanced_features_option_changed(self, widget):625 self.use_crypto_desc.set_sensitive(use_device)
668 if not widget.get_active():
669 return
670
671 use_volume_manager = self.use_lvm.get_active() or self.use_zfs.get_active()
672 if not use_volume_manager:
673 self.use_crypto.set_active(False)
674 self.use_crypto.set_sensitive(use_volume_manager)
675 self.use_crypto_desc.set_sensitive(use_volume_manager)
676626
677 def initialize_resize_mode(self):627 def initialize_resize_mode(self):
678 disk_id = self.get_current_disk_partman_id()628 disk_id = self.get_current_disk_partman_id()
@@ -854,23 +804,19 @@ class PageGtk(PageBase):
854 ticked = False804 ticked = False
855 for option, name in option_to_widget:805 for option, name in option_to_widget:
856 opt_widget = getattr(self, name)806 opt_widget = getattr(self, name)
857 opt_desc = getattr(self, name + '_desc', None)807 opt_desc = getattr(self, name + '_desc')
858808
859 if option in options:809 if option in options:
860 opt_widget.show()810 opt_widget.show()
811 opt_desc.show()
861 opt_widget.set_label(options[option].title)812 opt_widget.set_label(options[option].title)
862813 opt_desc.set_markup(fmt % options[option].desc)
863 if opt_desc:
864 opt_desc.show()
865 opt_desc.set_markup(fmt % options[option].desc)
866
867 if not ticked and opt_widget.get_sensitive():814 if not ticked and opt_widget.get_sensitive():
868 opt_widget.set_active(True)815 opt_widget.set_active(True)
869 ticked = True816 ticked = True
870 else:817 else:
871 opt_widget.hide()818 opt_widget.hide()
872 if opt_desc:819 opt_desc.hide()
873 opt_desc.hide()
874820
875 # Process the default selection821 # Process the default selection
876 self.part_ask_option_changed(None)822 self.part_ask_option_changed(None)
@@ -899,17 +845,15 @@ class PageGtk(PageBase):
899 return (choice, '%s B' % self.resizewidget.get_size(),845 return (choice, '%s B' % self.resizewidget.get_size(),
900 'resize_use_free')846 'resize_use_free')
901847
902 elif self.use_device.get_active() or self.use_zfs.get_active():848 elif self.use_device.get_active():
903 def choose_recipe():849 def choose_recipe():
904 # TODO dmitrij.ledkov 2012-07-23: RAID recipe?850 # TODO dmitrij.ledkov 2012-07-23: RAID recipe?
905851
906 have_lvm = 'some_device_lvm' in self.extra_options852 have_lvm = 'some_device_lvm' in self.extra_options
907 want_lvm = (self.use_lvm.get_active() and853 want_lvm = self.use_lvm.get_active()
908 not self.use_zfs.get_active())
909854
910 have_crypto = 'some_device_crypto' in self.extra_options855 have_crypto = 'some_device_crypto' in self.extra_options
911 want_crypto = (self.use_crypto.get_active() and856 want_crypto = self.use_crypto.get_active()
912 not self.use_zfs.get_active())
913857
914 if not ((want_crypto and have_crypto) or858 if not ((want_crypto and have_crypto) or
915 (want_lvm and have_lvm)):859 (want_lvm and have_lvm)):
@@ -1150,16 +1094,6 @@ class PageGtk(PageBase):
1150 is_removable = misc.is_removable_device(self.recovery_key_location.get_text())1094 is_removable = misc.is_removable_device(self.recovery_key_location.get_text())
1151 self.recovery_key_location_warning.set_visible(not is_removable)1095 self.recovery_key_location_warning.set_visible(not is_removable)
11521096
1153 def show_overwrite_space(self, show_hide):
1154 if show_hide:
1155 action = 'show'
1156 else:
1157 action = 'hide'
1158
1159 for widget in ['crypto_extra_label',
1160 'crypto_overwrite_space', 'crypto_extra_time']:
1161 getattr(getattr(self, widget), action)()
1162
1163 @plugin.only_this_page1097 @plugin.only_this_page
1164 def partman_dialog(self, devpart, partition, create=True):1098 def partman_dialog(self, devpart, partition, create=True):
1165 from gi.repository import Gtk, GObject1099 from gi.repository import Gtk, GObject
@@ -1728,7 +1662,6 @@ class PageGtk(PageBase):
1728 self.move_crypto_widgets()1662 self.move_crypto_widgets()
1729 self.show_encryption_passphrase(True)1663 self.show_encryption_passphrase(True)
1730 self.generate_recovery_key()1664 self.generate_recovery_key()
1731 self.show_overwrite_space(not(self.use_crypto.get_active() and self.use_zfs.get_active()))
1732 self.controller.go_to_page(self.current_page)1665 self.controller.go_to_page(self.current_page)
1733 self.controller.toggle_next_button('install_button')1666 self.controller.toggle_next_button('install_button')
1734 self.info_loop(None)1667 self.info_loop(None)
@@ -3421,10 +3354,6 @@ class Page(plugin.Plugin):
3421 elif question.startswith('partman/confirm'):3354 elif question.startswith('partman/confirm'):
3422 description = self.extended_description(question)3355 description = self.extended_description(question)
34233356
3424 if hasattr(self.ui, "use_zfs"):
3425 if (self.ui.use_zfs.get_active() and self.ui.use_device.get_active()):
3426 description = self.update_zfs_description(self.extended_description(question))
3427
3428 response = self.frontend.question_dialog(3357 response = self.frontend.question_dialog(
3429 self.description(question),3358 self.description(question),
3430 description,3359 description,
@@ -3503,45 +3432,6 @@ class Page(plugin.Plugin):
35033432
3504 return plugin.Plugin.run(self, priority, question)3433 return plugin.Plugin.run(self, priority, question)
35053434
3506 def update_zfs_description(self, description):
3507 """Update the description in the partman dialog to display custom
3508 messages"""
3509
3510 disks = re.findall(r"\(([^)]+)\)", description)
3511 device = ""
3512 if disks:
3513 device = "/dev/" + disks[0]
3514
3515 misc.execute_root('/usr/share/ubiquity/zsys-setup', 'layout', device)
3516
3517 zsys_layout = '/tmp/zsys-setup/layout'
3518 lines = description.splitlines()
3519 # Remove the last line of the output from partman which corresponds to
3520 # the ext4 partition
3521 del(lines[-1])
3522
3523 if not os.path.exists(zsys_layout):
3524 return description
3525
3526 with open(zsys_layout, 'r') as f:
3527 layout = f.readlines()
3528
3529 partlabel = misc.utf8(self.db.metaget('ubiquity/text/partman_confirm_zfs', 'extended_description'),
3530 errors='replace')
3531 for line in layout:
3532 if not line.startswith("part:"):
3533 continue
3534
3535 line = line.strip()
3536 (t, f, u, p) = line.split(':')
3537
3538 lines.append(" " + partlabel % {
3539 'partid': os.path.basename(p),
3540 'parttype': f,
3541 'partusage': u})
3542
3543 return "\n".join(lines)
3544
3545 def ok_handler(self):3435 def ok_handler(self):
3546 if self.install_bootloader and not self.is_bootdev_preseeded():3436 if self.install_bootloader and not self.is_bootdev_preseeded():
3547 self.preseed('grub-installer/bootdev', self.ui.get_grub_choice())3437 self.preseed('grub-installer/bootdev', self.ui.get_grub_choice())
@@ -3551,19 +3441,7 @@ class Page(plugin.Plugin):
3551 self.ui.get_autopartition_choice()3441 self.ui.get_autopartition_choice()
3552 self.preseed_as_c(self.current_question, autopartition_choice,3442 self.preseed_as_c(self.current_question, autopartition_choice,
3553 seen=False)3443 seen=False)
3554 telemetry_method = method3444 telemetry.get().set_partition_method(method)
3555 try:
3556 if self.ui.use_zfs.get_active() and method == 'use_device':
3557 telemetry_method = "use_zfs"
3558 except AttributeError: # zfs not implemented on this frontend
3559 pass
3560
3561 self.db.set('ubiquity/use_zfs',
3562 'true' if telemetry_method == 'use_zfs' else 'false')
3563 telemetry.get().set_partition_method(telemetry_method)
3564 keystore_key = self.ui.get_crypto_keys()
3565 if keystore_key:
3566 self.db.set('ubiquity/zfs_keystore_key', keystore_key)
3567 # Don't exit partman yet.3445 # Don't exit partman yet.
3568 else:3446 else:
3569 self.finish_partitioning = True3447 self.finish_partitioning = True

Subscribers

People subscribed via source and target branches