From 5674e79c0225e25378ab7d70a4f011f37221f5f2 Mon Sep 17 00:00:00 2001 From: Hyung-Kyu Choi Date: Fri, 27 Apr 2018 16:06:30 +0900 Subject: [PATCH] Make a copy of scripts and files in docker from scripts/command - Make a copy of scripts and files in ./docker from ./scripts/command - This files will be used with currrent CI and will be removed when CI is updated Signed-off-by: Hyung-Kyu Choi --- docker/change_gitmodule.sh | 21 +++++++ docker/common.sh | 2 + docker/docker_build.sh | 8 +++ docker/docker_build_cross_arm_ubuntu.sh | 42 ++++++++++++++ ...cker_build_cross_arm_ubuntu_without_aclbuild.sh | 67 ++++++++++++++++++++++ docker/docker_run.sh | 24 ++++++++ 6 files changed, 164 insertions(+) create mode 100755 docker/change_gitmodule.sh create mode 100755 docker/common.sh create mode 100755 docker/docker_build.sh create mode 100755 docker/docker_build_cross_arm_ubuntu.sh create mode 100755 docker/docker_build_cross_arm_ubuntu_without_aclbuild.sh create mode 100755 docker/docker_run.sh diff --git a/docker/change_gitmodule.sh b/docker/change_gitmodule.sh new file mode 100755 index 0000000..3ffcce2 --- /dev/null +++ b/docker/change_gitmodule.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Background for this hack +# +# To fetch submodule repositories from github.sec.samsung.net, we must +# authenticate the user, who is fetching the source tree, regardless of +# communication protocol (e.g., ssh, https). Note that the policy of Samsung's +# internal github does not allow to access the repository without +# authentication. Because of this, the replacement below is a workaround to +# pass the login information of our CI account, git-bot-sec, using an API token. +# Since the URL in .gitmodules is written with `git@` that requires ssh key +# authentication and we don't really want to put git-bot-sec's ssh private key +# somewhere, we decided to use a token-based authentication method. + +SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +HOST_HOME=$SCRIPT_ROOT/../ + +USERNAME=git-bot-sec +TOKEN=acb137d756874f7c7746a95e31ebb3994f1c4505 + +sed -i "s/git@github.sec.samsung.net:/https:\/\/$USERNAME:$TOKEN@github.sec.samsung.net\//" $HOST_HOME/.gitmodules diff --git a/docker/common.sh b/docker/common.sh new file mode 100755 index 0000000..ec2ca7b --- /dev/null +++ b/docker/common.sh @@ -0,0 +1,2 @@ +#!/bin/bash +export DOCKER_IMAGE_NAME=nnfw_docker diff --git a/docker/docker_build.sh b/docker/docker_build.sh new file mode 100755 index 0000000..92cd78d --- /dev/null +++ b/docker/docker_build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +source ./common.sh + +docker build --build-arg http_proxy="$http_proxy" \ + --build-arg https_proxy="$https_proxy" \ + -t $DOCKER_IMAGE_NAME \ + - < ./Dockerfile diff --git a/docker/docker_build_cross_arm_ubuntu.sh b/docker/docker_build_cross_arm_ubuntu.sh new file mode 100755 index 0000000..ff155fe --- /dev/null +++ b/docker/docker_build_cross_arm_ubuntu.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +source ./common.sh + +SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +HOST_HOME=$SCRIPT_ROOT/../ +DOCKER_HOME=/home + +GIT_SSL_NO_VERIFY=1 + +DOCKER_VOLUMES+=" -v $HOST_HOME:$DOCKER_HOME" + +DOCKER_ENV_VARS+=" -e http_proxy" +DOCKER_ENV_VARS+=" -e no_proxy" +DOCKER_ENV_VARS+=" -e GIT_SSL_NO_VERIFY" + +DOCKER_RUN_OPTS="--rm" +DOCKER_RUN_OPTS+=" -w $DOCKER_HOME" +DOCKER_RUN_OPTS+=" -it" + +# Change .gitmodules to work around the permission issue +CMD_SUBMODULE="docker/change_gitmodule.sh" +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME sh -c "$CMD_SUBMODULE" + +CMD="export TARGET_ARCH=armv7l && export CROSS_BUILD=1 && make acl && make && make install" + +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME sh -c "$CMD" +BUILD_RESULT=$? + +# Newly created files during above docker run can have different ownership. +# This may cause some problems, for example, some jenkins slaves or developers +# can't remove built files due to lack of permission. +# To address this issue, let's change owner of all files +# in NNFW to owner of NNFW. +NNFW_OWNER_UID=$(stat -c "%u" $HOST_HOME) +NNFW_OWNER_GID=$(stat -c "%g" $HOST_HOME) + +CMD="chown -R $NNFW_OWNER_UID:$NNFW_OWNER_GID $DOCKER_HOME" +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME $CMD + +exit $BUILD_RESULT diff --git a/docker/docker_build_cross_arm_ubuntu_without_aclbuild.sh b/docker/docker_build_cross_arm_ubuntu_without_aclbuild.sh new file mode 100755 index 0000000..e2ffebb --- /dev/null +++ b/docker/docker_build_cross_arm_ubuntu_without_aclbuild.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source $SCRIPT_ROOT/common.sh + +HOST_HOME=$SCRIPT_ROOT/../ +DOCKER_HOME=/home + +GIT_SSL_NO_VERIFY=1 + +DOCKER_VOLUMES+=" -v $HOST_HOME:$DOCKER_HOME" + +DOCKER_ENV_VARS+=" -e http_proxy" +DOCKER_ENV_VARS+=" -e no_proxy" +DOCKER_ENV_VARS+=" -e GIT_SSL_NO_VERIFY" + +DOCKER_ENV_VARS+=" -e TARGET_ARCH=armv7l" +DOCKER_ENV_VARS+=" -e CROSS_BUILD=1" +DOCKER_ENV_VARS+=" -e ROOTFS_DIR=/opt/rootfs" +DOCKER_ENV_VARS+=" -e EXT_ACL_FOLDER=/opt/libarmcl" + +DOCKER_RUN_OPTS="--rm" +DOCKER_RUN_OPTS+=" -w $DOCKER_HOME" + + +TMP_DIR=$HOST_HOME/tmp +mkdir -p $TMP_DIR/libarmcl + +# prepare armcl library +wget http://npuarchive.mooo.com/archive/nnfw/libarmcl/libarmcl.tar.gz -O $TMP_DIR/libarmcl.tar.gz -nv +tar -zxvf $TMP_DIR/libarmcl.tar.gz -C $TMP_DIR/libarmcl + +# prepare rootfs +wget http://npuarchive.mooo.com/archive/nnfw/rootfs/rootfs_arm_ubuntu.tar.gz -O $TMP_DIR/rootfs.tar.gz -nv +tar -zxf $TMP_DIR/rootfs.tar.gz -C $TMP_DIR + +DOCKER_VOLUMES+=" -v $TMP_DIR/arm:/opt/rootfs" +DOCKER_VOLUMES+=" -v $TMP_DIR/libarmcl:/opt/libarmcl" + +# Change .gitmodules to work around the permission issue +CMD_SUBMODULE="docker/change_gitmodule.sh" +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME sh -c "$CMD_SUBMODULE" + +if [ -n "$DOCKER_INTERACTIVE" ]; then + DOCKER_RUN_OPTS+=" -it" + CMD="/bin/bash" +else + CMD="make external_acl && make && make install && make build_test_suite" +fi + +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME sh -c "$CMD" +BUILD_RESULT=$? + +# Newly created files during above docker run can have different ownership. +# This may cause some problems, for example, some jenkins slaves or developers +# can't remove built files due to lack of permission. +# To address this issue, let's change owner of all files +# in NNFW to owner of NNFW. +NNFW_OWNER_UID=$(stat -c "%u" $HOST_HOME) +NNFW_OWNER_GID=$(stat -c "%g" $HOST_HOME) + +CMD="chown -R $NNFW_OWNER_UID:$NNFW_OWNER_GID $DOCKER_HOME" +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME $CMD + +rm -rf $TMP_DIR +exit $BUILD_RESULT diff --git a/docker/docker_run.sh b/docker/docker_run.sh new file mode 100755 index 0000000..7681692 --- /dev/null +++ b/docker/docker_run.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +source ./common.sh + +SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +HOST_HOME=$SCRIPT_ROOT/../ +DOCKER_HOME=/home + +GIT_SSL_NO_VERIFY=1 + +DOCKER_VOLUMES+=" -v $HOST_HOME:$DOCKER_HOME" + +DOCKER_ENV_VARS+=" -e http_proxy" +DOCKER_ENV_VARS+=" -e no_proxy" +DOCKER_ENV_VARS+=" -e GIT_SSL_NO_VERIFY" + +DOCKER_RUN_OPTS="--rm" +DOCKER_RUN_OPTS+=" -w $DOCKER_HOME" +DOCKER_RUN_OPTS+=" -it" + +CMD="/bin/bash" + +docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME $CMD -- 2.7.4