From 53f3967be732cc29580fabb86f814687d3dbfa3e Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 29 Jan 2020 09:36:09 -0800 Subject: [PATCH 1/4] envsetup: Keep pseudo tty enabled in all cases where piping or redirection of input with | or >& is needed we can first pipe the output to `cat -v`, its a livable workaround since most of it is in autobuilder scripts Signed-off-by: Khem Raj --- envsetup.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/envsetup.sh b/envsetup.sh index 19d98e1f0..570fc8e1d 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -467,12 +467,10 @@ dkr() { check_docker || return 1 CMD="$1" - PSEUDOTTY="" if [ -z "$CMD" ]; then echo "setting dkr action to shell" CMD="/bin/bash" - PSEUDOTTY="--tty" fi SSH_AUTH_DIR=~/ @@ -494,7 +492,7 @@ dkr() { SSH_AUTH_DIR=$(readlink -f $SSH_AUTH_SOCK) fi - docker run --rm -i ${PSEUDOTTY} --log-driver=none -a stdin -a stdout -a stderr \ + docker run --rm -it \ -v $(pwd):$(pwd) \ -v ~/.ssh:/home/build/.ssh \ -v ~/.gitconfig:/home/build/.gitconfig \ From 371214650cb052f4b2e032b59ea63863f43d2541 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 29 Jan 2020 12:49:15 -0800 Subject: [PATCH 2/4] envsetup: Specify workdir in container to be OE_BASE setting workdir helps avoid a cd on container start additionally use $@ for parameters, this lets us pass all the parameters to bitbake in container instead of limit of 8 ( even though 8 is big some autobuild tests can use a lot bigger number e.g. sstate checker scripts in OE AB) Signed-off-by: Khem Raj --- envsetup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/envsetup.sh b/envsetup.sh index 570fc8e1d..5ca60ea99 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -471,8 +471,9 @@ dkr() { if [ -z "$CMD" ]; then echo "setting dkr action to shell" CMD="/bin/bash" + else + shift fi - SSH_AUTH_DIR=~/ unset MAP_DL_DIR @@ -502,8 +503,9 @@ dkr() { -v $SSH_AUTH_DIR:/ssh-agent \ -e SSH_AUTH_SOCK=/ssh-agent \ -e MACHINE=$MACHINE \ + -w ${OE_BASE} \ --user $(id -u):$(id -g) \ - ${DOCKER_REPO} /bin/bash -c "cd $(pwd) && . envsetup.sh && $CMD $2 $3 $4 $5 $6 $7 $8" + ${DOCKER_REPO} /bin/bash -c ". envsetup.sh && $CMD $@" } bitbake() { From ada9581277507ce1394a98008c22973f20d5bc6b Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 29 Jan 2020 13:07:27 -0800 Subject: [PATCH 3/4] envsetup: Resolve symlinks before bind mounting oe dirs into container Sometimes, user may create a symlink into usual TMPDIR which may span across a mount point on host, this helps in deducing that, and passing right directories to be bind mounted for tmp/sstate-cache/downloads Signed-off-by: Khem Raj --- envsetup.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/envsetup.sh b/envsetup.sh index 5ca60ea99..f5bf698bd 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -479,15 +479,9 @@ dkr() { unset MAP_DL_DIR unset MAP_TMPDIR unset MAP_SSTATE_DIR - if [ -n "$CUSTOM_DL_DIR" ]; then - MAP_DL_DIR="-v $CUSTOM_DL_DIR:$CUSTOM_DL_DIR" - fi - if [ -n "$CUSTOM_TMPDIR" ]; then - MAP_TMPDIR="-v $CUSTOM_TMPDIR:$CUSTOM_TMPDIR" - fi - if [ -n "$CUSTOM_SSTATE_DIR" ]; then - MAP_SSTATE_DIR="-v $CUSTOM_SSTATE_DIR:$CUSTOM_SSTATE_DIR" - fi + MAP_TMPDIR="-v $(readlink -f $OE_BUILD_TMPDIR):$(readlink -f $OE_BUILD_TMPDIR)" + MAP_DL_DIR="-v $(readlink -f $OE_DL_DIR):$(readlink -f $OE_DL_DIR)" + MAP_SSTATE_DIR="-v $(readlink -f $OE_SSTATE_DIR):$(readlink -f $OE_SSTATE_DIR)" if [ -n "$SSH_AUTH_SOCK" ]; then SSH_AUTH_DIR=$(readlink -f $SSH_AUTH_SOCK) From 7f742691f081ffe514c7d598ef12b29ac4ee2cf2 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 29 Jan 2020 13:35:10 -0800 Subject: [PATCH 4/4] envsetup: Add a flag to launch docker with or without pseudo-tty Signed-off-by: Khem Raj --- envsetup.sh | 8 +++++++- local.sh.example | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/envsetup.sh b/envsetup.sh index f5bf698bd..a42afecfa 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -474,6 +474,12 @@ dkr() { else shift fi + if [ "$DOCKER_PSEUDO_TTY" = "no" ]; then + PSEUDO_TTY="" + else + PSEUDO_TTY="-t" + fi + SSH_AUTH_DIR=~/ unset MAP_DL_DIR @@ -487,7 +493,7 @@ dkr() { SSH_AUTH_DIR=$(readlink -f $SSH_AUTH_SOCK) fi - docker run --rm -it \ + docker run --rm -i $PSEUDO_TTY \ -v $(pwd):$(pwd) \ -v ~/.ssh:/home/build/.ssh \ -v ~/.gitconfig:/home/build/.gitconfig \ diff --git a/local.sh.example b/local.sh.example index 27163ca8f..9720a196a 100644 --- a/local.sh.example +++ b/local.sh.example @@ -18,3 +18,10 @@ # configure docker container to run bitbake in #export DOCKER_REPO=yoedistro/yoe-build:buster + +# Flag to control docker launch with pseudo-tty +# when output is piped or redirected to files then +# then docker should be launched without tty +# otherwise it will emit all control characters into +# redirected log files, default is 'yes' +#export DOCKER_PSEUDO_TTY=no