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 | ||||
|         self.pinfo(":: preparing the install tree") | ||||
|         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.copy_updates() | ||||
|         self.installtree.fix_problems() | ||||
|  | ||||
| @ -68,6 +68,7 @@ class BaseImageClass(BaseLoraxClass): | ||||
|     def __init__(self): | ||||
|         BaseLoraxClass.__init__(self) | ||||
|         self.srctree, self.dsttree = None, None | ||||
|         self.pkgs_to_remove = set() | ||||
| 
 | ||||
|     def parse_template(self, template_file, variables={}): | ||||
|         template = ltmpl.Template() | ||||
| @ -102,6 +103,9 @@ class BaseImageClass(BaseLoraxClass): | ||||
|             fname = os.path.join(self.dsttree, fname) | ||||
|             remove_(fname) | ||||
| 
 | ||||
|     def removepkg(self, pkgname): | ||||
|         self.pkgs_to_remove.add(pkgname) | ||||
| 
 | ||||
|     def symlink(self, link_target, link_name): | ||||
|         link_name = os.path.join(self.dsttree, link_name) | ||||
|         symlink_(link_target, link_name) | ||||
|  | ||||
| @ -621,6 +621,7 @@ class Install(BaseImageClass): | ||||
|     def __init__(self, installtree, template_file, workdir="/tmp"): | ||||
|         BaseImageClass.__init__(self) | ||||
| 
 | ||||
|         self.installtree = installtree | ||||
|         self.srctree = installtree.rootdir | ||||
|         self.dsttree = installtree.rootdir | ||||
|         self.template_file = template_file | ||||
| @ -632,6 +633,21 @@ class Install(BaseImageClass): | ||||
|         # copy the .buildstamp | ||||
|         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_bootloaders() | ||||
|         self.rename_repos() | ||||
| @ -642,13 +658,6 @@ class Install(BaseImageClass): | ||||
|         self.remove_unnecessary_files() | ||||
|         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 | ||||
|         self.pinfo("copying custom files") | ||||
|         self.copy_custom_files() | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user