aboutsummaryrefslogtreecommitdiff
path: root/linaro_image_tools/media_create/chroot_utils.py
diff options
context:
space:
mode:
authorMilo Casagrande <milo@ubuntu.com>2013-12-12 10:27:04 +0100
committerMilo Casagrande <milo.casagrande@linaro.org>2013-12-12 10:33:30 +0100
commit446eff79076e0799c0d6462eef602315e4dcf6b0 (patch)
tree5c21a8469d2954fd4c11c968269616f8b31bef0d /linaro_image_tools/media_create/chroot_utils.py
parentc6b92495b603f82c2bcc1d60c0c1409f422830f2 (diff)
Make sure we can run l-i-t from the checkout.
* With some hwpack and dev models, we do not run inside a chroot. This can be a problem on system where l-i-t has not been installed resulting in an error when trying to run linaro-hwpack-install. Reworked then the way we pass the command to run, considering the full path in the case when not in a chroot. * Fixed tests. Change-Id: I6af1384c20b62cba9c34d65cde8f9fdee0ab8d8a
Diffstat (limited to 'linaro_image_tools/media_create/chroot_utils.py')
-rw-r--r--linaro_image_tools/media_create/chroot_utils.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/linaro_image_tools/media_create/chroot_utils.py b/linaro_image_tools/media_create/chroot_utils.py
index 83b0f6d..1fe06d7 100644
--- a/linaro_image_tools/media_create/chroot_utils.py
+++ b/linaro_image_tools/media_create/chroot_utils.py
@@ -33,6 +33,10 @@ from linaro_image_tools.hwpack.handler import HardwarepackHandler
local_atexit = []
+class ChrootException(Exception):
+ """Base class for chroot exceptions."""
+
+
def prepare_chroot(chroot_dir, tmp_dir):
"""Prepares a chroot to run commands in it (networking and QEMU setup)."""
chroot_etc = os.path.join(chroot_dir, 'etc')
@@ -49,15 +53,22 @@ def install_hwpacks(
extract_kpkgs=False, *hwpack_files):
"""Install the given hwpacks onto the given rootfs."""
+ install_command = 'linaro-hwpack-install'
+ linaro_hwpack_install_path = find_command(
+ install_command, prefer_dir=tools_dir)
+
+ if not linaro_hwpack_install_path:
+ raise ChrootException("The program linaro-hwpack-install could not "
+ "be found found: cannot proceed.")
+ else:
+ linaro_hwpack_install_path = os.path.abspath(
+ linaro_hwpack_install_path)
+
# In case we just want to extract the kernel packages, don't force qemu
# with chroot, as we could have archs without qemu support
-
if not extract_kpkgs:
prepare_chroot(rootfs_dir, tmp_dir)
- linaro_hwpack_install_path = find_command(
- 'linaro-hwpack-install', prefer_dir=tools_dir)
-
# FIXME: shouldn't use chroot/usr/bin as this might conflict with
# installed packages; would be best to use some custom directory like
# chroot/linaro-image-tools/bin
@@ -79,6 +90,11 @@ def install_hwpacks(
"that qemu-user-static is installed and properly "
"configured before trying again.")
raise
+ else:
+ # We are not in the chroot, we do not copy the linaro-hwpack-install
+ # file, but we might not have l-i-t installed, so we need the full path
+ # of the linaro-hwpack-install program to run.
+ install_command = linaro_hwpack_install_path
try:
for hwpack_file in hwpack_files:
@@ -86,12 +102,14 @@ def install_hwpacks(
if os.path.basename(hwpack_file) in verified_files:
hwpack_verified = True
install_hwpack(rootfs_dir, hwpack_file, extract_kpkgs,
- hwpack_force_yes or hwpack_verified)
+ hwpack_force_yes or hwpack_verified,
+ install_command)
finally:
run_local_atexit_funcs()
-def install_hwpack(rootfs_dir, hwpack_file, extract_kpkgs, hwpack_force_yes):
+def install_hwpack(rootfs_dir, hwpack_file, extract_kpkgs, hwpack_force_yes,
+ install_command):
"""Install an hwpack on the given rootfs.
Copy the hwpack file to the rootfs and run linaro-hwpack-install passing
@@ -111,7 +129,7 @@ def install_hwpack(rootfs_dir, hwpack_file, extract_kpkgs, hwpack_force_yes):
architecture, _ = hwpack.get_field("architecture")
name, _ = hwpack.get_field("name")
- args = ['linaro-hwpack-install',
+ args = [install_command,
'--hwpack-version', version,
'--hwpack-arch', architecture,
'--hwpack-name', name]