From 9a681625f26111e1e809aeee3ee218d4795d5055 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sat, 20 Jul 2019 22:12:43 +0530 Subject: [PATCH] drone: Switch to debian buster Signed-off-by: baalajimaestro --- .drone.yml | 4 +++- build.sh | 50 +++++++++++++++++++++++++++++++------------------- runner.sh | 4 ---- xml_strip.py | 9 +++++++++ 4 files changed, 43 insertions(+), 24 deletions(-) create mode 100644 xml_strip.py diff --git a/.drone.yml b/.drone.yml index 2371509..2155a4a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,7 @@ name: MaestroCI Build Bot steps: - name: test - image: ubuntu:rolling + image: baalajimaestro/android_build:latest environment: TELEGRAM_TOKEN: from_secret: TELEGRAM_TOKEN @@ -11,5 +11,7 @@ steps: from_secret: TELEGRAM_CHAT GH_REPO_NAME: from_secret: GH_REPO_NAME + GH_PERSONAL_TOKEN: + from_secret: GH_PERSONAL_TOKEN commands: - bash ./runner.sh diff --git a/build.sh b/build.sh index e25903f..d62d109 100644 --- a/build.sh +++ b/build.sh @@ -13,23 +13,21 @@ ##### Build Env Dependencies build_env() { + TELEGRAM_TOKEN=$(cat /tmp/tg_token) TELEGRAM_CHAT=$(cat /tmp/tg_chat) +export GH_PERSONAL_TOKEN=$(cat /tmp/gh_token) export TELEGRAM_TOKEN export TELEGRAM_CHAT cd ~ +git clone https://baalajimaestro:${GH_PERSONAL_TOKEN}@github.com/baalajimaestro/google-git-cookies.git > /dev/null 2>&1 +cd google-git-cookies +bash run.sh +cd .. +rm -rf google-git-cookies git config --global user.email "baalajimaestro@raphielgang.org" git config --global user.name "baalajimaestro" -git clone https://github.com/akhilnarang/scripts > /dev/null 2>&1 -cd scripts -bash setup/android_build_env.sh > /dev/null 2>&1 -echo "Build Dependencies Installed....." -sudo unlink /usr/bin/python -curl -sLo upload-github-release-asset.sh https://gist.githubusercontent.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447/raw/dbadd7d310ce8446de89c4ffdf1db0b400d0f6c3/upload-github-release-asset.sh -sudo apt-get install p7zip-full p7zip-rar wget curl brotli -y > /dev/null 2>&1 -sudo ln -s /usr/bin/python2.7 /usr/bin/python -cd .. -rm -rf scripts +echo "Google Git Cookie Set!" } cyan=' ' @@ -191,7 +189,8 @@ prepare_source() { printf "%s\n" "**************************" printf "%s\n\n" $($reset) source_android_scr=$prepare_source_scr - repo init -u $repo_init_url -b $repo_branch + repo init -u $repo_init_url -b $repo_branch --depth 1 + python3 /drone/src/xml_strip.py sync_android_scr=1 ##### if this fails idc, its your problem biatch } @@ -223,7 +222,8 @@ sync_source() { printf '%s\n' "Repo Sync Started" printf "%s\n" "*********************************************" printf "%s\n\n" $($reset) - repo sync -j$(nproc) --no-tags --no-clone-bundle -c > /dev/null 2>&1 + repo sync --force-sync --current-branch --no-tags --no-clone-bundle --optimized-fetch --prune -j$(nproc) -q > sync.log 2>&1 + bash telegram -f sync.log printf "%s\n\n" $($cyan) printf "%s\n" "*********************************************" printf '%s\n' "Repo Sync Finished" @@ -240,7 +240,6 @@ start_env() { setup_paths() { source build/envsetup.sh - export USE_CCACHE=1 ####### Workaround the Missing Lunch combos for official trees if [ $prepare_source_scr ]; then printf "%s\n\n" $($cyan) @@ -301,7 +300,12 @@ clean_target() { } upload() { - +# if [ $telegram_scr ] && [ ! $(grep -c "#### build completed successfully" build.log) -eq 1 ]; then +# bash telegram -D -M " +# *Build for $device_scr failed!*" +# bash telegram -f build.log +# exit +# fi case $build_type_scr in bacon) file=$(ls $OUT_SCR/*201*.zip | tail -n 1) @@ -332,15 +336,15 @@ upload() { git commit -m "[MaestroCI]: Releasing Build ${prepare_source_scr}-$(date +%d%m%y)" git tag "$(date +%d%m%y)-${prepare_source_scr}-$(cat /tmp/build_no)" git remote rm origin - git remote add origin https://baalajimaestro:$(cat /tmp/gh_token)@github.com/baalajimaestro/Generic-ROM-Builder.git + git remote add origin https://baalajimaestro:${GH_PERSONAL_TOKEN}@github.com/baalajimaestro/Generic-ROM-Builder.git git push origin binary --follow-tags build_date_scr=$(date +%F_%H-%M) if [ ! -z $build_orig_scr ] && [ $upload_scr ]; then - bash upload-github-release-asset.sh github_api_token=$(cat /tmp/gh_token) owner=baalajimaestro repo=$(cat /tmp/gh_repo) tag="$(date +%d%m%y)-${prepare_source_scr}-$(cat /tmp/build_no)" filename=$file + bash upload-github-release-asset.sh github_api_token=$GH_PERSONAL_TOKEN owner=baalajimaestro repo=$(cat /tmp/gh_repo) tag="$(date +%d%m%y)-${prepare_source_scr}-$(cat /tmp/build_no)" filename=$file file=`ls $HOME/buildscript/*.img | tail -n 1` id=$(gdrive upload --parent $G_FOLDER $file | grep "Uploaded" | cut -d " " -f 2) elif [ -z $build_orig_scr ] && [ $upload_scr ]; then - bash upload-github-release-asset.sh github_api_token=$(cat /tmp/gh_tokens) owner=baalajimaestro repo=$(cat /tmp/gh_repo) tag="$(date +%d%m%y)-${prepare_source_scr}-$(cat /tmp/build_no)" filename=$file + bash upload-github-release-asset.sh github_api_token=$GH_PERSONAL_TOKEN owner=baalajimaestro repo=$(cat /tmp/gh_repo) tag="$(date +%d%m%y)-${prepare_source_scr}-$(cat /tmp/build_no)" filename=$file fi if [ $telegram_scr ] && [ $upload_scr ]; then @@ -351,11 +355,13 @@ upload() { } build() { - +# if [ -f build.log ]; then +# rm -f build.log +# fi if [ -f out/.lock ]; then rm -f out/.lock fi - + export USE_CCACHE=0 cd $DEVICEPATH_SCR mk_scr=`grep .mk AndroidProducts.mk | cut -d "/" -f "2"` product_scr=`grep "PRODUCT_NAME :=" $mk_scr | cut -d " " -f 3` @@ -377,6 +383,12 @@ build() { Time: *$(date "+%r")* " fi mka bacon | grep $device_scr + printf "%s\n\n" $($cyan) + printf "%s\n" "***********************************************" + printf '%s\n' "Finished build with target $($yellow)"$build_type_scr""$($cyan)" for"$($yellow)" $device_scr $($cyan)" + printf "%s\n" "***********************************************" + printf "%s\n\n" $($reset) + sleep 2 } build_env diff --git a/runner.sh b/runner.sh index fe40962..20476a5 100644 --- a/runner.sh +++ b/runner.sh @@ -10,16 +10,12 @@ # shellcheck disable=1090 echo "***BuildBot***" -apt update > /dev/null 2>&1 -apt upgrade -y > /dev/null 2>&1 echo $TELEGRAM_TOKEN > /tmp/tg_token echo $GH_PERSONAL_TOKEN > /tmp/gh_token echo $GH_REPO_NAME > /tmp/gh_repo echo $DRONE_BUILD_NUMBER > /tmp/build_no echo $TELEGRAM_CHAT > /tmp/tg_chat echo `pwd` > /tmp/loc -apt install sudo git lsb-core apt-utils -y > /dev/null 2>&1 -echo 'Initial Dependencies Installed......' sudo echo "ci ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers useradd -m -d /home/ci ci useradd -g ci wheel diff --git a/xml_strip.py b/xml_strip.py new file mode 100644 index 0000000..d3ebfb9 --- /dev/null +++ b/xml_strip.py @@ -0,0 +1,9 @@ +import os + +useless_deps=["darwin"] +with open('/home/ci/.repo/manifest.xml') as oldfile, open('/home/ci/.repo/manifest_new.xml', 'w') as newfile: + for line in oldfile: + if not any(deps in line for deps in useless_deps): + newfile.write(line) +os.remove('/home/ci/.repo/manifest.xml') +os.rename('/home/ci/.repo/manifest_new.xml','/home/ci/.repo/manifest.xml')