Start of xenial support
This commit is contained in:
@@ -68,28 +68,33 @@ FLAGS = parser.parse_args()
|
|||||||
|
|
||||||
class ImageBuilder(object):
|
class ImageBuilder(object):
|
||||||
|
|
||||||
_BASE_PACKAGES = [
|
_BASE_PACKAGES = {
|
||||||
'devscripts',
|
'devscripts',
|
||||||
'nano',
|
'nano',
|
||||||
'iputils-ping',
|
'iputils-ping',
|
||||||
'linux-firmware',
|
'linux-firmware',
|
||||||
'linux-firmware-nonfree',
|
|
||||||
'ubuntu-minimal',
|
'ubuntu-minimal',
|
||||||
'ubuntu-standard',
|
'ubuntu-standard',
|
||||||
'user-setup',
|
'user-setup',
|
||||||
]
|
}
|
||||||
|
|
||||||
_SUITES = [
|
_RELEASE_PACKAGES = {
|
||||||
|
'trusty': {
|
||||||
|
'linux-firmware-nonfree',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
_SUITES = {
|
||||||
'%(release)s',
|
'%(release)s',
|
||||||
'%(release)s-updates',
|
'%(release)s-updates',
|
||||||
]
|
}
|
||||||
|
|
||||||
_SECTIONS = [
|
_SECTIONS = {
|
||||||
'main',
|
'main',
|
||||||
'restricted',
|
'restricted',
|
||||||
'universe',
|
'universe',
|
||||||
'multiverse',
|
'multiverse',
|
||||||
]
|
}
|
||||||
|
|
||||||
_DIVERSIONS = {
|
_DIVERSIONS = {
|
||||||
'/sbin/initctl': '/bin/true',
|
'/sbin/initctl': '/bin/true',
|
||||||
@@ -229,7 +234,7 @@ class ImageBuilder(object):
|
|||||||
'apt-get',
|
'apt-get',
|
||||||
'install',
|
'install',
|
||||||
'--assume-yes',
|
'--assume-yes',
|
||||||
*self._BASE_PACKAGES,
|
*(self._BASE_PACKAGES | self._RELEASE_PACKAGES.get(self._release, set())),
|
||||||
env=env)
|
env=env)
|
||||||
|
|
||||||
def _WriteVersion(self, chroot_path, timestamp):
|
def _WriteVersion(self, chroot_path, timestamp):
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
class Error(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class SubprocessFailure(Error):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class IconModule(object):
|
class IconModule(object):
|
||||||
|
|
||||||
def __init__(self, chroot_path):
|
def __init__(self, chroot_path):
|
||||||
@@ -13,7 +20,11 @@ class IconModule(object):
|
|||||||
|
|
||||||
def Exec(self, *args, **kwargs):
|
def Exec(self, *args, **kwargs):
|
||||||
print('+', args)
|
print('+', args)
|
||||||
subprocess.check_call(args, **kwargs)
|
try:
|
||||||
|
subprocess.check_call(args, **kwargs)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print('ERROR:', e)
|
||||||
|
raise SubprocessFailure(e)
|
||||||
|
|
||||||
def ExecChroot(self, *args, **kwargs):
|
def ExecChroot(self, *args, **kwargs):
|
||||||
self.Exec('chroot', self._chroot_path, *args, **kwargs)
|
self.Exec('chroot', self._chroot_path, *args, **kwargs)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ FLAGS = parser.parse_args()
|
|||||||
def main():
|
def main():
|
||||||
module = icon_lib.IconModule(FLAGS.chroot_path)
|
module = icon_lib.IconModule(FLAGS.chroot_path)
|
||||||
module.InstallPackages(
|
module.InstallPackages(
|
||||||
'daemontools-run', 'genisoimage', 'git', 'python3-openssl',
|
'upstart', 'daemontools-run', 'genisoimage', 'git', 'python3-openssl',
|
||||||
'python3-requests', 'python3-ws4py')
|
'python3-requests', 'python3-ws4py')
|
||||||
|
|
||||||
os.makedirs(os.path.join(FLAGS.chroot_path, 'icon', 'config'), exist_ok=True)
|
os.makedirs(os.path.join(FLAGS.chroot_path, 'icon', 'config'), exist_ok=True)
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import icon_lib
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='iconograph systemid')
|
parser = argparse.ArgumentParser(description='iconograph systemid')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -14,10 +16,27 @@ FLAGS = parser.parse_args()
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
module = icon_lib.IconModule(FLAGS.chroot_path)
|
||||||
|
|
||||||
os.mkdir(os.path.join(FLAGS.chroot_path, 'systemid'))
|
os.mkdir(os.path.join(FLAGS.chroot_path, 'systemid'))
|
||||||
|
|
||||||
init = os.path.join(FLAGS.chroot_path, 'etc', 'init', 'systemid.conf')
|
tool_path = os.path.join(FLAGS.chroot_path, 'icon', 'systemid')
|
||||||
with open(init, 'w') as fh:
|
os.makedirs(tool_path, exist_ok=True)
|
||||||
|
|
||||||
|
script = os.path.join(tool_path, 'startup.sh')
|
||||||
|
with open(script, 'w') as fh:
|
||||||
|
os.fchmod(fh.fileno(), 0o755)
|
||||||
|
fh.write("""\
|
||||||
|
#!/bin/bash
|
||||||
|
mount -o data=journal,noatime,sync LABEL=SYSTEMID /systemid
|
||||||
|
. /systemid/systemid
|
||||||
|
echo ${SYSTEMID} > /etc/hostname
|
||||||
|
hostname --file /etc/hostname
|
||||||
|
grep ${SYSTEMID} /etc/hosts >/dev/null || echo "127.0.2.1 ${SYSTEMID}" >> /etc/hosts
|
||||||
|
""")
|
||||||
|
|
||||||
|
upstart = os.path.join(FLAGS.chroot_path, 'etc', 'init', 'systemid.conf')
|
||||||
|
with open(upstart, 'w') as fh:
|
||||||
fh.write("""
|
fh.write("""
|
||||||
description "Mount /systemid"
|
description "Mount /systemid"
|
||||||
|
|
||||||
@@ -27,15 +46,41 @@ task
|
|||||||
emits systemid-ready
|
emits systemid-ready
|
||||||
|
|
||||||
script
|
script
|
||||||
mount -o data=journal,noatime,sync LABEL=SYSTEMID /systemid
|
/icon/systemid/startup.sh
|
||||||
. /systemid/systemid
|
|
||||||
echo ${SYSTEMID} > /etc/hostname
|
|
||||||
hostname --file /etc/hostname
|
|
||||||
grep ${SYSTEMID} /etc/hosts >/dev/null || echo "127.0.2.1 ${SYSTEMID}" >> /etc/hosts
|
|
||||||
initctl emit --no-wait systemid-ready
|
initctl emit --no-wait systemid-ready
|
||||||
end script
|
end script
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
systemd = os.path.join(FLAGS.chroot_path, 'lib', 'systemd', 'system', 'systemid.service')
|
||||||
|
with open(systemd, 'w') as fh:
|
||||||
|
fh.write("""
|
||||||
|
[Unit]
|
||||||
|
Description=Mount /systemid and configure from it
|
||||||
|
DefaultDependencies=no
|
||||||
|
Conflicts=shutdown.target
|
||||||
|
After=systemd-remount-fs.service
|
||||||
|
Before=sysinit.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
ExecStart=/icon/systemid/startup.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sysinit.target
|
||||||
|
""")
|
||||||
|
try:
|
||||||
|
module.ExecChroot(
|
||||||
|
'systemctl',
|
||||||
|
'unmask',
|
||||||
|
'systemid.service')
|
||||||
|
module.ExecChroot(
|
||||||
|
'systemctl',
|
||||||
|
'enable',
|
||||||
|
'systemid.service')
|
||||||
|
except icon_lib.SubprocessFailure:
|
||||||
|
# trusty backwards-compat
|
||||||
|
pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user