Add arch option
authorGui Chen <gui.chen@intel.com>
Mon, 12 Sep 2011 01:03:05 +0000 (09:03 +0800)
committerJF Ding <jian-feng.ding@intel.com>
Mon, 12 Sep 2011 15:42:02 +0000 (08:42 -0700)
Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/configmgr.py
mic/imager/baseimager.py

index cc2cec72fc4303a9aa2598fb07f24f37aea360b1..05408b64145a8a265b7896d2b9018043b41d2f4c 100644 (file)
@@ -35,7 +35,7 @@ DEFAULT_CREATE = {
     "tmpdir": DEFAULT_TMPDIR,
     "cachedir": DEFAULT_CACHEDIR,
     "outdir": DEFAULT_OUTDIR,
-    "arch": None,
+    "arch": "i586",
     "pkgmgr": "yum",
     "name": "output",
     "ksfile": None,
index 9bdb9cd7cb2c3786e679348bb004b3b6dcf52330..623de8e57db2c81668a0e6d4058af9b6a81c8207 100644 (file)
@@ -73,8 +73,8 @@ class BaseImageCreator(object):
             self.cachedir = createopts['cachedir']
 
             self.destdir = createopts['outdir']
-            # target arch for non-x86 image
-            self.target_arch = createopts['arch']
+
+            self.arch = createopts['arch']
             self._local_pkgs_path = createopts['local_pkgs_path']
 
         else:
@@ -83,7 +83,7 @@ class BaseImageCreator(object):
             self.tmpdir = "/var/tmp/mic"
             self.cachedir = "/var/tmp/mic/cache"
             self.destdir = "."
-            self.target_arch = None
+            self.arch = "noarch"
             self._local_pkgs_path = None
 
         self.__builddir = None
@@ -128,6 +128,16 @@ class BaseImageCreator(object):
                     self._dep_checks.append("mkfs.btrfs")
                     break
 
+        # make sure arch available
+        if not self.arch:
+            raise CreatorError("Architecture for creator is not available")
+        if self.arch.startswith("arm"):
+            if not self.set_target_arch(self.arch):
+                raise CreatorError("Architecture %s is not support" % self.arch)
+        else:
+            self.target_arch = None
+        print self.arch, self.target_arch
+
         # make sure the specified tmpdir and cachedir exist
         if not os.path.exists(self.tmpdir):
             os.makedirs(self.tmpdir)
@@ -139,20 +149,19 @@ class BaseImageCreator(object):
             return False
 
         self.target_arch = arch
-        if self.target_arch.startswith("arm"):
-            for dep in self._dep_checks:
-                if dep == "extlinux":
-                    self._dep_checks.remove(dep)
-
-            if not os.path.exists("/usr/bin/qemu-arm") or not misc.is_statically_linked("/usr/bin/qemu-arm"):
-                self._dep_checks.append("qemu-arm-static")
-
-            if os.path.exists("/proc/sys/vm/vdso_enabled"):
-                vdso_fh = open("/proc/sys/vm/vdso_enabled","r")
-                vdso_value = vdso_fh.read().strip()
-                vdso_fh.close()
-                if (int)(vdso_value) == 1:
-                    msger.warning("vdso is enabled on your host, which might cause problems with arm emulations.\n"
+        for dep in self._dep_checks:
+            if dep == "extlinux":
+                self._dep_checks.remove(dep)
+
+        if not os.path.exists("/usr/bin/qemu-arm") or not misc.is_statically_linked("/usr/bin/qemu-arm"):
+            self._dep_checks.append("qemu-arm-static")
+
+        if os.path.exists("/proc/sys/vm/vdso_enabled"):
+            vdso_fh = open("/proc/sys/vm/vdso_enabled","r")
+            vdso_value = vdso_fh.read().strip()
+            vdso_fh.close()
+            if (int)(vdso_value) == 1:
+                msger.warning("vdso is enabled on your host, which might cause problems with arm emulations.\n"
                                   "\tYou can disable vdso with following command before starting image build:\n"
                                   "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled")