Merge lp:~jamiebennett/casper/debconf-speedup-work into lp:casper

Proposed by Jamie Bennett
Status: Merged
Merge reported by: Stéphane Graber
Merged at revision: not available
Proposed branch: lp:~jamiebennett/casper/debconf-speedup-work
Merge into: lp:casper
Diff against target: 380 lines (+191/-26) (has conflicts)
12 files modified
bin/casper-preseed (+13/-6)
bin/casper-set-selections (+92/-0)
debian/casper.install (+1/-0)
debian/changelog (+13/-0)
debian/copyright (+10/-0)
hooks/casper (+1/-0)
scripts/casper (+28/-0)
scripts/casper-bottom/10adduser (+11/-14)
scripts/casper-bottom/22sslcert (+1/-0)
scripts/casper-bottom/24preseed (+9/-5)
scripts/casper-bottom/45disable_guest_account (+1/-1)
scripts/casper-functions (+11/-0)
Text conflict in debian/changelog
Text conflict in scripts/casper-bottom/24preseed
To merge this branch: bzr merge lp:~jamiebennett/casper/debconf-speedup-work
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+18561@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jamie Bennett (jamiebennett) wrote :

Investigations into speeding up the casper boot process revealed that a significant proportion of time was spent in debconf-communicate calls. To solve this, one persistent debconf-communicate call is made with subsequent scripts using the confmodule approach.

Also in this branch is a quicker way to disable the guest user account.

Revision history for this message
Colin Watson (cjwatson) wrote :

You have two sets of merge conflicts in here (I'm surprised bzr let you commit those without some effort, actually). Could you please resolve them?

review: Needs Fixing
Revision history for this message
Colin Watson (cjwatson) wrote :

Also, the version number should be 1.212 rather than 1.211ubuntu1 - and since this is associated with a bug report, it would be best to close that in the changelog in the usual way.

Revision history for this message
James Westby (james-w) wrote :

On Wed, 03 Feb 2010 23:38:26 -0000, Colin Watson <email address hidden> wrote:
> Review: Needs Fixing
> You have two sets of merge conflicts in here (I'm surprised bzr let you commit those without some effort, actually). Could you please resolve them?

The diff it is showing is the diff that would result if you did the
merge, so are the conflicts just conflicts between this branch and the
target?

Thanks,

James

Revision history for this message
Colin Watson (cjwatson) wrote :

Yes, you're right. Sorry about that. I'll merge this now, then.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/casper-preseed'
2--- bin/casper-preseed 2006-10-16 15:05:58 +0000
3+++ bin/casper-preseed 2010-02-03 20:58:09 +0000
4@@ -2,18 +2,25 @@
5 set -e
6 PATH=/usr/sbin:/usr/bin:/sbin:/bin
7
8+# Only do this once.
9+if [ -z "$DEBCONF_REDIR" ]; then
10+ exec <&4
11+ export DEBIAN_HAS_FRONTEND=1
12+ export DEBCONF_REDIR=1
13+fi
14+
15 root="$1"
16+. "$root/usr/share/debconf/confmodule"
17+
18 question="$2"
19 value="$3"
20 seen="$4"
21 [ "$seen" ] || seen=true
22
23-if ! (echo "SET $question $value"; echo "FSET $question seen $seen") | chroot "$1" debconf-communicate -fnoninteractive casper >/dev/null; then
24- chroot "$1" debconf-communicate -fnoninteractive casper >/dev/null <<EOF
25-REGISTER debian-installer/dummy $question
26-SET $question $value
27-FSET $question seen $seen
28-EOF
29+if ! db_set "$question" "$value"; then
30+ db_register debian-installer/dummy "$question"
31+ db_set "$question" "$value"
32 fi
33+db_fset "$question" seen "$seen"
34
35 exit 0
36
37=== added file 'bin/casper-set-selections'
38--- bin/casper-set-selections 1970-01-01 00:00:00 +0000
39+++ bin/casper-set-selections 2010-02-03 20:58:09 +0000
40@@ -0,0 +1,92 @@
41+#!/bin/sh
42+# Cloned-and-hacked from preseed/debconf-set-selections for casper.
43+set -e
44+
45+OLDIFS="$IFS"
46+CR=$(echo -en "\r")
47+NL="
48+"
49+
50+. /scripts/casper-functions
51+load_confmodule
52+
53+# Returns the first field in the current line
54+first_field() {
55+ echo "$line" | grep -q "[[:space:]]" || return 1
56+ echo "$line" | sed -r 's/^([^[:space:]]*).*/\1/'
57+}
58+
59+# Returns any fields after the first field in the current line
60+rest_line() {
61+ if echo "$line" | grep -q "[[:space:]]"; then
62+ echo "$line" | sed 's/^[^[:space:]]*[[:space:]]*//'
63+ fi
64+}
65+
66+SEEN=1
67+if [ "$1" = --unseen ]; then
68+ SEEN=
69+ shift
70+fi
71+
72+file="$1"
73+
74+parse_error() {
75+ echo "Error parsing preconfiguration file: $*" >&2
76+ exit 1
77+}
78+
79+IFS="$NL"
80+multiline=""
81+# TODO: this squashes \r elsewhere in the line too
82+for line in $(grep -v '^#\|^[[:space:]]*$' "$file" | sed "s/$CR//g"); do
83+ IFS="$OLDIFS"
84+
85+ line="$(echo "$line" | sed 's/^[[:space:]]*//')"
86+ if echo "$line" | grep -q '\\$'; then
87+ multiline="${multiline:+$multiline }$(echo "$line" | \
88+ sed 's/[[:space:]]*\\$//')"
89+ continue
90+ elif [ -n "$multiline" ]; then
91+ line="$multiline $line"
92+ multiline=""
93+ fi
94+
95+ package=""
96+ var=""
97+ type=""
98+ val=""
99+ if ! package="$(first_field)"; then
100+ parse_error "Syntax error: unable to determine template owner"
101+ fi
102+ line="$(rest_line)"
103+ if ! var="$(first_field)"; then
104+ parse_error "Syntax error: unable to determine template name"
105+ fi
106+ line="$(rest_line)"
107+ if ! type="$(first_field)"; then
108+ # Allow for lines without separator before an empty value
109+ if [ "$line" ]; then
110+ type="$line"
111+ else
112+ parse_error "Syntax error: unable to determine template type"
113+ fi
114+ fi
115+ line="$(rest_line)"
116+ val="$line"
117+
118+ if [ "$type" = seen ]; then
119+ # Set seen flag.
120+ db_fset "$var" "$type" "$val" || true # how to handle this error?
121+ else
122+ if ! db_set "$var" "$val"; then
123+ # Question does not exist yet.
124+ db_register debian-installer/dummy "$var"
125+ db_set "$var" "$val"
126+ db_subst "$var" ID "$var"
127+ fi
128+ if [ "$SEEN" ]; then
129+ db_fset "$var" seen true
130+ fi
131+ fi
132+done
133
134=== modified file 'debian/casper.install'
135--- debian/casper.install 2009-09-23 14:21:43 +0000
136+++ debian/casper.install 2010-02-03 20:58:09 +0000
137@@ -3,6 +3,7 @@
138 bin/casper-new-uuid sbin
139 bin/casper-preseed usr/share/casper
140 bin/casper-reconfigure usr/share/casper
141+bin/casper-set-selections usr/share/casper
142 bin/casper-snapshot sbin
143 hooks usr/share/initramfs-tools
144 scripts usr/share/initramfs-tools
145
146=== modified file 'debian/changelog'
147--- debian/changelog 2010-01-27 13:56:03 +0000
148+++ debian/changelog 2010-02-03 20:58:09 +0000
149@@ -1,3 +1,4 @@
150+<<<<<<< TREE
151 casper (1.211) UNRELEASED; urgency=low
152
153 [ Mario Limonciello ]
154@@ -12,6 +13,18 @@
155
156 -- Jonathan Riddell <jriddell@ubuntu.com> Wed, 27 Jan 2010 13:55:42 +0000
157
158+=======
159+casper (1.211ubuntu1) lucid; urgency=low
160+
161+ * Speed up work around debconf-communicate. Replace several calls to
162+ debconf-communicate with one persistent invocation followed by
163+ confmodule calls.
164+ * Disable guest account by rm'ing rather than waiting for dpkg to
165+ remove it.
166+
167+ -- Jamie Bennett <jamie@linuxuk.org> Wed, 03 Feb 2010 12:37:53 -0800
168+
169+>>>>>>> MERGE-SOURCE
170 casper (1.210) lucid; urgency=low
171
172 [ Scott James Remnant ]
173
174=== modified file 'debian/copyright'
175--- debian/copyright 2009-01-13 18:56:31 +0000
176+++ debian/copyright 2010-02-03 20:58:09 +0000
177@@ -28,6 +28,16 @@
178 3. This notice may not be removed or altered from any source
179 distribution.
180
181+License (bin/casper-set-selections):
182+
183+ The Debian installer preseeder is copyright 2004 by Joey Hess
184+ <joeyh@debian.org> and others.
185+
186+ This program is free software; you can redistribute it and/or modify
187+ it under the terms of the GNU General Public License as published by
188+ the Free Software Foundation; either version 2 of the License, or
189+ (at your option) any later version.
190+
191 License (everything else):
192
193 Copyright (C) 2006 Marco Amadori <marco.amadori@gmail.com>
194
195=== modified file 'hooks/casper'
196--- hooks/casper 2009-05-23 22:30:56 +0000
197+++ hooks/casper 2010-02-03 20:58:09 +0000
198@@ -33,6 +33,7 @@
199 mkdir -p ${DESTDIR}/lib/casper
200 copy_exec /usr/share/casper/casper-reconfigure /bin
201 copy_exec /usr/share/casper/casper-preseed /bin
202+copy_exec /usr/share/casper/casper-set-selections /bin
203
204 mkdir -p ${DESTDIR}/lib/udev
205 copy_exec /lib/udev/cdrom_id /lib/udev
206
207=== modified file 'scripts/casper'
208--- scripts/casper 2009-10-06 12:07:52 +0000
209+++ scripts/casper 2010-02-03 20:58:09 +0000
210@@ -651,6 +651,27 @@
211 mount -n -o bind /dev "${rootmnt}/dev"
212 fi
213
214+ # Open up two fifo's fd's for debconf-communicate to use. Speeds up
215+ # the Casper process considerably.
216+ log_begin_msg "Creating debconf-communicate fifo mechanism"
217+ mkfifo /tmp/debconf-in.fifo
218+ mkfifo /tmp/debconf-out.fifo
219+
220+ chroot /root debconf-communicate -fnoninteractive casper > /tmp/debconf-out.fifo < /tmp/debconf-in.fifo &
221+
222+ # Save the PID so it can be killed later.
223+ DEBCONF_COMMUNICATE_PID="$!"
224+
225+ if [ ! -p /tmp/debconf-in.fifo ] || [ ! -p /tmp/debconf-out.fifo ]; then
226+ log_warning_msg "failed to setup debconf-communicate channel"
227+ fi
228+ log_end_msg
229+
230+ # Order matters!
231+ # These file descriptors must stay open until we're finished with
232+ # debconf-communicate.
233+ exec 4</tmp/debconf-out.fifo 3>/tmp/debconf-in.fifo
234+
235 maybe_break casper-bottom
236 [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-bottom"
237
238@@ -661,6 +682,13 @@
239 umount "${rootmnt}/dev"
240 fi
241
242+ # Kill the debconf-communicate instance and close fd's associated with
243+ # debconf-communicate.
244+ kill $DEBCONF_COMMUNICATE_PID
245+ exec 3>&- 4>&-
246+ rm -f /tmp/debconf-in.fifo
247+ rm -f /tmp/debconf-out.fifo
248+
249 exec 1>&6 6>&-
250 exec 2>&7 7>&-
251 kill "$tailpid"
252
253=== modified file 'scripts/casper-bottom/10adduser'
254--- scripts/casper-bottom/10adduser 2010-01-05 16:54:40 +0000
255+++ scripts/casper-bottom/10adduser 2010-02-03 20:58:09 +0000
256@@ -17,28 +17,25 @@
257 esac
258
259 . /scripts/casper-functions
260+load_confmodule
261
262 log_begin_msg "$DESCRIPTION"
263
264 # U6aMy0wojraho is just a blank password
265-chroot /root debconf-communicate -fnoninteractive casper > /dev/null <<EOF
266-set passwd/root-password-crypted *
267-set passwd/user-password-crypted U6aMy0wojraho
268-set passwd/user-fullname $USERFULLNAME
269-set passwd/username $USERNAME
270-set passwd/user-uid 999
271-EOF
272+db_set passwd/root-password-crypted '*'
273+db_set passwd/user-password-crypted U6aMy0wojraho
274+db_set passwd/user-fullname "$USERFULLNAME"
275+db_set passwd/username "$USERNAME"
276+db_set passwd/user-uid 999
277
278 chroot /root /usr/lib/user-setup/user-setup-apply > /dev/null
279
280 # Clear out debconf database again to avoid confusing ubiquity later.
281-chroot /root debconf-communicate -fnoninteractive casper > /dev/null <<EOF
282-set passwd/root-password-crypted
283-set passwd/user-password-crypted
284-set passwd/user-fullname
285-set passwd/username
286-set passwd/user-uid
287-EOF
288+db_set passwd/root-password-crypted
289+db_set passwd/user-password-crypted
290+db_set passwd/user-fullname
291+db_set passwd/username
292+db_set passwd/user-uid
293
294 if [ -f /root/etc/sudoers ]; then
295 if [ "${BUILD_SYSTEM}" = "Ubuntu" ]; then
296
297=== modified file 'scripts/casper-bottom/22sslcert'
298--- scripts/casper-bottom/22sslcert 2010-01-05 16:54:40 +0000
299+++ scripts/casper-bottom/22sslcert 2010-02-03 20:58:09 +0000
300@@ -17,6 +17,7 @@
301 esac
302
303 . /scripts/casper-functions
304+load_confmodule
305
306 log_begin_msg "$DESCRIPTION"
307
308
309=== modified file 'scripts/casper-bottom/24preseed'
310--- scripts/casper-bottom/24preseed 2010-01-20 23:33:29 +0000
311+++ scripts/casper-bottom/24preseed 2010-02-03 20:58:09 +0000
312@@ -17,11 +17,12 @@
313 esac
314
315 . /scripts/casper-functions
316+load_confmodule
317
318 log_begin_msg "$DESCRIPTION"
319
320 if [ -e /preseed.cfg ]; then
321- chroot /root debconf-set-selections < /preseed.cfg
322+ casper-set-selections /preseed.cfg
323 fi
324
325 locations=
326@@ -64,16 +65,19 @@
327 esac
328 done
329
330+<<<<<<< TREE
331 if [ "$locations" ]; then
332 for item in $locations; do
333 chroot /root debconf-set-selections < "/root$item"
334 done
335+=======
336+if [ "$location" ]; then
337+ casper-set-selections "/root$location"
338+>>>>>>> MERGE-SOURCE
339 fi
340
341-reply="$(echo "GET preseed/early_command" | chroot /root debconf-communicate -fnoninteractive casper)"
342-if [ "${reply#0 }" != "$reply" ]; then
343- reply="${reply#0 }"
344- sh -c "$reply"
345+if db_get preseed/early_command && [ "$RET" ]; then
346+ sh -c "$RET"
347 fi
348
349 # Clear out debconf database backup files to save memory.
350
351=== modified file 'scripts/casper-bottom/45disable_guest_account'
352--- scripts/casper-bottom/45disable_guest_account 2010-01-05 16:54:40 +0000
353+++ scripts/casper-bottom/45disable_guest_account 2010-02-03 20:58:09 +0000
354@@ -20,6 +20,6 @@
355
356 log_begin_msg "$DESCRIPTION"
357
358-chroot /root dpkg -P gdm-guest-session || true
359+chroot /root rm -r /usr/share/gdm/guest-session
360
361 log_end_msg
362
363=== modified file 'scripts/casper-functions'
364--- scripts/casper-functions 2008-09-18 23:39:20 +0000
365+++ scripts/casper-functions 2010-02-03 20:58:09 +0000
366@@ -39,3 +39,14 @@
367 echo "C"
368 fi
369 }
370+
371+load_confmodule() {
372+ # Only do this once.
373+ if [ -z "$DEBCONF_REDIR" ]; then
374+ exec <&4
375+ export DEBIAN_HAS_FRONTEND=1
376+ export DEBCONF_REDIR=1
377+ fi
378+
379+ . /root/usr/share/debconf/confmodule
380+}

Subscribers

People subscribed via source and target branches