From 4f3a5e35873d1d6b6536a49ee63cd531f2e736cb Mon Sep 17 00:00:00 2001 From: Syuugo Date: Sun, 4 Sep 2022 23:44:31 +0900 Subject: [PATCH 1/2] Fix --- scripts/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 7f05a31..58dbf4d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -439,7 +439,7 @@ sudo mount -o loop "$WORK_DIR"/wsa/"$ARCH"/system_ext.img "$MOUNT_DIR"/system_ex echo -e "done\n" if [ "$REMOVE_AMAZON" ]; then - echo "Remove Amazon AppStore" + 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 @@ -631,7 +631,7 @@ if [ "$GAPPS_BRAND" != 'none' ]; then fi echo "Umount images" -sudo find "$MOUNT_DIR" -exec touch -amt 200901010000.00 {} \; >/dev/null 2>&1 +sudo find "$MOUNT_DIR" -exec touch -hamt 200901010000.00 {} \; sudo umount "$MOUNT_DIR"/vendor sudo umount "$MOUNT_DIR"/product sudo umount "$MOUNT_DIR"/system_ext From 89bf5023892c8475fdf21850ac1e1db4610c78c6 Mon Sep 17 00:00:00 2001 From: Howard Wu <40033067+Howard20181@users.noreply.github.com> Date: Mon, 5 Sep 2022 13:41:13 +0800 Subject: [PATCH 2/2] Install dependencies only if needed --- scripts/run.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 6 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index 3329ad2..1be6535 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -34,6 +34,70 @@ abort() { exit 1 } +echo "Checking and ensuring dependencies" +check_dependencies() { + command -v whiptail >/dev/null 2>&1 || NEED_INSTALL+=("whiptail") + command -v seinfo >/dev/null 2>&1 || NEED_INSTALL+=("setools") + command -v lzip >/dev/null 2>&1 || NEED_INSTALL+=("lzip") + command -v wine64 >/dev/null 2>&1 || NEED_INSTALL+=("wine") + command -v winetricks >/dev/null 2>&1 || NEED_INSTALL+=("winetricks") + command -v patchelf >/dev/null 2>&1 || NEED_INSTALL+=("patchelf") + command -v resize2fs >/dev/null 2>&1 || NEED_INSTALL+=("e2fsprogs") + command -v pip >/dev/null 2>&1 || NEED_INSTALL+=("python3-pip") + command -v aria2c >/dev/null 2>&1 || NEED_INSTALL+=("aria2") +} +check_dependencies +declare -A os_pm_install; +# os_pm_install["/etc/redhat-release"]=yum +# os_pm_install["/etc/arch-release"]=pacman +# os_pm_install["/etc/gentoo-release"]=emerge +# os_pm_install["/etc/SuSE-release"]=zypp +os_pm_install["/etc/debian_version"]=apt-get +# os_pm_install["/etc/alpine-release"]=apk + +declare -A PM_UPDATE_MAP; +PM_UPDATE_MAP["yum"]="check-update" +PM_UPDATE_MAP["pacman"]="-Syu --noconfirm" +PM_UPDATE_MAP["emerge"]="-auDN @world" +PM_UPDATE_MAP["zypp"]="update -y" +PM_UPDATE_MAP["apt-get"]="update" +PM_UPDATE_MAP["apk"]="update" + +declare -A PM_INSTALL_MAP; +PM_INSTALL_MAP["yum"]="install -y" +PM_INSTALL_MAP["pacman"]="-S --noconfirm --needed" +PM_INSTALL_MAP["emerge"]="-a" +PM_INSTALL_MAP["zypp"]="install -y" +PM_INSTALL_MAP["apt-get"]="install -y" +PM_INSTALL_MAP["apk"]="add" + +check_package_manager() { + for f in "${!os_pm_install[@]}"; do + if [[ -f $f ]]; then + PM="${os_pm_install[$f]}" + readarray -td ' ' UPDATE_OPTION <<<"${PM_UPDATE_MAP[$PM]} "; unset 'UPDATE_OPTION[-1]'; + readarray -td ' ' INSTALL_OPTION <<<"${PM_INSTALL_MAP[$PM]} "; unset 'INSTALL_OPTION[-1]'; + break + fi + done +} + +check_package_manager +if [ -n "${NEED_INSTALL[*]}" ]; then + if [ -z "$PM" ]; then + echo "Unable to determine package manager: unknown distribution" + exit 1 + else + if ! sudo "$PM" "${UPDATE_OPTION[@]}" && sudo "$PM" "${INSTALL_OPTION[@]}" "${NEED_INSTALL[@]}"; then abort; fi + fi +fi +pip list --disable-pip-version-check | grep -E "^requests " >/dev/null 2>&1 || python3 -m pip install requests + +winetricks list-installed | grep -E "^msxml6" >/dev/null 2>&1 || { + cp -r ../wine/.cache/* ~/.cache + winetricks -q msxml6 || abort +} + function Radiolist { declare -A o="$1" shift @@ -48,12 +112,6 @@ function YesNoBox { whiptail --title "${o[title]}" --yesno "${o[text]}" 0 0 } -echo "Dependencies" -sudo apt update && sudo apt -y install setools lzip wine winetricks patchelf whiptail e2fsprogs python3-pip aria2 -python3 -m pip install requests -cp -r ../wine/.cache/* ~/.cache -winetricks msxml6 || abort - ARCH=$( Radiolist '([title]="Build arch" [default]="x64")' \