Merge lp:~smoser/curtin/trunk.install-kernel-fix into lp:~curtin-dev/curtin/trunk

Proposed by Scott Moser
Status: Merged
Approved by: Scott Moser
Approved revision: 328
Merge reported by: Scott Moser
Merged at revision: not available
Proposed branch: lp:~smoser/curtin/trunk.install-kernel-fix
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 33 lines (+12/-8)
1 file modified
curtin/commands/curthooks.py (+12/-8)
To merge this branch: bzr merge lp:~smoser/curtin/trunk.install-kernel-fix
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
curtin developers Pending
Review via email: mp+280999@code.launchpad.net

Commit message

fix logic error in kernel installation

If a kernel package was available but not installed
the code would use the fallback path, rather than installing it.

This fixes the logic error and uses 'has_pkg_available'.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

Do we have unittest for this? Would be a nice add.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'curtin/commands/curthooks.py'
2--- curtin/commands/curthooks.py 2015-12-17 18:25:51 +0000
3+++ curtin/commands/curthooks.py 2015-12-18 20:54:06 +0000
4@@ -188,17 +188,21 @@
5 package = "linux-{flavor}{map_suffix}".format(
6 flavor=flavor, map_suffix=map_suffix)
7
8- util.apt_update(target)
9- out, err = in_chroot(['apt-cache', 'search', package], capture=True)
10-
11- if (len(out.strip()) > 0 and
12- not util.has_pkg_installed(package, target)):
13- util.install_packages([package], target=target)
14+ if util.has_pkg_available(package, target):
15+ if util.has_pkg_installed(package, target):
16+ LOG.debug("Kernel package '%s' already installed", package)
17+ else:
18+ LOG.debug("installing kernel package '%s'", package)
19+ util.install_packages([package], target=target)
20 else:
21- LOG.warn("Tried to install kernel %s but package not found."
22- % package)
23 if kernel_fallback is not None:
24+ LOG.info("Kernel package '%s' not available. "
25+ "Installing fallback package '%s'.",
26+ package, kernel_fallback)
27 util.install_packages([kernel_fallback], target=target)
28+ else:
29+ LOG.warn("Kernel package '%s' not available and no fallback."
30+ " System may not boot.", package)
31
32
33 def apply_debconf_selections(cfg, target):

Subscribers

People subscribed via source and target branches