summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Müller-Klieser <S.Mueller-Klieser@phytec.de>2016-03-23 12:24:27 (GMT)
committerStefan Müller-Klieser <s.mueller-klieser@phytec.de>2016-04-05 10:39:32 (GMT)
commit1825578b7e3cdbd880bf8a67a15d14608307ba5c (patch)
tree0d04f9c402ee7f49e5e8162060cd15fa2ae5845e
parent0d5cd98794d07c5b0f279fa5b2d505cf9614479d (diff)
downloadmeta-phytec-1825578b7e3cdbd880bf8a67a15d14608307ba5c.zip
meta-phytec-1825578b7e3cdbd880bf8a67a15d14608307ba5c.tar.bz2
scripts: init: remove bashisms and make it POSIX compliant
We experienced some odd behavior on some systems. Being POSIX compliant should make things more robust. Everything should work as before. Dash is now supported, too. Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
-rwxr-xr-xscripts/init41
1 files changed, 21 insertions, 20 deletions
diff --git a/scripts/init b/scripts/init
index f0d9973..7a129e2 100755
--- a/scripts/init
+++ b/scripts/init
@@ -1,24 +1,18 @@
-#!/bin/bash
-# Using bash is important. We need the variable BASH_SOURCE which is the
-# filepath of the bash script.
-
+#!/bin/sh
# This script is a init script for our bsp. It resides in the bsp release specific folder
# this is the soc specific init script. It assumes that you have only one soc layer
# which holds all your machines.
PHYLINUX_API_VERSION="2"
-
-# Try to find ROOTDIR from path of bash script.
-DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
-# stdlib function 'realpath' is not accessable from shell/bash. What a pitty.
-# We cannot resolve symbolic links easily.
+# Try to find ROOTDIR from arg0 of shell process.
+DIR="`dirname $(readlink -f $0)`"
# Try to find ROOTDIR of the Yocto BSP. Walk up the directory tree until we
# find the sources/meta-phytec or .repo directory. Returns the empty string as
# an error code.
-function find_root_dir() {
+find_root_dir() {
dir=$(readlink -f "$1") # should return an absoulte path
- while [ ! "$dir" == "/" ]; do
+ while [ ! "$dir" = "/" ]; do
if [ -d "$dir/.repo" ]; then
# or [ -d "$dir/sources/meta-phytec" ];
echo $dir;
@@ -31,7 +25,7 @@ function find_root_dir() {
}
ROOTDIR=$(find_root_dir "$DIR")
-if [ "$ROOTDIR" == "" ]; then
+if [ "$ROOTDIR" = "" ]; then
echo >&2 "ERROR: Cannot find root directory of the Yocto BSP."
echo >&2 "Is '$DIR' in a checkout of a BSP? Aborting..."
exit 1;
@@ -42,22 +36,27 @@ fi
PHYTEC_DIR="${ROOTDIR}/sources/meta-phytec"
install -m 0644 ${PHYTEC_DIR}/conf/doc/HOWTO ${ROOTDIR}
-# Setup template directory. All caller to overwrite default TEMPLATECONF.
+# Setup template directory. Allow caller to overwrite default TEMPLATECONF.
if [ -z "${TEMPLATECONF}" ]; then
- TEMPLATECONF="${ROOTDIR}/tools/templateconf"
+ export TEMPLATECONF="${ROOTDIR}/tools/templateconf"
install -d ${TEMPLATECONF}
install -m 0644 ${PHYTEC_DIR}/conf/bblayers.conf.sample ${TEMPLATECONF}
install -m 0644 ${PHYTEC_DIR}/conf/local.conf.sample ${TEMPLATECONF}
install -m 0644 ${PHYTEC_DIR}/conf/conf-notes.txt ${TEMPLATECONF}
fi
-
# Init a build directory if we dont have one.
# NOTE: Since the script 'oe-buildenv-internal' will use the current working
# directory as the base for the build directory, we set the build directory
-# explicitly to '${ROOTDIR}/build' here. So the 'init' script's actions don't
-# depend on the current working directory of the caller.
-bash -c "TEMPLATECONF=\"${TEMPLATECONF}\" source ${ROOTDIR}/sources/poky/oe-init-build-env \"${ROOTDIR}/build\"" > /dev/null
+# explicitly as argument here. So the 'init' script's actions don't depend on
+# the current working directory of the caller. This method works for dash, too.
+if [ -z "${1}" ]; then
+ set -- "${ROOTDIR}/build"
+else
+ set -- "${ROOTDIR}/${1}"
+fi
+cd ${ROOTDIR}/sources/poky/
+. ./oe-init-build-env > /dev/null
${PHYTEC_DIR}/scripts/copy_site_conf.py
${PHYTEC_DIR}/scripts/init_machine.py
@@ -69,7 +68,9 @@ echo " - proxy settings"
echo " - DL_DIR"
echo " - SSTATE_DIR"
echo ""
-echo "To set up your shell environment for some Yocto work, you have to type:"
-echo "$ source sources/poky/oe-init-build-env"
+echo "To set up your shell environment for some Yocto work, you have to type this"
+echo "command, including the 'dot':"
+echo ""
+echo " $ . sources/poky/oe-init-build-env"
echo ""
echo ""