From 173329e9680e57fd4d27c6ed0860fb5b98573013 Mon Sep 17 00:00:00 2001 From: hbai Date: Wed, 29 Sep 2021 22:18:02 -0400 Subject: [PATCH] stx tools: Add scripts to setup builder This commit adds finishSetup.sh, userenv for builder setup and stx-builder.Dockerfile and buildrc are also updated Story: 2008846 Task: 43484 Signed-off-by: hbai Change-Id: I9a70a8d7b18ba7cb8d689e513dba67231582bb42 --- stx/dockerfiles/stx-builder.Dockerfile | 1 + stx/toCOPY/builder/buildrc | 3 +- stx/toCOPY/builder/finishSetup.sh | 29 +++++++++++++++ stx/toCOPY/builder/userenv | 51 ++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100755 stx/toCOPY/builder/finishSetup.sh create mode 100644 stx/toCOPY/builder/userenv diff --git a/stx/dockerfiles/stx-builder.Dockerfile b/stx/dockerfiles/stx-builder.Dockerfile index d57f2cbca..b857d37bc 100644 --- a/stx/dockerfiles/stx-builder.Dockerfile +++ b/stx/dockerfiles/stx-builder.Dockerfile @@ -45,6 +45,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ fakeroot \ pristine-tar \ repo \ + libdistro-info-perl \ proxychains && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ diff --git a/stx/toCOPY/builder/buildrc b/stx/toCOPY/builder/buildrc index a8b2bca1c..8ede4b829 100644 --- a/stx/toCOPY/builder/buildrc +++ b/stx/toCOPY/builder/buildrc @@ -31,5 +31,6 @@ export MY_BUILD_TOOLS_DIR=$MY_REPO/build-tools export LAYER=$LAYER export STX_CONFIG_DIR=$MY_REPO/stx-tools export STX_GIT_SRC_DIR=$MY_REPO/stx/git -export PATH=$PATH:$MY_BUILD_TOOLS_DIR/stx + +export PATH=$PATH:$MY_BUILD_TOOLS_DIR/stx:/opt/LAT/lat export PYTHONPATH=$PYTHONPATH:$MY_BUILD_TOOLS_DIR/stx diff --git a/stx/toCOPY/builder/finishSetup.sh b/stx/toCOPY/builder/finishSetup.sh new file mode 100755 index 000000000..20adcfabe --- /dev/null +++ b/stx/toCOPY/builder/finishSetup.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +. $HOME/buildrc + +REPOMGR=aptly +if [ "$REPOMGR" == "aptly" ]; then + REPO_BIN="deb [trusted=yes] ${REPOMGR_DEPLOY_URL}deb-local-binary bullseye main" + REPO_SRC="deb-src [trusted=yes] ${REPOMGR_DEPLOY_URL}deb-local-source bullseye main" + ret=`grep 'deb-local-binary' /etc/apt/sources.list` + if [ "x$ret" == "x" ]; then + sed -i "1i\\${REPO_BIN}" /etc/apt/sources.list + fi + ret=`grep 'deb-local-source' /etc/apt/sources.list` + if [ "x$ret" == "x" ]; then + sed -i "1i\\${REPO_SRC}" /etc/apt/sources.list + fi +fi + +addgroup -gid 751 cgts > /dev/null 2>&1 +adduser --uid $MYUID --ingroup cgts --home /home/$MYUNAME --shell /bin/bash --disabled-password --gecos "" $MYUNAME > /dev/null 2>&1 +ret=`cat /etc/sudoers | grep "${MYUNAME}"` +if [ "x$ret" == "x" ]; then + echo "${MYUNAME} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers +fi +chown -R ${MYUNAME}:cgts /localdisk +cp -f /root/buildrc /home/$MYUNAME/ +cp -f /root/localrc /home/$MYUNAME/ +cp -f /root/userenv /home/$MYUNAME/ +chown -R ${MYUNAME}:cgts /home/$MYUNAME diff --git a/stx/toCOPY/builder/userenv b/stx/toCOPY/builder/userenv new file mode 100644 index 000000000..d934493c7 --- /dev/null +++ b/stx/toCOPY/builder/userenv @@ -0,0 +1,51 @@ +# Common configuration for StarlingX builder + +# Find the other rc files +BUILDRC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd) + +# Allow local overrides of env variables +if [[ -f $BUILDRC_DIR/localrc ]]; then + source $BUILDRC_DIR/localrc +fi +# Allow local overrides of env variables +if [[ -f $BUILDRC_DIR/buildrc ]]; then + source $BUILDRC_DIR/buildrc +fi + +if [ ! -d $MY_REPO_ROOT_DIR ]; then + mkdir -p $MY_REPO_ROOT_DIR > /dev/null 2>&1 +fi +if [ ! -d $MY_WORKSPACE ]; then + mkdir -p $MY_WORKSPACE > /dev/null 2>&1 +fi + +cat < + git config --global user.email + +If proxy used: + ssh -D 8080 -qTfnN + echo "alias wget='proxychains wget'" >>~/.bashrc + echo "alias repo='proxychains repo'" >>~/.bashrc + source ~/.bashrc + +To start a fresh source tree: + cd \$MY_REPO_ROOT_DIR + repo init -u https://opendev.org/starlingx/manifest.git -m default.xml + repo sync + +To build all packages: + build-pkgs or build-pkgs -p + +To fill local binary repo: + debdownloader + +To make image: + build-image [ -t std|rt ] + +EOF + +cd ${MY_WORKSPACE}