Merge lp:~smoser/maas-images/trunk.disable-kernel-hooks into lp:maas-images

Proposed by Scott Moser
Status: Merged
Merged at revision: 387
Proposed branch: lp:~smoser/maas-images/trunk.disable-kernel-hooks
Merge into: lp:maas-images
Diff against target: 46 lines (+24/-0)
1 file modified
bin/maas-cloudimg2ephemeral (+24/-0)
To merge this branch: bzr merge lp:~smoser/maas-images/trunk.disable-kernel-hooks
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+336051@code.launchpad.net

Commit message

stop grub scripts from running when upgrading an image.

An upgrade that brought a new kernel would cause grub's' kernel
hook scripts to run. Those would fail to run and cause failure
(at least in trusty). This is similar to code that is currently
in the kpack-from-image, but handles putting things back more elegantly.
(kpack-from-image doesn't have to put things back).

I found this when running with '--proposed'.

To post a comment you must log in.
388. By Scott Moser

cleanup a bit and add debug

389. By Scott Moser

check taht it exists.

Revision history for this message
Lee Trager (ltrager) wrote :

LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/maas-cloudimg2ephemeral'
2--- bin/maas-cloudimg2ephemeral 2017-05-05 15:19:06 +0000
3+++ bin/maas-cloudimg2ephemeral 2018-01-17 20:00:58 +0000
4@@ -42,6 +42,7 @@
5
6 VERBOSITY=0
7 TOP_D="${0%/*}"
8+DISABLE_SUFFIX=".eph-temp-disabled"
9 command -v unshare-pidns >/dev/null 2>&1 || PATH="${0%/*}:$PATH"
10
11 error() { echo "$@" 1>&2; }
12@@ -88,11 +89,34 @@
13 EOF
14 [ $? -eq 0 ] && chmod 755 "$dir/usr/sbin/policy-rc.d" ||
15 { error "failed to write policy-rc.d"; return 1; }
16+
17+ ( set -e;
18+ cd "$dir"
19+ for f in ./etc/kernel/*.d/*-grub; do
20+ [ -x "$f" ] || continue
21+ abs=${f#.}
22+ debug 2 "Disabling $abs via dpkg-divert rename"
23+ chroot "$dir" dpkg-divert --local --rename --divert \
24+ "${abs}${DISABLE_SUFFIX}" "${abs}"
25+ done
26+ )
27 }
28
29 undisable_services() {
30 local dir="$1"
31 rm -f "$dir/usr/sbin/policy-rc.d"
32+
33+ ( set -e;
34+ cd "$dir"
35+ for f in ./etc/kernel/*.d/*${DISABLE_SUFFIX}; do
36+ [ -e "$f" ] || continue
37+ abs=${f#.}
38+ orig=${abs%${DISABLE_SUFFIX}}
39+ debug 2 "Re-enabling $orig via dpkg-divert removal."
40+ chroot "$dir" dpkg-divert --local --remove --rename --divert \
41+ "${abs}" "${orig}"
42+ done
43+ )
44 }
45
46 check_required_vars() {

Subscribers

People subscribed via source and target branches