Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix installation script for A/B system-as-root devices #14

Merged
merged 2 commits into from
Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,26 @@ WORK_FOLDER='microg'
ZIP_FILE="$3"
ADDOND='70-microg.sh'
PRIVAPP_PERMISSIONS='privapp-permissions-microg.xml'
SYSTEM="/system"

cd /tmp
mkdir $WORK_FOLDER
cd $WORK_FOLDER
unzip -o "$ZIP_FILE"

mount /system

# A/B system-as-root devices have the actual system partition
# mounted under /system/system when in the recovery.
# Snippet taken from F-Droid Privileged Extension.
system_as_root=`getprop ro.build.system_root_image`
Roboe marked this conversation as resolved.
Show resolved Hide resolved
if [ "$system_as_root" == "true" ]; then
SYSTEM="/system/system"
fi

echo -n -e 'ui_print Installing apps...\n' > /proc/self/fd/$2

# Prepare work folder
BUILD_VERSION_SDK="$(grep -F ro.build.version.sdk /system/build.prop)"
BUILD_VERSION_SDK="$(grep -F ro.build.version.sdk ${SYSTEM}/build.prop)"
BUILD_VERSION_SDK_INT="${BUILD_VERSION_SDK#*=}"
if [ "${BUILD_VERSION_SDK_INT}" -ge 21 ]
then # each apk has its own subdirectory in /system/priv-app or /system/app
Expand Down Expand Up @@ -68,20 +75,20 @@ echo "$TARGET_APKS" | xargs -n 1 rm -f
echo "$TARGET_DIRS" | xargs -n 1 rm -rf

# Copy new files and fix permissions
cp -r system/* /system/
cp -r system/* ${SYSTEM}/
echo "$TARGET_APKS" | xargs -n 1 chmod 644
echo "$TARGET_DIRS" | xargs -n 1 chmod 755


echo -n -e 'ui_print Installing OTA survival script...\n' > /proc/self/fd/$2

cp ${ADDOND} /system/addon.d/
cp ${ADDOND} ${SYSTEM}/addon.d/

if [ "${BUILD_VERSION_SDK_INT}" -ge 27 ]
then # Android 8+ require an explicit permission whitelist file for privileged apps
echo -n -e 'ui_print Whitelisting privapp permissions...\n' > /proc/self/fd/$2

cp ${PRIVAPP_PERMISSIONS} /system/etc/permissions/
cp ${PRIVAPP_PERMISSIONS} ${SYSTEM}/etc/permissions/
fi

echo -n -e 'ui_print done\n' > /proc/self/fd/$2
Expand Down
4 changes: 3 additions & 1 deletion templates/addond-head
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/sbin/sh
#
# ADDOND_VERSION=2
#
# /system/addon.d/70-microg.sh
# During a system upgrade, this script backs up microG apps,
# /system is formatted and reinstalled, then the files are restored.
Expand All @@ -9,4 +11,4 @@

list_files() {
cat <<EOF
/etc/permissions/privapp-permissions-microg.xml
etc/permissions/privapp-permissions-microg.xml