diff --git a/builder b/builder index c4ded65..3a0b19f 100644 --- a/builder +++ b/builder @@ -18,7 +18,6 @@ source "$ScriptDir/helper.lib" # Common SteamPath=$(reg_readkey "HKCU\Software\Valve\Steam" "SteamPath") DocumentsPath=$(reg_readkey "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "Personal") -WorkDir="$(dirname "$(readlink -e "$0")")" ThirdPartyBin="$ScriptDir/3rd-party-bin" # Usefull KF2 executables / Paths / Configs @@ -55,8 +54,7 @@ KFPublishConfig="$KFPublish/Config" KFPublishLocalization="$KFPublish/Localization" # Tmp files -MutWsInfoName="wsinfo.txt" -MutWsInfo="$KFDoc/$MutWsInfoName" +MutWsInfo="$KFDoc/wsinfo.txt" KFEditorConfBackup="$KFEditorConf.backup" function show_help () @@ -83,7 +81,7 @@ EOF function show_version () { cat < /dev/null) EOF } @@ -111,7 +109,7 @@ function init_build () :> "$MutBuildConfig" - while read Package + while read -r Package do if [[ -z "$PackageList" ]]; then PackageList="$Package" @@ -129,6 +127,7 @@ function read_build_settings () if ! [[ -f "$MutBuildConfig" ]]; then init_build; fi if bash -n "$MutBuildConfig"; then + # shellcheck source=./.shellcheck/build.ini source "$MutBuildConfig" else echo "$MutBuildConfig broken! Check this file before continue or create new one using $0 --init-build" @@ -141,6 +140,7 @@ function read_test_settings () if ! [[ -f "$MutTestConfig" ]]; then init_test; fi if bash -n "$MutTestConfig"; then + # shellcheck source=./.shellcheck/test.ini source "$MutTestConfig" else echo "$MutTestConfig broken! Check this file before continue or create new one using $0 --init-test" @@ -150,20 +150,22 @@ function read_test_settings () function merge_packages () # $1: Mutator name { + local ModificationTime="" local UpkList="" + local PID="" cp -f "$KFUnpublishScript/$1.u" "$KFWin64" - while read Upk + while read -r Upk do cp -f "$MutSource/$1/$Upk" "$KFWin64" UpkList="$UpkList $Upk" done < <(find "$MutSource/$1" -type f -name '*.upk' -printf "%f\n") if [[ -n "$UpkList" ]]; then - local ModificationTime=$(stat -c %y "$KFWin64/$1.u") - CMD //C "cd "$(cygpath -w "$KFWin64")" && $(basename "$KFEditorMergePackages") make $UpkList $1.u" & - local PID="$!" + ModificationTime=$(stat -c %y "$KFWin64/$1.u") + CMD //C "cd \"$(cygpath -w "$KFWin64")\" && $(basename \""$KFEditorMergePackages"\") make $UpkList $1.u" & + PID="$!" while ps -p "$PID" &> /dev/null do if [[ "$ModificationTime" != "$(stat -c %y "$KFWin64/$1.u")" ]]; then # file changed @@ -189,6 +191,8 @@ function compiled () function compile () { + local PID="" + read_build_settings if ! command -v multini &> /dev/null; then @@ -208,9 +212,10 @@ function compile () mkdir -p "$KFUnpublishPackages" "$KFUnpublishScript" - pushd "$MutSource" - find $PackageBuildOrder -type f -name '*.upk' -exec cp -f {} "$KFUnpublishPackages" \; - popd + for Package in $PackageBuildOrder + do + find "$MutSource/$Package" -type f -name '*.upk' -exec cp -f {} "$KFUnpublishPackages" \; + done if [[ -d "$MutLocalization" ]]; then mkdir -p "$KFUnpublishLocalization" @@ -223,7 +228,7 @@ function compile () fi CMD //C "$(cygpath -w "$KFEditor")" make -stripsource -useunpublished & - local PID="$!" + PID="$!" while ps -p "$PID" &> /dev/null do if compiled; then kill "$PID"; break; fi @@ -258,6 +263,8 @@ function brewed () function brew () { + local PID="" + read_build_settings if ! compiled ; then @@ -269,8 +276,8 @@ function brew () mkdir -p "$KFPublishBrewedPC" - CMD //C "cd "$(cygpath -w "$KFWin64")" && "$(basename "$KFEditor")" brewcontent -platform=PC $PackageUpload -useunpublished" & - local PID="$!" + CMD //C "cd \"$(cygpath -w "$KFWin64")\" && \"$(basename "$KFEditor")\" brewcontent -platform=PC $PackageUpload -useunpublished" & + PID="$!" while ps -p "$PID" &> /dev/null do if brewed; then kill "$PID"; break; fi @@ -312,6 +319,8 @@ function brew_manual () function upload () { + local PreparedWsDir="" + read_build_settings if ! compiled ; then @@ -335,7 +344,7 @@ function upload () publish_common fi - local PreparedWsDir=$(mktemp -d -u -p "$KFDoc") + PreparedWsDir=$(mktemp -d -u -p "$KFDoc") cat > "$MutWsInfo" <