-
-
Save aitorCalderon/df2f40174221c02f2494c426cc9e4454 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Copyright (C) 2019-2020 ArianK16a | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
export USERNAME=arian | |
export HOSTNAME=server | |
LOCAL_PATH="$(pwd)" | |
telegram () { | |
/home/arian/telegram.sh/telegram "$1" "$2" "$3" "$4" "$5" | |
} | |
prepare () { | |
cd $LOCAL_PATH | |
source build/envsetup.sh | |
export CCACHE_EXEC=$(which ccache) | |
export USE_CCACHE=1 | |
ccache -M 100G | |
} | |
prepare_vanilla () { | |
rm -rf vendor/extra | |
git clone https://github.com/ArianK16a/android_vendor_extra.git -b vanilla vendor/extra | |
export TARGET_UNOFFICIAL_BUILD_ID= | |
} | |
prepare_gapps () { | |
rm -rf vendor/extra | |
git clone https://github.com/ArianK16a/android_vendor_extra.git -b gapps vendor/extra | |
export TARGET_UNOFFICIAL_BUILD_ID=GMS | |
} | |
# build device gapps | |
build () { | |
prepare | |
breakfast "$1" | |
repo sync --force-sync -q | |
bash "$LOCAL_PATH"/picks.sh | |
if [ "$2" = "gapps" ]; then | |
prepare_gapps | |
else | |
prepare_vanilla | |
fi | |
make clean | |
# make installclean | |
telegram -N -M "*(i)* \`"$(basename $LOCAL_PATH)"\` compilation for \`"$1"\` *started* on "$HOSTNAME"." | |
build_start=$(date +"%s") | |
brunch "$1" | |
build_result "$1" "$2" | |
if [ -f $LOCAL_PATH/.last_build_time ]; then | |
upload "$1" "$2" | |
fi | |
} | |
convertsecs() { | |
h=$(bc <<< "${1}/3600") | |
m=$(bc <<< "(${1}%3600)/60") | |
s=$(bc <<< "${1}%60") | |
printf "%02d:%02d:%02d\n" $h $m $s | |
} | |
# build_result device gapps | |
build_result () { | |
result=$(echo $?) | |
build_end=$(date +"%s") | |
diff=$(($build_end - $build_start)) | |
time=$(convertsecs "$diff") | |
if [ "$2" = "gapps" ]; then | |
type="GMS" | |
else | |
type="VANILLA" | |
fi | |
if [ "$result" = "0" ]; then | |
telegram -M "*(i)* \`"$(basename $LOCAL_PATH)"\` compilation for \`"$1"\` *completed successfully* on "$HOSTNAME". Build variant: \`$type\`. Build time: \`$time\`." | |
echo "$time" > $LOCAL_PATH/.last_build_time | |
else | |
telegram -M "*(i)* \`"$(basename $LOCAL_PATH)"\` compilation for \`"$1"\` *failed* on "$HOSTNAME". Build variant: \`$type\`. Build time: \`$time\`." | |
# exit -1 | |
fi | |
} | |
# upload device gapps | |
upload () { | |
if [ "$1" = "" ]; then | |
echo "specify a device" | |
fi | |
project="$(basename $LOCAL_PATH)" | |
rsync -Ph out/target/product/"$1"/lineage-*-"$1".zip [email protected]:/home/frs/project/ephedraceae/"$1"/"$project"/ | |
rsync -Ph out/target/product/"$1"/lineage-*-"$1".zip.md5sum [email protected]:/home/frs/project/ephedraceae/"$1"/"$project"/ | |
release "$1" "$project" "$2" | |
} | |
# release device project gapps | |
release () { | |
device="$1" | |
project="$2" | |
if [ "$3" = "gapps" ]; then | |
type="GMS" | |
else | |
type="VANILLA" | |
fi | |
download_link="https://sourceforge.net/projects/ephedraceae/files/"$1"/"$2"/$(basename $(ls out/target/product/"$1"/lineage-*-"$1".zip))" | |
time="$(cat $LOCAL_PATH/.last_build_time)" | |
md5sum="$(cat "$LOCAL_PATH"/out/target/product/"$1"/lineage-*-"$1".zip.md5sum | awk '{print $1}')" | |
md5sum_link="$download_link".md5sum | |
if [ "$3" = "gapps" ]; then | |
device_variant="$1_gms" | |
else | |
device_variant="$1" | |
fi | |
changelog_link=https://raw.githubusercontent.com/arian-ota/changelog/"$project"/"$device_variant".txt | |
telegram -c -1001426238293 -M " \ | |
*New LineageOS 17.1 build for Mi 9T available!* | |
💬 Variant: \`"$type"\` | |
*Download* | |
⬇️ ["$project"]("$download_link") | |
✅ [md5sum]("$md5sum_link") | |
🚧 [Changelog]("$changelog_link") | |
@StarWarsFlowers | |
" | |
update_ota "$device" "$project" "$3" | |
} | |
# update_ota device project gapps | |
update_ota () { | |
if [ "$1" = "" ]; then | |
echo "specify a device" | |
return -1 | |
fi | |
if [ "$2" = "" ]; then | |
echo "specify a project" | |
return -1 | |
fi | |
if [ "$3" = "gapps" ]; then | |
device="$1_gms" | |
else | |
device="$1" | |
fi | |
breakfast "$1" | |
datetime=$(cat "$OUT"/system/build.prop | grep ro.build.date.utc=) | |
datetime="${datetime#*=}" | |
filename=$(cat "$OUT"/system/build.prop | grep ro.lineage.version=) | |
filename="${filename#*=}" | |
filename=lineage-"$filename".zip | |
id=$(cat "$OUT"/"$filename".md5sum | awk '{print $1}') | |
romtype=$(cat "$OUT"/system/build.prop | grep ro.lineage.releasetype=) | |
romtype="${romtype#*=}" | |
size=$(ls -l "$OUT"/"$filename" | awk '{print $5}') | |
url="https://sourceforge.net/projects/ephedraceae/files/"$1"/"$2"/"$filename"/download" | |
version=$(cat "$OUT"/system/build.prop | grep ro.lineage.build.version=) | |
version="${version#*=}" | |
cd "$LOCAL_PATH"/ota | |
git add -A && git stash && git reset | |
git fetch [email protected]:arian-ota/ota.git "$2" | |
git checkout FETCH_HEAD | |
if [ -f "$device".json ]; | |
then | |
rm "$device".json | |
fi | |
echo -e "{ | |
\"response\": [ | |
{ | |
\"datetime\": \"$datetime\", | |
\"filename\": \"$filename\", | |
\"id\": \"$id\", | |
\"romtype\": \"$romtype\", | |
\"size\": \"$size\", | |
\"url\": \"$url\", | |
\"version\": \"$version\" | |
} | |
] | |
}" > "$device".json | |
git add "$device".json | |
git commit -m "$device: Automatic OTA update" | |
git push [email protected]:arian-ota/ota.git HEAD:"$2" | |
cd $LOCAL_PATH | |
update_changelog $1 $2 $3 | |
} | |
# update_changelog device project gapps | |
update_changelog () { | |
if [ "$1" = "" ]; then | |
echo "specify a device" | |
return -1 | |
fi | |
if [ "$2" = "" ]; then | |
echo "specify a project" | |
return -1 | |
fi | |
if [ "$3" = "gapps" ]; then | |
device="$1_gms" | |
else | |
device="$1" | |
fi | |
cd "$LOCAL_PATH"/changelog | |
git add -A && git stash && git reset | |
git fetch [email protected]:arian-ota/changelog.git "$2" | |
git checkout FETCH_HEAD | |
cd $LOCAL_PATH | |
export changelog="$LOCAL_PATH"/changelog/"$device".txt | |
if [ -f $changelog ]; | |
then | |
rm $changelog | |
fi | |
touch $changelog | |
for i in $(seq 7); | |
do | |
export After_Date=`date --date="$i days ago" +%F` | |
k=$(expr $i - 1) | |
export Until_Date=`date --date="$k days ago" +%F` | |
echo "====================" >> $changelog; | |
echo " $Until_Date " >> $changelog; | |
echo "====================" >> $changelog; | |
while read path; | |
do | |
# https://www.cyberciti.biz/faq/unix-linux-bash-script-check-if-variable-is-empty/ | |
Git_log=`git --git-dir ./${path}/.git log --after=$After_Date --until=$Until_Date --pretty=tformat:"%h %s [%an]" --abbrev-commit --abbrev=7` | |
if [ ! -z "${Git_log}" ]; then | |
printf "\n* ${path}\n${Git_log}\n" >> $changelog; | |
fi | |
done < ./.repo/project.list; | |
done | |
cd changelog | |
git add "$device".txt | |
git commit -m "$device: Automatic changelog update" | |
git push [email protected]:arian-ota/changelog.git HEAD:"$2" | |
cd $LOCAL_PATH | |
} | |
if [ -f env_overwrite.sh ]; then | |
source env_overwrite.sh | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment