diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-03-22 20:04:58 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-03-22 20:19:25 +0000 |
commit | 44d2b7d102944de678e24fc4b45131aacfd7a3cd (patch) | |
tree | c22945ed86131f5585745dd64c806376f85b484b /morphlib/builder.py | |
parent | 4392d1101bb8c9d6d30b3be554112aef8dbc4adb (diff) | |
download | morph-44d2b7d102944de678e24fc4b45131aacfd7a3cd.tar.gz |
Squashme: Temporary changes to make boot with btrfs work.
This is achieved by copying vmlinuz, System.map and extlinux.conf
to the default subvolume.
Diffstat (limited to 'morphlib/builder.py')
-rw-r--r-- | morphlib/builder.py | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py index d63f1886..41f2fab2 100644 --- a/morphlib/builder.py +++ b/morphlib/builder.py @@ -433,11 +433,12 @@ class SystemBuilder(BlobBuilder): # pragma: no cover self._create_subvolume(factory_path) self._unpack_strata(factory_path) self._create_fstab(factory_path) - boot_path = os.path.join(mount_point, 'boot') - self._install_boot_files(factory_path, boot_path) - self._install_extlinux(mount_point) + self._create_extlinux_config(factory_path) self._create_subvolume_snapshot( mount_point, 'factory', 'factory-run') + factory_run_path = os.path.join(mount_point, 'factory-run') + self._install_boot_files(factory_run_path, mount_point) + self._install_extlinux(mount_point) self._unmount(mount_point) except BaseException: self._unmount(mount_point) @@ -517,36 +518,41 @@ class SystemBuilder(BlobBuilder): # pragma: no cover with open(fstab, 'w') as f: f.write('proc /proc proc defaults 0 0\n') f.write('sysfs /sys sysfs defaults 0 0\n') - f.write('/dev/disk/by-label/baserock / btrfs errors=remount-ro 0 1\n') + f.write('/dev/sda1 / btrfs errors=remount-ro 0 1\n') - def _install_boot_files(self, subvolume, destination): - os.mkdir(destination) - self.ex.runv(['cp', os.path.join(subvolume, 'boot', 'vmlinuz'), - os.path.join(destination, 'vmlinuz')]) - - def _install_extlinux(self, path): - with self.build_watch('install-bootloader'): - conf = os.path.join(path, 'extlinux.conf') - logging.debug('configure extlinux %s' % conf) - with open(conf, 'w') as f: - f.write('default linux\n') - f.write('timeout 1\n') - f.write('label linux\n') - f.write('kernel /boot/vmlinuz\n') - f.write('append root=/dev/disk/by-label/baserock rootflags=subvol=factory-run init=/sbin/init quiet rw\n') - - self.ex.runv(['extlinux', '--install', '%s' % path]) - - # Weird hack that makes extlinux work. - # FIXME: There is a bug somewhere. - self.ex.runv(['sync']) - time.sleep(2) + def _create_extlinux_config(self, path): + config = os.path.join(path, 'extlinux.conf') + with open(config, 'w') as f: + f.write('default linux\n') + f.write('timeout 1\n') + f.write('label linux\n') + f.write('kernel /boot/vmlinuz\n') + f.write('append root=/dev/sda1 rootflags=subvol=factory-run init=/sbin/init quiet rw\n') def _create_subvolume_snapshot(self, path, source, target): with self.build_watch('create-subvolume-snapshot'): self.ex.runv(['btrfs', 'subvolume', 'snapshot', source, target], cwd=path) + def _install_boot_files(self, sourcefs, targetfs): + with self.build_watch('install-boot-files'): + logging.debug('installing boot files into root volume') + shutil.copy2(os.path.join(sourcefs, 'extlinux.conf'), + os.path.join(targetfs, 'extlinux.conf')) + os.mkdir(os.path.join(targetfs, 'boot')) + shutil.copy2(os.path.join(sourcefs, 'boot', 'vmlinuz'), + os.path.join(targetfs, 'boot', 'vmlinuz')) + shutil.copy2(os.path.join(sourcefs, 'boot', 'System.map'), + os.path.join(targetfs, 'boot', 'System.map')) + + def _install_extlinux(self, path): + with self.build_watch('install-bootloader'): + self.ex.runv(['extlinux', '--install', path]) + + # FIXME this hack seems to be necessary to let extlinux finish + self.ex.runv(['sync']) + time.sleep(2) + def _unmount(self, mount_point): if mount_point is not None: with self.build_watch('unmount-filesystem'): |