3 Commits
upsilon ... rho

Author SHA1 Message Date
Alessandro Astone
5e27245f7f Add version and arch checks 2022-02-08 00:49:51 +01:00
Alessandro Astone
1f437b8a66 Always cleanup on failure 2022-02-08 00:49:20 +01:00
Alessandro Astone
3a32cd9346 Fixup the install-time removal of Provision apk 2021-12-08 18:00:01 +01:00
3 changed files with 62 additions and 15 deletions

View File

@@ -9,7 +9,10 @@
DATE=$(date -u +%Y%m%d_%H%M%S) DATE=$(date -u +%Y%m%d_%H%M%S)
TOP=$(realpath .) TOP=$(realpath .)
ANDROIDV=11.0.0 ANDROIDV=11.0.0
SDKV=30
GARCH=$1 GARCH=$1
CPUARCH=$GARCH
[ ! -z "$2" ] && CPUARCH=$2
OUT=$TOP/out OUT=$TOP/out
BUILD=$TOP/build BUILD=$TOP/build
METAINF=$BUILD/meta METAINF=$BUILD/meta
@@ -52,6 +55,10 @@ function create() {
test -d $OUT/$GARCH/system/addon.d || mkdir -p $OUT/$GARCH/system/addon.d test -d $OUT/$GARCH/system/addon.d || mkdir -p $OUT/$GARCH/system/addon.d
cp -f addond_head $OUT/$GARCH/system/addon.d cp -f addond_head $OUT/$GARCH/system/addon.d
cp -f addond_tail $OUT/$GARCH/system/addon.d cp -f addond_tail $OUT/$GARCH/system/addon.d
echo "Writing build props..."
echo "arch=$CPUARCH" > $OUT/$GARCH/build.prop
echo "version=$SDKV" >> $OUT/$GARCH/build.prop
echo "version_nice=$ANDROIDV" >> $OUT/$GARCH/build.prop
} }
function zipit() { function zipit() {

View File

@@ -11,11 +11,11 @@ distclean:
gapps_arm: gapps_arm:
@echo "Compiling GApps for arm..." @echo "Compiling GApps for arm..."
@bash $(BUILD_GAPPS) arm 2>&1 @bash $(BUILD_GAPPS) arm armv7l 2>&1
gapps_arm64: gapps_arm64:
@echo "Compiling GApps for arm64..." @echo "Compiling GApps for arm64..."
@bash $(BUILD_GAPPS) arm64 2>&1 @bash $(BUILD_GAPPS) arm64 aarch64 2>&1
gapps_x86: gapps_x86:
@echo "Compiling GApps for x86..." @echo "Compiling GApps for x86..."

View File

@@ -21,12 +21,29 @@ ui_print() {
echo "ui_print" > "$OUTFD"; echo "ui_print" > "$OUTFD";
} }
getprop2() {
grep -m 1 "^$2=" $1 | cut -d= -f2
}
nice_arch() {
case $1 in
aarch64*|armv8*)
echo "arm64"
;;
arm*)
echo "arm"
;;
*)
echo $1
;;
esac
}
cleanup() { cleanup() {
ui_print "Cleaning up files" ui_print "Cleaning up files"
cd ../ rm -rf $TMP/system
rm -rf system rm -rf $TMP/bin
rm -rf bin rm $TMP/toybox
rm toybox
ui_print "Unmounting partitions" ui_print "Unmounting partitions"
umount -l "$SYSTEM_MNT" umount -l "$SYSTEM_MNT"
@@ -34,12 +51,20 @@ cleanup() {
umount -l /system_ext || true umount -l /system_ext || true
} }
error_no_space() { error() {
ui_print "Not enough space for GApps! Aborting" ui_print "$1"
cleanup cleanup
exit 1 exit 1
} }
error_no_space() {
error "Not enough space for GApps! Aborting"
}
error_mounting() {
error "Could not mount $1! Aborting"
}
get_block_for_mount_point() { get_block_for_mount_point() {
grep -v "^#" /etc/recovery.fstab | grep "[[:blank:]]$1[[:blank:]]" | tail -n1 | tr -s [:blank:] ' ' | cut -d' ' -f1 grep -v "^#" /etc/recovery.fstab | grep "[[:blank:]]$1[[:blank:]]" | tail -n1 | tr -s [:blank:] ' ' | cut -d' ' -f1
} }
@@ -113,6 +138,15 @@ cd "$TMP"
unzip -o "$ZIP" unzip -o "$ZIP"
rm -rf META-INF rm -rf META-INF
# Check for arch. We need to do this before extracting our toybox, since that might be
# compiled for a different architecture. Just hope that all environments have at least
# a proper `grep` and `uname`.
GAPPS_ARCH=$(getprop2 $TMP/build.prop arch)
CPU_ARCH=$(uname -m)
if [ $GAPPS_ARCH != $CPU_ARCH ]; then
error "This package is built for $(nice_arch $GAPPS_ARCH) but your device is $(nice_arch $CPU_ARCH)! Aborting"
fi
ui_print "Setting up environment" ui_print "Setting up environment"
TOYBOX="${TMP}/toybox" TOYBOX="${TMP}/toybox"
chmod +x "$TOYBOX" chmod +x "$TOYBOX"
@@ -170,11 +204,19 @@ mkdir -p "$SYSTEM_MNT" || true
if mount -o rw "$SYSTEM_BLOCK" "$SYSTEM_MNT"; then if mount -o rw "$SYSTEM_BLOCK" "$SYSTEM_MNT"; then
ui_print "$SYSTEM_MNT mounted" ui_print "$SYSTEM_MNT mounted"
else else
ui_print "Could not mount $SYSTEM_MNT! Aborting" error_mounting "$SYSTEM_MNT"
exit 1
fi fi
SYSTEM_OUT="${SYSTEM_MNT}/system" SYSTEM_OUT="${SYSTEM_MNT}/system"
# Compare sdk version
GAPPS_VERSION=$(getprop2 $TMP/build.prop version)
ANDROID_VERSION=$(getprop2 $SYSTEM_OUT/build.prop ro.build.version.sdk)
if [ "$GAPPS_VERSION" != "$ANDROID_VERSION" ]; then
gapps_version_nice=$(getprop2 $TMP/build.prop version_nice)
android_version_nice=$(getprop2 $SYSTEM_OUT/build.prop ro.build.version.release)
error "This package is for Android $gapps_version_nice (SDK $GAPPS_VERSION) but your system is Android $android_version_nice (SDK $ANDROID_VERSION)! Aborting"
fi
# Ignore {product,system_ext} block devices in case they are symlinks # Ignore {product,system_ext} block devices in case they are symlinks
# This is common on devices where maintainers have chosen not to use # This is common on devices where maintainers have chosen not to use
# real partitions because of their size being too small to be useful # real partitions because of their size being too small to be useful
@@ -190,8 +232,7 @@ if [ -n "$PRODUCT_BLOCK" ]; then
if mount -o rw "$PRODUCT_BLOCK" /product; then if mount -o rw "$PRODUCT_BLOCK" /product; then
ui_print "/product mounted" ui_print "/product mounted"
else else
ui_print "Could not mount /product" error_mounting "/product"
exit 1
fi fi
fi fi
if [ -n "$SYSTEM_EXT_BLOCK" ]; then if [ -n "$SYSTEM_EXT_BLOCK" ]; then
@@ -199,8 +240,7 @@ if [ -n "$SYSTEM_EXT_BLOCK" ]; then
if mount -o rw "$SYSTEM_EXT_BLOCK" /system_ext; then if mount -o rw "$SYSTEM_EXT_BLOCK" /system_ext; then
ui_print "/system_ext mounted" ui_print "/system_ext mounted"
else else
ui_print "Could not mount /system_ext" error_mounting "/system_ext"
exit 1
fi fi
fi fi
@@ -270,7 +310,7 @@ if [ -n "$SYSTEM_EXT_BLOCK" ]; then
fi fi
if [ -e product/priv-app/SetupWizardPrebuilt ] ; then if [ -e product/priv-app/SetupWizardPrebuilt ] ; then
rm -rf /system/system_ext/priv-app/Provision rm -rf "${SYSTEM_OUT}/system_ext/priv-app/Provision"
fi fi
cleanup cleanup