summaryrefslogtreecommitdiff
path: root/extensions/writeexts.py
diff options
context:
space:
mode:
authorJames Thomas <james.thomas@codethink.co.uk>2016-01-12 15:04:14 +0000
committerBaserock Gerrit <gerrit@baserock.org>2016-02-25 17:41:30 +0000
commitfd393b16341e467d07cde0259c335aadc5c4caea (patch)
tree520abde4cd446b8c349ec7ac03395115a2cb26d8 /extensions/writeexts.py
parent4e8e32e58a38b1497b59de25ab7bc7273f2e8e04 (diff)
downloaddefinitions-fd393b16341e467d07cde0259c335aadc5c4caea.tar.gz
Split creation of the bootloader config/install into separate function
This will allow us to use the existing btfs layout function on other partitions (namely /boot) Change-Id: I6d43e6eb25c263f7c18eb06b96fa6076483f8e67
Diffstat (limited to 'extensions/writeexts.py')
-rw-r--r--extensions/writeexts.py74
1 files changed, 46 insertions, 28 deletions
diff --git a/extensions/writeexts.py b/extensions/writeexts.py
index f356a34a..93f67433 100644
--- a/extensions/writeexts.py
+++ b/extensions/writeexts.py
@@ -305,6 +305,10 @@ class WriteExtension(Extension):
self.create_btrfs_system_layout(
temp_root, mp, version_label='factory',
rootfs_uuid=self.get_uuid(raw_disk))
+ if self.bootloader_config_is_wanted():
+ self.create_bootloader_config(
+ temp_root, mp, version_label='factory',
+ rootfs_uuid=self.get_uuid(raw_disk))
except BaseException as e:
sys.stderr.write('Error creating Btrfs system layout')
raise
@@ -435,11 +439,17 @@ class WriteExtension(Extension):
'''Separate base OS versions from state using subvolumes.
'''
- initramfs = self.find_initramfs(temp_root)
version_root = os.path.join(mountpoint, 'systems', version_label)
- state_root = os.path.join(mountpoint, 'state')
os.makedirs(version_root)
+ os.symlink(
+ version_label, os.path.join(mountpoint, 'systems', 'default'))
+
+ # Only do the next step if the device is actually btrfs
+ if device and device.filesystem is not 'btrfs':
+ return
+
+ state_root = os.path.join(mountpoint, 'state')
os.makedirs(state_root)
system_dir = self.create_orig(version_root, temp_root)
@@ -451,35 +461,40 @@ class WriteExtension(Extension):
self.create_run(version_root)
- os.symlink(
- version_label, os.path.join(mountpoint, 'systems', 'default'))
+ if device:
+ self.create_partition_mountpoints(device, system_dir)
- if self.bootloader_config_is_wanted():
- self.install_kernel(version_root, temp_root)
- if self.get_dtb_path() != '':
- self.install_dtb(version_root, temp_root)
- self.install_syslinux_menu(mountpoint, version_root)
- if initramfs is not None:
- # Using initramfs - can boot a rootfs with a filesystem UUID
- self.install_initramfs(initramfs, version_root)
+ def create_bootloader_config(self, temp_root, mountpoint, version_label,
+ rootfs_uuid, device=None):
+ '''Setup the bootloader.
+
+ '''
+ initramfs = self.find_initramfs(temp_root)
+ version_root = os.path.join(mountpoint, 'systems', version_label)
+ system_dir = os.path.join(version_root, 'orig')
+
+ self.install_kernel(version_root, temp_root)
+ if self.get_dtb_path() != '':
+ self.install_dtb(version_root, temp_root)
+ self.install_syslinux_menu(mountpoint, version_root)
+ if initramfs is not None:
+ # Using initramfs - can boot a rootfs with a filesystem UUID
+ self.install_initramfs(initramfs, version_root)
+ self.generate_bootloader_config(mountpoint,
+ rootfs_uuid=rootfs_uuid)
+ else:
+ if device:
+ # A partitioned disk or image - boot with partition UUID
+ root_part = device.get_partition_by_mountpoint('/')
+ root_guid = device.get_partition_uuid(root_part)
self.generate_bootloader_config(mountpoint,
- rootfs_uuid=rootfs_uuid)
+ root_guid=root_guid)
+ if self.get_bootloader_install() == 'extlinux':
+ self.install_syslinux_blob(device, system_dir)
else:
- if device:
- # A partitioned disk or image - boot with partition UUID
- root_part = device.get_partition_by_mountpoint('/')
- root_guid = device.get_partition_uuid(root_part)
- self.generate_bootloader_config(mountpoint,
- root_guid=root_guid)
- if self.get_bootloader_install() == 'extlinux':
- self.install_syslinux_blob(device, system_dir)
- else:
- # Unpartitioned and no initramfs - cannot boot with a UUID
- self.generate_bootloader_config(mountpoint)
- self.install_bootloader(mountpoint)
-
- if device:
- self.create_partition_mountpoints(device, system_dir)
+ # Unpartitioned and no initramfs - cannot boot with a UUID
+ self.generate_bootloader_config(mountpoint)
+ self.install_bootloader(mountpoint)
def create_partition_mountpoints(self, device, system_dir):
'''Create (or empty) partition mountpoints in the root filesystem
@@ -933,6 +948,9 @@ class WriteExtension(Extension):
dev.sector_size)
self.create_btrfs_system_layout(temp_root, part_mount_dir,
'factory', rfs_uuid, dev)
+ if self.bootloader_config_is_wanted():
+ self.create_bootloader_config(temp_root, part_mount_dir,
+ 'factory', rfs_uuid, dev)
else:
# Copy files to partition from unpacked rootfs
src_dir = os.path.join(temp_root,