forked from Akianonymus/rom_builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·131 lines (104 loc) · 3.99 KB
/
build.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
#!/bin/bash
source /drone/src/config.sh
# Email for git
ci_repo=$(cat /drone/src/.git/config | grep url | sed 's|url = https://github.com/||' | sed 's|.git||')
git config --global user.email "$GITHUB_EMAIL"
git config --global user.name "$GITHUB_USER"
TELEGRAM_TOKEN=$(cat /tmp/tg_token)
TELEGRAM_CHAT=$(cat /tmp/tg_chat)
GITHUB_TOKEN=$(cat /tmp/gh_token)
export TELEGRAM_TOKEN
export TELEGRAM_CHAT
export GITHUB_TOKEN
function trim_darwin() {
cd .repo/manifests
cat default.xml | grep -v darwin >temp && cat temp >default.xml && rm temp
git commit -a -m "Magic"
cd ../
cat manifest.xml | grep -v darwin >temp && cat temp >manifest.xml && rm temp
cd ../
}
function dogbin()
{
# Usage: dogbin <file> or | dogbin (Share dogbin logs)
# Variables
local tmp;
local url;
# Get output
tmp=$(mktemp);
if [ ! -z "${1}" ] && [ -f "${1}" ]; then
tee "${tmp}" < "${1}";
else
cat | tee "${tmp}";
fi;
echo '';
# Trim line rewrites
edittrimoutput "${tmp}";
# Upload to dogbin
url="http://del.dog/$(timeout -k 10 10 curl -X POST -s --data-binary @"${tmp}" \
https://del.dog/documents | grep key | cut -d \" -f 4)";
echo " dogbin: ${url}";
# Delete temp file
rm "${tmp}";
}
export outdir="out/target/product/$device"
ci_url="$(echo "https://cloud.drone.io/"$ci_repo"/"$(cat /tmp/build_no)"/1/2" | tr -d " ")"
cd /home/ci
git clone https://"$GITHUB_USER":"${GITHUB_TOKEN}"@github.com/"$GITHUB_USER"/google-git-cookies.git >/dev/null 2>&1
if [ -e google-git-cookies ]; then
cd google-git-cookies
bash setup_cookies.sh
cd ../
rm -rf google-git-cookies
else
echo "google-git-cookies repo not found on your account, see steps on README"
fi
mkdir "$ROM"
cd "$ROM"
repo init -u "$manifest_url" -b "$branch" --depth 1 >/dev/null 2>&1
echo "Sync started for "$manifest_url""
telegram -M "Sync Started for ["$ROM"]("$manifest_url")"
SYNC_START=$(date +"%s")
#trim_darwin >/dev/null 2>&1
repo sync --force-sync --current-branch --no-tags --no-clone-bundle --optimized-fetch --prune -j$(nproc --all) -q 2>&1 >>logwe 2>&1
bash /drone/src/clone.sh
SYNC_END=$(date +"%s")
SYNC_DIFF=$((SYNC_END - SYNC_START))
if [ -e frameworks/base ]; then
echo "Sync completed successfully in $((SYNC_DIFF / 60)) minute(s) and $((SYNC_DIFF % 60)) seconds"
echo "Build Started"
telegram -M "Sync completed successfully in $((SYNC_DIFF / 60)) minute(s) and $((SYNC_DIFF % 60)) seconds
Build Started: [See Progress]("$ci_url")"
BUILD_START=$(date +"%s")
. build/envsetup.sh >/dev/null 2>&1
source /drone/src/config.sh
# if [ -e device/"$oem"/"$device" ]; then
# python3 /drone/src/dependency_cloner.py
# fi
lunch "$rom_vendor_name"_"$device"-userdebug >/dev/null 2>&1
mka bacon | grep "$device"
BUILD_END=$(date +"%s")
BUILD_DIFF=$((BUILD_END - BUILD_START))
export finalzip_path=$(ls "$outdir"/*201*.zip | tail -n -1)
export zip_name=$(echo "$finalzip_path" | sed "s|"$outdir"/||")
export tag=$( echo "$zip_name" | sed 's|.zip||')
if [ -e "$finalzip_path" ]; then
echo "Build completed successfully in $((BUILD_DIFF / 60)) minute(s) and $((BUILD_DIFF % 60)) seconds"
echo "Uploading"
github-release "$release_repo" "$tag" "master" ""$ROM" for "$device"
Date: $(env TZ="$timezone" date)" "$finalzip_path"
echo "Uploaded"
telegram -M "Build completed successfully in $((BUILD_DIFF / 60)) minute(s) and $((BUILD_DIFF % 60)) seconds
Download: ["$zip_name"](https://github.com/"$release_repo"/releases/download/"$tag"/"$zip_name")"
else
echo "Build failed in $((BUILD_DIFF / 60)) minute(s) and $((BUILD_DIFF % 60)) seconds"
telegram -N -M "Build failed in $((BUILD_DIFF / 60)) minute(s) and $((BUILD_DIFF % 60)) seconds"
exit 1
fi
else
echo "Sync failed in $((SYNC_DIFF / 60)) minute(s) and $((SYNC_DIFF % 60)) seconds"
dogbin logwe
telegram -N -M "Sync failed in $((SYNC_DIFF / 60)) minute(s) and $((SYNC_DIFF % 60)) seconds
dogbin: ${url}"
exit 1
fi