Skip to content

Commit

Permalink
[WIP] Continue boximg chain implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
alenz33 committed Apr 23, 2015
1 parent 040bdf0 commit 4e1d2a2
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 7 deletions.
41 changes: 35 additions & 6 deletions conduct/buildsteps/deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from conduct.buildsteps.base import BuildStep
from conduct.util import systemCall, chrootedSystemCall
from conduct.param import Parameter, oneof
from conduct.param import Parameter, oneof, listof

class Debootstrap(BuildStep):
'''
Expand All @@ -43,11 +43,18 @@ class Debootstrap(BuildStep):
description='Desired architecture'),
'destdir' : Parameter(type=str,
description='Destination directory'),
'includes' : Parameter(type=listof(str),
description='Packages to include',
default=[]),
}

def run(self):
cmd = 'debootstrap --verbose --arch=%s ' % self.arch

if self.includes:
for pkg in self.includes:
cmd += '--include %s ' % pkg

if self._isForeignArch():
# separate first and second stage
cmd += '--foreign '
Expand Down Expand Up @@ -82,18 +89,40 @@ class InstallDebPkg(BuildStep):
'chrootdir' : Parameter(type=str,
description='Chroot directory (if desired)',
default=''),
'depsonly' : Parameter(type=bool,
description='Install dependencies only',
default=False),
}

def run(self):
cmd = 'env DEBIAN_FRONTEND=noninteractive ' \
self._syscall = lambda cmd: (chrootedSystemCall(self.chrootdir, cmd, log=self.log) \
if self.chrootdir else systemCall(cmd, log=self.log))
self._installCmd = 'env DEBIAN_FRONTEND=noninteractive ' \
'apt-get install --yes --force-yes ' \
'--no-install-recommends ' \
'-o Dpkg::Options::="--force-overwrite" ' \
'-o Dpkg::Options::="--force-confnew" ' \
'%s' % self.pkg
'%s'

if self.depsonly:
deps = self._determineDependencies()

if self.chrootdir:
chrootedSystemCall(self.chrootdir, cmd, log=self.log)
for pkg in deps:
self._syscall(self._installCmd % pkg)
else:
systemCall(cmd, log=self.log)
# install actual pkg
self._syscall(self._installCmd % self.pkg)

def _determineDependencies(self):
try:
out = self._syscall('apt-cache show %s | grep Depends:' % self.pkg)
except RuntimeError as e:
self.log.exception(e)
return [] # no deps

out = out[9:] # strip 'Depends: '
depStrs = [entry.strip() for entry in out.split(',')]

return [entry.split(' ')[0] for entry in depStrs]


42 changes: 41 additions & 1 deletion etc/chains/frm2/boximg.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
SOURCES_LIST = '''
deb http://ftp.de.debian.org/debian/ {chain.distribution} main
deb http://ftp.de.debian.org/debian/ {chain.distribution}-backports main
deb [trusted=yes] https://forge.frm2.tum.de/repos/apt/debian {chain.distribution} main extra
'''

GRUB_DEV_MAP = '''
Expand Down Expand Up @@ -111,7 +112,8 @@
description='Boostrap basic system',
distribution='{chain.distribution}',
arch='{steps.imgdef.config[ARCH]}',
destdir='{steps.tmpdir.tmpdir}/mount')
destdir='{steps.tmpdir.tmpdir}/mount',
includes=['apt-transport-https', 'ca-certificates'])

steps.srclst = Step('fs.WriteFile',
description='Create source list',
Expand Down Expand Up @@ -162,3 +164,41 @@
description='Enable policy-rc.d',
command='chmod +x /usr/sbin/policy-rc.d',
chrootdir='{steps.mount.mountpoint}')

steps.pkgbasedeps = Step('deb.InstallDebPkg',
description='Install base img pkg)',
pkg='boxes-base',
chrootdir='{steps.mount.mountpoint}',
depsonly=True)

steps.pkgplatformdeps = Step('deb.InstallDebPkg',
description='Install platform img pkg)',
pkg='boxes-{steps.imgdef.config[PLATFORM]}',
chrootdir='{steps.mount.mountpoint}',
depsonly=True)

steps.pkgimgdeps = Step('deb.InstallDebPkg',
description='Install specific img pkg)',
pkg='boxes-{chain.imgname}',
chrootdir='{steps.mount.mountpoint}',
depsonly=True)

steps.pkgbase = Step('deb.InstallDebPkg',
description='Install base img pkg)',
pkg='boxes-base',
chrootdir='{steps.mount.mountpoint}')

steps.pkgplatform = Step('deb.InstallDebPkg',
description='Install platform img pkg)',
pkg='boxes-{steps.imgdef.config[PLATFORM]}',
chrootdir='{steps.mount.mountpoint}')

steps.pkgimg = Step('deb.InstallDebPkg',
description='Install specific img pkg)',
pkg='boxes-{chain.imgname}',
chrootdir='{steps.mount.mountpoint}')

steps.delpolicy = Step('fs.RmPath',
description='Reenable init.d invokation',
path='{steps.mount.mountpoint}/usr/sbin/policy-rc.d')

0 comments on commit 4e1d2a2

Please sign in to comment.