diff options
author | James Thomas <james.thomas@codethink.co.uk> | 2016-01-13 15:52:12 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2016-02-25 14:10:48 +0000 |
commit | 85716982b15829e19634ed2af65c9231a752ea7b (patch) | |
tree | b90440d4d337e256d1bc5fe5f7ebffe9874351b0 | |
parent | 9629a993b9d32ab93c38f25350c4d54a9461d7fb (diff) | |
download | definitions-85716982b15829e19634ed2af65c9231a752ea7b.tar.gz |
Split btrfs filesystem functions in layout and rootfs creation
This will allow us to mirror the baserock btrfs layout on a non btrfs
partition
Change-Id: If5dbba133a187eeb26eae671da7dd71495127c8e
-rw-r--r-- | extensions/writeexts.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/extensions/writeexts.py b/extensions/writeexts.py index 93f67433..a135eadb 100644 --- a/extensions/writeexts.py +++ b/extensions/writeexts.py @@ -303,6 +303,8 @@ class WriteExtension(Extension): with self.mount(raw_disk) as mp: try: self.create_btrfs_system_layout( + mp, version_label='factory') + self.create_btrfs_system_rootfs( temp_root, mp, version_label='factory', rootfs_uuid=self.get_uuid(raw_disk)) if self.bootloader_config_is_wanted(): @@ -434,9 +436,8 @@ class WriteExtension(Extension): subprocess.check_call(['umount', mount_point]) os.rmdir(mount_point) - def create_btrfs_system_layout(self, temp_root, mountpoint, version_label, - rootfs_uuid, device=None): - '''Separate base OS versions from state using subvolumes. + def create_btrfs_system_layout(self, mountpoint, version_label): + '''Create the btrfs folder layout required for baserock ''' version_root = os.path.join(mountpoint, 'systems', version_label) @@ -445,10 +446,12 @@ class WriteExtension(Extension): 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 + def create_btrfs_system_rootfs(self, temp_root, mountpoint, version_label, + rootfs_uuid, device=None): + '''Separate base OS versions from state using subvolumes. + ''' + version_root = os.path.join(mountpoint, 'systems', version_label) state_root = os.path.join(mountpoint, 'state') os.makedirs(state_root) @@ -946,8 +949,10 @@ class WriteExtension(Extension): # Install root filesystem rfs_uuid = self.get_uuid(location, part.extent.start * dev.sector_size) - self.create_btrfs_system_layout(temp_root, part_mount_dir, - 'factory', rfs_uuid, dev) + self.create_btrfs_system_layout(part_mount_dir, 'factory') + self.create_btrfs_system_rootfs(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) |