Move completely into tmpfs

This commit is contained in:
Ian Gulliver
2016-03-31 10:02:05 -07:00
parent 75f77093aa
commit 93ee57a06e

View File

@@ -101,6 +101,7 @@ class ImageBuilder(object):
self._ico_server_path = os.path.dirname(sys.argv[0]) self._ico_server_path = os.path.dirname(sys.argv[0])
self._exec_chroot = []
self._umount = [] self._umount = []
self._rmtree = [] self._rmtree = []
@@ -133,19 +134,10 @@ class ImageBuilder(object):
iso_path) iso_path)
self._umount.append(iso_path) self._umount.append(iso_path)
tmpfs_path = os.path.join(root, 'tmpfs') upper_path = os.path.join(root, 'upper')
os.mkdir(tmpfs_path)
self._Exec(
'mount',
'--types', 'tmpfs',
'none',
tmpfs_path)
self._umount.append(tmpfs_path)
upper_path = os.path.join(tmpfs_path, 'upper')
os.mkdir(upper_path) os.mkdir(upper_path)
work_path = os.path.join(tmpfs_path, 'work') work_path = os.path.join(root, 'work')
os.mkdir(work_path) os.mkdir(work_path)
union_path = os.path.join(root, 'union') union_path = os.path.join(root, 'union')
@@ -183,6 +175,12 @@ class ImageBuilder(object):
'install', 'install',
'--assume-yes', '--assume-yes',
*self._BASE_PACKAGES) *self._BASE_PACKAGES)
self._exec_chroot.append([
chroot_path,
'service',
'atd',
'stop',
])
self._ExecChroot( self._ExecChroot(
chroot_path, chroot_path,
'apt-get', 'apt-get',
@@ -238,6 +236,13 @@ class ImageBuilder(object):
print('Building image in:', root) print('Building image in:', root)
self._Exec(
'mount',
'--types', 'tmpfs',
'none',
root)
self._umount.append(root)
chroot_path = self._Debootstrap(root) chroot_path = self._Debootstrap(root)
union_path = self._CreateUnion(root) union_path = self._CreateUnion(root)
self._FixSourcesList(chroot_path) self._FixSourcesList(chroot_path)
@@ -253,8 +258,9 @@ class ImageBuilder(object):
try: try:
self._BuildImage() self._BuildImage()
finally: finally:
pass for cmd in reversed(self._exec_chroot):
for path in self._umount: self._ExecChroot(*cmd)
for path in reversed(self._umount):
self._Exec('umount', path) self._Exec('umount', path)
for path in self._rmtree: for path in self._rmtree:
shutil.rmtree(path) shutil.rmtree(path)