From a2aea661e2ed1965dd0e21ea356c26c282dd6ca0 Mon Sep 17 00:00:00 2001 From: minoplhy Date: Wed, 30 Oct 2024 20:08:41 +0700 Subject: [PATCH] build_gitea: support patch url --- build_gitea/Linux/build.sh | 21 +++++++++++++++++++-- build_gitea/README.md | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/build_gitea/Linux/build.sh b/build_gitea/Linux/build.sh index 08b4bb4..aef8172 100644 --- a/build_gitea/Linux/build.sh +++ b/build_gitea/Linux/build.sh @@ -48,7 +48,7 @@ while [ ${#} -gt 0 ]; do *) ;; esac - ;; # Add Patches to your Gitea build. Format -> patch1.patch or patch1.patch,patch2.patch (Absolute path) + ;; # Add Patches to your Gitea build. Format -> patch1.patch or patch1.patch,https://patch (Absolute path) *) ;; esac @@ -133,7 +133,7 @@ then if git show-ref $GITEA_GIT_TAG --quiet; then git checkout $GITEA_GIT_TAG else - echo -e "\GITEA_GIT_TAG variable doesn't match the repo tag/version. exit to prevent further issue." && exit 1 + echo -e "\nGITEA_GIT_TAG variable doesn't match the repo tag/version. exit to prevent further issue." && exit 1 fi else echo -e "GITEA_GIT_TAG variable not found. will build on "main" branch." @@ -142,6 +142,23 @@ fi if [[ -n $PATCH_FILES ]] then for patch in $(echo "$PATCH_FILES" | tr ',' '\n'); do + case $patch in + http://*|https://*) + # The random part: + # https://stackoverflow.com/questions/2793812/generate-a-random-filename-in-unix-shell + NEW_PATCH_PATH=$DESTINATION/$(head /dev/urandom | tr -cd 'a-f0-9' | head -c 32)".patch" + + if wget $patch -O $NEW_PATCH_PATH; then + printf "Info: '%s' has been downloaded. Filename: %s\n" $patch $NEW_PATCH_PATH + else + printf "Info: '%s' Download failed! The task is aborted.\n" $patch + exit 1 + fi + + patch=$NEW_PATCH_PATH ;; + *) ;; + esac + if git apply --check $patch; then git apply $patch printf "Info: PATCH '%s' applied successful!\n" $patch diff --git a/build_gitea/README.md b/build_gitea/README.md index 1341fbf..27f9ea2 100644 --- a/build_gitea/README.md +++ b/build_gitea/README.md @@ -56,7 +56,7 @@ while [ ${#} -gt 0 ]; do *) ;; esac - ;; # Add Patches to your Gitea build. Format -> patch1.patch or patch1.patch,patch2.patch (Absolute path) + ;; # Add Patches to your Gitea build. Format -> patch1.patch or patch1.patch,https://patch (Absolute path) *) ;; esac