summaryrefslogtreecommitdiff
path: root/morphlib/builder2.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-07-26 11:36:20 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-07-26 12:03:36 +0100
commit5300fdafdf891de473529c1bec618d5d3f88fa59 (patch)
tree23bbcce148971f715420ac51d4f30509194f78ff /morphlib/builder2.py
parente20f9de6e4235d7ab2087031d405827253faeccb (diff)
downloadmorph-5300fdafdf891de473529c1bec618d5d3f88fa59.tar.gz
Refactor: move kernel artifact creation into base class
Diffstat (limited to 'morphlib/builder2.py')
-rw-r--r--morphlib/builder2.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index 83f5ae84..5820dc44 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -550,6 +550,25 @@ class SystemKindBuilder(BuilderBase): # pragma: no cover
f.write('sysfs /sys sysfs defaults 0 0\n')
f.write('/dev/sda1 / btrfs defaults,rw,noatime 0 1\n')
+ def copy_kernel_into_artifact_cache(self, path):
+ '''Copy the installed kernel image into the local artifact cache.
+
+ The kernel image will be a separate artifact from the root
+ filesystem/disk image/whatever. This is sometimes useful with
+ funky bootloaders or virtualisation.
+
+ '''
+
+ name = self.artifact.source.morphology['name']+'-kernel'
+ a = self.new_artifact(name)
+ with self.local_artifact_cache.put(a) as dest:
+ for basename in ['zImage', 'vmlinuz']:
+ installed_path = os.path.join(path, 'boot', basename)
+ if os.path.exists(installed_path):
+ with open(installed_path) as kernel:
+ shutil.copyfileobj(kernel, dest)
+ break
+
class SystemKindBuilderFactory(object): # pragma: no cover