-
Notifications
You must be signed in to change notification settings - Fork 0
/
builduu.sh
executable file
·135 lines (116 loc) · 4.46 KB
/
builduu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
mkdir -p /tmp/rom
cd /tmp/rom
pwd
# export sync start time
SYNC_START=$(date +"%s")
git config --global user.name TheGhoulEater
git config --global user.email [email protected]
git config --global credential.helper store
echo "https://PrajjuS:${GH_TOKEN}@github.com" > ~/.git-credentials
# Rom repo sync & dt ( Add roms and update case functions )
rom_one(){
repo init --depth=1 --no-repo-verify -u https://github.com/Project-Elixir/official_manifest -b snow -g default,-mips,-darwin,-notdefault
git clone https://github.com/PrajjuS/local_manifest_vince --depth 1 -b CI .repo/local_manifests
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --force-sync -j$(nproc --all)
export SELINUX_IGNORE_NEVERALLOWS=true
source build/envsetup.sh && lunch aosp_vince-userdebug
}
rom_two(){
repo init --depth=1 --no-repo-verify -u https://github.com/ProjectSakura/android -b 12
git clone https://github.com/PrajjuS/local_manifest_vince --depth 1 -b sakura-12 .repo/local_manifests
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --force-sync -j8
repo sync --force-sync -j1 --fail-fast
export SELINUX_IGNORE_NEVERALLOWS=true
source build/envsetup.sh && lunch lineage_vince-userdebug
}
# setup TG message and build posts
telegram_message() {
curl -s -X POST "https://api.telegram.org/bot${BOTTOKEN}/sendMessage" -d chat_id="${CHATID}" \
-d "parse_mode=Markdown" \
-d text="$1"
}
telegram_build() {
curl --progress-bar -F document=@"$1" "https://api.telegram.org/bot${BOTTOKEN}/sendDocument" \
-F chat_id="${CHATID}" \
-F "disable_web_page_preview=true" \
-F "parse_mode=Markdown" \
-F caption="$2"
}
# Function to be chose based on rom flag in .yml
case "${rom}" in
"ProjectElixir") rom_one
;;
"ProjectSakura") rom_two
;;
*) echo "Invalid option!"
exit 1
;;
esac
# export sync end time and diff with sync start
SYNC_END=$(date +"%s")
SDIFF=$((SYNC_END - SYNC_START))
# Send 'Build Triggered' message in TG along with sync time
telegram_message "
*$rom Build Triggered*
*Date:* \`$(date +"%d-%m-%Y %T")\`
*Sync Time:* \`$((SDIFF / 60)) minute(s) and $((SDIFF % 60)) seconds\`" &> /dev/null
# export build start time
BUILD_START=$(date +"%s")
# setup ccache
export CCACHE_DIR=/tmp/ccache
export CCACHE_EXEC=$(which ccache)
export USE_CCACHE=1
export CCACHE_COMPRESS=true
export CCACHE_COMPRESSLEVEL=1
export CCACHE_LIMIT_MULTIPLE=1
export CCACHE_MAXSIZE=150G
ccache -z
# Build commands for each roms on basis of rom flag in .yml / an additional full build.log is kept.
case "${rom}" in
"ProjectElixir") mka bacon -j30 2>&1 | tee build.log
;;
"ProjectSakura") mka bacon -j18 2>&1 | tee build.log
;;
*) echo "Invalid option!"
exit 1
;;
esac
ls -a $(pwd)/out/target/product/${T_DEVICE}/ # show /out contents
BUILD_END=$(date +"%s")
DIFF=$((BUILD_END - BUILD_START))
# sorting final zip ( commonized considering ota zips, .md5sum etc with similiar names in diff roms)
ZIP=$(find $(pwd)/out/target/product/${T_DEVICE}/ -maxdepth 1 -name "*${T_DEVICE}*.zip" | perl -e 'print sort { length($b) <=> length($a) } <>' | head -n 1)
ZIPNAME=$(basename ${ZIP})
ZIPSIZE=$(du -sh ${ZIP} | awk '{print $1}')
echo "${ZIP}"
# Post Build finished with Time,duration,md5,size&Tdrive link OR post build_error&trimmed build.log in TG
telegram_post(){
if [ -f $(pwd)/out/target/product/${T_DEVICE}/${ZIPNAME} ]; then
rclone copy ${ZIP} vince-new:/Roms/${rom} -P
MD5CHECK=$(md5sum ${ZIP} | cut -d' ' -f1)
DWD=${TDRIVE}${rom}/${ZIPNAME}
telegram_message "
*$rom Build Finished Successfully*
*Build Time:* \`$(($DIFF / 3600)) hour(s) and $(($DIFF % 3600 / 60)) minute(s) and $(($DIFF % 60)) seconds\`
*ROM:* \`${ZIPNAME}\`
*MD5 Checksum:* \`${MD5CHECK}\`
*Download Link:* [Here](${DWD})
*Size:* \`${ZIPSIZE}\`
*Date:* \`$(date +"%d-%m-%Y %T")\`" &> /dev/null
else
BUILD_LOG=$(pwd)/build.log
tail -n 10000 ${BUILD_LOG} >> $(pwd)/buildtrim.txt
LOG1=$(pwd)/buildtrim.txt
echo "CHECK BUILD LOG" >> $(pwd)/out/build_error
LOG2=$(pwd)/out/build_error
TRANSFER=$(curl -T ${LOG1} https://temp.sh/$(basename ${LOG1}))
telegram_build ${LOG2} "
*$rom Build Failed to Compile*
*Build Time:* \`$(($DIFF / 3600)) hour(s) and $(($DIFF % 3600 / 60)) minute(s) and $(($DIFF % 60)) seconds\`
*Build Log:* [Here](${TRANSFER})
*Date:* $(date +"%d-%m-%Y %T")" &> /dev/null
fi
}
telegram_post
ccache -s