From 84753d982946b6263bcead3b31a5dcbac716bcca Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Thu, 31 Mar 2016 11:50:37 -0700 Subject: [PATCH] Mount /persistent if possible --- server/build_image.py | 26 +++++++++++++++++++++----- server/chroot_files/persistent.conf | 11 +++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 server/chroot_files/persistent.conf diff --git a/server/build_image.py b/server/build_image.py index 39e9afe..25971c8 100755 --- a/server/build_image.py +++ b/server/build_image.py @@ -97,6 +97,14 @@ class ImageBuilder(object): '/etc/init.d/systemd-logind': '/bin/true', } + _CHROOT_COPIES = { + 'persistent.conf': 'etc/init/persistent.conf', + } + + _ISO_COPIES = { + 'loopback.cfg': 'boot/grub/loopback.cfg', + } + def __init__(self, source_iso, dest_iso, archive, arch, release, ca_cert, base_url, image_type): self._source_iso = source_iso self._dest_iso = dest_iso @@ -222,6 +230,12 @@ class ImageBuilder(object): source) os.unlink(os.path.join(chroot_path, 'usr', 'sbin', 'policy-rc.d')) + def _CopyChrootFiles(self, chroot_path): + for source, dest in self._CHROOT_COPIES.items(): + shutil.copyfile( + os.path.join(self._ico_server_path, 'chroot_files', source), + os.path.join(chroot_path, dest)) + def _InstallIconograph(self, chroot_path): self._ExecChroot( chroot_path, @@ -255,10 +269,11 @@ class ImageBuilder(object): os.path.join(union_path, 'casper', 'filesystem.squashfs'), '-noappend') - def _FixGrub(self, union_path): - shutil.copyfile( - os.path.join(self._ico_server_path, 'iso_files', 'loopback.cfg'), - os.path.join(union_path, 'boot', 'grub', 'loopback.cfg')) + def _CopyISOFiles(self, union_path): + for source, dest in self._ISO_COPIES.items(): + shutil.copyfile( + os.path.join(self._ico_server_path, 'iso_files', source), + os.path.join(union_path, dest)) def _CreateISO(self, union_path): self._Exec( @@ -285,11 +300,12 @@ class ImageBuilder(object): self._AddDiversions(chroot_path) self._InstallPackages(chroot_path) self._RemoveDiversions(chroot_path) + self._CopyChrootFiles(chroot_path) self._InstallIconograph(chroot_path) if FLAGS.shell: self._Exec('bash', cwd=root) self._Squash(chroot_path, union_path) - self._FixGrub(union_path) + self._CopyISOFiles(union_path) self._CreateISO(union_path) def BuildImage(self): diff --git a/server/chroot_files/persistent.conf b/server/chroot_files/persistent.conf new file mode 100644 index 0000000..57d6cb3 --- /dev/null +++ b/server/chroot_files/persistent.conf @@ -0,0 +1,11 @@ +description "Mount /persistent" + +start on filesystem + +script + DEV=$(findfs LABEL=persistent) + if test "$?" = "0"; then + mkdir /persistent + mount "${DEV}" /persistent + fi +end script