-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.py
59 lines (51 loc) · 2.03 KB
/
build.py
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
import os
from subprocess import *
from git import Repo
from datetime import datetime
from shutil import *
from telethon import TelegramClient, events, sync
from telethon.sessions import StringSession
from dotenv import load_dotenv
# Set environmental variables
load_dotenv("env")
# Set Additional variables
now = datetime.now().strftime("%d%m%Y-%M")
zip_name = "Triton-Rova-" + now
k_out = "out/arch/arm64/boot/Image.gz-dtb"
anyk_repo_link = "https://github.com/Thagoo/AnyKernel3"
API_ID = os.environ.get('API_ID')
API_HASH = os.environ.get('API_HASH')
STRING_SESSION = os.environ.get('STRING_SESSION')
CHANNEL_ID = os.environ.get('CHANNEL_ID')
client = TelegramClient(StringSession(STRING_SESSION), API_ID, API_HASH)
client.start()
def Get_AnyK():
""" Clone AnyKernel repo from git"""
Repo.clone_from(anyk_repo_link, "AnyKernel3")
rmtree("AnyKernel3/.git")
def Cp_Ul():
""" Copy build output, archive and upload to TG """
copy(k_out, "AnyKernel3")
call('cd AnyKernel3;zip temp.zip * -r9;mv temp.zip ..', shell=True)
os.rename('temp.zip', zip_name+'.zip')
# Upload file to Telegram
client.send_file(CHANNEL_ID, file=zip_name+'.zip', caption="Triton kernel for rolex or riva \nfollow @tboxxx for more updates", force_document=True)
print("Compilation Successfull \n" + zip_name)
def Build():
""" Compilation """
print("Compiling Triton kernel")
Get_AnyK()
os.environ['KBUILD_BUILD_USER'] = "Thago"
os.environ['KBUILD_BUILD_HOST'] = "DroneCI"
path= os.environ['PATH']
os.environ['PATH'] = "/tmp/proton/bin:"+path
call('make O=out ARCH=arm64 rova_defconfig; make -j32 O=out \ ARCH=arm64 \ CC=clang \ CROSS_COMPILE=aarch64-linux-gnu- \ CROSS_COMPILE_ARM32=arm-linux-gnueabi- \ AR=llvm-ar \ NM=llvm-nm', shell=True)
if not os.path.exists(k_out):
print('Compilation error')
# Send a message to TG about error and exit
client.send_message(CHANNEL_ID, 'Build stopped Compilation Error')
exit()
else:
Cp_Ul()
if __name__ == "__main__":
Build()