diff --git a/.cirrus.yml b/.cirrus.yml index cbe237abbdf..0e6e4a6623d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,7 +1,11 @@ env: CIRRUS_CLONE_DEPTH: 1 BUILD_HOSTNAME: "cirrus-ci.org" - bot_api: "ENCRYPTED[b16032643ad0994cda4822c9d477956f434278d0f786f8e131b585aa4f8510a11f3cd9f6a66a63568d2cba1c4dde25b4]" + bot_api: "ENCRYPTED[d5f8289d835b201789b2b31e728d0cd82a100f1b47ddec69dd6ba49a3712fcfa2719b220fc6a8894865df517a78332ca]" + one: "ENCRYPTED[267097e8096e1e12efc9c6e71626703ddc8ae1c6730511b6207586a045e2dd3bd59dd0b9d632642fc58d89913cc539a8]" + two: "ENCRYPTED[7aa062112fa8a4acebe3b71432937334ed3fa05f2d8eaa044d7976e01cbf3fdff7f01f8c91a9e723304aa8b45816c459]" + three: "ENCRYPTED[799a19ef34b1bd39bd174dbc5b2044e1fd4124b0bf9436ed68a3a197e68be303e15a59b4b448a4f58c44b0faa3c3892b]" + four: "ENCRYPTED[9e0496c7d952b248073be75b1c017479eaf1e341786b6210025800b5d2f4d40b82452928bd6cc43ed1bc1065ee915363]" task: name: Test @@ -16,37 +20,16 @@ task: image: apon77/aosp:cirrus cpu: 2 memory: 4G - - env_script: - - env - show_script: - - cat $CIRRUS_WORKING_DIR/build_rom.sh - notify_script: - - rom_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) - - branch_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh | awk -F "-b " '{print $2}' | awk '{print $1}') - - rom_name=$rom_name-$branch_name - - device=$(grep unch $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) - - grep _jasmine_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=jasmine_sprout - - grep _laurel_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=laurel_sprout - - grep _GM8_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=GM8_sprout - - grep _maple_dsds $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=maple_dsds - - your_telegram_id=@ROM_builders_junk - - show=$(cat $CIRRUS_WORKING_DIR/build_rom.sh) - - curl -s "https://api.telegram.org/bot${bot_api}/sendmessage" -d "text=$device-$rom_name Started - - https://cirrus-ci.com/build/$CIRRUS_BUILD_ID - - $show" -d "chat_id=${your_telegram_id}" -d "parse_mode=HTML" - test_script: - - set -e - - curl -Ls https://raw.githubusercontent.com/ROM-builders/temporary/main/test.sh | bash + env_script: env + show_script: cat $CIRRUS_WORKING_DIR/build_rom.sh + notify_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/notify.sh | bash + test_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/test.sh | bash task: name: Build skip: $CIRRUS_BRANCH == 'main' only_if: $CIRRUS_REPO_OWNER == 'ROM-builders' - depends_on: - - Test + depends_on: Test timeout_in: 4h persistent_worker: labels: @@ -60,168 +43,21 @@ task: - /home/cirrus/roms:/home/cirrus/roms - /home/cirrus/ccache:/home/cirrus/ccache - /home/cirrus/.config:/home/cirrus/.config - - show_script: - - cat $CIRRUS_WORKING_DIR/build_rom.sh - test_script: - - set -e - - curl -Ls https://raw.githubusercontent.com/ROM-builders/temporary/main/test.sh | bash - sync_script: - - set -e - - rom_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) - - branch_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh | awk -F "-b " '{print $2}' | awk '{print $1}') - - rom_name=$rom_name-$branch_name - - mkdir -p ~/roms/$rom_name - - cd ~/roms/$rom_name - - rm -rf .repo/local_manifests - - command=$(head $CIRRUS_WORKING_DIR/build_rom.sh -n $(expr $(grep 'build/envsetup.sh' $CIRRUS_WORKING_DIR/build_rom.sh -n | cut -f1 -d:) - 1)) - - only_sync=$(grep 'repo sync' $CIRRUS_WORKING_DIR/build_rom.sh) - - bash -c "$command" || true - - - set -exv - - curl -sO https://api.cirrus-ci.com/v1/task/$CIRRUS_TASK_ID/logs/sync.log - - a=$(grep 'Cannot remove project' sync.log -m1|| true) - - b=$(grep "^fatal: remove-project element specifies non-existent project" sync.log -m1 || true) - - c=$(grep 'repo sync has finished' sync.log -m1 || true) - - d=$(grep 'Failing repos:' sync.log -n -m1 || true) - - e=$(grep 'fatal: Unable' sync.log || true) - - f=$(grep 'error.GitError' sync.log || true) - - g=$(grep 'error: Cannot checkout' sync.log || true) - - if [[ $a == *'Cannot remove project'* ]] - - then - - a=$(echo $a | cut -d ':' -f2 | tr -d ' ') - - rm -rf $a - - fi - - if [[ $b == *'remove-project element specifies non-existent'* ]] - - then exit 1 - - fi - - if [[ $d == *'Failing repos:'* ]] - - then - - d=$(expr $(grep 'Failing repos:' sync.log -n -m 1| cut -d ':' -f1) + 1) - - d2=$(expr $(grep 'Try re-running' sync.log -n -m1 | cut -d ':' -f1) - 1 ) - - fail_paths=$(head -n $d2 sync.log | tail -n +$d) - - for path in $fail_paths - - do - - rm -rf $path - - aa=$(echo $path|awk -F '/' '{print $NF}') - - rm -rf .repo/project-objects/*$aa.git - - rm -rf .repo/projects/$path.git - - done - - fi - - if [[ $e == *'fatal: Unable'* ]] - - then - - fail_paths=$(grep 'fatal: Unable' sync.log | cut -d ':' -f2 | cut -d "'" -f2) - - for path in $fail_paths - - do - - rm -rf $path - - aa=$(echo $path|awk -F '/' '{print $NF}') - - rm -rf .repo/project-objects/*$aa.git - - rm -rf .repo/project-objects/$path.git - - rm -rf .repo/projects/$path.git - - done - - fi - - if [[ $f == *'error.GitError'* ]] - - then - - rm -rf $(grep 'error.GitError' sync.log | cut -d ' ' -f2) - - fi - - if [[ $g == *'error: Cannot checkout'* ]] - - then - - coerr=$(grep 'error: Cannot checkout' sync.log | cut -d ' ' -f 4| tr -d ':') - - for i in $coerr - - do - - rm -rf .repo/project-objects/$i.git - - done - - fi - #- (repo forall -c 'git checkout .' && bash -c "$only_sync") || (find -name shallow.lock -delete && find -name index.lock -delete && bash -c "$only_sync") - - - if [[ $c == *'repo sync has finished'* ]] - - then true - - else - - repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j$(nproc --all) - - fi - - - rm -rf sync.log - - build_script: - - set -e - - rom_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) - - branch_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh | awk -F "-b " '{print $2}' | awk '{print $1}') - - rom_name=$rom_name-$branch_name - - device=$(grep unch $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) - - grep _jasmine_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=jasmine_sprout - - grep _laurel_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=laurel_sprout - - grep _GM8_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=GM8_sprout - - grep _maple_dsds $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=maple_dsds - - cd ~/roms/$rom_name - - export CCACHE_DIR=~/ccache/$rom_name/$device - - export CCACHE_EXEC=$(which ccache) - - export USE_CCACHE=1 - - ccache -M 8G - - ccache -z - - ls device/*/*/vendorsetup.sh | grep -v generic && echo "Please remove vendorsetup.sh file from device tree, use local manifest for cloning and removing repositories." && exit 1 || true - - command=$(tail $CIRRUS_WORKING_DIR/build_rom.sh -n +$(expr $(grep 'build/envsetup.sh' $CIRRUS_WORKING_DIR/build_rom.sh -n | cut -f1 -d:) - 1)| head -n -1 | grep -v 'rclone copy') - - bash -c "$command" - - ccache_stats_script: - - set -e - - rom_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) - - branch_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh | awk -F "-b " '{print $2}' | awk '{print $1}') - - rom_name=$rom_name-$branch_name - - device=$(grep unch $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) - - grep _jasmine_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=jasmine_sprout - - grep _laurel_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=laurel_sprout - - grep _GM8_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=GM8_sprout - - grep _maple_dsds $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=maple_dsds - - export CCACHE_DIR=~/ccache/$rom_name/$device - - ccache -s - - upload_script: - - set -e - - rom_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) - - branch_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh | awk -F "-b " '{print $2}' | awk '{print $1}') - - rom_name=$rom_name-$branch_name - - device=$(grep unch $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) - - grep _jasmine_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=jasmine_sprout - - grep _laurel_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=laurel_sprout - - grep _GM8_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=GM8_sprout - - grep _maple_dsds $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=maple_dsds - - cd ~/roms/$rom_name - - engzip=$(ls out/target/product/$device/*-eng*.zip | grep -v "retrofit" || true) - - otazip=$(ls out/target/product/$device/*-ota-*.zip | grep -v "hentai" | grep -v "evolution" | grep -v "retrofit" || true) - - awaken=$(ls out/target/product/$device/Project-Awaken*.zip || true) - - octavi=$(ls out/target/product/$device/OctaviOS-R*.zip || true) - - p404=$(ls out/target/product/$device/?.*zip || true) - - cipher=$(ls out/target/product/$device/CipherOS-*-OTA-*.zip || true) - - rm -rf $engzip $otazip $awaken $octavi $p404 $cipher - - dlink=$(basename out/target/product/$device/*.zip) - - command=$(grep 'rclone copy' $CIRRUS_WORKING_DIR/build_rom.sh) - - if [[ $device == jasmine_sprout ]]; then command="rclone copy out/target/product/jasmine_sprout/*zip cirrus:jasmine_sprout -P"; fi - - if [[ $device == laurel_sprout ]]; then command="rclone copy out/target/product/laurel_sprout/*zip cirrus:laurel_sprout -P"; fi - - if [[ $device == GM8_sprout ]]; then command="rclone copy out/target/product/GM8_sprout/*zip cirrus:GM8_sprout -P"; fi - - if [[ $device == maple_dsds ]]; then command="rclone copy out/target/product/maple_dsds/*zip cirrus:maple_dsds -P"; fi - - bash -c "$command" - - echo "Download link https://roms.cirrus-ci.workers.dev/0:/$device/$dlink" - - remove_script: - - set -e - - rom_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) - - branch_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh | awk -F "-b " '{print $2}' | awk '{print $1}') - - rom_name=$rom_name-$branch_name - - device=$(grep unch $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) - - grep _jasmine_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=jasmine_sprout - - grep _laurel_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=laurel_sprout - - grep _GM8_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=GM8_sprout - - grep _maple_dsds $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=maple_dsds - - cd ~/roms/$rom_name - - rm -rf out/target/product/$device + show_script: cat $CIRRUS_WORKING_DIR/build_rom.sh + test_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/test.sh | bash + sync_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/sync.sh | bash + tsync_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/tsync.sh | bash + build_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/build.sh | bash + ccache_stats_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/ccache_stats.sh | bash + upload_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/upload.sh | bash + remove_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/remove.sh | bash task: name: Post Build skip: $CIRRUS_BRANCH == 'main' only_if: $CIRRUS_REPO_OWNER == 'ROM-builders' skip_notifications: true - depends_on: - - Build + depends_on: Build timeout_in: 2m persistent_worker: labels: @@ -231,18 +67,5 @@ task: image: apon77/aosp:cirrus cpu: 2 memory: 4G - - post_build_script: - - set -e - - rom_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) - - branch_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh | awk -F "-b " '{print $2}' | awk '{print $1}') - - rom_name=$rom_name-$branch_name - - device=$(grep unch $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) - - grep _jasmine_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=jasmine_sprout - - grep _laurel_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=laurel_sprout - - grep _GM8_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=GM8_sprout - - grep _maple_dsds $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=maple_dsds - - your_telegram_id=@ROM_builders_channel - - curl -s "https://api.telegram.org/bot${bot_api}/sendmessage" -d "text=$device-$rom_name Succeed - - https://cirrus-ci.com/build/$CIRRUS_BUILD_ID" -d "chat_id=${your_telegram_id}" -d "parse_mode=HTML" + test_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/test.sh | bash + post_build_script: curl -s https://raw.githubusercontent.com/ROM-builders/temporary/main/ci/post_build.sh | bash diff --git a/ci/build.sh b/ci/build.sh new file mode 100755 index 00000000000..a06a4c3f8b3 --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -e +cd ~/roms/$rom_name +export CCACHE_DIR=~/ccache/$rom_name/$device +export CCACHE_EXEC=$(which ccache) +export USE_CCACHE=1 +ccache -M 8G +ccache -z +ls device/*/*/vendorsetup.sh | grep -v generic && echo "Please remove vendorsetup.sh file from device tree, use local manifest for cloning and removing repositories." && exit 1 || true +if [[ " LineageOS-cm-14.1 LineageOS-lineage-15.1 LineageOS-lineage-16.0 " == *"$rom_name"* ]]; then sudo mkdir -p /usr/share/man/man1; sudo apt update; sudo apt install openjdk-8-jdk --no-install-recommends -y; sudo curl -L -o /etc/java-8-openjdk/security/java.security https://raw.githubusercontent.com/Apon77Lab/repo_update/java/java.security; sudo ln -sf /usr/bin/python2 /usr/bin/python; fi +command=$(tail $CIRRUS_WORKING_DIR/build_rom.sh -n +$(expr $(grep 'build/envsetup.sh' $CIRRUS_WORKING_DIR/build_rom.sh -n | cut -f1 -d:) - 1)| head -n -1 | grep -v 'rclone copy') +bash -c "$command" + +succeed_date=$(date +%s) +curl -X PATCH "$two?cirrus_build_id=eq.https://cirrus-ci.com/build/$CIRRUS_BUILD_ID" -H "apikey: $three" -H "Authorization: Bearer $four" -H "Content-Type: application/json" -H "Prefer: return=minimal" -d "{ \"succeed_date\": \"$succeed_date\" }" diff --git a/ci/ccache_stats.sh b/ci/ccache_stats.sh new file mode 100755 index 00000000000..237fdf45a81 --- /dev/null +++ b/ci/ccache_stats.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e +export CCACHE_DIR=~/ccache/$rom_name/$device +ccache -s diff --git a/ci/notify.sh b/ci/notify.sh new file mode 100755 index 00000000000..0054a4d61b7 --- /dev/null +++ b/ci/notify.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +rom_name=$(grep 'repo init' $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) +branch_name=$(grep 'repo init' $CIRRUS_WORKING_DIR/build_rom.sh | awk -F "-b " '{print $2}' | awk '{print $1}') +only_rom=$rom_name +rom_name=$rom_name-$branch_name +device=$(grep unch $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) +grep _jasmine_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=jasmine_sprout +grep _laurel_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=laurel_sprout +grep _GM8_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=GM8_sprout +grep _SCW_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=SCW_sprout +grep _maple_dsds $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=maple_dsds +your_telegram_id=@ROM_builders_junk +show=$(cat $CIRRUS_WORKING_DIR/build_rom.sh) +curl -s "https://api.telegram.org/bot${bot_api}/sendmessage" -d "text=$device-$rom_name Started +https://cirrus-ci.com/build/$CIRRUS_BUILD_ID $show" -d "chat_id=${your_telegram_id}" -d "parse_mode=HTML" + +github_userid=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/ROM-builders/temporary/commits/$CIRRUS_CHANGE_IN_REPO -q '.author.id') +github_username=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/ROM-builders/temporary/commits/$CIRRUS_CHANGE_IN_REPO -q '.author.login') +triggered_date=$(date +%s) +if [[ $BRANCH == *pull/* ]]; then CIRRUS_COMMIT_MESSAGE="" ; fi +curl -X POST "$two" -H "apikey: $three" -H "Authorization: Bearer $four" -H "Content-Type: application/json" -H "Prefer: return=minimal" -d "{ \"github_userid\": \"$github_userid\", \"github_username\": \"$github_username\", \"triggered_date\": \"$triggered_date\", \"branch\": \"$BRANCH\", \"cirrus_build_id\": \"https://cirrus-ci.com/build/$CIRRUS_BUILD_ID\", \"cirrus_task_id\": \"https://cirrus-ci.com/task/$CIRRUS_TASK_ID\", \"cirrus_last_green_build_id\": \"https://cirrus-ci.com/build/$CIRRUS_LAST_GREEN_BUILD_ID\", \"cirrus_commit_message\": \"$CIRRUS_COMMIT_MESSAGE\", \"rom_name\": \"$only_rom\", \"rom_branch\": \"$branch_name\", \"device\": \"$device\" }" diff --git a/ci/post_build.sh b/ci/post_build.sh new file mode 100755 index 00000000000..020d169fb8b --- /dev/null +++ b/ci/post_build.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e +your_telegram_id=@ROM_builders_channel +curl -s "https://api.telegram.org/bot${bot_api}/sendmessage" -d "text=$device-$rom_name Succeed +https://cirrus-ci.com/build/$CIRRUS_BUILD_ID" -d "chat_id=${your_telegram_id}" -d "parse_mode=HTML" diff --git a/ci/remove.sh b/ci/remove.sh new file mode 100755 index 00000000000..0032e1617a8 --- /dev/null +++ b/ci/remove.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -e +rm -rf ~/roms/$rom_name/out/target/product/$device diff --git a/ci/sync.sh b/ci/sync.sh new file mode 100755 index 00000000000..1d6a4cc1341 --- /dev/null +++ b/ci/sync.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e +mkdir -p ~/roms/$rom_name +cd ~/roms/$rom_name +rm -rf .repo/local_manifests +command=$(head $CIRRUS_WORKING_DIR/build_rom.sh -n $(expr $(grep 'build/envsetup.sh' $CIRRUS_WORKING_DIR/build_rom.sh -n | cut -f1 -d:) - 1)) +only_sync=$(grep 'repo sync' $CIRRUS_WORKING_DIR/build_rom.sh) +bash -c "$command" || true diff --git a/ci/test.sh b/ci/test.sh new file mode 100755 index 00000000000..e3073dfd1db --- /dev/null +++ b/ci/test.sh @@ -0,0 +1,139 @@ +#!/usr/bin/env bash + +set -e + +ccheck(){ + check=$(grep "$1" $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) + if [[ $check -gt 0 ]]; then echo "$2"; exit 1; fi +} + +ccheck 'rm ' 'Please dont use rm inside script, use local manifest for this purpose.' +ccheck 'find ' 'Please dont use find inside script, use local manifest for this purpose.' +ccheck 'unlink ' 'Please dont use unlink inside script, use local manifest for this purpose.' +ccheck 'shred ' 'Please dont use shred inside script, use local manifest for this purpose.' +ccheck 'sudo ' 'Please dont use sudo inside script.' +ccheck 'repo forall ' 'Please dont use repo forall inside script.' +ccheck 'curl ' 'Please dont use curl inside script.' +ccheck 'mmma ' 'Please dont use mmma inside script.' +ccheck 'mv ' 'Please dont use mv inside script, use local manifest for this purpose.' +ccheck 'sed ' 'Please dont use sed inside script, use local manifest for this purpose.' +ccheck 'tee ' 'Please dont use tee inside script, its not needed at all..' +ccheck ' clean' 'Please dont use make clean. Server does make installclean by default, which is enough for most of the cases.' +ccheck ' clobber' 'Please dont use make clobber. Server does make installclean by default, which is enough for most of the cases.' +ccheck ' installclean' 'Please dont use make installclean. Server does make installclean by default, which is enough for most of the cases.' +ccheck 'cmka ' 'Please dont use cmka. Server does make installclean by default, which is enough for most of the cases.' +ccheck 'patch ' 'Please dont use patch inside script, use local manifest for this purpose.' +ccheck ' && ' 'Please dont use && inside script, put that command in next line for this purpose.' +ccheck ' & ' 'Please dont use & inside script.' +ccheck "||" 'Please dont use or operator inside script' +ccheck 'git fetch ' 'Please dont use fetch inside script, use local manifest for this purpose.' +ccheck 'repopick ' 'Please dont use repopick inside script, use local manifest for this purpose.' +ccheck "cd *" 'Please dont use cd inside script, use local manifest for this purpose.' + +init_check=$(grep 'repo init' $CIRRUS_WORKING_DIR/build_rom.sh | grep 'depth=1') +if [[ $init_check != *default,-mips,-darwin,-notdefault* ]]; then echo Please use --depth=1 and -g default,-mips,-darwin,-notdefault tags in repo init line.; exit 1; fi + +clone_check=$(grep 'git clone' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) +if [[ $clone_check -gt 1 ]]; then echo Please use local manifest to clone trees and other repositories, we dont allow git clone to clone trees.; exit 1; fi + +manifests_check=$(grep 'git clone' $CIRRUS_WORKING_DIR/build_rom.sh) +if [[ $manifests_check != *.repo/local_manifests* ]]; then echo Please follow git clone line from main branch.; exit 1; fi + +url=https://$(grep 'repo init' $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 3-5 | cut -d ' ' -f 1) +r_name=$(grep 'repo init' $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) +name_check=$(curl -Ls $url 2>&1 | grep 'repo init' | grep $r_name | wc -l) +if [[ $r_name == "Havoc-OS" ]]; then name_check=1; fi +if [[ $name_check == 0 ]]; then echo Please use init line url from rom manifest, its case sensitive. Also follow the format of build_rom.sh file of temporary repo main branch.; exit 1; fi + +j_check=$(tail $CIRRUS_WORKING_DIR/build_rom.sh -n +$(expr $(grep 'build/envsetup.sh' $CIRRUS_WORKING_DIR/build_rom.sh -n | cut -f1 -d:) - 1)| head -n -1 | grep -v 'rclone copy' | grep '\-j' | wc -l) +if [[ $j_check -gt 0 ]]; then echo Please dont specify j value in make line.; exit 1; fi + +bliss_check=$(grep blissify $CIRRUS_WORKING_DIR/build_rom.sh | grep '\-c' | wc -l) +if [[ $bliss_check -gt 0 ]]; then echo Please dont use make clean flag. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi + +bliss_check=$(grep blissify $CIRRUS_WORKING_DIR/build_rom.sh | grep '\--clean' | wc -l) +if [[ $bliss_check -gt 0 ]]; then echo Please dont use make clean flag. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi + +bliss_check=$(grep blissify $CIRRUS_WORKING_DIR/build_rom.sh | grep '\-d' | wc -l) +if [[ $bliss_check -gt 0 ]]; then echo Please dont use make installclean flag. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi + +bliss_check=$(grep blissify $CIRRUS_WORKING_DIR/build_rom.sh | grep '\--devclean' | wc -l) +if [[ $bliss_check -gt 0 ]]; then echo Please dont use make installclean flag. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi + +aospa_check=$(grep "rom-build.sh" $CIRRUS_WORKING_DIR/build_rom.sh | grep '\-c' | wc -l) +if [[ $aospa_check -gt 0 ]]; then echo Please dont use make clean flag. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi + +aospa_check=$(grep "rom-build.sh" $CIRRUS_WORKING_DIR/build_rom.sh | grep '\--clean' | wc -l) +if [[ $aospa_check -gt 0 ]]; then echo Please dont use make clean flag. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi + +aospa_check=$(grep "rom-build.sh" $CIRRUS_WORKING_DIR/build_rom.sh | grep '\-i' | wc -l) +if [[ $aospa_check -gt 0 ]]; then echo Please dont use make installclean flag. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi + +aospa_check=$(grep "rom-build.sh" $CIRRUS_WORKING_DIR/build_rom.sh | grep '\--installclean' | wc -l) +if [[ $aospa_check -gt 0 ]]; then echo Please dont use make installclean flag. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi + +rclone_check=$(grep 'rclone copy' $CIRRUS_WORKING_DIR/build_rom.sh) +rclone_string="rclone copy out/target/product/\$(grep unch \$CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1)/*.zip cirrus:\$(grep unch \$CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) -P" +if [[ $rclone_check != *$rclone_string* ]]; then echo Please follow rclone copy line of main branch.; exit 1; fi + +sync_check=$(grep 'repo sync' $CIRRUS_WORKING_DIR/build_rom.sh) +sync_string="repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j" +if [[ $sync_check != *$sync_string* ]]; then echo Please follow repo sync line of main branch.; exit 1; fi + +rom_name=$(grep 'repo init' $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) +branch_name=$(grep 'repo init' $CIRRUS_WORKING_DIR/build_rom.sh | awk -F "-b " '{print $2}' | awk '{print $1}') +rom_name=$rom_name-$branch_name +supported_roms=' AICP-t13.0 alphadroid-project-alpha-13 AOSPA-uvite ArrowOS-arrow-13.1 ArrowOS-arrow-14.0 bananadroid-13 BlissRoms-typhoon BootleggersROM-tirimbino CarbonROM-cr-9.0 CherishOS-tiramisu CipherOS-thirteen crdroidandroid-11.0 crdroidandroid-12.1 crdroidandroid-13.0 crdroidandroid-14.0 DerpFest-AOSP-14 Evolution-X-udc Havoc-OS-thirteen LineageOS-cm-14.1 LineageOS-lineage-15.1 LineageOS-lineage-16.0 LineageOS-lineage-17.1 LineageOS-lineage-18.1 LineageOS-lineage-19.1 LineageOS-lineage-20.0 Octavi-Staging-thirteen P-404-tokui PixelExperience-thirteen PixelExperience-thirteen-plus PixelExtended-thunder PixelOS-AOSP-thirteen PixysOS-twelve PixysOS-thirteen Project-Awaken-triton ProjectBlaze-13 RisingTechOSS-thirteen ResurrectionRemix-Q Spark-Rom-pyro-next SuperiorOS-thirteen syberia-project-13.0 VoltageOS-13 yaap-thirteen ' + +if [[ $supported_roms != *" $rom_name "* ]]; then echo Not supported rom or branch.; exit 1; fi + +device=$(grep unch $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) +grep _jasmine_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=jasmine_sprout +grep _laurel_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=laurel_sprout +grep _GM8_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=GM8_sprout +grep _SCW_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=SCW_sprout +grep _maple_dsds $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=maple_dsds + +if [[ $BRANCH != *pull/* ]]; then + if [[ $BRANCH != $device-$rom_name-* ]]; then echo Please use proper branch naming described in push group.; exit 1; fi; + if [[ $CIRRUS_COMMIT_MESSAGE == "Update build_rom.sh" ]]; then echo Please use proper commit message.; exit 1; fi; +fi + +if [[ $device == 'copy' ]]; then echo "Please use lunch or brunch command with device codename after . build/envsetup.sh" ; exit 1; fi +if [[ $device == 'mi439' ]]; then echo "Please use device codename Mi439 also create your dt with this device code name." ; exit 1; fi + +if [[ $BRANCH == *pull/* ]]; then + if [[ $CIRRUS_COMMIT_MESSAGE != $device-$rom_name-* ]]; then echo Please use proper PR label described in telegram group.; exit 1; fi + lunch_check=$(grep "unch" $CIRRUS_WORKING_DIR/build_rom.sh | grep -v 'rclone' | wc -l) + if [[ $rom_name != 'Corvus-R-12-test' ]]; then + if [[ $lunch_check -gt 1 ]]; then echo Please build for one device at a time.; exit 1; fi + fi + cd /tmp/cirrus-ci-build + PR_NUM=$(echo $BRANCH|awk -F '/' '{print $2}') + AUTHOR=$(gh pr view $PR_NUM|grep author| awk '{print $2}') + + for id in 66806243 25178653 100027207 77049889 37245252 87101173 91236805 56505303 77262770 60956846 1133897 92011891 80823029 58514579 102499518 73420351 69832543 + do + logins+=" $(gh api -H "Accept: application/vnd.github+json" /user/$id -q '.login')" + done + + for value in $logins + do + if [[ $AUTHOR == $value ]]; then echo Please check \#bad_people instruction in telegram group.; exit 1; fi + done + + joindate=$(date -d $(curl -s https://api.github.com/users/$AUTHOR | grep created_at | cut -d '"' -f4) +%s) + nowdate=$(date +%s) + datediff=$(expr $nowdate - $joindate) + if [[ $datediff -lt 2592000 ]]; then echo Please don\'t try to run build with your new account. Use your original account for doing PR.; exit 1; fi +fi + +if [[ $CIRRUS_USER_PERMISSION == write ]]; then + if [ -z "$CIRRUS_PR" ]; then true; else + echo You are push user. Don\'t do pr and please follow pinned message in push group.; exit 1 + fi +fi + +echo Test passed +echo "rom_name=$rom_name" >> $CIRRUS_ENV +echo "device=$device" >> $CIRRUS_ENV diff --git a/ci/tsync.sh b/ci/tsync.sh new file mode 100755 index 00000000000..bca77549803 --- /dev/null +++ b/ci/tsync.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +mkdir -p ~/roms/$rom_name +cd ~/roms/$rom_name +find .repo -name '*.lock' -delete + +needed_device=$(awk -F "path=" '/device\// {print $2}' .repo/local_manifests/* | awk -F '"' '{print $2}') +needed_kernel=$(awk -F "path=" '/kernel\// {print $2}' .repo/local_manifests/* | awk -F '"' '{print $2}') +needed_vendor=$(awk -F "path=" '/vendor\// {print $2}' .repo/local_manifests/* | awk -F '"' '{print $2}') +devices='asus xiaomi realme motorola micromax wingtech oneplus lenovo' +for device in $devices; do + safe_to_remove_device=$(ls device/$device/* -d 2> /dev/null | grep -v $needed_device) + safe_to_remove_kernel=$(ls kernel/$device/* -d 2> /dev/null | grep -v $needed_kernel) + safe_to_remove_vendor=$(ls vendor/$device/* -d 2> /dev/null | grep -v $needed_vendor) + if [[ -n "$safe_to_remove_device" ]]; then rm -rf $safe_to_remove_device; echo removed $safe_to_remove_device; fi + if [[ -n "$safe_to_remove_kernel" ]]; then rm -rf $safe_to_remove_kernel; echo removed $safe_to_remove_kernel; fi + if [[ -n "$safe_to_remove_vendor" ]]; then rm -rf $safe_to_remove_vendor; echo removed $safe_to_remove_vendor; fi +done +curl -sO https://api.cirrus-ci.com/v1/task/$CIRRUS_TASK_ID/logs/sync.log + +a=$(grep 'Cannot remove project' sync.log -m1|| true) +b=$(grep "^fatal: remove-project element specifies non-existent project" sync.log -m1 || true) +c=$(grep 'repo sync has finished' sync.log -m1 || true) +d=$(grep 'Failing repos:' sync.log -n -m1 || true) +e=$(grep 'fatal: Unable' sync.log || true) +f=$(grep 'error.GitError' sync.log || true) +g=$(grep 'error: Cannot checkout' sync.log || true) +echo -e "a=$a \nb=$b \nc=$c \nd=$d \ne=$e \nf=$f \ng=$g \n" + +if [[ $a == *'Cannot remove project'* ]]; then + a=$(echo $a | cut -d ':' -f2 | tr -d ' ') + rm -rf $a + echo removed $a +fi + +if [[ $b == *'remove-project element specifies non-existent'* ]]; then exit 1; fi + +if [[ $d == *'Failing repos:'* ]]; then + d=$(expr $(grep 'Failing repos:' sync.log -n -m 1| cut -d ':' -f1) + 1) + d2=$(expr $(grep 'Try re-running' sync.log -n -m1 | cut -d ':' -f1) - 1 ) + fail_paths=$(head -n $d2 sync.log | tail -n +$d) + echo -e "d=$d \nd2=$d2 \nfail_paths=$fail_paths" + for path in $fail_paths + do + rm -rf $path + echo removed $path + aa=$(echo $path|awk -F '/' '{print $NF}') + rm -rf .repo/project-objects/*$aa.git .repo/projects/$path.git + echo removed .repo/project-objects/*$aa.git .repo/projects/$path.git + done +fi + +if [[ $e == *'fatal: Unable'* ]]; then + fail_paths=$(grep 'fatal: Unable' sync.log | cut -d ':' -f2 | cut -d "'" -f2) + echo -e "fail_paths=$fail_paths" + for path in $fail_paths + do + rm -rf $path + echo removed $path + aa=$(echo $path|awk -F '/' '{print $NF}') + rm -rf .repo/project-objects/*$aa.git .repo/project-objects/$path.git .repo/projects/$path.git + echo removed .repo/project-objects/*$aa.git .repo/project-objects/$path.git .repo/projects/$path.git + done +fi + +if [[ $f == *'error.GitError'* ]]; then + rm -rf $(grep 'error.GitError' sync.log | cut -d ' ' -f2) +fi + +if [[ $g == *'error: Cannot checkout'* ]]; then + coerr=$(grep 'error: Cannot checkout' sync.log | cut -d ' ' -f 4| tr -d ':') + echo -e "coerr=$coerr" + for i in $coerr + do + rm -rf .repo/project-objects/$i.git + echo removed .repo/project-objects/$i.git + done +fi + +if [[ $c == *'repo sync has finished'* ]]; then + true +else + repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync +fi +rm -rf sync.log + +dirty_dirs="prebuilts/clang/host/linux-x86" +for dir in $dirty_dirs +do + [[ -n $(git -C "$dir" status -s) ]] && (rm -rf "$dir"; echo removed $dir; repo sync) || true +done diff --git a/ci/upload.sh b/ci/upload.sh new file mode 100755 index 00000000000..437059a5af2 --- /dev/null +++ b/ci/upload.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e +cd ~/roms/$rom_name +engzip=$(ls out/target/product/$device/*-eng*.zip | grep -v "retrofit" || true) +otazip=$(ls out/target/product/$device/*-ota-*.zip | grep -v "hentai" | grep -v "evolution" || true) +awaken=$(ls out/target/product/$device/Project-Awaken*.zip || true) +octavi=$(ls out/target/product/$device/OctaviOS-R*.zip || true) +p404=$(ls out/target/product/$device/?.*zip || true) +cipher=$(ls out/target/product/$device/CipherOS-*-OTA-*.zip || true) +rm -rf $engzip $otazip $awaken $octavi $p404 $cipher +dlink=$(basename out/target/product/$device/*.zip) +unzip -P $one -q ~/.config/1.zip -d ~ +file=out/target/product/$device/*.zip +rsync -vhcP -e ssh $file apon77@frs.sourceforge.net:/home/frs/project/rom-builders/$device/ +echo "Download link https://sourceforge.net/projects/rom-builders/files/$device/$dlink/download" diff --git a/test.sh b/test.sh deleted file mode 100755 index 0e19a30c1f8..00000000000 --- a/test.sh +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/bash -set -e - -init_check=$(grep 'repo init' $CIRRUS_WORKING_DIR/build_rom.sh | grep 'depth=1') -if [[ $init_check != *default,-mips,-darwin,-notdefault* ]]; then echo Please use --depth=1 and -g default,-mips,-darwin,-notdefault tags in repo init line.; exit 1; fi - - -clone_check=$(grep 'git clone' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $clone_check -gt 1 ]]; then echo Please use local manifest to clone trees and other repositories, we dont allow git clone to clone trees.; exit 1; fi - -rm_check=$(grep 'rm ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $rm_check -gt 0 ]]; then echo Please dont use rm inside script, use local manifest for this purpose.; exit 1; fi - -url=https://$(grep init $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 3-5 | cut -d ' ' -f 1) -r_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) -name_check=$(curl -Ls $url 2>&1 | grep 'repo init' | grep $r_name | wc -l) -if [[ $r_name == "Havoc-OS" ]]; then name_check=1; fi -if [[ $name_check == 0 ]]; then echo Please use init line url from rom manifest, its case sensitive. Also follow the format of build_rom.sh file of temporary repo main branch.; exit 1; fi - -command=$(tail $CIRRUS_WORKING_DIR/build_rom.sh -n +$(expr $(grep 'build/envsetup.sh' $CIRRUS_WORKING_DIR/build_rom.sh -n | cut -f1 -d:) - 1)| head -n -1 | grep -v 'rclone copy') -j_check=$(tail $CIRRUS_WORKING_DIR/build_rom.sh -n +$(expr $(grep 'build/envsetup.sh' $CIRRUS_WORKING_DIR/build_rom.sh -n | cut -f1 -d:) - 1)| head -n -1 | grep -v 'rclone copy' | grep '\-j' | wc -l) -if [[ $j_check -gt 0 ]]; then echo Please dont specify j value in make line.; exit 1; fi - -sudo_check=$(grep 'sudo ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $sudo_check -gt 0 ]]; then echo Please dont use sudo inside script.; exit 1; fi - -forall_check=$(grep 'repo forall ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $forall_check -gt 0 ]]; then echo Please dont use repo forall inside script.; exit 1; fi - -curl_check=$(grep 'curl ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $curl_check -gt 0 ]]; then echo Please dont use curl inside script.; exit 1; fi - -mmma_check=$(grep 'mmma ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $mmma_check -gt 0 ]]; then echo Please dont use mmma inside script.; exit 1; fi - -mv_check=$(grep 'mv ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $mv_check -gt 0 ]]; then echo Please dont use mv inside script, use local manifest for this purpose.; exit 1; fi - -sed_check=$(grep 'sed ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $sed_check -gt 0 ]]; then echo Please dont use sed inside script, use local manifest for this purpose.; exit 1; fi - -tee_check=$(grep 'tee ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $tee_check -gt 0 ]]; then echo Please dont use tee inside script, its not needed at all..; exit 1; fi - -clean_check=$(grep ' clean' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $clean_check -gt 0 ]]; then echo Please dont use make clean. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi - -bliss_check=$(grep blissify $CIRRUS_WORKING_DIR/build_rom.sh | grep '\-c' | wc -l) -if [[ $bliss_check -gt 0 ]]; then echo Please dont use make clean flag. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi - -bliss_check=$(grep blissify $CIRRUS_WORKING_DIR/build_rom.sh | grep '\-d' | wc -l) -if [[ $bliss_check -gt 0 ]]; then echo Please dont use make installclean flag. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi - -clobber_check=$(grep ' clobber' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $clobber_check -gt 0 ]]; then echo Please dont use make clobber. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi - -installclean_check=$(grep ' installclean' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $installclean_check -gt 0 ]]; then echo Please dont use make installclean. Server does make installclean by default, which is enough for most of the cases.; exit 1; fi - -patch_check=$(grep 'patch ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $patch_check -gt 0 ]]; then echo Please dont use patch inside script, use local manifest for this purpose.; exit 1; fi - -and_check=$(grep ' && ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $and_check -gt 0 ]]; then echo 'Please dont use && inside script, put that command in next line for this purpose.'; exit 1; fi - -and_check2=$(grep ' & ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $and_check2 -gt 0 ]]; then echo 'Please dont use & inside script.'; exit 1; fi - -rclone_check=$(grep 'rclone copy' $CIRRUS_WORKING_DIR/build_rom.sh) -rclone_string="rclone copy out/target/product/\$(grep unch \$CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1)/*.zip cirrus:\$(grep unch \$CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) -P" -if [[ $rclone_check != *$rclone_string* ]]; then echo Please follow rclone copy line of main branch.; exit 1; fi - -sync_check=$(grep 'repo sync' $CIRRUS_WORKING_DIR/build_rom.sh) -sync_string="repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j" -if [[ $sync_check != *$sync_string* ]]; then echo Please follow repo sync line of main branch.; exit 1; fi - -fetch_check=$(grep 'git fetch ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $fetch_check -gt 0 ]]; then echo Please dont use fetch inside script, use local manifest for this purpose.; exit 1; fi - -pick_check=$(grep 'repopick ' $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $pick_check -gt 0 ]]; then echo Please dont use repopick inside script, use local manifest for this purpose.; exit 1; fi - -cd_check=$(grep "cd *" $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $cd_check -gt 0 ]]; then echo Please dont use cd inside script, use local manifest for this purpose.; exit 1; fi - -or_check=$(grep "||" $CIRRUS_WORKING_DIR/build_rom.sh | wc -l) -if [[ $or_check -gt 0 ]]; then echo Please dont use or operator inside script; exit 1; fi - - - -rom_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d / -f 4) -branch_name=$(grep init $CIRRUS_WORKING_DIR/build_rom.sh | awk -F "-b " '{print $2}' | awk '{print $1}') -rom_name=$rom_name-$branch_name -supported_roms=' AICP-s12.1 AOSPA-sapphire AospExtended-12.1.x AOSPK-twelve ArrowOS-arrow-12.1 BlissRoms-arcadia-next Bootleggers-BrokenLab-sambunimbo CarbonROM-cr-9.0 CherishOS-twelve-one CipherOS-twelve-L ConquerOS-twelve Corvus-R-12-test crdroidandroid-11.0 crdroidandroid-12.1 DerpFest-12-12.1 DotOS-dot12.1 Evolution-X-elle Evolution-X-snow Fork-Krypton-A12 ForkLineageOS-lineage-19.1 Fusion-OS-twelve Havoc-OS-eleven Havoc-OS-twelve Komodo-OS-12.1 lighthouse-os-sailboat_L1 LineageOS-lineage-14.1 LineageOS-lineage-15.1 LineageOS-lineage-16.0 LineageOS-lineage-17.1 LineageOS-lineage-18.1 LineageOS-lineage-19.1 P-404-shinka PixelExperience-twelve PixelExperience-twelve-plus PixelExtended-snow PixelOS-Pixelish-twelve PixysOS-twelve PotatoProject-frico_mr1-release Project-Awaken-12.1 ProjectBlaze-12.1 Project-Fluid-fluid-12.1 ProjectRadiant-twelve ProjectStreak-twelve.one Project-Kaleidoscope-sunflowerleaf ResurrectionRemix-Q RiceDroid-twelve ShapeShiftOS-android_12 Spark-Rom-spark SuperiorOS-twelvedotone StagOS-s12.1 StyxProject-S syberia-project-12.1 The-RAVEN-OS-twelve VoltageOS-12l xdroid-oss-twelve yaap-twelve ' -if [[ $supported_roms != *" $rom_name "* ]]; then echo Not supported rom or branch.; exit 1; fi - -device=$(grep unch $CIRRUS_WORKING_DIR/build_rom.sh -m 1 | cut -d ' ' -f 2 | cut -d _ -f 2 | cut -d - -f 1) -grep _jasmine_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=jasmine_sprout -grep _laurel_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=laurel_sprout -grep _GM8_sprout $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=GM8_sprout -grep _maple_dsds $CIRRUS_WORKING_DIR/build_rom.sh > /dev/null && device=maple_dsds - -if [[ $BRANCH != *pull/* ]]; then -if [[ $BRANCH != $device-$rom_name-* ]]; then echo Please use proper branch naming described in push group.; exit 1; fi; -if [[ $CIRRUS_COMMIT_MESSAGE == "Update build_rom.sh" ]]; then echo Please use proper commit message.; exit 1; fi; -fi - -if [[ $device == 'copy' ]]; then echo "Please use lunch or brunch command with device codename after . build/envsetup.sh" ; exit 1; fi -if [[ $device == 'mi439' ]]; then echo "Please use device codename Mi439 also create your dt with this device code name." ; exit 1; fi - -if [[ $BRANCH == *pull/* ]]; then - -if [[ $CIRRUS_COMMIT_MESSAGE != $device-$rom_name-* ]]; then echo Please use proper PR label described in telegram group.; exit 1; fi - -lunch_check=$(grep "unch" $CIRRUS_WORKING_DIR/build_rom.sh | grep -v 'rclone' | wc -l) -if [[ $rom_name != 'Corvus-R-12-test' ]]; then -if [[ $lunch_check -gt 1 ]]; then echo Please build for one device at a time.; exit 1; fi -fi - -cd /tmp/cirrus-ci-build -PR_NUM=$(echo $BRANCH|awk -F '/' '{print $2}') -AUTHOR=$(gh pr view $PR_NUM|grep author| awk '{print $2}') -for value in vicenteicc2008 random2907 RioChanY ajitlenka30 basic-general ZunayedDihan Badroel07 Ravithakral SumonSN SevralT yograjsingh-cmd nit-in Sanjeev stunner ini23 CyberTechWorld horoid ishakumari772 atharv2951 Lite120 anant-goel 01soni247 fakeriz Krtonia -do - if [[ $AUTHOR == $value ]]; then - echo Please check \#pr instruction in telegram group.; exit 1; fi -done -fi - -if [[ $CIRRUS_USER_PERMISSION == write ]]; then -if [ -z "$CIRRUS_PR" ]; then echo fine; else -echo You are push user. Don\'t do pr and please follow pinned message in push group.; exit 1 -fi -fi - -echo Test passed