Skip to content

Commit

Permalink
customize.sh: Remove overlayfs workaround
Browse files Browse the repository at this point in the history
Users with devices that use overlayfs for `/system` must upgrade to
Magisk 26.0 or newer.

Signed-off-by: Andrew Gunnerson <[email protected]>
  • Loading branch information
chenxiaolong committed Apr 20, 2023
1 parent 0c9eaea commit 3009f65
Showing 1 changed file with 6 additions and 31 deletions.
37 changes: 6 additions & 31 deletions app/magisk/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,11 @@ has_overlays() {
[ "${count}" -gt 0 ]
}

target=

for mountpoint in /system /product /system_ext /vendor; do
if has_overlays "^${mountpoint}"; then
echo "Cannot use ${mountpoint}: contains overlayfs mounts"
# Magisk fails to mount files when the parent directory does not exist
elif [ ! -d "${mountpoint}/etc/permissions" ]; then
echo "Cannot use ${mountpoint}: etc/permissions/ does not exist"
elif [ ! -d "${mountpoint}/priv-app" ]; then
echo "Cannot use ${mountpoint}: priv-app/ does not exist"
else
echo "Using ${mountpoint} as the installation target"
target=${mountpoint}
break
if [ -n "${MAGISK_VER_CODE}"]; then
echo "Magisk version: ${MAGISK_VER_CODE}"
if has_overlays /system && [ "${MAGISK_VER_CODE}" -lt 26000 ]; then
echo "Magisk v26.0 (26000) or newer is required because this device uses overlayfs"
rm -rv "${MODPATH}" 2>&1
exit 1
fi
done

if [ -z "${target}" ]; then
echo 'No suitable installation target found'
echo 'This OS is not supported'
rm -rv "${MODPATH}" 2>&1
exit 1
fi

if [ "${target}" != /system ]; then
echo 'Removing addon.d script since installation target is not /system'
rm -rv "${MODPATH}/system/addon.d" 2>&1 || exit 1

echo "Adjusting overlay for installation to ${target}"
mv -v "${MODPATH}/system" "${MODPATH}/${target#/}" 2>&1 || exit 1
mkdir -v "${MODPATH}/system" 2>&1 || exit 1
mv -v "${MODPATH}/${target#/}" "${MODPATH}/system/${target#/}" 2>&1 || exit 1
fi

0 comments on commit 3009f65

Please sign in to comment.