diff --git a/AAP.sh b/AAP.sh index 7998fd6..eca70a1 100755 --- a/AAP.sh +++ b/AAP.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash #by Akina | LuoYan #2024-06-03 Rewrite #shellcheck disable=SC2059,SC2086,SC2166 @@ -57,7 +57,7 @@ print_help() { printf "${BLUE}%s${RESET}\n\n" " APatch Auto Patch Tool Written by Akina -Version: 5.0.0 +Version: 6.0.0 Current DIR: $(pwd) -h, -v, print the usage and version. @@ -65,6 +65,7 @@ Current DIR: $(pwd) -k [RELEASE NAME], specify a kernelpatch version [RELEASE NAME]. -d /PATH/TO/DIR specify a folder containing kptools and kpimg as the kptools to be used. -s \"STRING\", specify a superkey. Use STRING as superkey. +-K, Specify the KPMs to be embedded. -I, directly install to current slot after patch. -S, Install to another slot (for OTA). -E [ARGS], Add args [ARGS] to kptools when patching." @@ -86,7 +87,7 @@ In addition, you can use \`APTOOLDEBUG=1 ${0} [ARGS]\` format to enter verbose m # 参数解析 DOWNLOADKP=true -while getopts ":hvi:k:IVs:Sd:E:" OPT; do +while getopts ":hvi:k:KIVs:Sd:E:" OPT; do case $OPT in h | v) print_help @@ -107,6 +108,10 @@ while getopts ":hvi:k:IVs:Sd:E:" OPT; do fi done ;; + K) + EMBEDKPMS=true + msg_info "The -K parameter was received. Will embed KPMs." + ;; i) BOOTPATH="$(realpath ${OPTARG})" if [ -e "${BOOTPATH}" ]; then diff --git a/AAPFunction b/AAPFunction index c7a70c5..e3e3e9f 100755 --- a/AAPFunction +++ b/AAPFunction @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash #rewrited #shellcheck disable=SC2086 get_device_boot() { @@ -73,8 +73,27 @@ get_tools() { done fi } - +analyze_kpms_path() { + unset KPMP # Reset array KPMP + while true; do + msg_info "Now enter your KPMs' path(Enter \"done\" to finish this operation): " + read TKPM + if [ "${TKPM}" = "done" ]; then + break + fi + KPMP+=($(realpath ${TKPM})) + msg_info "Current seleted KPMs: ${KPMP[*]}" + msg_info "Totally: ${#KPMP[@]}" + done + for i in "${KPMP[@]}"; do + EXTRAARGS+=" --embed-extra-path=$i --extra-type=kpm" + done + msg_info "Current EXTRAARGS: ${EXTRAARGS}" +} patch_boot() { + if [ "${EMBEDKPMS}" = "true" ]; then + analyze_kpms_path + fi msg_info "Unpacking image..." ./magiskboot unpack boot${BOOTSUFFIX}.img EXITSTATUS=$?