Merge ~waveform/ubuntu/+source/ubuntu-settings:growroot-almost into ~ubuntu-desktop/ubuntu/+source/ubuntu-settings:master

Proposed by Dave Jones
Status: Merged
Merged at revision: 4b10fc4690401bb6aeb7cef014543df42daef138
Proposed branch: ~waveform/ubuntu/+source/ubuntu-settings:growroot-almost
Merge into: ~ubuntu-desktop/ubuntu/+source/ubuntu-settings:master
Diff against target: 299 lines (+203/-1)
12 files modified
data/raspberrypi/01-use-network-manager.yaml (+4/-0)
data/raspberrypi/growroot-almost (+74/-0)
data/raspberrypi/growroot-almost.service (+16/-0)
data/raspberrypi/meson.build (+11/-0)
data/raspberrypi/mkswap.service (+16/-0)
data/raspberrypi/swapfile.swap (+8/-0)
debian/changelog (+17/-0)
debian/control (+1/-1)
debian/rules (+5/-0)
debian/ubuntu-raspi-settings-desktop.install (+5/-0)
debian/ubuntu-raspi-settings-desktop.lintian-overrides (+14/-0)
debian/ubuntu-raspi-settings-desktop.postinst (+32/-0)
Reviewer Review Type Date Requested Status
Ubuntu Desktop Pending
Review via email: mp+439835@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Dave Jones (waveform) wrote :

Please see associated bug; it should link to both relevant merge requests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/data/raspberrypi/01-use-network-manager.yaml b/data/raspberrypi/01-use-network-manager.yaml
2new file mode 100644
3index 0000000..4a8fd08
4--- /dev/null
5+++ b/data/raspberrypi/01-use-network-manager.yaml
6@@ -0,0 +1,4 @@
7+# Let NetworkManager manage all devices on this system
8+network:
9+ version: 2
10+ renderer: NetworkManager
11diff --git a/data/raspberrypi/growroot-almost b/data/raspberrypi/growroot-almost
12new file mode 100755
13index 0000000..9b13e3e
14--- /dev/null
15+++ b/data/raspberrypi/growroot-almost
16@@ -0,0 +1,74 @@
17+#!/bin/sh
18+
19+set -eu
20+
21+MYNAME=${0##*/}
22+
23+usage() {
24+ echo "Usage: $MYNAME [ -u | --unused SECTORS ] MOUNT-POINT"
25+}
26+
27+help() {
28+ usage
29+ cat << EOF
30+
31+Resizes the ext2/3/4 file-system at the specified MOUNT-POINT to the size of
32+the underlying block device, optionally leaving the specified number of
33+512-byte sectors unused at the end of the device. This is intended to make
34+later encapsulation of the file-system in LUKS easier to manage.
35+
36+Typically this tool must be run as root.
37+EOF
38+}
39+
40+main() {
41+ if ! parsed_args=$(getopt -n "$MYNAME" -o hu: --long help,unused: -- "$@"); then
42+ usage
43+ exit 1
44+ fi
45+
46+ unused=0
47+ eval set -- "$parsed_args"
48+ while :; do
49+ case "$1" in
50+ -s | --unused)
51+ unused="$2"
52+ shift 2
53+ ;;
54+ -h | --help)
55+ help
56+ exit 0
57+ ;;
58+ --)
59+ shift
60+ break
61+ ;;
62+ *)
63+ echo "Internal error: $1 unknown" >&2
64+ exit 63
65+ ;;
66+ esac
67+ done
68+ if [ "$#" -ne 1 ]; then
69+ usage
70+ exit 1
71+ fi
72+
73+ mount_point="$1"
74+ fstype=$(findmnt --output FSTYPE --noheadings "$mount_point")
75+ case "$fstype" in
76+ ext2|ext3|ext4)
77+ device=$(findmnt --output SOURCE --noheadings "$mount_point")
78+
79+ old_size=$(blockdev --getsz "$device") # sectors
80+ new_size=$((old_size - unused))
81+ resize2fs "$device" "$new_size"s
82+ ;;
83+ *)
84+ echo "Specified mount is not an ext file-system" >&2
85+ exit 1
86+ ;;
87+ esac
88+}
89+
90+main "$@"
91diff --git a/data/raspberrypi/growroot-almost.service b/data/raspberrypi/growroot-almost.service
92new file mode 100644
93index 0000000..478fdff
94--- /dev/null
95+++ b/data/raspberrypi/growroot-almost.service
96@@ -0,0 +1,16 @@
97+[Unit]
98+Description=Grow the root file-system, leaving 16MB space for LUKS headers
99+DefaultDependencies=no
100+Requires=local-fs.target
101+After=local-fs.target
102+Before=mkswap.service
103+ConditionPathExists=!/etc/growroot-grown
104+
105+[Service]
106+Type=oneshot
107+# 32768 512-sectors is 16MB
108+ExecStart=/usr/sbin/growroot-almost --unused 32768 /
109+ExecStartPost=touch /etc/growroot-grown
110+
111+[Install]
112+WantedBy=swap.target
113diff --git a/data/raspberrypi/meson.build b/data/raspberrypi/meson.build
114index a390c5e..5a0daeb 100644
115--- a/data/raspberrypi/meson.build
116+++ b/data/raspberrypi/meson.build
117@@ -1,6 +1,7 @@
118 etc = get_option('sysconfdir')
119 var_lib = get_option('sharedstatedir')
120 usr_share = get_option('datadir')
121+sbin = get_option('sbindir')
122
123 install_data('10-raspi-eth0.link',
124 install_dir: 'lib/systemd/network')
125@@ -16,3 +17,13 @@ install_data('raspi-zswap.conf',
126 install_dir: usr_share / 'initramfs-tools/modules.d')
127 install_data('99-fake-cloud.cfg',
128 install_dir: etc / 'cloud/cloud.cfg.d')
129+install_data('mkswap.service',
130+ install_dir: '/lib/systemd/system')
131+install_data('swapfile.swap',
132+ install_dir: '/lib/systemd/system')
133+install_data('01-use-network-manager.yaml',
134+ install_dir: etc / 'netplan')
135+install_data('growroot-almost',
136+ install_dir: sbin)
137+install_data('growroot-almost.service',
138+ install_dir: '/lib/systemd/system')
139diff --git a/data/raspberrypi/mkswap.service b/data/raspberrypi/mkswap.service
140new file mode 100644
141index 0000000..6fc4829
142--- /dev/null
143+++ b/data/raspberrypi/mkswap.service
144@@ -0,0 +1,16 @@
145+[Unit]
146+Description=Create the default swapfile
147+DefaultDependencies=no
148+Requires=local-fs.target
149+After=local-fs.target
150+Before=swapfile.swap
151+ConditionPathExists=!/swapfile
152+
153+[Service]
154+Type=oneshot
155+ExecStartPre=fallocate -l 1GiB /swapfile
156+ExecStartPre=chmod 600 /swapfile
157+ExecStart=mkswap /swapfile
158+
159+[Install]
160+WantedBy=swap.target
161diff --git a/data/raspberrypi/swapfile.swap b/data/raspberrypi/swapfile.swap
162new file mode 100644
163index 0000000..d52a3f6
164--- /dev/null
165+++ b/data/raspberrypi/swapfile.swap
166@@ -0,0 +1,8 @@
167+[Unit]
168+Description=The default swapfile
169+
170+[Swap]
171+What=/swapfile
172+
173+[Install]
174+WantedBy=swap.target
175diff --git a/debian/changelog b/debian/changelog
176index 27c9fa0..416d831 100644
177--- a/debian/changelog
178+++ b/debian/changelog
179@@ -1,3 +1,20 @@
180+ubuntu-settings (23.04.4) UNRELEASED; urgency=medium
181+
182+ [ Dave Jones ]
183+ * ubuntu-raspi-settings-desktop: migrated livecd-rootfs hacks that
184+ introduce mkswap.service and swapfile.swap (LP: #2004430)
185+ * ubuntu-raspi-settings-desktop: migrated netplan network-manager
186+ configuration (LP: #2004430)
187+ * ubuntu-raspi-settings-desktop: add growroot-almost service to expand
188+ root fs leaving 16MB slack for potential LUKS encapsulation (LP: #2013080)
189+ * Bump standards version to current (4.6.2)
190+
191+ [ William 'jawn-smith' Wilson ]
192+ * Add oem-config-setup to ubuntu-raspi-settings-desktop.postinst
193+ (LP: #2011722)
194+
195+ -- Dave Jones <dave.jones@canonical.com> Tue, 28 Mar 2023 13:48:22 +0100
196+
197 ubuntu-settings (23.04.3) lunar; urgency=medium
198
199 * gnome-initial-setup.desktop: Set StartupWMClass to fix app name & icon
200diff --git a/debian/control b/debian/control
201index 5735844..18486e5 100644
202--- a/debian/control
203+++ b/debian/control
204@@ -3,7 +3,7 @@ Section: x11
205 Priority: optional
206 Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>
207 Build-Depends: debhelper-compat (= 12), meson (>= 0.40.1), dh-translations
208-Standards-Version: 4.6.0.1
209+Standards-Version: 4.6.2
210 Vcs-Browser: https://git.launchpad.net/~ubuntu-desktop/ubuntu/+source/ubuntu-settings
211 Vcs-Git: https://git.launchpad.net/~ubuntu-desktop/ubuntu/+source/ubuntu-settings
212
213diff --git a/debian/rules b/debian/rules
214index 6c33aaa..2e1de50 100755
215--- a/debian/rules
216+++ b/debian/rules
217@@ -6,6 +6,11 @@
218 override_dh_missing:
219 dh_missing --fail-missing
220
221+override_dh_installsystemd:
222+ dh_installsystemd -pubuntu-raspi-settings-desktop --name=mkswap mkswap.service
223+ dh_installsystemd -pubuntu-raspi-settings-desktop --name=swapfile swapfile.swap
224+ dh_installsystemd -pubuntu-raspi-settings-desktop --name=growroot-almost growroot-almost.service
225+
226 override_dh_installgsettings:
227 dh_installgsettings -pubuntu-raspi-settings --priority 15
228 dh_installgsettings --remaining-packages
229diff --git a/debian/ubuntu-raspi-settings-desktop.install b/debian/ubuntu-raspi-settings-desktop.install
230index 6e4a375..6ec0480 100644
231--- a/debian/ubuntu-raspi-settings-desktop.install
232+++ b/debian/ubuntu-raspi-settings-desktop.install
233@@ -1,3 +1,8 @@
234 usr/share/initramfs-tools/modules.d/raspi-zswap.conf
235 var/lib/polkit-1/localauthority/10-vendor.d/disable-suspend.pkla
236 usr/lib/NetworkManager/conf.d/ZZraspi-wifi-powersave-off.conf
237+lib/systemd/system/mkswap.service
238+lib/systemd/system/swapfile.swap
239+etc/netplan/01-use-network-manager.yaml
240+usr/sbin/growroot-almost
241+lib/systemd/system/growroot-almost.service
242diff --git a/debian/ubuntu-raspi-settings-desktop.lintian-overrides b/debian/ubuntu-raspi-settings-desktop.lintian-overrides
243new file mode 100644
244index 0000000..a8b9ee3
245--- /dev/null
246+++ b/debian/ubuntu-raspi-settings-desktop.lintian-overrides
247@@ -0,0 +1,14 @@
248+# Yes, we actually want swap.target for the swap file, and for growing the
249+# root fs that contains the swap file...
250+systemd-service-file-refers-to-unusual-wantedby-target swap.target [lib/systemd/system/mkswap.service]
251+systemd-service-file-refers-to-unusual-wantedby-target swap.target [lib/systemd/system/growroot-almost.service]
252+
253+# We don't support any init-system other than systemd, and mkswap is a trivial
254+# oneshot service
255+package-supports-alternative-init-but-no-init.d-script [lib/systemd/system/mkswap.service]
256+systemd-service-file-missing-documentation-key [lib/systemd/system/mkswap.service]
257+
258+# growroot-almost is also an utterly trivial script (and service) that should
259+# only be run once
260+no-manual-page [usr/sbin/growroot-almost]
261+systemd-service-file-missing-documentation-key [lib/systemd/system/growroot-almost.service]
262diff --git a/debian/ubuntu-raspi-settings-desktop.postinst b/debian/ubuntu-raspi-settings-desktop.postinst
263new file mode 100644
264index 0000000..afe9b1b
265--- /dev/null
266+++ b/debian/ubuntu-raspi-settings-desktop.postinst
267@@ -0,0 +1,32 @@
268+#!/bin/sh
269+
270+set -e
271+
272+case "$1" in
273+ configure)
274+ # Unconditionally remove the obsolete (unpackaged) links activating the
275+ # (previously unpackaged) mkswap.service and swapfile.swap units. These
276+ # will instead be activated by dh_installsystemd creating links in
277+ # /etc/systemd/system/swap.target.wants (which is where they should be
278+ # rather than under /lib)
279+ rm -f \
280+ /lib/systemd/system/swap.target.wants/mkswap.service \
281+ /lib/systemd/system/swap.target.wants/swapfile.swap
282+ # Unconditionally remove the obsolete (unpackaged) netplan config file.
283+ # This isn't done with rm_conffile or conffiles because those both
284+ # refuse to work except on upgrade. We can't do it on upgrade to
285+ # another package (e.g. ubuntu-raspi-settings) either because the
286+ # "proper" methods both demand the prior version actually owned the
287+ # file being removed. So...
288+ rm -f /etc/netplan/01-network-manager-all.yaml
289+ # Set up oem-config to run on firstboot if and only if it hasn't
290+ # already run
291+ if [ ! -f "/var/log/oem-config.log" ] && ! id oem 2>/dev/null ; then
292+ useradd -d /home/oem -G adm,sudo -m -N -u 29999 oem
293+ oem-config-prepare --quiet
294+ touch "/var/lib/oem-config/run"
295+ fi
296+ ;;
297+esac
298+
299+#DEBHELPER#

Subscribers

People subscribed via source and target branches

to all changes: