From f6e18a796d35ec64e9d1d9b9f661c1d3c0185af6 Mon Sep 17 00:00:00 2001 From: leafee98 Date: Wed, 13 Dec 2023 16:50:09 +0800 Subject: [PATCH] update build script, add --no-upload to build.sh --- .woodpecker/build.yml | 2 +- script/build.sh | 29 ++++++++++++++++------------- script/local_build.sh | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index 5978304..df62f3d 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -18,7 +18,7 @@ steps: --package-arch amd64 --apt-base $APT_BASE " - --upload-to-webdav "$WEBDAV_UPLOAD_TARGET" + --webdav-url "$WEBDAV_UPLOAD_TARGET" --webdav-user "$WEBDAV_USER" --webdav-pass "$WEBDAV_PASS" --package-dir packages/bin diff --git a/script/build.sh b/script/build.sh index a5722f2..1a282b3 100755 --- a/script/build.sh +++ b/script/build.sh @@ -14,16 +14,17 @@ function msg_warn { function usage { echo "$_PROGRAM_NAME:" - echo " --package add a dir to build, can use multi times" - echo " --package-dir all dir in this directory is a package," + echo " --package Add a dir to build, can be used multi times" + echo " --package-dir All dir in this directory is a package," echo " can use multi times" - echo " --makedeb-path specify the path of makedeb" - echo " --upload-to-webdav https://webdav_host/path/dir" - echo " upload built file to a webdav server" - echo " --webdav-user username of webdav server (if required)" - echo " --webdav-pass password of webdav server (if required)" + echo " --makedeb-path Specify the path of makedeb" + echo " --no-upload Don't upload built packages to webdav" + echo " --webdav-url https://webdav_host/path/dir" + echo " Upload built file to a webdav server" + echo " --webdav-user Username of webdav server (if required)" + echo " --webdav-pass Password of webdav server (if required)" echo ' --package-exists-hook "/path/to/hook --args {}"' - echo " this program will run the hook to check" + echo " This program will run the hook to check" echo " if specific file already built, the {} will" echo " be replaced with the final package name," echo " exit with 0 means package exists" @@ -68,7 +69,8 @@ _DELIMITER="================================================================" _PROGRAM_NAME="$0" _PACKGES_TO_BUILD=() MAKEDEB_PATH="" -UPLOAD_TO_WEBDAV="" +UPLOAD_TO_WEBDAV=1 +WEBDAV_URL="" WEBDAV_USER="" WEBDAV_PASS="" PACKAGE_DIR=() @@ -80,7 +82,8 @@ while (( "$#" >= 1 )); do --package) _PACKGES_TO_BUILD+=("$2") ; shift ;; --package-dir) PACKAGE_DIR+=("$2") ; shift ;; --makedeb-path) MAKEDEB_PATH="$2" ; shift ;; - --upload-to-webdav) UPLOAD_TO_WEBDAV="$2" ; shift ;; + --no-upload) UPLOAD_TO_WEBDAV=0 ;; + --webdav-url) WEBDAV_URL="$2" ; shift ;; --webdav-user) WEBDAV_USER="$2" ; shift ;; --webdav-pass) WEBDAV_PASS="$2" ; shift ;; --package-exists-hook) @@ -182,9 +185,9 @@ for package in "${_PACKGES_TO_BUILD[@]}" ; do exit 4 fi - if [[ -n "${UPLOAD_TO_WEBDAV}" ]] ; then - msg_info "Uploading $package_name to $UPLOAD_TO_WEBDAV" - upload_to_webdav "$package_name" "$UPLOAD_TO_WEBDAV" "$WEBDAV_USER" "$WEBDAV_PASS" + if [[ -n "${WEBDAV_URL}" ]] && (( UPLOAD_TO_WEBDAV )) ; then + msg_info "Uploading $package_name to $WEBDAV_URL" + upload_to_webdav "$package_name" "$WEBDAV_URL" "$WEBDAV_USER" "$WEBDAV_PASS" fi ) || true diff --git a/script/local_build.sh b/script/local_build.sh index 1007d7a..b2290a5 100755 --- a/script/local_build.sh +++ b/script/local_build.sh @@ -18,7 +18,7 @@ APT_BASE=https://dufs.leafee98.com/apt --package-dir packages/normal \ -- \ -f - # --upload-to-webdav "$WEBDAV_UPLOAD_TARGET" \ + # --webdav-url "$WEBDAV_UPLOAD_TARGET" \ # --webdav-user "$WEBDAV_USER" \ # --webdav-pass "$WEBDAV_PASS" \