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
=== modified file 'bin/maas-cloudimg2ephemeral'
--- bin/maas-cloudimg2ephemeral 2017-05-05 15:19:06 +0000
+++ bin/maas-cloudimg2ephemeral 2018-01-17 20:00:58 +0000
@@ -42,6 +42,7 @@
4242
43VERBOSITY=043VERBOSITY=0
44TOP_D="${0%/*}"44TOP_D="${0%/*}"
45DISABLE_SUFFIX=".eph-temp-disabled"
45command -v unshare-pidns >/dev/null 2>&1 || PATH="${0%/*}:$PATH"46command -v unshare-pidns >/dev/null 2>&1 || PATH="${0%/*}:$PATH"
4647
47error() { echo "$@" 1>&2; }48error() { echo "$@" 1>&2; }
@@ -88,11 +89,34 @@
88EOF89EOF
89 [ $? -eq 0 ] && chmod 755 "$dir/usr/sbin/policy-rc.d" ||90 [ $? -eq 0 ] && chmod 755 "$dir/usr/sbin/policy-rc.d" ||
90 { error "failed to write policy-rc.d"; return 1; }91 { error "failed to write policy-rc.d"; return 1; }
92
93 ( set -e;
94 cd "$dir"
95 for f in ./etc/kernel/*.d/*-grub; do
96 [ -x "$f" ] || continue
97 abs=${f#.}
98 debug 2 "Disabling $abs via dpkg-divert rename"
99 chroot "$dir" dpkg-divert --local --rename --divert \
100 "${abs}${DISABLE_SUFFIX}" "${abs}"
101 done
102 )
91}103}
92104
93undisable_services() {105undisable_services() {
94 local dir="$1"106 local dir="$1"
95 rm -f "$dir/usr/sbin/policy-rc.d"107 rm -f "$dir/usr/sbin/policy-rc.d"
108
109 ( set -e;
110 cd "$dir"
111 for f in ./etc/kernel/*.d/*${DISABLE_SUFFIX}; do
112 [ -e "$f" ] || continue
113 abs=${f#.}
114 orig=${abs%${DISABLE_SUFFIX}}
115 debug 2 "Re-enabling $orig via dpkg-divert removal."
116 chroot "$dir" dpkg-divert --local --remove --rename --divert \
117 "${abs}" "${orig}"
118 done
119 )
96}120}
97121
98check_required_vars() {122check_required_vars() {

Subscribers

People subscribed via source and target branches