From 7ae314440f9539c2b0fd0df31c1f6c25f807dc84 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Fri, 5 Nov 2021 13:14:27 +0100 Subject: [PATCH] Fix GitlabCI repository url and improve Android dockerfiles --- .gitlab-ci.yml | 9 +++++---- build_scripts/Android/Dockerfile | 9 ++++++++- build_scripts/GitlabCI/Android.Dockerfile | 4 +++- build_scripts/GitlabCI/getRepoArgs.sh | 9 +++++++++ 4 files changed, 25 insertions(+), 6 deletions(-) create mode 100755 build_scripts/GitlabCI/getRepoArgs.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a3be771bd..35e94ac96 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,7 +13,6 @@ workflow: - if: $CI_COMMIT_BRANCH variables: - REPO_ARGS_CMD: '[ -n "$CI_MERGE_REQUEST_ID" ] && echo --build-arg REPO_URL=\"$CI_MERGE_REQUEST_SOURCE_PROJECT_URL\" --build-arg REPO_BRANCH=\"$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME\" || echo --build-arg REPO_URL=\"$CI_REPOSITORY_URL\" --build-arg REPO_BRANCH=\"$CI_COMMIT_BRANCH\"' UBUNTU_TESTING_IMAGE_TAG: "$CI_REGISTRY_IMAGE/gitlabci_outputs/ubuntu_testing:$CI_COMMIT_SHA" build-ubuntu-test-image: @@ -27,7 +26,7 @@ build-ubuntu-test-image: - > docker build -t $UBUNTU_TESTING_IMAGE_TAG - $($REPO_ARGS_CMD) + $($CI_PROJECT_DIR/build_scripts/GitlabCI/getRepoArgs.sh) --file $CI_PROJECT_DIR/build_scripts/GitlabCI/gitlabCI.Dockerfile Dockercontext - docker push $UBUNTU_TESTING_IMAGE_TAG @@ -74,7 +73,8 @@ build-android-arm-apk: script: - mkdir Dockercontext - > - docker build -t retroshare:android_arm_latest $($REPO_ARGS_CMD) + docker build -t retroshare:android_arm_latest + $($CI_PROJECT_DIR/build_scripts/GitlabCI/getRepoArgs.sh) --file $CI_PROJECT_DIR/build_scripts/GitlabCI/Android.Dockerfile Dockercontext # see https://stackoverflow.com/a/59055906 @@ -92,7 +92,8 @@ build-android-arm64-apk: script: - mkdir Dockercontext - > - docker build -t retroshare:android_arm64_latest $($REPO_ARGS_CMD) + docker build -t retroshare:android_arm64_latest + $($CI_PROJECT_DIR/build_scripts/GitlabCI/getRepoArgs.sh) --build-arg ANDROID_PLATFORM_VER=21 --build-arg ANDROID_NDK_ARCH=arm64 --file $CI_PROJECT_DIR/build_scripts/GitlabCI/Android.Dockerfile diff --git a/build_scripts/Android/Dockerfile b/build_scripts/Android/Dockerfile index 6ff2ba2f5..2e4b8c762 100644 --- a/build_scripts/Android/Dockerfile +++ b/build_scripts/Android/Dockerfile @@ -16,6 +16,11 @@ # docker login registry.gitlab.com # docker push ${CI_IMAGE_NAME} +## To extract the generated APK easily you can run after the build complete +# docker cp \ +# $(docker create --rm ${CI_IMAGE_NAME}):/retroshare-service-android-build/android-build/build/outputs/apk/debug/android-build-debug.apk \ +# /tmp/RetroShare_Android_Service.apk + FROM ubuntu:20.04 @@ -85,6 +90,7 @@ RUN qmake ../RetroShare/jsonapi-generator/src/ \ RUN mkdir /retroshare-service-android-build WORKDIR /retroshare-service-android-build +ARG RS_SERVICE_QMAKE_EXTRA_OPTS RUN $($PREPARE_TOOLCHAIN get_qt_dir | head -n 1)/bin/qmake ../RetroShare \ -spec android-clang \ CONFIG+=retroshare_service CONFIG+=rs_jsonapi \ @@ -93,7 +99,8 @@ RUN $($PREPARE_TOOLCHAIN get_qt_dir | head -n 1)/bin/qmake ../RetroShare \ NATIVE_LIBS_TOOLCHAIN_PATH=$NATIVE_LIBS_TOOLCHAIN_PATH \ CONFIG+=no_retroshare_gui CONFIG+=no_rs_service_webui_terminal_password \ CONFIG+=no_rs_service_terminal_login \ - CONFIG+=no_rs_sam3 CONFIG+=no_rs_sam3_libsam3 + CONFIG+=no_rs_sam3 CONFIG+=no_rs_sam3_libsam3 \ + $RS_SERVICE_QMAKE_EXTRA_OPTS RUN make -j$(nproc) RUN make install INSTALL_ROOT=/retroshare-service-android-build/android-build/ RUN $($PREPARE_TOOLCHAIN get_qt_dir | head -n 1)/bin/androiddeployqt \ diff --git a/build_scripts/GitlabCI/Android.Dockerfile b/build_scripts/GitlabCI/Android.Dockerfile index 30942e95a..a0844972d 100644 --- a/build_scripts/GitlabCI/Android.Dockerfile +++ b/build_scripts/GitlabCI/Android.Dockerfile @@ -25,6 +25,7 @@ WORKDIR /retroshare-service-android-build # ARG declared before FROM get wiped after it, so we need declaring it again ARG ANDROID_NDK_ARCH=arm +ARG RS_SERVICE_QMAKE_EXTRA_OPTS RUN $($PREPARE_TOOLCHAIN get_qt_dir | head -n 1)/bin/qmake ../RetroShare \ -spec android-clang \ CONFIG+=retroshare_service CONFIG+=rs_jsonapi \ @@ -33,7 +34,8 @@ RUN $($PREPARE_TOOLCHAIN get_qt_dir | head -n 1)/bin/qmake ../RetroShare \ NATIVE_LIBS_TOOLCHAIN_PATH=$NATIVE_LIBS_TOOLCHAIN_PATH \ CONFIG+=no_retroshare_gui CONFIG+=no_rs_service_webui_terminal_password \ CONFIG+=no_rs_service_terminal_login \ - CONFIG+=no_rs_sam3 CONFIG+=no_rs_sam3_libsam3 + CONFIG+=no_rs_sam3 CONFIG+=no_rs_sam3_libsam3 \ + $RS_SERVICE_QMAKE_EXTRA_OPTS RUN make -j$(nproc) RUN make install INSTALL_ROOT=/retroshare-service-android-build/android-build/ diff --git a/build_scripts/GitlabCI/getRepoArgs.sh b/build_scripts/GitlabCI/getRepoArgs.sh new file mode 100755 index 000000000..8794524e1 --- /dev/null +++ b/build_scripts/GitlabCI/getRepoArgs.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +[ -n "$CI_MERGE_REQUEST_ID" ] && + echo \ + --build-arg REPO_URL="$CI_MERGE_REQUEST_SOURCE_PROJECT_URL" \ + --build-arg REPO_BRANCH="$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" || + echo \ + --build-arg REPO_URL="$CI_REPOSITORY_URL" \ + --build-arg REPO_BRANCH="$CI_COMMIT_BRANCH"