Persistent module working.
This commit is contained in:
@@ -40,6 +40,10 @@ parser.add_argument(
|
||||
dest='image_type',
|
||||
action='store',
|
||||
required=True)
|
||||
parser.add_argument(
|
||||
'--module',
|
||||
dest='modules',
|
||||
nargs='*')
|
||||
parser.add_argument(
|
||||
'--release',
|
||||
dest='release',
|
||||
@@ -92,15 +96,11 @@ 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):
|
||||
def __init__(self, source_iso, dest_iso, archive, arch, release, ca_cert, base_url, image_type, modules):
|
||||
self._source_iso = source_iso
|
||||
self._dest_iso = dest_iso
|
||||
self._archive = archive
|
||||
@@ -109,6 +109,7 @@ class ImageBuilder(object):
|
||||
self._ca_cert = ca_cert
|
||||
self._base_url = base_url
|
||||
self._image_type = image_type
|
||||
self._modules = modules
|
||||
|
||||
self._ico_server_path = os.path.dirname(sys.argv[0])
|
||||
|
||||
@@ -209,6 +210,15 @@ class ImageBuilder(object):
|
||||
'apt-get',
|
||||
'clean')
|
||||
|
||||
def _RunModules(self, chroot_path):
|
||||
for module in self._modules:
|
||||
self._Exec(
|
||||
'%(module)s --chroot-path=%(chroot_path)s' % {
|
||||
'module': module,
|
||||
'chroot_path': chroot_path,
|
||||
},
|
||||
shell=True)
|
||||
|
||||
def _RemoveDiversions(self, chroot_path):
|
||||
for source in self._DIVERSIONS:
|
||||
self._ExecChroot(
|
||||
@@ -223,12 +233,6 @@ 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,
|
||||
@@ -292,8 +296,8 @@ class ImageBuilder(object):
|
||||
self._FixSourcesList(chroot_path)
|
||||
self._AddDiversions(chroot_path)
|
||||
self._InstallPackages(chroot_path)
|
||||
self._RunModules(chroot_path)
|
||||
self._RemoveDiversions(chroot_path)
|
||||
self._CopyChrootFiles(chroot_path)
|
||||
self._InstallIconograph(chroot_path)
|
||||
if FLAGS.shell:
|
||||
self._Exec('bash', cwd=root)
|
||||
@@ -322,7 +326,8 @@ def main():
|
||||
FLAGS.release,
|
||||
FLAGS.ca_cert,
|
||||
FLAGS.base_url,
|
||||
FLAGS.image_type)
|
||||
FLAGS.image_type,
|
||||
FLAGS.modules)
|
||||
builder.BuildImage()
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
description "Mount /persistent"
|
||||
|
||||
start on filesystem
|
||||
|
||||
script
|
||||
DEV=$(findfs LABEL=persistent)
|
||||
if test "$?" = "0"; then
|
||||
mkdir /persistent
|
||||
mount "${DEV}" /persistent
|
||||
fi
|
||||
end script
|
||||
@@ -75,7 +75,7 @@ class Imager(object):
|
||||
time.sleep(1) # yuck
|
||||
self._Exec(
|
||||
'mkfs.ext4',
|
||||
'-L', 'boot',
|
||||
'-L', 'BOOT',
|
||||
'-F',
|
||||
self._PartDev(1))
|
||||
|
||||
@@ -89,7 +89,7 @@ class Imager(object):
|
||||
time.sleep(1) # yuck
|
||||
self._Exec(
|
||||
'mkfs.ext4',
|
||||
'-L', 'persistent',
|
||||
'-L', 'PERSISTENT',
|
||||
'-F',
|
||||
self._PartDev(2))
|
||||
|
||||
|
||||
33
server/modules/persistent.py
Executable file
33
server/modules/persistent.py
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='iconograph persistent')
|
||||
parser.add_argument(
|
||||
'--chroot-path',
|
||||
dest='chroot_path',
|
||||
action='store',
|
||||
required=True)
|
||||
FLAGS = parser.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
os.mkdir(os.path.join(FLAGS.chroot_path, 'persistent'))
|
||||
|
||||
init = os.path.join(FLAGS.chroot_path, 'etc', 'init', 'persistent.conf')
|
||||
with open(init, 'w') as fh:
|
||||
fh.write("""
|
||||
description "Mount /persistent"
|
||||
|
||||
start on filesystem
|
||||
|
||||
script
|
||||
mount LABEL=PERSISTENT /persistent
|
||||
end script
|
||||
""")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user