Skip to content

Commit

Permalink
Add MakeDirs step.
Browse files Browse the repository at this point in the history
  • Loading branch information
alenz33 committed Mar 31, 2015
1 parent def3d55 commit 410cb6c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
29 changes: 28 additions & 1 deletion conduct/buildsteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from conduct.param import Parameter, oneof, none_or, dictof, listof, tupleof

__all__ = ['BuildStep', 'SystemCall', 'Config', 'TmpDir', 'RmPath',
'Partitioning', 'DevMapper', 'CreateFileSystem', 'Mount']
'Partitioning', 'DevMapper', 'CreateFileSystem', 'Mount', 'MakeDirs']


class BuildStepMeta(type):
Expand Down Expand Up @@ -527,6 +527,33 @@ def cleanup(self):
log=self.log)


class MakeDirs(BuildStep):
'''
This build step create the desired directories.
'''

parameters = {
'dirs' : Parameter(type=listof(str),
description='List of directories'),
'removeoncleanup' : Parameter(type=bool,
description='Remove the directories on clenup',
default=True),
}

def run(self):
for entry in self.dirs:
# TODO: Referencer support for nested types
entry = Referencer(entry).evaluate(self.chain)
self.log.debug('Create directory: %s ...' % entry)
ensureDirectory(entry)

def cleanup(self):
if self.removeoncleanup:
for entry in self.dirs:
entry = Referencer(entry).evaluate(self.chain)
shutil.rmtree(entry)





Expand Down
10 changes: 10 additions & 0 deletions etc/chains/frm2/boximg.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,13 @@
dev='{steps.devmap.mapped[0]}',
mountpoint='{steps.tmpdir.tmpdir}/mount')

steps.mkchrootdirs = Step('conduct.MakeDirs',
description='Create some necessary dirs for the chroot environment',
dirs=[
'{steps.mount.mountpoint}/boot/grub',
'{steps.mount.mountpoint}/proc',
'{steps.mount.mountpoint}/dev',
'{steps.mount.mountpoint}/sys',
'{steps.mount.mountpoint}/root',
])

0 comments on commit 410cb6c

Please sign in to comment.