Add installimg command for use in the templates
installimg SRCDIR DESTFILE Create a compressed cpio archive of the contents of SRCDIR and place it in DESTFILE. If SRCDIR doesn't exist or is empty nothing is created. Examples: installimg ${LORAXDIR}/product/ images/product.img
This commit is contained in:
parent
a7a3dd276d
commit
b064ae6166
@ -31,6 +31,7 @@ from pylorax.sysutils import joinpaths, cpfile, mvfile, replace, remove
|
|||||||
from pylorax.yumhelper import LoraxDownloadCallback, LoraxTransactionCallback, LoraxRpmCallback
|
from pylorax.yumhelper import LoraxDownloadCallback, LoraxTransactionCallback, LoraxRpmCallback
|
||||||
from pylorax.base import DataHolder
|
from pylorax.base import DataHolder
|
||||||
from pylorax.executils import runcmd, runcmd_output
|
from pylorax.executils import runcmd, runcmd_output
|
||||||
|
from pylorax.imgutils import mkcpio
|
||||||
|
|
||||||
from mako.lookup import TemplateLookup
|
from mako.lookup import TemplateLookup
|
||||||
from mako.exceptions import text_error_template
|
from mako.exceptions import text_error_template
|
||||||
@ -233,6 +234,23 @@ class LoraxTemplateRunner(object):
|
|||||||
for src in rglob(self._in(srcglob), fatal=True):
|
for src in rglob(self._in(srcglob), fatal=True):
|
||||||
cpfile(src, self._out(dest))
|
cpfile(src, self._out(dest))
|
||||||
|
|
||||||
|
def installimg(self, srcdir, destfile):
|
||||||
|
'''
|
||||||
|
installimg SRCDIR DESTFILE
|
||||||
|
Create a compressed cpio archive of the contents of SRCDIR and place
|
||||||
|
it in DESTFILE.
|
||||||
|
|
||||||
|
If SRCDIR doesn't exist or is empty nothing is created.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
installimg ${LORAXDIR}/product/ images/product.img
|
||||||
|
installimg ${LORAXDIR}/updates/ images/updates.img
|
||||||
|
'''
|
||||||
|
if not os.path.isdir(self._in(srcdir)) or not os.listdir(self._in(srcdir)):
|
||||||
|
return
|
||||||
|
logger.info("Creating image file %s from contents of %s", self._out(destfile), self._in(srcdir))
|
||||||
|
mkcpio(self._in(srcdir), self._out(destfile))
|
||||||
|
|
||||||
def mkdir(self, *dirs):
|
def mkdir(self, *dirs):
|
||||||
'''
|
'''
|
||||||
mkdir DIR [DIR ...]
|
mkdir DIR [DIR ...]
|
||||||
|
Loading…
Reference in New Issue
Block a user