From c95e9c76738ccd9f85ff35ab26bfaf3b2188fdd5 Mon Sep 17 00:00:00 2001 From: Hyy2001X <1804430051@qq.com> Date: Wed, 6 Jan 2021 14:44:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=20xray=20v2ray=20v2ray-plugin=20=E4=B8=BA?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/AutoBuild_DiyScript.sh | 4 ++++ Scripts/AutoBuild_Function.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Scripts/AutoBuild_DiyScript.sh b/Scripts/AutoBuild_DiyScript.sh index a56d474..ee80450 100644 --- a/Scripts/AutoBuild_DiyScript.sh +++ b/Scripts/AutoBuild_DiyScript.sh @@ -11,6 +11,10 @@ Diy_Core() { Diy-Part1() { # [ -e feeds.conf.default ] && sed -i "s/#src-git helloworld/src-git helloworld/g" feeds.conf.default [ ! -d package/lean ] && mkdir -p package/lean + + Update_Makefile xray package/lean/xray + Update_Makefile v2ray package/lean/v2ray + Update_Makefile v2ray-plugin package/lean/v2ray-plugin Replace_File Scripts/AutoUpdate.sh package/base-files/files/bin Replace_File Scripts/AutoBuild_Tools.sh package/base-files/files/bin diff --git a/Scripts/AutoBuild_Function.sh b/Scripts/AutoBuild_Function.sh index 15e3d62..e104d57 100644 --- a/Scripts/AutoBuild_Function.sh +++ b/Scripts/AutoBuild_Function.sh @@ -72,4 +72,33 @@ Replace_File() { fi fi unset _RENAME +} + +Update_Makefile() { + PKG_NAME="$1" + Makefile="$2/Makefile" + if [ -f ${Makefile} ];then + PKG_URL_MAIN="$(grep "PKG_SOURCE_URL:=" ${Makefile} | cut -c17-100)" + _process1=${PKG_URL_MAIN##*com/} + _process2=${_process1%%/tar*} + api_URL="https://api.github.com/repos/${_process2}/releases" + PKG_DL_URL="https://codeload.github.com/${_process2}/tar.gz/v" + Offical_Version="$(curl -s ${api_URL} 2>/dev/null | grep 'tag_name' | egrep -o '[0-9].+[0-9.]+' | awk 'NR==1')" + Source_Version="$(grep "PKG_VERSION:=" ${Makefile} | cut -c14-20)" + Source_HASH="$(grep "PKG_HASH:=" ${Makefile} | cut -c11-100)" + echo -e "Current ${PKG_NAME} version: ${Source_Version}\nOffical ${PKG_NAME} version: ${Offical_Version}" + if [[ ! "${Source_Version}" == "${Offical_Version}" ]];then + echo -e "Update package ${PKG_NAME} [${Source_Version}] to [${Offical_Version}] ..." + sed -i "s?PKG_VERSION:=${Source_Version}?PKG_VERSION:=${Offical_Version}?g" ${Makefile} + wget -q ${PKG_DL_URL}${Offical_Version}? -O /tmp/tmp_file + if [[ $? == 0 ]];then + Offical_HASH=$(sha256sum /tmp/tmp_file | cut -d ' ' -f1) + sed -i "s?PKG_HASH:=${Source_HASH}?PKG_HASH:=${Offical_HASH}?g" ${Makefile} + else + echo "Update package [${PKG_NAME}] error,skip update ..." + fi + fi + else + echo "Package ${PKG_NAME} is not detected,skip update ..." + fi } \ No newline at end of file