forked from AdrianDC/advanced_development_shell_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
android_release_helpers.rc
211 lines (188 loc) · 5.59 KB
/
android_release_helpers.rc
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/bash
#
# Copyright 2015-2017 Adrian DC
#
# 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.
#
# === Standalone Source Helper ===
# source <(curl -Ls https://github.com/AdrianDC/android_development_shell_tools/raw/master/android_adb_host.rc)
# source <(curl -Ls https://github.com/AdrianDC/android_development_shell_tools/raw/master/android_adb_tools.rc)
# source <(curl -Ls https://github.com/AdrianDC/android_development_shell_tools/raw/master/android_adb_installers.rc)
# source <(curl -Ls https://github.com/AdrianDC/android_development_shell_tools/raw/master/android_release_helpers.rc)
# === ROM Output Cleaner ===
function outdevcl()
{
# Usage
if [ -z "${1}" ]; then
echo '';
echo ' Usage: outdevcl <devicename> (Advanced ROM output cleaner for rebuilds)';
echo '';
return;
fi;
# Out path
out_device_path=./out/target/product/${1};
# Rebuild the build properties
if [ -f "${out_device_path}/obj/ETC/system_build_prop_intermediates/build.prop" ]; then
rm -f "${out_device_path}/obj/ETC/system_build_prop_intermediates/build.prop";
fi;
# Run bootimage output cleaner
outbootdevcl "${1}";
# Delete relevant outputs
rm -rf "${out_device_path}/"*"${1}"*".zip";
rm -rf "${out_device_path}/"*"${1}"*".zip.md5sum";
rm -rf "${out_device_path}/data";
rm -rf "${out_device_path}/obj/ETC/system_build_prop_intermediates";
rm -rf "${out_device_path}/obj/PACKAGING/target_files_intermediates";
rm -rf "${out_device_path}/ota_temp/RECOVERY/RAMDISK";
rm -rf "${out_device_path}/"*"ota"*".zip";
rm -rf "${out_device_path}/system";
rm -rf "${out_device_path}/utilities";
rm -rf "${out_device_path}/system"*;
}
# === ROM Output Boot Cleaner ===
function outbootdevcl()
{
# Usage
if [ -z "${1}" ]; then
echo '';
echo ' Usage: outbootdevcl <devicename> (ROM output cleaner for bootimage rebuilds)';
echo '';
return;
fi;
# Out path
out_device_path=./out/target/product/${1};
# Rebuild the default properties
if [ -f "${out_device_path}/ota_temp/RECOVERY/RAMDISK/default.prop" ]; then
rm -f "${out_device_path}/ota_temp/RECOVERY/RAMDISK/default.prop";
fi;
if [ -f "${out_device_path}/recovery/root/default.prop" ]; then
rm -f "${out_device_path}/recovery/root/default.prop";
fi;
# Delete relevant outputs
rm -rf "${out_device_path}/boot"*;
rm -rf "${out_device_path}/combinedroot";
rm -rf "${out_device_path}/combined"*;
rm -rf "${out_device_path}/install";
rm -rf "${out_device_path}/kernel";
rm -rf "${out_device_path}/ramdisk"*;
rm -rf "${out_device_path}/recovery";
rm -rf "${out_device_path}/recovery"*;
rm -rf "${out_device_path}/root";
}
# === ROM Output Sepolicies Cleaner ===
function outsepdevcl()
{
# Usage
if [ -z "${1}" ]; then
echo '';
echo ' Usage: outsepdevcl <devicename> (ROM output cleaner for sepolicies rebuilds)';
echo '';
return;
fi;
# Out path
out_device_path=./out/target/product/${1};
# Cleanup ramdisk files
rm -f "${out_device_path}/root/file_contexts"*;
rm -f "${out_device_path}/root/"*"_contexts";
rm -f "${out_device_path}/root/sepolicy";
rm -f "${out_device_path}/combinedroot/file_contexts"*;
rm -f "${out_device_path}/combinedroot/"*"_contexts";
rm -f "${out_device_path}/combinedroot/sepolicy";
rm -f "${out_device_path}/recovery/root/file_contexts"*;
rm -f "${out_device_path}/recovery/root/"*"_contexts";
rm -f "${out_device_path}/recovery/root/sepolicy";
}
# === Ninja Disabler ===
function noninja()
{
# Usage
if [ -z "${1}" ]; then
echo '';
echo ' Usage: noninja <command...> (Run command without ninja)';
echo '';
return;
fi;
# Run command without ninja
export USE_NINJA=false;
export USE_SOONG_UI=false;
"${@}";
export USE_NINJA=;
export USE_SOONG_UI=;
}
# === Build Without Ninja ===
function mmo()
{
# Usage
if [ -z "${1}" ]; then
echo '';
echo ' Usage: mmo <command...> (Build module without ninja)';
echo '';
return;
fi;
# Build module without ninja
export USE_NINJA=false;
export USE_SOONG_UI=false;
mmm "${@}";
export USE_NINJA=;
export USE_SOONG_UI=;
}
# === Build & Install Without Ninja ===
function mmi()
{
# Usage
if [ -z "${1}" ]; then
echo '';
echo ' Usage: mmi <command...> (Build & install module without ninja)';
echo '';
return;
fi;
# Build & install module without ninja
export USE_NINJA=false;
export USE_SOONG_UI=false;
adbi mmm "${@}";
export USE_NINJA=;
export USE_SOONG_UI=;
}
# === Build & Listen Without Ninja ===
function mmil()
{
# Usage
if [ -z "${1}" ]; then
echo '';
echo ' Usage: mmil <command...> (Build & list module without ninja)';
echo '';
return;
fi;
# Build & list module without ninja
export USE_NINJA=false;
export USE_SOONG_UI=false;
adbil mmm "${@}";
export USE_NINJA=;
export USE_SOONG_UI=;
}
# === CCache Disabler ===
function noccache()
{
# Usage
if [ -z "${1}" ]; then
echo '';
echo ' Usage: noccache <command...> (Run command without CCache)';
echo '';
return;
fi;
# Run command without CCache
local use_ccache=${USE_CCACHE};
export USE_CCACHE=0;
"${@}";
export USE_CCACHE=${use_ccache};
}