Merge lp:~ev/partman-auto/overwrite into lp:~ubuntu-core-dev/partman-auto/ubuntu

Proposed by Evan
Status: Needs review
Proposed branch: lp:~ev/partman-auto/overwrite
Merge into: lp:~ubuntu-core-dev/partman-auto/ubuntu
Diff against target: 193 lines (+155/-0)
5 files modified
automatically_partition/_numbers (+1/-0)
automatically_partition/overwrite/choices (+72/-0)
automatically_partition/overwrite/do_option (+72/-0)
debian/changelog (+6/-0)
debian/partman-auto.templates (+4/-0)
To merge this branch: bzr merge lp:~ev/partman-auto/overwrite
Reviewer Review Type Date Requested Status
Ubuntu Installer Team Pending
Review via email: mp+41305@code.launchpad.net

Description of the change

Expose the home preservation path in automatic partitioning.

I'm not sure overwrite is the right word here. Perhaps reuse?

To post a comment you must log in.

Unmerged revisions

334. By Evan

Initial commit.

333. By Colin Watson

releasing version 93ubuntu1

332. By Colin Watson

sync up EFI recipes with changes from version 93

331. By Colin Watson

merge from Debian 93

330. By Colin Watson

Get memory size from /sys/firmware/memmap/* rather than using
dmi-available-memory, in line with current base-installer.

329. By Colin Watson

releasing version 91ubuntu4

328. By Colin Watson

Use /usr/lib/base-installer/dmi-available-memory if available to
determine memory size for RAM-dependent recipe elements (LP: #604765).

327. By Evan

releasing version 91ubuntu3

326. By Evan

Update template

325. By Evan

* Support resizing the largest partition on multiple disks.
* Support formatting the entire partition for any partition that can
  be resized.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'automatically_partition/_numbers'
2--- automatically_partition/_numbers 2006-11-23 12:07:01 +0000
3+++ automatically_partition/_numbers 2010-11-19 13:26:58 +0000
4@@ -1,4 +1,5 @@
5 10 resize_use_free
6+15 overwrite
7 20 some_device
8 50 biggest_free
9 80 custom
10
11=== added directory 'automatically_partition/overwrite'
12=== added file 'automatically_partition/overwrite/choices'
13--- automatically_partition/overwrite/choices 1970-01-01 00:00:00 +0000
14+++ automatically_partition/overwrite/choices 2010-11-19 13:26:58 +0000
15@@ -0,0 +1,72 @@
16+#!/bin/sh
17+
18+. /lib/partman/lib/base.sh
19+
20+set -e
21+
22+cleanup_ro_partitions=
23+mountpoint="$(mktemp -d /tmp/partman-auto.XXXXXX)"
24+cleanup () {
25+ # Just in case ...
26+ set +e
27+ umount $mountpoint
28+ rm -rf $mountpoint
29+ for p in $cleanup_ro_partitions; do
30+ blockdev --setrw $p
31+ done
32+}
33+trap cleanup EXIT HUP INT QUIT TERM
34+
35+overwrite=
36+disks=
37+if db_get partman-auto/disk; then
38+ disks="$RET"
39+fi
40+for dev in $DEVICES/*; do
41+ [ -d $dev ] || continue
42+ if [ "$disks" ]; then
43+ partman_disk="$(cat "$dev/device")"
44+ local found=0
45+ for preseed_disk in $disks; do
46+ preseed_id=$(mapdevfs $preseed_disk)
47+ case " $preseed_id " in
48+ *" $partman_disk "*)
49+ found=1
50+ ;;
51+ *)
52+ continue
53+ ;;
54+ esac
55+ done
56+ if [ "$found" = "0" ]; then
57+ continue
58+ fi
59+ fi
60+ cd $dev
61+ open_dialog PARTITIONS
62+ while { read_line num id size type fs path name; [ "$id" ]; }; do
63+ # TODO Run under newns
64+ # Reuse fstab mounts in do_option? Wont already be written
65+ # because we'll be deleting fstab?
66+ part=$dev//$id
67+ blockdev --setro $path
68+ cleanup_ro_partitions="$cleanup_ro_partitions $path"
69+ t="$(blkid -o value -s TYPE $path)"
70+ if [ -n "$t" ] && [ "$t" != "swap" ] && \
71+ mount $path $mountpoint 3>&-; then
72+ release="$(grep -s DISTRIB_ID $mountpoint/etc/lsb-release)"
73+ umount $path || true
74+ if [ "${release##DISTRIB_ID=}" = "Ubuntu" ]; then
75+ db_subst partman-auto/text/overwrite PARTITION "$(humandev "$path")"
76+ db_metaget partman-auto/text/overwrite description
77+ overwrite="$overwrite$NL$part$TAB$RET"
78+ fi
79+ fi
80+ blockdev --setrw $path
81+ done
82+ close_dialog
83+done
84+
85+if [ "$overwrite" ]; then
86+ printf %s "$overwrite"
87+fi
88
89=== added file 'automatically_partition/overwrite/do_option'
90--- automatically_partition/overwrite/do_option 1970-01-01 00:00:00 +0000
91+++ automatically_partition/overwrite/do_option 2010-11-19 13:26:58 +0000
92@@ -0,0 +1,72 @@
93+#!/bin/sh
94+
95+set -e
96+
97+. /lib/partman/lib/base.sh
98+
99+dev=${1%//*}
100+id=${1#*//}
101+
102+cd $dev
103+
104+setup_reuse_partition () {
105+ echo keep > $1/method
106+ cp $1/detected_filesystem $1/filesystem
107+ mkdir -p $1/options
108+ rm -f $1/format
109+ >$1/use_filesystem
110+}
111+
112+path=
113+cleanup () {
114+ set +e
115+ umount $path && rm -rf $mountpoint
116+ blockdev --setrw $path
117+}
118+
119+setup_reuse_partition $id
120+echo / > $id/mountpoint
121+update_partition $dev $id
122+
123+open_dialog PARTITION_INFO $id
124+read_line num i size type fs path name
125+close_dialog
126+mountpoint="$(mktemp -d /tmp/partman-auto.XXXXXX)"
127+blockdev --setro $path
128+mount $path $mountpoint 3>&-
129+trap cleanup EXIT HUP INT QUIT TERM
130+
131+if [ -f "$mountpoint/etc/fstab" ]; then
132+ while read uuid mp rest; do
133+ if [ "${uuid%=*}" != "UUID" ]; then
134+ continue
135+ fi
136+ uuid="${uuid#*=}"
137+ if [ ! -e "/dev/disk/by-uuid/$uuid" ]; then
138+ continue
139+ fi
140+
141+ for dev in $DEVICES/*; do
142+ cd $dev
143+ open_dialog PARTITIONS
144+ partitions=$(read_paragraph)
145+ close_dialog
146+ echo "$partitions" |
147+ while { read num i size type fs p name; [ "$i" ]; }; do
148+ if [ "$(cat $i/detected_filesystem)" = "linux-swap" ]; then
149+ # Swap will be automatically used.
150+ continue
151+ fi
152+ u="$(blkid -o value -s UUID $p)"
153+ if [ "$uuid" = "$u" ]; then
154+ setup_reuse_partition $i
155+ echo "$mp" > $i/mountpoint
156+ update_partition $dev $i
157+ break
158+ fi
159+ done
160+ done
161+ done < "$mountpoint/etc/fstab"
162+fi
163+
164+exit 100
165
166=== modified file 'debian/changelog'
167--- debian/changelog 2010-10-21 16:15:32 +0000
168+++ debian/changelog 2010-11-19 13:26:58 +0000
169@@ -1,3 +1,9 @@
170+partman-auto (93ubuntu2) UNRELEASED; urgency=low
171+
172+ * Add an option to overwrite an existing installation.
173+
174+ -- Evan Dandrea <evand@ubuntu.com> Wed, 10 Nov 2010 11:03:48 +0000
175+
176 partman-auto (93ubuntu1) natty; urgency=low
177
178 * Resynchronise with Debian. Remaining changes:
179
180=== modified file 'debian/partman-auto.templates'
181--- debian/partman-auto.templates 2010-07-12 18:17:52 +0000
182+++ debian/partman-auto.templates 2010-11-19 13:26:58 +0000
183@@ -175,6 +175,10 @@
184 Type: text
185 _Description: Guided - use entire partition, ${PARTITION}
186
187+Template: partman-auto/text/overwrite
188+Type: text
189+_Description: Guided - overwrite partition, ${PARTITION}
190+
191 Template: partman-auto/resize_insufficient_space
192 Type: error
193 _Description: Failed to create enough space for installation

Subscribers

People subscribed via source and target branches