From e245c968a2a1240a5357ca3a816dc274c4fb0eb9 Mon Sep 17 00:00:00 2001 From: wfc Date: Fri, 28 Feb 2025 14:52:37 +0800 Subject: [PATCH] fix: build option -g enhancement --- bin/build.sh | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/bin/build.sh b/bin/build.sh index 9b0261d..a0a628d 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -22,12 +22,33 @@ TmpDir=${BuildRootDir}/tmp TmpEnvFile=${TmpDir}/.env.tmp usage() { - echo "Usage: sh build.sh [-g] [extras|jar|dist|copy|tar|src-tar|deb|all]" + echo "Usage: sh build.sh [extras|jar|dist|copy|tar|srctar|deb|all] [-g]" exit 1 } SKIP_PRE_GIT_PULL=false +# Reorder arguments so that options come first +ARGS=() +for arg in "$@"; do + case $arg in + -g) + SKIP_PRE_GIT_PULL=true + ;; + *) + ARGS+=("$arg") + ;; + esac +done + +if SKIP_PRE_GIT_PULL=true; then + ARGS+=("-g") +fi + +# Restore positional parameters +set -- "${ARGS[@]}" + +# Process options while getopts "g" opt; do case ${opt} in g ) @@ -47,7 +68,7 @@ pre-build-tar(){ source ${BuildRootDir}/bin/control.sh cd ${BuildRootDir} sed -i "s/YYYYMMDD/${RelDate}/" ${BuildDockerDir}/env/wfc-release - git update-index --assume-unchanged ${BuildDockerDir}/env/wfc-release + # git update-index --assume-unchanged ${BuildDockerDir}/env/wfc-release } pre-git-pull(){ @@ -75,7 +96,7 @@ pre-build-deb(){ fi cd ${BuildRootDir} sed -i "s/YYYYMMDD/${RelDate}/" ${BuildDockerDir}/env/wfc-release - git update-index --assume-unchanged ${BuildDockerDir}/env/wfc-release + # git update-index --assume-unchanged ${BuildDockerDir}/env/wfc-release } build-extras(){ @@ -185,7 +206,7 @@ create-src-tar(){ --exclude=${BuildRelativeDir}/.vscode \ --exclude=${BuildRelativeDir}/.git \ --exclude=${BuildRelativeDir}/tmp \ - --exclude=${BuildRelativeDir}/release \ + --exclude=${BuildRelativeDir}/release \ --exclude=${BuildRelativeDir}/build/docker/nginx/html \ --exclude=${BuildRelativeDir}/build/docker/wfc/auth/jar/*.jar \ --exclude=${BuildRelativeDir}/build/docker/wfc/gateway/jar/*.jar \ @@ -214,8 +235,9 @@ post-build(){ # mv -f ${TmpEnvFile} ${BuildDockerDir}/.env # fi cd ${BuildRootDir} - git checkout ${BuildDockerDir}/env/wfc-release - git update-index --no-assume-unchanged ${BuildDockerDir}/env/wfc-release + sed -i "s/${RelDate}/YYYYMMDD/" ${BuildDockerDir}/env/wfc-release + # git checkout ${BuildDockerDir}/env/wfc-release + # git update-index --no-assume-unchanged ${BuildDockerDir}/env/wfc-release } case "$1" in @@ -256,7 +278,7 @@ case "$1" in create-deb post-build ;; - "src-tar") + "srctar") if [ "$SKIP_PRE_GIT_PULL" = false ]; then pre-git-pull fi @@ -266,10 +288,12 @@ case "$1" in # post-build ;; "all") - $0 tar - $0 deb + # Recursively call the script with the 'deb' argument and pass necessary parameters + $0 deb "${ARGS[@]:2}" + # Recursively call the script with the 'tar' argument and pass necessary parameters + $0 tar "${ARGS[@]:2}" ;; *) usage ;; -esac \ No newline at end of file +esac