Work around inconsitent wildcard matching behavior in ash [[

- *"/overlay"* is correct for bash [[, and works during an install in ash, but during a boot script in ash results in attempted filename completion and gives an operand error
- "*/overlay/*" works in ash [[, but shouldn't, since it doesn't work in bash [[
- the inconsitent ash behavior in install vs. boot script is likely due to the operating directory of the script in each scenario
This commit is contained in:
osm0sis
2024-03-04 16:16:04 -04:00
parent ffd510aee5
commit 5703c9bca1

View File

@@ -13,7 +13,7 @@ for APP in $(grep -v '^#' $LIST); do
/system/*) ;; /system/*) ;;
*) PREFIX=/system;; *) PREFIX=/system;;
esac esac
HIDEPATH=$MODPATH$PREFIX/$APP HIDEPATH=$MODPATH$PREFIX$APP
if [ -d "$APP" ]; then if [ -d "$APP" ]; then
mkdir -p $HIDEPATH mkdir -p $HIDEPATH
if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then
@@ -29,27 +29,29 @@ for APP in $(grep -v '^#' $LIST); do
touch $HIDEPATH touch $HIDEPATH
fi fi
fi fi
if [[ "$APP" = *"/overlay/"* ]]; then case $APP in
CFG=$(echo $APP | grep -oE '.*/overlay')/config/config.xml */overlay/*)
if [ -f "$CFG" ]; then CFG=$(echo $APP | grep -oE '.*/overlay')/config/config.xml
if [ -d "$APP" ]; then if [ -f "$CFG" ]; then
APK=$(readlink -f $APP/*.apk); if [ -d "$APP" ]; then
elif [[ "$APP" = *".apk" ]]; then APK=$(readlink -f $APP/*.apk);
APK=$(readlink -f $APP); elif [[ "$APP" = *".apk" ]]; then
fi APK=$(readlink -f $APP);
if [ -s "$APK" ]; then fi
PKGNAME=$(unzip -p $APK AndroidManifest.xml | tr -d '\0' | grep -oE '[[:alnum:].-_]+\*http' | cut -d\* -f1) if [ -s "$APK" ]; then
if [ "$PKGNAME" ] && grep -q "overlay package=\"$PKGNAME" $CFG; then PKGNAME=$(unzip -p $APK AndroidManifest.xml | tr -d '\0' | grep -oE '[[:alnum:].-_]+\*http' | cut -d\* -f1)
HIDECFG=$MODPATH$PREFIX$CFG if [ "$PKGNAME" ] && grep -q "overlay package=\"$PKGNAME" $CFG; then
if [ ! -f "$HIDECFG" ]; then HIDECFG=$MODPATH$PREFIX$CFG
mkdir -p $(dirname $HIDECFG) if [ ! -f "$HIDECFG" ]; then
cp -af $CFG $HIDECFG mkdir -p $(dirname $HIDECFG)
cp -af $CFG $HIDECFG
fi
sed -i 's;<overlay \(package="'"$PKGNAME"'".*\) />;<!-- overlay \1 -->;' $HIDECFG
fi fi
sed -i 's;<overlay \(package="'"$PKGNAME"'".*\) />;<!-- overlay \1 -->;' $HIDECFG
fi fi
fi fi
fi ;;
fi esac
if [[ -d "$APP" || "$APP" = *".apk" ]]; then if [[ -d "$APP" || "$APP" = *".apk" ]]; then
ui_print "! $(basename $APP .apk) ROM app disabled, please uninstall any user app versions/updates after next reboot" ui_print "! $(basename $APP .apk) ROM app disabled, please uninstall any user app versions/updates after next reboot"
[ "$HIDECFG" ] && ui_print "! + $PKGNAME entry commented out in copied overlay config" [ "$HIDECFG" ] && ui_print "! + $PKGNAME entry commented out in copied overlay config"