From 9c1ef821b3cdf1320cab26fbbd5487b2f1e283fc Mon Sep 17 00:00:00 2001 From: drebrez Date: Sat, 28 Oct 2017 02:45:15 +0200 Subject: [PATCH] Add architecture argument for the buildroot chroot (#832) * Add architecture argument for the buildroot chroot, defaults to device architecture * Output pmbootstrap log file after failure to debug Travis failure * Travis: disable timestamp based rebuilds --- .travis.yml | 3 +++ pmb/helpers/frontend.py | 5 ++++- pmb/parse/arguments.py | 5 +++-- test/test_chroot_interactive_shell.py | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d4ba9a3c..5b5ff617 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,10 +11,13 @@ install: "pip install flake8 pytest-cov python-coveralls" script: - test/static_code_analysis.sh - yes "" | ./pmbootstrap.py init + - ./pmbootstrap.py config timestamp_based_rebuild False - ./pmbootstrap.py kconfig_check - test/testcases_fast.sh - test/check_checksums.py after_success: - coveralls +after_failure: + - cat ~/.local/var/pmbootstrap/log.txt notifications: - email: false diff --git a/pmb/helpers/frontend.py b/pmb/helpers/frontend.py index c7d0ec62..3eac89f2 100644 --- a/pmb/helpers/frontend.py +++ b/pmb/helpers/frontend.py @@ -68,7 +68,10 @@ def _parse_suffix(args): if "rootfs" in args and args.rootfs: return "rootfs_" + args.device elif args.buildroot: - return "buildroot_" + args.deviceinfo["arch"] + if args.buildroot == "device": + return "buildroot_" + args.deviceinfo["arch"] + else: + return "buildroot_" + args.buildroot elif args.suffix: return args.suffix else: diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index e1e69cc9..dffeba50 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -192,8 +192,9 @@ def arguments(): if action == chroot: suffix.add_argument("-r", "--rootfs", action="store_true", help="Chroot for the device root file system") - suffix.add_argument("-b", "--buildroot", action="store_true", - help="Chroot for building packages for the device " + suffix.add_argument("-b", "--buildroot", nargs="?", const="device", + choices={"device"} | arch_choices, + help="Chroot for building packages, defaults to device " "architecture") suffix.add_argument("-s", "--suffix", default=None, help="Specify any chroot suffix, defaults to" diff --git a/test/test_chroot_interactive_shell.py b/test/test_chroot_interactive_shell.py index 645e1614..e9fca924 100644 --- a/test/test_chroot_interactive_shell.py +++ b/test/test_chroot_interactive_shell.py @@ -30,3 +30,21 @@ def test_chroot_interactive_shell(): input="echo hello_world\n", universal_newlines=True, stderr=subprocess.STDOUT) assert ret == "hello_world\n" + + +def test_chroot_arguments(): + """ + Open a shell with 'pmbootstrap chroot' for every architecture, pass 'uname -m\n' + as stdin and check the output + """ + pmb_src = os.path.realpath(os.path.join(os.path.dirname(__file__) + "/..")) + os.chdir(pmb_src) + + for arch in ["armhf", "aarch64", "x86_64"]: + ret = subprocess.check_output(["./pmbootstrap.py", "-q", "chroot", "-b", arch], + timeout=300, input="uname -m\n", + universal_newlines=True, stderr=subprocess.STDOUT) + if arch == "armhf": + assert ret == "armv7l\n" + else: + assert ret == arch + "\n"