mirror of
https://github.com/MustardChef/WSABuilds.git
synced 2024-11-23 11:49:16 +01:00
Exit when an error is encountered
This commit is contained in:
parent
a0e09aa774
commit
88cab1de9e
@ -40,4 +40,3 @@ out_file = download_dir / "gapps.zip"
|
||||
|
||||
if not os.path.isfile(out_file):
|
||||
urllib.request.urlretrieve(link, out_file)
|
||||
print("done", flush=True)
|
||||
|
@ -20,7 +20,6 @@ release_type_map = {"retail": "Retail", "release preview": "RP",
|
||||
release_type = release_type_map[sys.argv[2]] if sys.argv[2] != "" else "Retail"
|
||||
|
||||
cat_id = '858014f3-3934-4abe-8078-4aa193e74ca8'
|
||||
print("arch=" + arch + " release_type=" + release_type)
|
||||
|
||||
with open(Path.cwd().parent / ("xml/GetCookie.xml"), "r") as f:
|
||||
cookie_content = f.read()
|
||||
|
250
scripts/run.sh
250
scripts/run.sh
@ -1,9 +1,31 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "$0")" || exit
|
||||
|
||||
WORK_DIR=../_WORK_DIR_
|
||||
DOWNLOAD_DIR=../download
|
||||
OUTPUT_DIR=../output
|
||||
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
|
||||
abort() {
|
||||
echo "An error occurs, exit"
|
||||
if [ -d "$WORK_DIR" ]; then
|
||||
echo "Cleanup Work Directory"
|
||||
sudo rm -rf "$WORK_DIR"
|
||||
fi
|
||||
if [ -d "$DOWNLOAD_DIR" ]; then
|
||||
echo "Cleanup Download Directory"
|
||||
sudo rm -rf "$DOWNLOAD_DIR"
|
||||
fi
|
||||
if [ -d "$OUTPUT_DIR" ]; then
|
||||
echo "Cleanup Output Directory"
|
||||
sudo rm -rf "$OUTPUT_DIR"
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ ! "$BASH_VERSION" ] ; then
|
||||
echo "Please do not use sh to run this script, just execute it directly" 1>&2
|
||||
exit 1
|
||||
abort
|
||||
fi
|
||||
|
||||
function Radiolist {
|
||||
@ -29,12 +51,7 @@ function Gen_Rand_Str {
|
||||
echo "Dependencies"
|
||||
sudo apt update && sudo apt -y install setools lzip wine winetricks patchelf whiptail e2fsprogs
|
||||
cp -r ../wine/.cache/* ~/.cache
|
||||
winetricks msxml6
|
||||
|
||||
# ARCH=$(whiptail --nocancel --separate-output --checklist 'Build arch' 0 0 0 'x64' "X86_64" 'on' 'arm64' "AArch64" 'off' 3>&1 1>&2 2>&3)
|
||||
# if [ $? != 0 ]; then
|
||||
# ARCH=x64
|
||||
# fi
|
||||
winetricks msxml6 || abort
|
||||
|
||||
ARCH=$(
|
||||
Radiolist '([title]="Build arch"
|
||||
@ -65,7 +82,7 @@ MAGISK_VER=$(
|
||||
)
|
||||
|
||||
if (YesNoBox '([title]="Install Gapps" [text]="Do you want to install gapps?")'); then
|
||||
if [ -f ../download/MindTheGapps/MindTheGapps_"$ARCH".zip ]; then
|
||||
if [ -f "$DOWNLOAD_DIR"/MindTheGapps/MindTheGapps_"$ARCH".zip ]; then
|
||||
GAPPS_BRAND=$(
|
||||
Radiolist '([title]="Which gapps do you want to install?"
|
||||
[default]="OpenGapps")' \
|
||||
@ -113,83 +130,91 @@ ROOT_SOL=$(
|
||||
)
|
||||
|
||||
clear
|
||||
echo -e "ARCH=$ARCH\nRELEASE_TYPE=$RELEASE_TYPE\nMAGISK_VER=$MAGISK_VER\nGAPPS_VARIANT=$GAPPS_VARIANT\nREMOVE_AMAZON=$REMOVE_AMAZON\nROOT_SOL=$ROOT_SOL"
|
||||
echo -e "ARCH=$ARCH\nRELEASE_TYPE=$RELEASE_TYPE\nMAGISK_VER=$MAGISK_VER\nGAPPS_VARIANT=$GAPPS_VARIANT\nREMOVE_AMAZON=$REMOVE_AMAZON\nROOT_SOL=$ROOT_SOL\n"
|
||||
|
||||
echo "Download WSA"
|
||||
python3 downloadWSA.py "$ARCH" "$RELEASE_TYPE"
|
||||
python3 downloadWSA.py "$ARCH" "$RELEASE_TYPE" || abort
|
||||
echo -e "Download done\n"
|
||||
|
||||
echo "extractWSA"
|
||||
WSA_WORK_ENV=../_WORK_DIR_/ENV
|
||||
echo "Extract WSA"
|
||||
WSA_WORK_ENV="$WORK_DIR"/ENV
|
||||
if [ -f $WSA_WORK_ENV ]; then rm -f $WSA_WORK_ENV; fi
|
||||
export WSA_WORK_ENV
|
||||
python3 extractWSA.py "$ARCH"
|
||||
python3 extractWSA.py "$ARCH" || abort
|
||||
echo -e "Extract done\n"
|
||||
|
||||
echo "Download Magisk"
|
||||
python3 downloadMagisk.py "$ARCH" "$MAGISK_VER"
|
||||
python3 downloadMagisk.py "$ARCH" "$MAGISK_VER" || abort
|
||||
echo -e "done\n"
|
||||
|
||||
if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then
|
||||
if [ $GAPPS_BRAND = "OpenGapps" ]; then
|
||||
echo "Download OpenGApps"
|
||||
python3 downloadGapps.py "$ARCH" "$MAGISK_VER"
|
||||
python3 downloadGapps.py "$ARCH" "$MAGISK_VER" || abort
|
||||
echo -e "Download done\n"
|
||||
fi
|
||||
echo "Extract GApps"
|
||||
mkdir -p ../_WORK_DIR_/gapps
|
||||
mkdir -p "$WORK_DIR"/gapps || abort
|
||||
if [ $GAPPS_BRAND = "OpenGapps" ]; then
|
||||
unzip -p ../download/gapps.zip {Core,GApps}/'*.lz' | tar --lzip -C ../_WORK_DIR_/gapps -xvf - -i --strip-components=2 --exclude='setupwizardtablet-x86_64' --exclude='packageinstallergoogle-all' --exclude='speech-common' --exclude='markup-lib-arm' --exclude='markup-lib-arm64' --exclude='markup-all' --exclude='setupwizarddefault-x86_64' --exclude='pixellauncher-all' --exclude='pixellauncher-common'
|
||||
unzip -p "$DOWNLOAD_DIR"/gapps.zip {Core,GApps}/'*.lz' | tar --lzip -C "$WORK_DIR"/gapps -xvf - -i --strip-components=2 --exclude='setupwizardtablet-x86_64' --exclude='packageinstallergoogle-all' --exclude='speech-common' --exclude='markup-lib-arm' --exclude='markup-lib-arm64' --exclude='markup-all' --exclude='setupwizarddefault-x86_64' --exclude='pixellauncher-all' --exclude='pixellauncher-common' || abort
|
||||
else
|
||||
unzip ../download/MindTheGapps/MindTheGapps_"$ARCH".zip "system/*" -x "system/addon.d/*" "system/system_ext/priv-app/SetupWizard/*" -d ../_WORK_DIR_/gapps
|
||||
mv ../_WORK_DIR_/gapps/system/* ../_WORK_DIR_/gapps
|
||||
sudo rm -rf ../_WORK_DIR_/gapps/system
|
||||
unzip "$DOWNLOAD_DIR"/MindTheGapps/MindTheGapps_"$ARCH".zip "system/*" -x "system/addon.d/*" "system/system_ext/priv-app/SetupWizard/*" -d "$WORK_DIR"/gapps || abort
|
||||
mv "$WORK_DIR"/gapps/system/* "$WORK_DIR"/gapps || abort
|
||||
sudo rm -rf "$WORK_DIR"/gapps/system || abort
|
||||
fi
|
||||
echo -e "Extract done\n"
|
||||
fi
|
||||
|
||||
echo "Expand images"
|
||||
|
||||
e2fsck -yf ../_WORK_DIR_/wsa/"$ARCH"/system_ext.img
|
||||
SYSTEM_EXT_SIZE=$(($(du -sB512 ../_WORK_DIR_/wsa/"$ARCH"/system_ext.img | cut -f1) + 20000))
|
||||
if [ -d ../_WORK_DIR_/gapps/system_ext ]; then
|
||||
SYSTEM_EXT_SIZE=$(( SYSTEM_EXT_SIZE + $(du -sB512 ../_WORK_DIR_/gapps/system_ext | cut -f1) ))
|
||||
e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/system_ext.img || abort
|
||||
SYSTEM_EXT_SIZE=$(($(du -sB512 "$WORK_DIR"/wsa/"$ARCH"/system_ext.img | cut -f1) + 20000))
|
||||
if [ -d "$WORK_DIR"/gapps/system_ext ]; then
|
||||
SYSTEM_EXT_SIZE=$(( SYSTEM_EXT_SIZE + $(du -sB512 "$WORK_DIR"/gapps/system_ext | cut -f1) ))
|
||||
fi
|
||||
resize2fs ../_WORK_DIR_/wsa/"$ARCH"/system_ext.img "$SYSTEM_EXT_SIZE"s
|
||||
resize2fs "$WORK_DIR"/wsa/"$ARCH"/system_ext.img "$SYSTEM_EXT_SIZE"s || abort
|
||||
|
||||
e2fsck -yf ../_WORK_DIR_/wsa/"$ARCH"/product.img
|
||||
PRODUCT_SIZE=$(($(du -sB512 ../_WORK_DIR_/wsa/"$ARCH"/product.img | cut -f1) + 20000))
|
||||
if [ -d ../_WORK_DIR_/gapps/product ]; then
|
||||
PRODUCT_SIZE=$(( PRODUCT_SIZE + $(du -sB512 ../_WORK_DIR_/gapps/product | cut -f1) ))
|
||||
e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/product.img || abort
|
||||
PRODUCT_SIZE=$(($(du -sB512 "$WORK_DIR"/wsa/"$ARCH"/product.img | cut -f1) + 20000))
|
||||
if [ -d "$WORK_DIR"/gapps/product ]; then
|
||||
PRODUCT_SIZE=$(( PRODUCT_SIZE + $(du -sB512 "$WORK_DIR"/gapps/product | cut -f1) ))
|
||||
fi
|
||||
resize2fs ../_WORK_DIR_/wsa/"$ARCH"/product.img "$PRODUCT_SIZE"s
|
||||
resize2fs "$WORK_DIR"/wsa/"$ARCH"/product.img "$PRODUCT_SIZE"s || abort
|
||||
|
||||
e2fsck -yf ../_WORK_DIR_/wsa/"$ARCH"/system.img
|
||||
SYSTEM_SIZE=$(($(du -sB512 ../_WORK_DIR_/wsa/"$ARCH"/system.img | cut -f1) + 20000))
|
||||
if [ -d ../_WORK_DIR_/gapps ]; then
|
||||
SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du -sB512 ../_WORK_DIR_/gapps | cut -f1) - $(du -sB512 ../_WORK_DIR_/gapps/product | cut -f1) ))
|
||||
if [ -d ../_WORK_DIR_/gapps/system_ext ]; then
|
||||
SYSTEM_SIZE=$(( SYSTEM_SIZE - $(du -sB512 ../_WORK_DIR_/gapps/system_ext | cut -f1) ))
|
||||
e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/system.img || abort
|
||||
SYSTEM_SIZE=$(($(du -sB512 "$WORK_DIR"/wsa/"$ARCH"/system.img | cut -f1) + 20000))
|
||||
if [ -d "$WORK_DIR"/gapps ]; then
|
||||
SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du -sB512 "$WORK_DIR"/gapps | cut -f1) - $(du -sB512 "$WORK_DIR"/gapps/product | cut -f1) ))
|
||||
if [ -d "$WORK_DIR"/gapps/system_ext ]; then
|
||||
SYSTEM_SIZE=$(( SYSTEM_SIZE - $(du -sB512 "$WORK_DIR"/gapps/system_ext | cut -f1) ))
|
||||
fi
|
||||
fi
|
||||
if [ -d ../_WORK_DIR_/magisk ]; then
|
||||
SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du -sB512 ../_WORK_DIR_/magisk/magisk | cut -f1) ))
|
||||
if [ -d "$WORK_DIR"/magisk ]; then
|
||||
SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du -sB512 "$WORK_DIR"/magisk/magisk | cut -f1) ))
|
||||
fi
|
||||
if [ -f ../download/magisk.zip ]; then
|
||||
SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du -sB512 ../download/magisk.zip | cut -f1) ))
|
||||
if [ -f "$DOWNLOAD_DIR"/magisk.zip ]; then
|
||||
SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du -sB512 "$DOWNLOAD_DIR"/magisk.zip | cut -f1) ))
|
||||
fi
|
||||
resize2fs ../_WORK_DIR_/wsa/"$ARCH"/system.img "$SYSTEM_SIZE"s
|
||||
resize2fs "$WORK_DIR"/wsa/"$ARCH"/system.img "$SYSTEM_SIZE"s || abort
|
||||
|
||||
e2fsck -yf ../_WORK_DIR_/wsa/"$ARCH"/vendor.img
|
||||
VENDOR_SIZE=$(($(du -sB512 ../_WORK_DIR_/wsa/"$ARCH"/vendor.img | cut -f1) + 20000))
|
||||
resize2fs ../_WORK_DIR_/wsa/"$ARCH"/vendor.img "$VENDOR_SIZE"s
|
||||
e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/vendor.img || abort
|
||||
VENDOR_SIZE=$(($(du -sB512 "$WORK_DIR"/wsa/"$ARCH"/vendor.img | cut -f1) + 20000))
|
||||
resize2fs "$WORK_DIR"/wsa/"$ARCH"/vendor.img "$VENDOR_SIZE"s || abort
|
||||
echo -e "Expand images done\n"
|
||||
|
||||
echo "Mount images"
|
||||
MOUNT_DIR=../_WORK_DIR_/system
|
||||
sudo mkdir $MOUNT_DIR
|
||||
sudo mount -o loop ../_WORK_DIR_/wsa/"$ARCH"/system.img $MOUNT_DIR
|
||||
sudo mount -o loop ../_WORK_DIR_/wsa/"$ARCH"/vendor.img $MOUNT_DIR/vendor
|
||||
sudo mount -o loop ../_WORK_DIR_/wsa/"$ARCH"/product.img $MOUNT_DIR/product
|
||||
sudo mount -o loop ../_WORK_DIR_/wsa/"$ARCH"/system_ext.img $MOUNT_DIR/system_ext
|
||||
MOUNT_DIR="$WORK_DIR"/system || abort
|
||||
sudo mkdir $MOUNT_DIR || abort
|
||||
sudo mount -o loop "$WORK_DIR"/wsa/"$ARCH"/system.img $MOUNT_DIR || abort
|
||||
sudo mount -o loop "$WORK_DIR"/wsa/"$ARCH"/vendor.img $MOUNT_DIR/vendor || abort
|
||||
sudo mount -o loop "$WORK_DIR"/wsa/"$ARCH"/product.img $MOUNT_DIR/product || abort
|
||||
sudo mount -o loop "$WORK_DIR"/wsa/"$ARCH"/system_ext.img $MOUNT_DIR/system_ext || abort
|
||||
echo -e "done\n"
|
||||
|
||||
if [ $REMOVE_AMAZON = 'remove' ]; then
|
||||
echo "Remove Amazon AppStore"
|
||||
find $MOUNT_DIR/product/{etc/permissions,etc/sysconfig,framework,priv-app} | grep -e amazon -e venezia | sudo xargs rm -rf
|
||||
echo -e "done\n"
|
||||
fi
|
||||
|
||||
if [ "$ROOT_SOL" = 'magisk' ] || [ "$ROOT_SOL" = '' ]; then
|
||||
@ -198,8 +223,8 @@ if [ "$ROOT_SOL" = 'magisk' ] || [ "$ROOT_SOL" = '' ]; then
|
||||
sudo chcon --reference $MOUNT_DIR/init.environ.rc $MOUNT_DIR/sbin
|
||||
sudo chown root:root $MOUNT_DIR/sbin
|
||||
sudo chmod 0700 $MOUNT_DIR/sbin
|
||||
sudo cp ../_WORK_DIR_/magisk/magisk/* $MOUNT_DIR/sbin/
|
||||
sudo cp ../download/magisk.zip $MOUNT_DIR/sbin/magisk.apk
|
||||
sudo cp "$WORK_DIR"/magisk/magisk/* $MOUNT_DIR/sbin/
|
||||
sudo cp "$DOWNLOAD_DIR"/magisk.zip $MOUNT_DIR/sbin/magisk.apk
|
||||
sudo tee -a $MOUNT_DIR/sbin/loadpolicy.sh <<EOF
|
||||
#!/system/bin/sh
|
||||
mkdir -p /data/adb/magisk
|
||||
@ -216,15 +241,15 @@ EOF
|
||||
sudo find $MOUNT_DIR/sbin -type f -exec chmod 0755 {} \;
|
||||
sudo find $MOUNT_DIR/sbin -type f -exec chown root:root {} \;
|
||||
sudo find $MOUNT_DIR/sbin -type f -exec chcon --reference $MOUNT_DIR/product {} \;
|
||||
sudo patchelf --replace-needed libc.so "../linker/libc.so" ../_WORK_DIR_/magisk/magiskpolicy || true
|
||||
sudo patchelf --replace-needed libm.so "../linker/libm.so" ../_WORK_DIR_/magisk/magiskpolicy || true
|
||||
sudo patchelf --replace-needed libdl.so "../linker/libdl.so" ../_WORK_DIR_/magisk/magiskpolicy || true
|
||||
sudo patchelf --set-interpreter "../linker/linker64" ../_WORK_DIR_/magisk/magiskpolicy || true
|
||||
chmod +x ../_WORK_DIR_/magisk/magiskpolicy
|
||||
sudo patchelf --replace-needed libc.so "../linker/libc.so" "$WORK_DIR"/magisk/magiskpolicy || abort
|
||||
sudo patchelf --replace-needed libm.so "../linker/libm.so" "$WORK_DIR"/magisk/magiskpolicy || abort
|
||||
sudo patchelf --replace-needed libdl.so "../linker/libdl.so" "$WORK_DIR"/magisk/magiskpolicy || abort
|
||||
sudo patchelf --set-interpreter "../linker/linker64" "$WORK_DIR"/magisk/magiskpolicy || abort
|
||||
chmod +x "$WORK_DIR"/magisk/magiskpolicy
|
||||
TMP_PATH=$(Gen_Rand_Str 8)
|
||||
echo "/dev/"$TMP_PATH"(/.*)? u:object_r:magisk_file:s0" | sudo tee -a $MOUNT_DIR/vendor/etc/selinux/vendor_file_contexts
|
||||
echo '/data/adb/magisk(/.*)? u:object_r:magisk_file:s0' | sudo tee -a $MOUNT_DIR/vendor/etc/selinux/vendor_file_contexts
|
||||
sudo ../_WORK_DIR_/magisk/magiskpolicy --load $MOUNT_DIR/vendor/etc/selinux/precompiled_sepolicy --save $MOUNT_DIR/vendor/etc/selinux/precompiled_sepolicy --magisk "allow * magisk_file lnk_file *"
|
||||
sudo "$WORK_DIR"/magisk/magiskpolicy --load $MOUNT_DIR/vendor/etc/selinux/precompiled_sepolicy --save $MOUNT_DIR/vendor/etc/selinux/precompiled_sepolicy --magisk "allow * magisk_file lnk_file *"
|
||||
SERVER_NAME1=$(Gen_Rand_Str 12)
|
||||
SERVER_NAME2=$(Gen_Rand_Str 12)
|
||||
SERVER_NAME3=$(Gen_Rand_Str 12)
|
||||
@ -282,12 +307,13 @@ service $SERVER_NAME4 /dev/$TMP_PATH/magisk --boot-complete
|
||||
seclabel u:r:magisk:s0
|
||||
oneshot
|
||||
EOF
|
||||
echo -e "Integrate Magisk done\n"
|
||||
fi
|
||||
|
||||
echo "Merge Language Resources"
|
||||
cp ../_WORK_DIR_/wsa/"$ARCH"/resources.pri ../_WORK_DIR_/wsa/pri/en-us.pri
|
||||
cp ../_WORK_DIR_/wsa/"$ARCH"/AppxManifest.xml ../_WORK_DIR_/wsa/xml/en-us.xml
|
||||
tee ../_WORK_DIR_/wsa/priconfig.xml <<EOF
|
||||
cp "$WORK_DIR"/wsa/"$ARCH"/resources.pri "$WORK_DIR"/wsa/pri/en-us.pri
|
||||
cp "$WORK_DIR"/wsa/"$ARCH"/AppxManifest.xml "$WORK_DIR"/wsa/xml/en-us.xml
|
||||
tee "$WORK_DIR"/wsa/priconfig.xml <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<resources targetOsVersion="10.0.0" majorVersion="1">
|
||||
<index root="\" startIndexAt="\">
|
||||
@ -296,23 +322,25 @@ tee ../_WORK_DIR_/wsa/priconfig.xml <<EOF
|
||||
</index>
|
||||
</resources>
|
||||
EOF
|
||||
wine64 ../wine/makepri.exe new /pr ../_WORK_DIR_/wsa/pri /in MicrosoftCorporationII.WindowsSubsystemForAndroid /cf ../_WORK_DIR_/wsa/priconfig.xml /of ../_WORK_DIR_/wsa/"$ARCH"/resources.pri /o
|
||||
sed -i -zE "s/<Resources.*Resources>/<Resources>\n$(cat ../_WORK_DIR_/wsa/xml/* | grep -Po '<Resource [^>]*/>' | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/\$/\\$/g' | sed 's/\//\\\//g')\n<\/Resources>/g" ../_WORK_DIR_/wsa/"$ARCH"/AppxManifest.xml
|
||||
wine64 ../wine/makepri.exe new /pr "$WORK_DIR"/wsa/pri /in MicrosoftCorporationII.WindowsSubsystemForAndroid /cf "$WORK_DIR"/wsa/priconfig.xml /of "$WORK_DIR"/wsa/"$ARCH"/resources.pri /o
|
||||
sed -i -zE "s/<Resources.*Resources>/<Resources>\n$(cat "$WORK_DIR"/wsa/xml/* | grep -Po '<Resource [^>]*/>' | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/\$/\\$/g' | sed 's/\//\\\//g')\n<\/Resources>/g" "$WORK_DIR"/wsa/"$ARCH"/AppxManifest.xml
|
||||
echo -e "Merge Language Resources done\n"
|
||||
|
||||
echo "Add extra packages"
|
||||
sudo cp -r ../"$ARCH"/system/* $MOUNT_DIR
|
||||
sudo cp -r ../"$ARCH"/system/* $MOUNT_DIR || abort
|
||||
sudo find $MOUNT_DIR/system/priv-app -type d -exec chmod 0755 {} \;
|
||||
sudo find $MOUNT_DIR/system/priv-app -type f -exec chmod 0644 {} \;
|
||||
sudo find $MOUNT_DIR/system/priv-app -exec chcon --reference=$MOUNT_DIR/system/priv-app {} \;
|
||||
echo -e "Add extra packages done\n"
|
||||
|
||||
if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then
|
||||
echo "Integrate GApps"
|
||||
cp -r ../"$ARCH"/gapps/* ../_WORK_DIR_/gapps
|
||||
for d in $(find ../_WORK_DIR_/gapps -mindepth 1 -type d -type d); do
|
||||
cp -r ../"$ARCH"/gapps/* "$WORK_DIR"/gapps || abort
|
||||
for d in $(find "$WORK_DIR"/gapps -mindepth 1 -type d -type d); do
|
||||
sudo chmod 0755 "$d"
|
||||
sudo chown root:root "$d"
|
||||
done
|
||||
for f in $(find ../_WORK_DIR_/gapps -type f); do
|
||||
for f in $(find "$WORK_DIR"/gapps -type f); do
|
||||
type=$(echo "$f" | sed 's/.*\.//')
|
||||
if [ "$type" == "sh" ] || [ "$type" == "$f" ]; then
|
||||
sudo chmod 0755 "$f"
|
||||
@ -324,18 +352,18 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then
|
||||
sudo chcon --reference=$MOUNT_DIR/product/etc/permissions/com.android.settings.intelligence.xml "$f"
|
||||
done
|
||||
shopt -s extglob
|
||||
sudo cp -vr ../_WORK_DIR_/gapps/product/* $MOUNT_DIR/product/
|
||||
sudo rm -rf ../_WORK_DIR_/gapps/product
|
||||
sudo cp -vr "$WORK_DIR"/gapps/product/* $MOUNT_DIR/product/ || abort
|
||||
sudo rm -rf "$WORK_DIR"/gapps/product || abort
|
||||
if [ $GAPPS_BRAND = "MindTheGapps" ]; then
|
||||
mv ../_WORK_DIR_/gapps/priv-app/* ../_WORK_DIR_/gapps/system_ext/priv-app
|
||||
sudo cp --preserve=a -vr ../_WORK_DIR_/gapps/system_ext/* $MOUNT_DIR/system_ext/
|
||||
ls ../_WORK_DIR_/gapps/system_ext/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system_ext/etc/dir -type f -exec chmod 0644 {} \;
|
||||
ls ../_WORK_DIR_/gapps/system_ext/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system_ext/etc/dir -type d -exec chcon --reference=$MOUNT_DIR/system_ext/etc/permissions {} \;
|
||||
ls ../_WORK_DIR_/gapps/system_ext/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system_ext/etc/dir -type f -exec chcon --reference=$MOUNT_DIR/system_ext/etc/permissions {} \;
|
||||
mv "$WORK_DIR"/gapps/priv-app/* "$WORK_DIR"/gapps/system_ext/priv-app || abort
|
||||
sudo cp --preserve=a -vr "$WORK_DIR"/gapps/system_ext/* $MOUNT_DIR/system_ext/ || abort
|
||||
ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system_ext/etc/dir -type f -exec chmod 0644 {} \;
|
||||
ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system_ext/etc/dir -type d -exec chcon --reference=$MOUNT_DIR/system_ext/etc/permissions {} \;
|
||||
ls "$WORK_DIR"/gapps/system_ext/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system_ext/etc/dir -type f -exec chcon --reference=$MOUNT_DIR/system_ext/etc/permissions {} \;
|
||||
|
||||
sudo rm -rf ../_WORK_DIR_/gapps/system_ext
|
||||
sudo rm -rf "$WORK_DIR"/gapps/system_ext || abort
|
||||
fi
|
||||
sudo cp -vr ../_WORK_DIR_/gapps/* $MOUNT_DIR/system
|
||||
sudo cp -vr "$WORK_DIR"/gapps/* $MOUNT_DIR/system || abort
|
||||
|
||||
sudo find $MOUNT_DIR/system/{app,etc,framework,priv-app} -exec chown root:root {} \;
|
||||
sudo find $MOUNT_DIR/product/{app,etc,overlay,priv-app,lib64,lib,framework} -exec chown root:root {} \;
|
||||
@ -353,9 +381,9 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then
|
||||
sudo find $MOUNT_DIR/product/{app,etc,overlay,priv-app,lib64,lib,framework} -type f -exec chcon --reference=$MOUNT_DIR/product/etc/permissions/com.android.settings.intelligence.xml {} \;
|
||||
|
||||
if [ $GAPPS_BRAND = "OpenGapps" ]; then
|
||||
ls ../_WORK_DIR_/gapps/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system/etc/dir -type f -exec chmod 0644 {} \;
|
||||
ls ../_WORK_DIR_/gapps/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system/etc/dir -type d -exec chcon --reference=$MOUNT_DIR/system/etc/permissions {} \;
|
||||
ls ../_WORK_DIR_/gapps/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system/etc/dir -type f -exec chcon --reference=$MOUNT_DIR/system/etc/permissions {} \;
|
||||
ls "$WORK_DIR"/gapps/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system/etc/dir -type f -exec chmod 0644 {} \;
|
||||
ls "$WORK_DIR"/gapps/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system/etc/dir -type d -exec chcon --reference=$MOUNT_DIR/system/etc/permissions {} \;
|
||||
ls "$WORK_DIR"/gapps/etc/ | xargs -n 1 -I dir sudo find $MOUNT_DIR/system/etc/dir -type f -exec chcon --reference=$MOUNT_DIR/system/etc/permissions {} \;
|
||||
else
|
||||
sudo find $MOUNT_DIR/system_ext/{priv-app,etc} -exec chown root:root {} \;
|
||||
sudo find $MOUNT_DIR/system_ext/{priv-app,etc} -type d -exec chmod 0755 {} \;
|
||||
@ -364,18 +392,19 @@ if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then
|
||||
sudo find $MOUNT_DIR/system_ext/{priv-app,etc} -type f -exec chcon --reference=$MOUNT_DIR/system_ext/etc/permissions/com.android.settings.xml {} \;
|
||||
fi
|
||||
|
||||
sudo patchelf --replace-needed libc.so "../linker/libc.so" ../_WORK_DIR_/magisk/magiskpolicy || true
|
||||
sudo patchelf --replace-needed libm.so "../linker/libm.so" ../_WORK_DIR_/magisk/magiskpolicy || true
|
||||
sudo patchelf --replace-needed libdl.so "../linker/libdl.so" ../_WORK_DIR_/magisk/magiskpolicy || true
|
||||
sudo patchelf --set-interpreter "../linker/linker64" ../_WORK_DIR_/magisk/magiskpolicy || true
|
||||
chmod +x ../_WORK_DIR_/magisk/magiskpolicy
|
||||
sudo ../_WORK_DIR_/magisk/magiskpolicy --load $MOUNT_DIR/vendor/etc/selinux/precompiled_sepolicy --save $MOUNT_DIR/vendor/etc/selinux/precompiled_sepolicy "allow gmscore_app gmscore_app vsock_socket { create connect write read }" "allow gmscore_app device_config_runtime_native_boot_prop file read" "allow gmscore_app system_server_tmpfs dir search" "allow gmscore_app system_server_tmpfs file open"
|
||||
|
||||
sudo patchelf --replace-needed libc.so "../linker/libc.so" "$WORK_DIR"/magisk/magiskpolicy || abort
|
||||
sudo patchelf --replace-needed libm.so "../linker/libm.so" "$WORK_DIR"/magisk/magiskpolicy || abort
|
||||
sudo patchelf --replace-needed libdl.so "../linker/libdl.so" "$WORK_DIR"/magisk/magiskpolicy || abort
|
||||
sudo patchelf --set-interpreter "../linker/linker64" "$WORK_DIR"/magisk/magiskpolicy || abort
|
||||
chmod +x "$WORK_DIR"/magisk/magiskpolicy || abort
|
||||
sudo "$WORK_DIR"/magisk/magiskpolicy --load $MOUNT_DIR/vendor/etc/selinux/precompiled_sepolicy --save $MOUNT_DIR/vendor/etc/selinux/precompiled_sepolicy "allow gmscore_app gmscore_app vsock_socket { create connect write read }" "allow gmscore_app device_config_runtime_native_boot_prop file read" "allow gmscore_app system_server_tmpfs dir search" "allow gmscore_app system_server_tmpfs file open" || abort
|
||||
echo -e "Integrate GApps done\n"
|
||||
fi
|
||||
|
||||
if [ $GAPPS_VARIANT != 'none' ] && [ $GAPPS_VARIANT != '' ]; then
|
||||
echo "Fix GApps prop"
|
||||
sudo python3 fixGappsProp.py $MOUNT_DIR
|
||||
sudo python3 fixGappsProp.py $MOUNT_DIR || abort
|
||||
echo -e "done\n"
|
||||
fi
|
||||
|
||||
echo "Umount images"
|
||||
@ -384,23 +413,25 @@ sudo umount $MOUNT_DIR/vendor
|
||||
sudo umount $MOUNT_DIR/product
|
||||
sudo umount $MOUNT_DIR/system_ext
|
||||
sudo umount $MOUNT_DIR
|
||||
echo -e "done\n"
|
||||
|
||||
echo "Shrink images"
|
||||
e2fsck -yf ../_WORK_DIR_/wsa/"$ARCH"/system.img
|
||||
resize2fs -M ../_WORK_DIR_/wsa/"$ARCH"/system.img
|
||||
e2fsck -yf ../_WORK_DIR_/wsa/"$ARCH"/vendor.img
|
||||
resize2fs -M ../_WORK_DIR_/wsa/"$ARCH"/vendor.img
|
||||
e2fsck -yf ../_WORK_DIR_/wsa/"$ARCH"/product.img
|
||||
resize2fs -M ../_WORK_DIR_/wsa/"$ARCH"/product.img
|
||||
e2fsck -yf ../_WORK_DIR_/wsa/"$ARCH"/system_ext.img
|
||||
resize2fs -M ../_WORK_DIR_/wsa/"$ARCH"/system_ext.img
|
||||
e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/system.img || abort
|
||||
resize2fs -M "$WORK_DIR"/wsa/"$ARCH"/system.img || abort
|
||||
e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/vendor.img || abort
|
||||
resize2fs -M "$WORK_DIR"/wsa/"$ARCH"/vendor.img || abort
|
||||
e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/product.img || abort
|
||||
resize2fs -M "$WORK_DIR"/wsa/"$ARCH"/product.img || abort
|
||||
e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/system_ext.img || abort
|
||||
resize2fs -M "$WORK_DIR"/wsa/"$ARCH"/system_ext.img || abort
|
||||
echo -e "Shrink images done\n"
|
||||
|
||||
echo "Remove signature and add scripts"
|
||||
sudo rm -rf ../_WORK_DIR_/wsa/"$ARCH"/\[Content_Types\].xml ../_WORK_DIR_/wsa/"$ARCH"/AppxBlockMap.xml ../_WORK_DIR_/wsa/"$ARCH"/AppxSignature.p7x ../_WORK_DIR_/wsa/"$ARCH"/AppxMetadata
|
||||
cp ../download/vclibs.appx ../download/xaml.appx ../_WORK_DIR_/wsa/"$ARCH"
|
||||
tee ../_WORK_DIR_/wsa/"$ARCH"/Install.ps1 <<EOF
|
||||
# Automated Install script by Mioki
|
||||
# http://github.com/okibcn
|
||||
sudo rm -rf "$WORK_DIR"/wsa/"$ARCH"/\[Content_Types\].xml "$WORK_DIR"/wsa/"$ARCH"/AppxBlockMap.xml "$WORK_DIR"/wsa/"$ARCH"/AppxSignature.p7x "$WORK_DIR"/wsa/"$ARCH"/AppxMetadata || abort
|
||||
cp "$DOWNLOAD_DIR"/vclibs.appx "$DOWNLOAD_DIR"/xaml.appx "$WORK_DIR"/wsa/"$ARCH" || abort
|
||||
tee "$WORK_DIR"/wsa/"$ARCH"/Install.ps1 <<EOF
|
||||
# Automated Install script by Midonei
|
||||
# http://github.com/doneibcn
|
||||
function Test-Administrator {
|
||||
[OutputType([bool])]
|
||||
param()
|
||||
@ -432,7 +463,7 @@ elseif ((\$args.Count -eq 1) -and (\$args[0] -eq "EVAL")) {
|
||||
exit
|
||||
}
|
||||
|
||||
if (((Test-Path -Path $(ls -Q ../_WORK_DIR_/wsa/"$ARCH" | paste -sd "," -)) -eq \$false).Count) {
|
||||
if (((Test-Path -Path $(ls -Q "$WORK_DIR"/wsa/"$ARCH" | paste -sd "," -)) -eq \$false).Count) {
|
||||
Write-Error "Some files are missing in the folder. Please try to build again. Press any key to exist"
|
||||
\$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
|
||||
exit 1
|
||||
@ -490,6 +521,7 @@ Elseif (\$null -ne \$Installed) {
|
||||
Write-Host "All Done\`r\`nPress any key to exit"
|
||||
\$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
|
||||
EOF
|
||||
echo -e "Remove signature and add scripts done\n"
|
||||
|
||||
echo "Generate info"
|
||||
if [[ "$ROOT_SOL" = "none" ]]; then
|
||||
@ -508,7 +540,13 @@ else
|
||||
name2="-GApps-${GAPPS_VARIANT}"
|
||||
fi
|
||||
echo "WSA${name1}${name2}_${ARCH}"
|
||||
cat ../_WORK_DIR_/ENV
|
||||
rm -rf ../output
|
||||
mv ../_WORK_DIR_/wsa/"$ARCH" ../output
|
||||
sudo rm -rf ../_WORK_DIR_
|
||||
cat "$WORK_DIR"/ENV
|
||||
|
||||
echo -e "\nFinish building"
|
||||
rm -rf "$OUTPUT_DIR" || abort
|
||||
mv "$WORK_DIR"/wsa/"$ARCH" "$OUTPUT_DIR" || abort
|
||||
echo -e "done\n"
|
||||
|
||||
echo "Cleanup Work Directory"
|
||||
sudo rm -rf "$WORK_DIR"
|
||||
echo "done"
|
||||
|
Loading…
Reference in New Issue
Block a user