Add support for removing whole packages
Remove all files from a package if removepkg <pkg> is specified in install image template.
This commit is contained in:
parent
f277852f7a
commit
5036ff6bd8
@ -145,6 +145,16 @@ class Lorax(BaseLoraxClass):
|
|||||||
# prepare the install tree
|
# prepare the install tree
|
||||||
self.pinfo(":: preparing the install tree")
|
self.pinfo(":: preparing the install tree")
|
||||||
self.installtree.install_packages(packages=packages)
|
self.installtree.install_packages(packages=packages)
|
||||||
|
|
||||||
|
# XXX
|
||||||
|
if not os.path.isdir("/tmp/pkglists"):
|
||||||
|
os.makedirs("/tmp/pkglists")
|
||||||
|
|
||||||
|
for pkg in self.installtree.yum.installed_packages:
|
||||||
|
with open("/tmp/pkglists/%s" % pkg.name, "w") as f:
|
||||||
|
for filename in self.installtree.yum.get_file_list(pkg):
|
||||||
|
f.write("%s\n" % filename)
|
||||||
|
|
||||||
self.installtree.run_ldconfig()
|
self.installtree.run_ldconfig()
|
||||||
self.installtree.copy_updates()
|
self.installtree.copy_updates()
|
||||||
self.installtree.fix_problems()
|
self.installtree.fix_problems()
|
||||||
|
@ -68,6 +68,7 @@ class BaseImageClass(BaseLoraxClass):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
BaseLoraxClass.__init__(self)
|
BaseLoraxClass.__init__(self)
|
||||||
self.srctree, self.dsttree = None, None
|
self.srctree, self.dsttree = None, None
|
||||||
|
self.pkgs_to_remove = set()
|
||||||
|
|
||||||
def parse_template(self, template_file, variables={}):
|
def parse_template(self, template_file, variables={}):
|
||||||
template = ltmpl.Template()
|
template = ltmpl.Template()
|
||||||
@ -102,6 +103,9 @@ class BaseImageClass(BaseLoraxClass):
|
|||||||
fname = os.path.join(self.dsttree, fname)
|
fname = os.path.join(self.dsttree, fname)
|
||||||
remove_(fname)
|
remove_(fname)
|
||||||
|
|
||||||
|
def removepkg(self, pkgname):
|
||||||
|
self.pkgs_to_remove.add(pkgname)
|
||||||
|
|
||||||
def symlink(self, link_target, link_name):
|
def symlink(self, link_target, link_name):
|
||||||
link_name = os.path.join(self.dsttree, link_name)
|
link_name = os.path.join(self.dsttree, link_name)
|
||||||
symlink_(link_target, link_name)
|
symlink_(link_target, link_name)
|
||||||
|
@ -621,6 +621,7 @@ class Install(BaseImageClass):
|
|||||||
def __init__(self, installtree, template_file, workdir="/tmp"):
|
def __init__(self, installtree, template_file, workdir="/tmp"):
|
||||||
BaseImageClass.__init__(self)
|
BaseImageClass.__init__(self)
|
||||||
|
|
||||||
|
self.installtree = installtree
|
||||||
self.srctree = installtree.rootdir
|
self.srctree = installtree.rootdir
|
||||||
self.dsttree = installtree.rootdir
|
self.dsttree = installtree.rootdir
|
||||||
self.template_file = template_file
|
self.template_file = template_file
|
||||||
@ -632,6 +633,21 @@ class Install(BaseImageClass):
|
|||||||
# copy the .buildstamp
|
# copy the .buildstamp
|
||||||
shutil.copy2(self.conf.buildstamp, self.srctree)
|
shutil.copy2(self.conf.buildstamp, self.srctree)
|
||||||
|
|
||||||
|
# parse the template file
|
||||||
|
self.pinfo("parsing the template")
|
||||||
|
variables = {"buildarch": self.conf.buildarch,
|
||||||
|
"basearch": self.conf.basearch,
|
||||||
|
"libdir": self.conf.libdir}
|
||||||
|
self.parse_template(self.template_file, variables)
|
||||||
|
|
||||||
|
# XXX remove whole packages
|
||||||
|
for pkg in self.installtree.yum.installed_packages:
|
||||||
|
if pkg.name in self.pkgs_to_remove:
|
||||||
|
self.pinfo("removing not needed package %s" % pkg.name)
|
||||||
|
for fname in pkg.filelist:
|
||||||
|
self.pdebug("removing file %s%s" % (self.srctree, fname))
|
||||||
|
remove_("%s%s" % (self.srctree, fname))
|
||||||
|
|
||||||
self.copy_stubs()
|
self.copy_stubs()
|
||||||
self.copy_bootloaders()
|
self.copy_bootloaders()
|
||||||
self.rename_repos()
|
self.rename_repos()
|
||||||
@ -642,13 +658,6 @@ class Install(BaseImageClass):
|
|||||||
self.remove_unnecessary_files()
|
self.remove_unnecessary_files()
|
||||||
self.move_bins()
|
self.move_bins()
|
||||||
|
|
||||||
# parse the template file
|
|
||||||
self.pinfo("parsing the template")
|
|
||||||
variables = {"buildarch": self.conf.buildarch,
|
|
||||||
"basearch": self.conf.basearch,
|
|
||||||
"libdir": self.conf.libdir}
|
|
||||||
self.parse_template(self.template_file, variables)
|
|
||||||
|
|
||||||
# copy custom files
|
# copy custom files
|
||||||
self.pinfo("copying custom files")
|
self.pinfo("copying custom files")
|
||||||
self.copy_custom_files()
|
self.copy_custom_files()
|
||||||
|
Loading…
Reference in New Issue
Block a user