Add shebang to the art script.
Because there are still some that don't use bash as login shell.
Also fix /bin symlink in the chroot setup, like in the real root.
Test: Golem-style art invocation with silvermont target
Test: Vogar tests (run-libcore-tests.sh), which use the art script, in
chroot on device
Test: m out/host/linux-x86/bin/art && \
out/host/linux-x86/bin/art -showversion
with shebang "#!/bin/sh" and "#!/usr/bin/posh" (Policy-compliant
Ordinary SHell)
Change-Id: I7445b07f121eaa947e187ab822c7c098d5957f92
diff --git a/tools/art b/tools/art
index aa5abb7..e524b17 100755
--- a/tools/art
+++ b/tools/art
@@ -1,3 +1,4 @@
+#! /bin/sh
# Copyright (C) 2011 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +15,11 @@
# This script is used on host and device. It uses a common subset
# shell dialect that should work on the host (e.g. bash), and
-# Android (e.g. mksh).
+# Android (e.g. mksh). Try to switch to bash if the shebang above
+# has launched a pessimal shell on host.
+if [ -z "$KSH_VERSION" -a -z "$BASH_VERSION" -a -n "$(which bash)" ]; then
+ exec bash -c ". $0" -- "$@"
+fi
######################################
# Functions
diff --git a/tools/buildbot-setup-device.sh b/tools/buildbot-setup-device.sh
index 54c928a..b139c47 100755
--- a/tools/buildbot-setup-device.sh
+++ b/tools/buildbot-setup-device.sh
@@ -173,4 +173,7 @@
# Create /linkerconfig directory in chroot.
adb shell mkdir -p "$ART_TEST_CHROOT/linkerconfig"
+
+ # Create /bin symlink for shebang compatibility.
+ adb shell ln -s system/bin "$ART_TEST_CHROOT/bin"
fi
diff --git a/tools/buildbot-teardown-device.sh b/tools/buildbot-teardown-device.sh
index e067a70..3a75bbd 100755
--- a/tools/buildbot-teardown-device.sh
+++ b/tools/buildbot-teardown-device.sh
@@ -92,6 +92,9 @@
fi
}
+ # Remove /bin symlink from chroot.
+ adb shell rm -f "$ART_TEST_CHROOT/bin"
+
# Remove /apex from chroot.
adb shell rm -rf "$ART_TEST_CHROOT/apex"