-
Notifications
You must be signed in to change notification settings - Fork 56
/
redroid.py
100 lines (94 loc) · 3.93 KB
/
redroid.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
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
#!/usr/bin/env python3
import argparse
from stuff.gapps import Gapps
from stuff.litegapps import LiteGapps
from stuff.magisk import Magisk
from stuff.mindthegapps import MindTheGapps
from stuff.ndk import Ndk
from stuff.widevine import Widevine
import tools.helper as helper
import subprocess
def main():
dockerfile = ""
tags = []
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-a', '--android-version',
dest='android',
help='Specify the Android version to build',
default='11.0.0',
choices=['13.0.0', '12.0.0', '12.0.0_64only', '11.0.0', '10.0.0', '9.0.0', '8.1.0'])
parser.add_argument('-g', '--install-gapps',
dest='gapps',
help='Install OpenGapps to ReDroid',
action='store_true')
parser.add_argument('-lg', '--install-litegapps',
dest='litegapps',
help='Install LiteGapps to ReDroid',
action='store_true')
parser.add_argument('-n', '--install-ndk-translation',
dest='ndk',
help='Install libndk translation files',
action='store_true')
parser.add_argument('-mtg', '--install-mindthegapps',
dest='mindthegapps',
help='Install MindTheGapps to ReDroid',
action='store_true')
parser.add_argument('-m', '--install-magisk', dest='magisk',
help='Install Magisk ( Bootless )',
action='store_true')
parser.add_argument('-w', '--install-widevine', dest='widevine',
help='Integrate Widevine DRM (L3)',
action='store_true')
parser.add_argument('-c', '--container',
dest='container',
default='docker',
help='Specify container type',
choices=['docker', 'podman'])
args = parser.parse_args()
dockerfile = dockerfile + \
"FROM redroid/redroid:{}-latest\n".format(
args.android)
tags.append(args.android)
if args.gapps:
if args.android in ["11.0.0"]:
Gapps().install()
dockerfile = dockerfile + "COPY gapps /\n"
tags.append("gapps")
else:
helper.print_color( "WARNING: OpenGapps only supports 11.0.0", helper.bcolors.YELLOW)
if args.litegapps:
LiteGapps(args.android).install()
dockerfile = dockerfile + "COPY litegapps /\n"
tags.append("litegapps")
if args.mindthegapps:
MindTheGapps(args.android).install()
dockerfile = dockerfile + "COPY mindthegapps /\n"
tags.append("mindthegapps")
if args.ndk:
if args.android in ["11.0.0", "12.0.0", "12.0.0_64only"]:
arch = helper.host()[0]
if arch == "x86" or arch == "x86_64":
Ndk().install()
dockerfile = dockerfile+"COPY ndk /\n"
tags.append("ndk")
else:
helper.print_color(
"WARNING: Libndk seems to work only on redroid:11.0.0 or redroid:12.0.0", helper.bcolors.YELLOW)
if args.magisk:
Magisk().install()
dockerfile = dockerfile+"COPY magisk /\n"
tags.append("magisk")
if args.widevine:
Widevine(args.android).install()
dockerfile = dockerfile+"COPY widevine /\n"
tags.append("widevine")
print("\nDockerfile\n"+dockerfile)
with open("./Dockerfile", "w") as f:
f.write(dockerfile)
new_image_name = "redroid/redroid:"+"_".join(tags)
subprocess.run([args.container, "build", "-t", new_image_name, "."])
helper.print_color("Successfully built {}".format(
new_image_name), helper.bcolors.GREEN)
if __name__ == "__main__":
main()