deal with yum.conf inside yum backend by itself
authorGui Chen <gui.chen@intel.com>
Fri, 3 Feb 2012 07:59:34 +0000 (15:59 +0800)
committerGui Chen <gui.chen@intel.com>
Fri, 3 Feb 2012 07:59:34 +0000 (15:59 +0800)
Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/imager/baseimager.py
plugins/backend/yumpkgmgr.py
plugins/backend/zypppkgmgr.py

index 12bc80f..c993334 100644 (file)
@@ -865,10 +865,8 @@ class BaseImageCreator(object):
             self._excluded_pkgs = None
             self._required_groups = None
 
-        yum_conf = self._mktemp(prefix = "yum.conf-")
-
         pkg_manager = self.get_pkg_manager()
-        pkg_manager.setup(yum_conf, self._instroot)
+        pkg_manager.setup()
 
         for repo in kickstart.get_repos(self.ks, repo_urls):
             (name, baseurl, mirrorlist, inc, exc,
@@ -907,7 +905,6 @@ class BaseImageCreator(object):
             self._pkgs_license = pkg_manager.getPkgsLicense()
 
             pkg_manager.close()
-            os.unlink(yum_conf)
 
         # do some clean up to avoid lvm info leakage.  this sucks.
         for subdir in ("cache", "backup", "archive"):
index 1c112a5..adf1742 100644 (file)
@@ -16,7 +16,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc., 59
 # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import os, sys, re
+import os, sys, re, tempfile
 
 import rpmUtils
 import yum
@@ -81,6 +81,7 @@ class Yum(BackendPlugin, yum.YumBase):
 
     def close(self):
         try:
+            os.unlink(self.confpath)
             os.unlink(self.conf.installroot + "/yum.conf")
         except:
             pass
@@ -126,10 +127,15 @@ class Yum(BackendPlugin, yum.YumBase):
         for f in glob.glob(installroot + "/var/lib/rpm/__db*"):
             os.unlink(f)
 
-    def setup(self, confpath, installroot):
-        self._writeConf(confpath, installroot)
-        self._cleanupRpmdbLocks(installroot)
-        self.doConfigSetup(fn = confpath, root = installroot)
+    def setup(self):
+        # create yum.conf
+        (fn, self.confpath) = tempfile.mkstemp(dir=self.cachedir,
+                                               prefix='yum.conf-')
+        os.close(fn)
+        self._writeConf(self.confpath, self.instroot)
+        self._cleanupRpmdbLocks(self.instroot)
+        # do setup
+        self.doConfigSetup(fn = self.confpath, root = self.instroot)
         self.conf.cache = 0
         self.doTsSetup()
         self.doRpmDBSetup()
index a967b91..6b33553 100644 (file)
@@ -108,9 +108,7 @@ class Zypp(BackendPlugin):
         for f in glob.glob(installroot + "/var/lib/rpm/__db*"):
             os.unlink(f)
 
-    def setup(self, confpath=None, instroot=None):
-        if not self.instroot:
-            self.instroot = instroot
+    def setup(self):
         self._cleanupRpmdbLocks(self.instroot)
 
     def whatObsolete(self, pkg):