@@ -16,7 +16,7 @@ function gslr() {
16
16
echo -e " ~ Error [gslr:$RETC ], could not find any line containing ${RED} $2 ${RC} " && return $RETC
17
17
fi ;
18
18
else
19
- if test -z " $NPUT " ; then
19
+ if test -z " $1 " ; then
20
20
echo -e " ~ Error [gslr:3], lack of input" && return 1
21
21
fi ;
22
22
fi
@@ -151,69 +151,113 @@ function build.main() {
151
151
};
152
152
153
153
function patch.aosp_root() {
154
- files_to_patch=(
155
- " device/generic/common/device.mk"
156
- " bootable/newinstaller/Android.mk"
157
- " bootable/newinstaller/initrd/init"
158
- " bootable/newinstaller/install/scripts/1-install"
159
- " bootable/newinstaller/install/grub2/efi/boot/android.cfg"
160
- )
154
+ if test -n " $BIGDROID_PROJECT " ; then
155
+ files_to_patch=(
156
+ " initial_ramdisk/init"
157
+ " install_ramdisk/scripts/1-install"
158
+ " install_ramdisk/grub2/efi/boot/android.cfg"
159
+ )
160
+ else
161
+ files_to_patch=(
162
+ " device/generic/common/device.mk"
163
+ " bootable/newinstaller/Android.mk"
164
+ " bootable/newinstaller/initrd/init"
165
+ " bootable/newinstaller/install/scripts/1-install"
166
+ " bootable/newinstaller/install/grub2/efi/boot/android.cfg"
167
+ )
168
+ fi
169
+
170
+ # function get.patch_file() {
171
+ # local patch_file="$1"
172
+ # local line
173
+ # for line in "${files_to_patch[@]}"; do
174
+ # echo "$line" | grep -q ".*${patch_file}\$" && break
175
+ # done
176
+ # echo "$aosp_root/$line"
177
+ # }
161
178
162
179
function patch.apply() {
163
- local FILE=" $1 "
180
+ local FILE=" ${1##*/ } "
181
+ local FILE_PATH=" $1 "
164
182
echo -e " ==== Applying GearLock patches to $FILE "
165
- case " $FILE " in
166
- " ${files_to_patch[0]} " )
167
- local _dir=" $( echo " $0 " | grep -q ' vendor' && echo ' vendor' || echo ' bootable' ) "
168
- gslr " $aosp_root /$FILE " \
169
- ' PRODUCT_COPY_FILES := \\' \
170
- " PRODUCT_COPY_FILES := \\ \n $_dir \/gearlock\/out\/gri\/gearlock:gearlock \\ " \
171
- || handleError " Failed to patch $aosp_root /$FILE "
172
- ;;
173
-
174
- " ${files_to_patch[1]} " )
175
- line=" $( grep -n ' BUILT_IMG.*:=.*$(.*)' " $aosp_root /$FILE " | head -n1 \
176
- | sed ' s|/|\\/|g; s|initrd.img|initrd.img gearlock|' ) "
177
-
178
- sed -i " ${line%%:* } s/.*/${line#*: } /" " $aosp_root /$FILE " \
179
- || handleError " Failed to patch $aosp_root /$FILE "
180
- ;;
181
-
182
- " ${files_to_patch[2]} " )
183
- gslr " $aosp_root /$FILE " " mount_sdcard" " mount_sdcard; hook_gearinit" \
184
- || handleError " Failed to patch $aosp_root /$FILE "
185
- ;;
183
+
184
+ if [ " ${FILE} " == " device.mk" ]; then
185
+ local _dir=" $( echo " $0 " | grep -q ' vendor' && echo ' vendor' || echo ' bootable' ) "
186
+ gslr " $FILE_PATH " \
187
+ ' PRODUCT_COPY_FILES := \\' \
188
+ " PRODUCT_COPY_FILES := \\\\ \n $_dir \/gearlock\/out\/gri\/gearlock:gearlock \\\\ " \
189
+ || handleError " Failed to patch $FILE "
190
+
191
+ elif [ " ${FILE} " == " Android.mk" ]; then
192
+ line=" $( grep -n ' BUILT_IMG.*:=.*$(.*)' " $FILE_PATH " | head -n1 \
193
+ | sed ' s|/|\\/|g; s| gearlock||; s|initrd.img|initrd.img gearlock|' ) "
194
+
195
+ sed -i " ${line%%:* } s/.*/${line#*: } /" " $FILE_PATH " \
196
+ || handleError " Failed to patch $FILE "
197
+
198
+ elif [ " ${FILE} " == " init" ]; then
199
+ gslr " $FILE_PATH " " mount_sdcard" " mount_sdcard; hook_gearinit" \
200
+ || handleError " Failed to patch $FILE "
186
201
187
- " ${files_to_patch[3]} " )
188
- line=" $( grep -n ' files=.*".*initrd.img.*"' " $aosp_root / $FILE " | head -n1 \
189
- | sed ' s|initrd.img|initrd.img /mnt/$SRC/gearlock|; s|/|\\/|g' ) "
202
+ elif [ " ${FILE} " == " 1-install " ] ; then
203
+ line=" $( grep -n ' files=.*".*initrd.img.*"' " $FILE_PATH " | head -n1 \
204
+ | sed ' s| /mnt/$SRC/gearlock||; s| initrd.img|initrd.img /mnt/$SRC/gearlock|; s|/|\\/|g' ) "
190
205
191
- sed -i " ${line%%:* } s/.*/${line#*: } /" " $aosp_root /$FILE " \
192
- || handleError " Failed to patch $aosp_root /$FILE "
193
- ;;
206
+ sed -i " ${line%%:* } s/.*/${line#*: } /" " $FILE_PATH " \
207
+ || handleError " Failed to patch $FILE "
194
208
195
- " ${files_to_patch[4]} " )
196
- sed -i ' s/add_entry.*$/& NORECOVERY=1/g' " $aosp_root / $FILE "
209
+ elif [ " ${FILE} " == " android.cfg " ] ; then
210
+ sed -i ' s/add_entry.*$/& NORECOVERY=1/g' " $FILE_PATH "
197
211
sed -i ' s|submenu "Advanced options -> ".*$|& \
198
212
add_entry "$live - Boot into GearLock recovery mode" ALWAYSRECOVERY=1\
199
213
add_entry "$live - Boot into GearLock recovery mode with NOGFX=1 flag" ALWAYSRECOVERY=1 NOGFX=1\
200
- add_entry "$live - Boot with Auto-ExtFs-Repair flag" quiet FIXFS=1|' " $aosp_root /$FILE "
201
- ;;
202
- esac
203
- (
204
- cd " $aosp_root /${FILE%/* } " || handleError " Failed to change dir to $aosp_root /${FILE%/* } "
205
- git commit -a -m " Update/apply GearLock patches for $FILE " --author=" AXON <axonasif@gmail.com>" 1> /dev/null
206
- )
214
+ add_entry "$live - Boot with Auto-ExtFs-Repair flag" quiet FIXFS=1|' " $FILE_PATH "
215
+ fi
216
+
217
+ if test -z " $BIGDROID_PROJECT " ; then
218
+ local ORIG_PWD=" $( pwd) "
219
+ FILE=" $FILE_PATH "
220
+ cd " ${FILE%/* } " || handleError " Failed to change dir to ${FILE%/* } "
221
+ git commit -a -m " Update/apply GearLock patches for ${FILE/ " $aosp_root " / } " --author=" AXON <axonasif@gmail.com>" 1> /dev/null
222
+ cd " $ORIG_PWD "
223
+ fi
207
224
}
208
225
209
226
# Start with updating/placing hook script
210
- local HOOK_PATH=" $aosp_root /bootable/newinstaller/initrd/scripts/0-hook"
211
- rsync " $_execDir /installer/hook" " $HOOK_PATH " || handleError " Failed to copy hook into $HOOK_PATH "
227
+ HOOK_PATH=" $(
228
+ if test -n " $BIGDROID_PROJECT " ; then
229
+ echo " $aosp_root /initial_ramdisk/scripts/0-hook"
230
+ else
231
+ echo " $aosp_root /bootable/newinstaller/initrd/scripts/0-hook"
232
+ fi
233
+ ) " && {
234
+ rsync " $_execDir /installer/hook" " $HOOK_PATH " || handleError " Failed to copy hook into $HOOK_PATH "
235
+ (
236
+ test -z " $BIGDROID_PROJECT " && {
237
+ cd " ${HOOK_PATH%/* } " || return 1
238
+ cd ../../ || return 1
239
+ git commit -a -m " Update/apply GearLock hook" --author=" AXON <axonasif@gmail.com>" 1> /dev/null
240
+ }
241
+ )
242
+ }
212
243
213
244
# Now let's find which files we need to patch
214
245
for _file in " ${files_to_patch[@]} " ; do
215
- ! grep -i -E -q ' gearlock|gearinit' " $aosp_root /$_file " \
216
- && patch.apply " $_file "
246
+ local patch_sum_file=" $_execDir /.patch_sum"
247
+ local _sel_file=" $aosp_root /$_file "
248
+ test -e " $_sel_file " && {
249
+ if test -z " $NO_PATCH_SUM " && test -e " $patch_sum_file " ; then
250
+ test " $( sha256sum " $_sel_file " | awk ' {print $1}' ) " ! = " $( echo " $( < " $patch_sum_file " ) " | grep " ${_sel_file##*/ } " | awk ' {print $2}' ) " && {
251
+ patch.apply " $_sel_file " && \
252
+ sed -i " s|${_sel_file##*/ } .*|${_sel_file##*/ } $( sha256sum " $_sel_file " | awk ' {print $1}' ) |" " $patch_sum_file "
253
+ }
254
+ else
255
+ export NO_PATCH_SUM=true
256
+ ! grep -i -E -q ' gearlock|gearinit' " $_sel_file " \
257
+ && patch.apply " $_sel_file " && \
258
+ echo " ${_sel_file##*/ } $( sha256sum " $_sel_file " | awk ' {print $1}' ) " >> " $patch_sum_file "
259
+ fi
260
+ }
217
261
done
218
262
}
219
263
@@ -225,34 +269,29 @@ function gen.newVersion() {
225
269
" $SEMVER_BIN " " $@ "
226
270
}
227
271
# Gather the data we need
228
- local CURRENT_VERSION PATCH_VERSION MINOR_VERSION VERSION_FILE LAST_SYNC_FILE
272
+ local CURRENT_VERSION PATCH_VERSION MINOR_VERSION VERSION_FILE
229
273
230
- LAST_SYNC_FILE=" ${_execDir} /.last_sync"
231
- LAST_SYNC_HARSH=" $( git log --all --ancestry-path ^$( < " $LAST_SYNC_FILE " ) --format=format:%H | tail -n 1) " || return
232
- LAST_COMMIT_HARSH=" $( git rev-parse HEAD) "
233
- NEW_COMMITS=" $( git rev-list --no-merges ${LAST_SYNC_HARSH} ...${LAST_COMMIT_HARSH} | wc -l) "
274
+ NEW_COMMITS=" $( git log --no-merges --pretty=format:" %s" | sed ' /Update version code/Q' | grep -v -i ' ^Update.*' | wc -l) "
234
275
VERSION_FILE=" ${_execDir} /core/version"
235
276
236
277
# Handling what we need to do
237
278
for times in $( seq $NEW_COMMITS ) ; do
238
279
CURRENT_VERSION=" $( < " $VERSION_FILE " ) " || return
239
- PATCH_VERSION=" $( semver get patch $CURRENT_VERSION ) " || return
240
- MINOR_VERSION=" $( semver get minor $CURRENT_VERSION ) " || return
280
+ PATCH_VERSION=" $( semver get patch " $CURRENT_VERSION " ) " || return
281
+ MINOR_VERSION=" $( semver get minor " $CURRENT_VERSION " ) " || return
241
282
242
283
# Version updating logic
243
284
local bumpPoint=" 40"
244
285
local bumpPointMajor=" 10"
245
286
if [ " $PATCH_VERSION " != " $bumpPoint " ] && [ " $PATCH_VERSION " -lt " $bumpPoint " ]; then
246
- echo " $( semver bump patch $CURRENT_VERSION ) " > " $VERSION_FILE "
287
+ echo " $( semver bump patch " $CURRENT_VERSION " ) " > " $VERSION_FILE "
247
288
elif [ " $MINOR_VERSION " == " $bumpPointMajor " ]; then
248
- echo " $( semver bump major $CURRENT_VERSION ) " > " $VERSION_FILE "
289
+ echo " $( semver bump major " $CURRENT_VERSION " ) " > " $VERSION_FILE "
249
290
elif [ " $PATCH_VERSION " == " $bumpPoint " ]; then
250
- echo " $( semver bump minor $CURRENT_VERSION ) " > " $VERSION_FILE "
291
+ echo " $( semver bump minor " $CURRENT_VERSION " ) " > " $VERSION_FILE "
251
292
fi
252
293
done
253
294
254
- # Update last commit hash cache file
255
- echo " $LAST_COMMIT_HARSH " > " $LAST_SYNC_FILE "
256
295
257
296
}
258
297
@@ -272,29 +311,29 @@ function gen.conventionalChangelog() {
272
311
# Now lets phrase them
273
312
for log in " $featLog " " $fixLog " " $perfLog " " $refactorLog " " $choreLog " " $buildLog " " $ciLog " ; do
274
313
if test -n " $log " ; then
275
- logName=" $( echo " $log " | head -n1 | sed ' s|(.*)||g' | cut -d ' : ' -f1 ) "
314
+ logName=" $( echo " $log " | head -n1 | cut -d ' : ' -f1 | sed ' s|(.*)||g' ) "
276
315
# Create H1
277
316
case " $logName " in
278
317
" feat" )
279
- echo " # Feature " >> " $output "
318
+ echo " ### New Features " >> " $output "
280
319
;;
281
320
" fix" )
282
- echo -e " \n\n# Bugfix " >> " $output "
321
+ echo -e " \n\n### Bug Fixes " >> " $output "
283
322
;;
284
323
" perf" )
285
- echo -e " \n\n# Performance Improvements" >> " $output "
324
+ echo -e " \n\n### Performance Improvements" >> " $output "
286
325
;;
287
326
" refactor" )
288
- echo -e " \n\n# Refactoring " >> " $output "
327
+ echo -e " \n\n### Refactors " >> " $output "
289
328
;;
290
329
" chore" )
291
- echo -e " \n\n# Chore " >> " $output "
330
+ echo -e " \n\n### Chores " >> " $output "
292
331
;;
293
332
" build" )
294
- echo -e " \n\n# Build" >> " $output "
333
+ echo -e " \n\n### Build System " >> " $output "
295
334
;;
296
335
" ci" )
297
- echo -e " \n\n# Ci " >> " $output "
336
+ echo -e " \n\n### Continuous Integration " >> " $output "
298
337
;;
299
338
esac
300
339
@@ -343,7 +382,7 @@ function setup.devEnv() {
343
382
\033[0;31msudo chroot \" $NEW_ROOT \" /gearlock/bin/env GDEBUG=true /gearlock/bin/bash\033[0m"
344
383
}
345
384
346
-
385
+ # CLAP
347
386
case " $1 " in
348
387
--aosp-project-makefile)
349
388
aosp_root=" $( pwd) " || handleError " Failed to locate \$ aosp_root"
@@ -352,7 +391,6 @@ case "$1" in
352
391
patch.aosp_root
353
392
build.main " -mx23"
354
393
;;
355
-
356
394
--aosp-project-vendorsetup)
357
395
shift
358
396
test -z " $1 " && handleError " Failed to locate \$ aosp_root"
@@ -362,7 +400,11 @@ case "$1" in
362
400
patch.aosp_root
363
401
build.main " -mx23"
364
402
;;
365
-
403
+ --bigdroid-project-hook)
404
+ export BIGDROID_PROJECT=true
405
+ test -z " $SYSTEM_DIR " && exit 1
406
+ exec " $0 " --aosp-project-vendorsetup " $MOUNT_DIR "
407
+ ;;
366
408
--run-check)
367
409
RUN_CHECK=true
368
410
build.setVars
0 commit comments