Added ARM support and fixed some issues
authorShuangquan Zhou <shuangquan.zhou@intel.com>
Thu, 18 Aug 2011 09:08:38 +0000 (17:08 +0800)
committerShuangquan Zhou <shuangquan.zhou@intel.com>
Thu, 18 Aug 2011 09:08:38 +0000 (17:08 +0800)
Note:in host env,
     yum supports armv7l,armv7hl,armv7nhl,armv5tel
     zypp supports armv7l,armv5tel

Signed-off-by: Shuangquan Zhou <shuangquan.zhou@intel.com>
mic/chroot.py
mic/configmgr.py
mic/imager/baseimager.py
mic/imager/livecd.py
mic/utils/fs_related.py
mic/utils/misc.py
plugins/backend/yumpkgmgr.py
plugins/backend/zypppkgmgr.py
plugins/imager/livecd_plugin.py
plugins/imager/liveusb_plugin.py
plugins/imager/raw_plugin.py

index 8b519e7706c8a97c4869c6adfd051eba5330d2d6..82153c482f271f5673fdcf7c7c8ae2390fd8b3e0 100644 (file)
@@ -27,6 +27,8 @@ import mic.utils.misc as misc
 import mic.utils.errors as errors
 from mic import msger
 
+chroot_lockfd = -1
+chroot_lock = ""
 BIND_MOUNTS = (
                 "/proc",
                 "/proc/sys/fs/binfmt_misc",
index 69a77271b57d1ca25b447c9350ba6839a66b3b7b..64e336a21fd20451cca23804b56bad126fc74d17 100644 (file)
@@ -34,7 +34,7 @@ DEFAULT_CREATE = {
     "tmpdir": DEFAULT_TMPDIR,
     "cachedir": DEFAULT_CACHEDIR,
     "outdir": DEFAULT_OUTDIR,
-    "arch": "i586",
+    "arch": None,
     "pkgmgr": "zypp",
     "name": "output",
     "ksfile": None,
index 233e65a5caa3d4ea4fa5435246a738e1b4943d3d..7d596b402f2ec0be9792c0834e546ca0fe581b9a 100644 (file)
@@ -77,6 +77,8 @@ class BaseImageCreator(object):
             self.cachedir = createopts['cachedir']
 
             self.destdir = createopts['outdir']
+            # target arch for non-x86 image
+            self.target_arch = createopts['arch']
         else:
             self.ks = None
             self.repometadata = None
@@ -84,6 +86,7 @@ class BaseImageCreator(object):
             self.tmpdir = "/var/tmp"
             self.cachedir = "/var/cache"
             self.destdir = "."
+            self.target_arch = None
 
         self.__builddir = None
         self.__bindmounts = []
@@ -106,8 +109,6 @@ class BaseImageCreator(object):
         self._local_pkgs_path = None
         # available size in root fs, init to 0
         self._root_fs_avail = 0
-        # target arch for non-x86 image
-        self.target_arch = None
         # Name of the disk image file that is created. """
         self._img_name = None
         # Image format """
@@ -404,7 +405,7 @@ class BaseImageCreator(object):
         RPM's n-v-r in the case of e.g. xen)
 
         """
-        def get_kernel_versions(self, instroot):
+        def get_kernel_versions(instroot):
             ret = {}
             versions = set()
             files = glob.glob(instroot + "/boot/vmlinuz-*")
index 1a9c84ed9d0e54f000ecc30809e8d021ec882cc1..acb2042e1bbe0f60d9ea7c0d278d3b06884d779b 100644 (file)
@@ -101,7 +101,7 @@ class LiveImageCreatorBase(LoopImageCreator):
         """Return a menu options string for syslinux configuration.
         """
         if self.ks is None:
-            return "bootinstall autoinst"
+            return "liveinst autoinst"
         r = kickstart.get_menu_args(self.ks)
         return r
 
index 6b9a68438f7827397ad469cd78a4cad8a3ee83c5..daa3960487e0230605f40789c37dca5db3b8c771 100644 (file)
@@ -184,7 +184,7 @@ class BindChrootMount:
             raise MountError("Bind-mounting '%s' to '%s' failed" %
                              (self.src, self.dest))
         if self.option:
-            rc = subprocess.call([self.mountcmd, "-o", "remount,%s" % self.option, self.dest])
+            rc = subprocess.call([self.mountcmd, "--bind", "-o", "remount,%s" % self.option, self.dest])
             if rc != 0:
                 raise MountError("Bind-remounting '%s' failed" % self.dest)
         self.mounted = True
index 77bab8ab8935d20a6fc1afb1c234d7b1d261bc57..b5e815075e19aba2fa07a999bb17596dc3bfdf58 100644 (file)
@@ -42,9 +42,6 @@ xmlparse = cElementTree.parse
 from errors import *
 from fs_related import *
 
-chroot_lockfd = -1
-chroot_lock = ""
-
 def setlocale():
     import locale
     import codecs
index 380fffd8599774b8cdf0cad828fbfa9b8b0a84d6..570ba9892d7a99e6b9eb7634eb07441d7377ff44 100644 (file)
@@ -57,10 +57,13 @@ class Yum(BackendPlugin, yum.YumBase):
         self.creator = creator
 
         if self.creator.target_arch:
-            if rpmUtils.arch.arches.has_key(self.creator.target_arch):
-                self.arch.setup_arch(self.creator.target_arch)
-            else:
-                raise CreatorError("Invalid target arch: %s" % self.creator.target_arch)
+            if not rpmUtils.arch.arches.has_key(self.creator.target_arch):
+                rpmUtils.arch.arches["armv7hl"] = "noarch"
+                rpmUtils.arch.arches["armv7tnhl"] = "armv7nhl"
+                rpmUtils.arch.arches["armv7tnhl"] = "armv7thl"
+                rpmUtils.arch.arches["armv7thl"] = "armv7hl"
+                rpmUtils.arch.arches["armv7nhl"] = "armv7hl"
+            self.arch.setup_arch(self.creator.target_arch)
 
         self.__recording_pkgs = recording_pkgs
         self.__pkgs_content = {}
index 9fdc22d8a97021d14c3a9a6e7fa19c2fa8d35f3d..9bec0932950fb6057cf97253bf2a9a8817a62fb0 100644 (file)
@@ -582,7 +582,7 @@ class Zypp(BackendPlugin):
 
         """ Set system architecture """
         if self.creator.target_arch and self.creator.target_arch.startswith("arm"):
-            arches = ["armv7l", "armv7nhl", "armv7hl"]
+            arches = ["armv7l", "armv7nhl", "armv7hl", "armv5tel"]
             if self.creator.target_arch not in arches:
                 raise CreatorError("Invalid architecture: %s" % self.creator.target_arch)
             arch_map = {}
@@ -592,6 +592,8 @@ class Zypp(BackendPlugin):
                 arch_map["armv7nhl"] = zypp.Arch_armv7nhl()
             elif self.creator.target_arch == "armv7hl":
                 arch_map["armv7hl"] = zypp.Arch_armv7hl()
+            elif self.creator.target_arch == "armv5tel":
+                arch_map["armv5tel"] = zypp.Arch_armv5tel()
             zconfig.setSystemArchitecture(arch_map[self.creator.target_arch])
 
         print "zypp architecture: %s" % zconfig.systemArchitecture()
index 238c615f3b278018e708d843db26aeb8ec43b876..fe0b6925247651052dad8c7c9ba7d725f7687218 100644 (file)
@@ -93,7 +93,7 @@ class LiveCDPlugin(ImagerPlugin):
         try:
             chroot.chroot(extmnt, None,  "/bin/env HOME=/root /bin/bash")
         except:
-            raise CreatorError("Failed to chroot to %s." %img)
+            raise CreatorError("Failed to chroot to %s." %target)
         finally:
             chroot.cleanup_after_chroot("img", extloop, os_image_dir, extmnt)
 
index ac6622d66b186ebed22ce2c40acaf6b513f649fa..04c4fac479696781b7205bd7b6a0a57b887dfa17 100644 (file)
@@ -91,7 +91,7 @@ class LiveUSBPlugin(ImagerPlugin):
         try:
             chroot.chroot(extmnt, None,  "/bin/env HOME=/root /bin/bash")
         except:
-            raise CreatorError("Failed to chroot to %s." %img)
+            raise CreatorError("Failed to chroot to %s." %target)
         finally:
             chroot.cleanup_after_chroot("img", extloop, os_image_dir, extmnt)
 
index 6f97329f7912f3a8c1e4863b8453801154dda909..e1c7ac535a29729b9e7f1dce4bdb53df6b48f2e7 100644 (file)
@@ -176,6 +176,7 @@ class RawPlugin(ImagerPlugin):
         if rc != 0:
             raise CreatorError("Failed to dd")
         srcloop.cleanup()
+        shutil.rmtree(srcmnt, ignore_errors = True)
         return image
 
 mic_plugin = ["raw", RawPlugin]