From: Shuangquan Zhou Date: Thu, 18 Aug 2011 09:08:38 +0000 (+0800) Subject: Added ARM support and fixed some issues X-Git-Tag: 0.1~197 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dcbf9cc171f11f7ceca1e4b7df6638b73a456545;p=tools%2Fmic.git Added ARM support and fixed some issues Note:in host env, yum supports armv7l,armv7hl,armv7nhl,armv5tel zypp supports armv7l,armv5tel Signed-off-by: Shuangquan Zhou --- diff --git a/mic/chroot.py b/mic/chroot.py index 8b519e7..82153c4 100644 --- a/mic/chroot.py +++ b/mic/chroot.py @@ -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", diff --git a/mic/configmgr.py b/mic/configmgr.py index 69a7727..64e336a 100644 --- a/mic/configmgr.py +++ b/mic/configmgr.py @@ -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, diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index 233e65a..7d596b4 100644 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -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-*") diff --git a/mic/imager/livecd.py b/mic/imager/livecd.py index 1a9c84e..acb2042 100644 --- a/mic/imager/livecd.py +++ b/mic/imager/livecd.py @@ -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 diff --git a/mic/utils/fs_related.py b/mic/utils/fs_related.py index 6b9a684..daa3960 100644 --- a/mic/utils/fs_related.py +++ b/mic/utils/fs_related.py @@ -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 diff --git a/mic/utils/misc.py b/mic/utils/misc.py index 77bab8a..b5e8150 100644 --- a/mic/utils/misc.py +++ b/mic/utils/misc.py @@ -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 diff --git a/plugins/backend/yumpkgmgr.py b/plugins/backend/yumpkgmgr.py index 380fffd..570ba98 100644 --- a/plugins/backend/yumpkgmgr.py +++ b/plugins/backend/yumpkgmgr.py @@ -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 = {} diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index 9fdc22d..9bec093 100644 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -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() diff --git a/plugins/imager/livecd_plugin.py b/plugins/imager/livecd_plugin.py index 238c615..fe0b692 100644 --- a/plugins/imager/livecd_plugin.py +++ b/plugins/imager/livecd_plugin.py @@ -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) diff --git a/plugins/imager/liveusb_plugin.py b/plugins/imager/liveusb_plugin.py index ac6622d..04c4fac 100644 --- a/plugins/imager/liveusb_plugin.py +++ b/plugins/imager/liveusb_plugin.py @@ -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) diff --git a/plugins/imager/raw_plugin.py b/plugins/imager/raw_plugin.py index 6f97329..e1c7ac5 100644 --- a/plugins/imager/raw_plugin.py +++ b/plugins/imager/raw_plugin.py @@ -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]