2
0
mirror of https://gitlab.com/Nanolx/NanoDroid synced 2024-10-31 09:20:23 +00:00

CommonInstaller:

- improve migrate_magisk_custom()
- update detect_bootmode()
- cleanup old modules during installation not just for Full / microG packages
- since libraries suck up additional space, increase reqSizeM by 100 MB
- improved install_bromite_webview()
- remove useless bit from install_microg()
- improved nanodroid_install_apk(), nanodroid_install_lib()
- package alias support for nanodroid_install_apk()
This commit is contained in:
Christopher Roy Bratusek 2018-11-09 21:11:57 +01:00
parent 09fd4588c6
commit 3bf712455a

View File

@ -55,7 +55,8 @@ com.android.vending"
########################################################################################## ##########################################################################################
detect_bootmode () { detect_bootmode () {
ps | grep zygote | grep -qv grep && BOOTMODE=true || BOOTMODE=false [ -z ${BOOTMODE} ] && BOOTMODE=false
${BOOTMODE} || ps | grep zygote | grep -qv grep && BOOTMODE=true
${BOOTMODE} || ps -A | grep zygote | grep -qv grep && BOOTMODE=true ${BOOTMODE} || ps -A | grep zygote | grep -qv grep && BOOTMODE=true
} }
@ -99,9 +100,10 @@ is_mounted() {
return $? return $?
} }
set_perm() { set_perm () {
chown ${2}:${3} ${1} || error "failed change owner for ${1}" chown ${2}:${3} ${1} || error "failed change owner for ${1}"
chmod ${4} ${1} || error "failed to change mode for ${1}" chmod ${4} ${1} || error "failed to change mode for ${1}"
if [ ! -z "${5}" ]; then if [ ! -z "${5}" ]; then
chcon ${5} ${1} 2>/dev/null chcon ${5} ${1} 2>/dev/null
else chcon 'u:object_r:system_file:s0' ${1} 2>/dev/null else chcon 'u:object_r:system_file:s0' ${1} 2>/dev/null
@ -166,7 +168,7 @@ show_banner () {
ui_print " created by Nanolx " ui_print " created by Nanolx "
case ${MODID} in case ${MODID} in
NanoDroid ) NanoDroid )
ui_print " Full package " ui_print " Full package "
;; ;;
NanoDroid_microG ) NanoDroid_microG )
ui_print " microG package " ui_print " microG package "
@ -175,7 +177,7 @@ show_banner () {
ui_print " F-Droid package " ui_print " F-Droid package "
;; ;;
NanoDroid_BromiteWebView ) NanoDroid_BromiteWebView )
ui_print " Bromite WebView package" ui_print " Bromite WebView package "
;; ;;
esac esac
ui_print "*****************************" ui_print "*****************************"
@ -249,7 +251,8 @@ migrate_magisk_custom () {
chmod 0644 /data/adb chmod 0644 /data/adb
fi fi
cp -r ${1} /data/adb/magisk mv ${1} /data/adb/magisk
cp /data/adb/magisk/magisk.apk /data/adb/magisk.apk
} }
detect_mode () { detect_mode () {
@ -309,6 +312,8 @@ detect_mode () {
magisk_install_preinst magisk_install_preinst
;; ;;
esac esac
${BOOTMODE} || rm -rf "${MODPATH}"
else unset MODPATH else unset MODPATH
fi fi
@ -543,6 +548,8 @@ magisk_install_setup () {
${BOOTMODE} && RESTORE_PATH=${REALPATH} || RESTORE_PATH=${MODPATH} ${BOOTMODE} && RESTORE_PATH=${REALPATH} || RESTORE_PATH=${MODPATH}
request_size_check "${INSTALLER}" request_size_check "${INSTALLER}"
reqSizeM=$((reqSizeM + 100))
mount_magisk_img mount_magisk_img
case ${MODID} in case ${MODID} in
@ -586,12 +593,6 @@ magisk_install_preinst () {
ui_print " << backing up patched services.jar" ui_print " << backing up patched services.jar"
cp ${RESTORE_PATH}/system/framework/services.jar ${TMPDIR}/services.jar cp ${RESTORE_PATH}/system/framework/services.jar ${TMPDIR}/services.jar
fi fi
${BOOTMODE} || rm -rf "${MODPATH}"
for dir in app etc priv-app bin; do
mkdir -p "${MODPATH}/system/${dir}"
done
} }
magisk_install_postinst () { magisk_install_postinst () {
@ -711,13 +712,6 @@ install_microg () {
for app in GsfProxy DroidGuard; do for app in GsfProxy DroidGuard; do
nanodroid_install_apk ${app} nanodroid_install_apk ${app}
done done
if [ -z "$(find /data/app -type d -name 'org.microg.gms.droidguard*')" ]; then
cp -r "${INSTALLER}/system/priv-app/DroidGuard/" \
/data/app/org.microg.gms.droidguard-1
set_perm_recursive /data/app/org.microg.gms.droidguard-1 1000 1000 0755 0644
fi
fi fi
nanodroid_install_file etc/permissions/features.xml nanodroid_install_file etc/permissions/features.xml
@ -973,18 +967,14 @@ install_bromite_webview () {
x86_64 ) BROMITE_ARCH=x86 ;; x86_64 ) BROMITE_ARCH=x86 ;;
esac esac
if [ -d /system/app/webview ]; then if [ -d /system/app/webview -a "${MODE}" = "SYSTEM" ]; then
if [ "${MODE}" = "MAGISK" ]; then echo " backing up webview to /sdcard/nanodroid_backups/app/webview"
mkdir -p "${MODPATH}/system/app/webview" mkdir -p /sdcard/nanodroid_backups/app
touch "${MODPATH}/system/app/webview/.replace" rm -rf /sdcard/nanodroid_backups/app/webview
else mv /system/app/webview /sdcard/nanodroid_backups/app/
mkdir -p /sdcard/nanodroid_backups/app
rm -rf /sdcard/nanodroid_backups/app/webview
mv /system/app/webview /sdcard/nanodroid_backups/app/
fi
fi fi
nanodroid_install_apk BromiteWebView_${BROMITE_ARCH} multilib nanodroid_install_apk BromiteWebView_${BROMITE_ARCH} multilib webview
fi fi
} }
@ -1058,6 +1048,9 @@ nanodroid_install_dir () {
nanodroid_install_apk () { nanodroid_install_apk () {
app=${1} app=${1}
multilib=${2}
alias=${3}
unset prefix unset prefix
unset source unset source
@ -1072,22 +1065,31 @@ nanodroid_install_apk () {
[ -z "${source}" ] && error "app ${app} not found" [ -z "${source}" ] && error "app ${app} not found"
if [ "${UNFOLD_APP_DIR}" -eq 1 ]; then if [ "${UNFOLD_APP_DIR}" -eq 1 ]; then
dest="${dir}" dest="${MODPATH}/${dir}"
mkdir -p "${MODPATH}/${dir}"
else else
dest="${dir}/${app}" if [ -z "${alias}" ]; then
mkdir -p "${MODPATH}/${dir}/${app}" dest="${MODPATH}/${dir}/${app}"
else dest="${MODPATH}/${dir}/${alias}"
fi
fi fi
if [ ! -z "${alias}" ]; then
dest_apk=${alias}.apk
else
dest_apk=${app}.apk
fi
mkdir -p "${dest}"
echo " installing app: ${app}" echo " installing app: ${app}"
cp "${source}" "${MODPATH}/${dest}" || \ cp "${source}" "${dest}/${dest_apk}" || \
error "failed to install ${source} to ${dest}" error "failed to install ${source} to ${dest}"
set_perm_data -r "${MODPATH}/${dest}" installinfo_add "${dest}/${dest_apk}"
installinfo_add "/${dest}/${app}.apk" nanodroid_install_lib "${dest}/${dest_apk}" "${2}"
nanodroid_install_lib "${2}" set_perm_data -r "${dest}"
} }
nanodroid_install_file () { nanodroid_install_file () {
@ -1125,8 +1127,11 @@ nanodroid_install_file () {
} }
nanodroid_install_lib () { nanodroid_install_lib () {
apk="${MODPATH}/${dest}/${app}.apk" apk="${1}"
multilib="${1}" dest="$(dirname ${1})"
multilib="${2}"
unset libd
if [ "${UNFOLD_APP_DIR}" -eq 1 ]; then if [ "${UNFOLD_APP_DIR}" -eq 1 ]; then
case ${ARCH} in case ${ARCH} in
@ -1134,7 +1139,7 @@ nanodroid_install_lib () {
arm64 | x86_64 ) libd=${MODPATH}/system/lib64 ;; arm64 | x86_64 ) libd=${MODPATH}/system/lib64 ;;
esac esac
else else
libd=${MODPATH}/${dir}/${app}/lib libd=${dest}/lib
fi fi
rm -rf ${TMP_LIBDIR} rm -rf ${TMP_LIBDIR}
@ -1143,7 +1148,7 @@ nanodroid_install_lib () {
unset srcdir unset srcdir
"${INSTALLER}/system/xbin/unzip.${BIN_ARCH}" \ "${INSTALLER}/system/xbin/unzip.${BIN_ARCH}" \
-oq ${apk} "lib/*" -d "${TMP_LIBDIR}" \ -oq "${apk}" "lib/*" -d "${TMP_LIBDIR}" \
2>/dev/null 2>/dev/null
unzip_return=$? unzip_return=$?
@ -1174,16 +1179,14 @@ nanodroid_install_lib () {
echo " from: ${srcdir}" echo " from: ${srcdir}"
echo " into: ${libd}/${lib_arch}" echo " into: ${libd}/${lib_arch}"
mkdir -p ${libd}/${lib_arch} mkdir -p "${libd}/${lib_arch}"
for lib in ${srcdir}/*; do for lib in ${srcdir}/*; do
echo " library: $(basename ${lib})" echo " library: $(basename ${lib})"
cp ${lib} ${libd}/${lib_arch}/ || \ cp ${lib} "${libd}/${lib_arch}/" || \
error "installing libraries failed" error "installing libraries failed"
set_perm_data ${libd}/${lib_arch}/$(basename ${lib}) installinfo_add "/${dir}/${app}/lib/${lib_arch}/$(basename ${lib})"
installinfo_add /${dir}/${app}/lib/${lib_arch}/$(basename ${lib})
done done
fi fi
done done