diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2df31140f75cecdb8753559a235a50a5a5e4cb5d..c21556ee15ddf4008257e90340958b25a152c69b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,24 +1,18 @@ -stages: - - build - variables: - DOCKER_DRIVER: overlay2 - CONTAINER_IMAGE: registry.gitlab.e.foundation:5000/$CI_PROJECT_PATH + DOCKER_HOST: tcp://docker:2375 + DOCKER_TLS_CERTDIR: "" .build_image: stage: build image: docker:git services: - - docker:18-dind - variables: - IMAGE_TAG: $CI_COMMIT_REF_NAME - IMAGE_TAG_RELEASE: prod + - docker:20.10.16-dind script: - - "docker pull $CONTAINER_IMAGE:$IMAGE_TAG || true" - - "docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.e.foundation:5000" - - "docker build --cache-from $CONTAINER_IMAGE:$IMAGE_TAG -t $CONTAINER_IMAGE -t $CONTAINER_IMAGE:$IMAGE_TAG -t $CONTAINER_IMAGE:$IMAGE_TAG_RELEASE -f $DOCKERFILE ." - - "docker push $CONTAINER_IMAGE:$IMAGE_TAG" - - 'if [ "${CI_COMMIT_REF_NAME}" = master ] ; then docker push $CONTAINER_IMAGE:$IMAGE_TAG_RELEASE ; fi' + - "docker pull $CI_REGISTRY_IMAGE:$IMAGE_TAG || true" + - "docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY" + - "docker build --cache-from $CI_REGISTRY_IMAGE:$IMAGE_TAG -t $CI_REGISTRY_IMAGE:$IMAGE_TAG -f $DOCKERFILE ." + - "docker push $CI_REGISTRY_IMAGE:$IMAGE_TAG" + - 'if [ "${CI_COMMIT_REF_NAME}" = master ] ; then docker tag $CI_REGISTRY_IMAGE:$IMAGE_TAG $CI_REGISTRY_IMAGE:$IMAGE_TAG_RELEASE && docker push $CI_REGISTRY_IMAGE:$IMAGE_TAG_RELEASE ; fi' build_prod: extends: .build_image @@ -29,8 +23,6 @@ build_prod: build_community: extends: .build_image - before_script: - - "mv build-community.sh src/build.sh" variables: IMAGE_TAG: $CI_COMMIT_REF_NAME-community IMAGE_TAG_RELEASE: community diff --git a/Dockerfile b/Dockerfile index 095c31e682ae6ad8816d4b84dbb0c3db2a93a75f..d9e506394b63d6fd41d5ffb69d6bb3b90699712b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -162,7 +162,7 @@ RUN apt-get -qq update RUN apt-get -qqy upgrade RUN apt-get install -y bc bison bsdmainutils build-essential ccache cgpt clang cron \ - curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick img2simg kmod \ + curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick img2simg kmod jq \ lib32ncurses5-dev libncurses5 lib32readline-dev lib32z1-dev libtinfo5 liblz4-tool \ libncurses5-dev libsdl1.2-dev libssl-dev libxml2 \ libxml2-utils lsof lzop maven openjdk-8-jdk pngcrush \ diff --git a/Dockerfile.community b/Dockerfile.community index b06f7f8b893ebe11a606edcb5ab3f57c3fc1a28e..a45cd774aa9dcdab7c94ec03a65a77f4c44aa911 100644 --- a/Dockerfile.community +++ b/Dockerfile.community @@ -134,6 +134,7 @@ VOLUME /root/.ssh # Copy required files ##################### COPY src/ /root/ +COPY build-community.sh /root/build.sh # Create missing directories ############################ @@ -153,7 +154,7 @@ RUN apt-get -qq update RUN apt-get -qqy upgrade RUN apt-get install -y bc bison bsdmainutils build-essential ccache cgpt clang cron \ - curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick kmod \ + curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick kmod jq \ lib32ncurses5-dev libncurses5 lib32readline-dev lib32z1-dev libtinfo5 liblz4-tool \ libncurses5-dev libsdl1.2-dev libssl-dev libxml2 \ libxml2-utils lsof lzop maven pngcrush \ diff --git a/build-community.sh b/build-community.sh index 84d375f2d81a612a97067364e788cfee3411233c..4d67cab1948f01177ba241f3426ad0980db0f775 100755 --- a/build-community.sh +++ b/build-community.sh @@ -129,7 +129,7 @@ for branch in ${BRANCH_NAME//,/ }; do if [ -d "$path" ]; then cd "$path" git reset -q --hard - git clean -q -fd + git clean -q -dffx cd "$SRC_DIR/$branch_dir" fi done @@ -139,10 +139,9 @@ for branch in ${BRANCH_NAME//,/ }; do yes | repo init -u "$REPO" --reference "$MIRROR_DIR" -b "$branch" &>> "$repo_log" else TAG_PREFIX="" - curl https://gitlab.e.foundation/api/v4/projects/659/repository/tags | grep "\"name\":\"$branch\"" - if [ $? == 0 ] + if curl -s https://gitlab.e.foundation/api/v4/projects/659/repository/tags?search?${BRANCH_NAME} | jq -r ".[].name" | grep -q "${BRANCH_NAME}" then - echo "Branch name $branch is a tag on e/os/releases, prefix with refs/tags/ for 'repo init'" + echo ">> [$(date)] Branch name $branch is a tag on e/os/releases, prefix with refs/tags/ for 'repo init'" TAG_PREFIX="refs/tags/" fi @@ -279,7 +278,7 @@ for branch in ${BRANCH_NAME//,/ }; do logsubdir= fi - DEBUG_LOG="$LOGS_DIR/$logsubdir/eelo-$los_ver-$builddate-$RELEASE_TYPE-$codename.log" + DEBUG_LOG="$LOGS_DIR/$logsubdir/eos-$los_ver-$builddate-$RELEASE_TYPE-$codename.log" if [ -f /root/userscripts/pre-build.sh ]; then echo ">> [$(date)] Running pre-build.sh for $codename" >> "$DEBUG_LOG" @@ -298,8 +297,8 @@ for branch in ${BRANCH_NAME//,/ }; do # Start the build echo ">> [$(date)] Starting build for $codename, $branch branch" | tee -a "$DEBUG_LOG" build_successful=false - echo "ANDROID_JACK_VM_ARGS=${ANDROID_JACK_VM_ARGS}" - echo "Switch to Python2" + echo ">> [$(date)] ANDROID_JACK_VM_ARGS=${ANDROID_JACK_VM_ARGS}" + echo ">> [$(date)] Switch to Python2" ln -fs /usr/bin/python2 /usr/bin/python @@ -375,7 +374,7 @@ for branch in ${BRANCH_NAME//,/ }; do fi fi - echo "Switch back to Python3" + echo ">> [$(date)] Switch back to Python3" ln -fs /usr/bin/python3 /usr/bin/python fi done diff --git a/src/build.sh b/src/build.sh index 47e5c2ba9cd0c9624ce80b21cdd49954bcb55ce5..b16bd865f10aceb94e709bbc95ddffc6868e0f1f 100755 --- a/src/build.sh +++ b/src/build.sh @@ -94,9 +94,9 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then echo ">> [$(date)] (Re)initializing branch repository" TAG_PREFIX="" - if curl https://gitlab.e.foundation/api/v4/projects/659/repository/tags | grep "\"name\":\"${BRANCH_NAME}\"" + if curl -s https://gitlab.e.foundation/api/v4/projects/659/repository/tags?search?${BRANCH_NAME} | jq -r ".[].name" | grep -q ${BRANCH_NAME} then - echo "Branch name ${BRANCH_NAME} is a tag on e/os/releases, prefix with refs/tags/ for 'repo init'" + echo ">> [$(date)] Branch name ${BRANCH_NAME} is a tag on e/os/releases, prefix with refs/tags/ for 'repo init'" TAG_PREFIX="refs/tags/" fi if [ -n ${REPO_INIT_DEPTH} ] && [ ${REPO_INIT_DEPTH} -gt 0 ]; then @@ -240,8 +240,8 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then # Start the build echo ">> [$(date)] Starting build for ${DEVICE}, ${BRANCH_NAME} branch" build_successful=false - echo "ANDROID_JACK_VM_ARGS=${ANDROID_JACK_VM_ARGS}" - echo "Switch to Python2" + echo ">> [$(date)] ANDROID_JACK_VM_ARGS=${ANDROID_JACK_VM_ARGS}" + echo ">> [$(date)] Switch to Python2" ln -fs /usr/bin/python2 /usr/bin/python BRUNCH_DEVICE=${DEVICE} @@ -393,7 +393,7 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then fi - echo "Switch back to Python3" + echo ">> [$(date)] Switch back to Python3" ln -fs /usr/bin/python3 /usr/bin/python fi