Skip to content

Commit 051f793

Browse files
committed
AK3: fix unset PATCHVBMETAFLAG, only read kernel strings once
1 parent b52433b commit 051f793

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tools/ak3-core.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,14 @@ flash_boot() {
355355
echo "Attempting kernel unpack with busybox $comp..." >&2;
356356
$comp -dc $kernel > kernel;
357357
fi;
358-
if strings kernel 2>/dev/null | grep -q -E '^/data/adb/ksud$'; then
358+
strings kernel > stringstmp 2>/dev/null;
359+
if grep -q -E '^/data/adb/ksud$' stringstmp; then
359360
touch $home/kernelsu_patched;
360-
strings kernel 2>/dev/null | grep -E -m1 'Linux version.*#' > $home/vertmp;
361+
grep -E -m1 'Linux version.*#' stringstmp > $home/vertmp;
361362
else
362363
ui_print " " "Warning: No KernelSU support detected in kernel!";
363364
fi;
365+
rm -f stringstmp;
364366
if [ "$comp" ]; then
365367
$bin/magiskboot compress=$comp kernel kernel.$comp;
366368
if [ $? != 0 ] && $comp --help 2>/dev/null; then
@@ -390,10 +392,8 @@ flash_boot() {
390392
if [ $? != 0 ]; then
391393
abort "Repacking image failed. Aborting...";
392394
fi;
393-
if [ -f .magisk ]; then
394-
touch $home/magisk_patched;
395-
unset PATCHVBMETAFLAG;
396-
fi;
395+
[ "$PATCHVBMETAFLAG" ] && unset PATCHVBMETAFLAG;
396+
[ -f .magisk ] && touch $home/magisk_patched;
397397

398398
cd $home;
399399
if [ -f "$bin/futility" -a -d "$bin/chromeos" ]; then
@@ -875,7 +875,7 @@ setup_ak() {
875875
esac;
876876
for name in $parttype; do
877877
for part in $name$slot $name; do
878-
if [ "$(grep -w "$part" /proc/mtd 2> /dev/null)" ]; then
878+
if [ "$(grep -w "$part" /proc/mtd 2>/dev/null)" ]; then
879879
mtdmount=$(grep -w "$part" /proc/mtd);
880880
mtdpart=$(echo $mtdmount | cut -d\" -f2);
881881
if [ "$mtdpart" == "$part" ]; then

0 commit comments

Comments
 (0)