Fix pack script for windows

This commit is contained in:
Daniel 2019-05-22 22:18:13 +02:00
parent 196233358b
commit 7bbfdf288f
2 changed files with 28 additions and 4 deletions

View file

@ -11,12 +11,18 @@ destDirPart1="dist"
destDirPart2="core" destDirPart2="core"
function check { function check {
# output
output="main"
# get version # get version
version=$(grep "info.Set" main.go | cut -d'"' -f4) version=$(grep "info.Set" main.go | cut -d'"' -f4)
# build versioned file name # build versioned file name
filename="portmaster_v${version//./-}" filename="portmaster_v${version//./-}"
# platform # platform
platform="${GOOS}_${GOARCH}" platform="${GOOS}_${GOARCH}"
if [[ $GOOS == "windows" ]]; then
filename="${filename}.exe"
output="${output}.exe"
fi
# build destination path # build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
@ -29,19 +35,25 @@ function check {
} }
function build { function build {
# output
output="main"
# get version # get version
version=$(grep "info.Set" main.go | cut -d'"' -f4) version=$(grep "info.Set" main.go | cut -d'"' -f4)
# build versioned file name # build versioned file name
filename="portmaster_v${version//./-}" filename="portmaster_v${version//./-}"
# platform # platform
platform="${GOOS}_${GOARCH}" platform="${GOOS}_${GOARCH}"
if [[ $GOOS == "windows" ]]; then
filename="${filename}.exe"
output="${output}.exe"
fi
# build destination path # build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
# check if file exists # check if file exists
if [[ -f $destPath ]]; then if [[ -f $destPath ]]; then
echo "[core] $platform already built in version $version, skipping..." echo "[core] $platform already built in version $version, skipping..."
exit 0 return
fi fi
# build # build
@ -51,7 +63,7 @@ function build {
exit 1 exit 1
fi fi
mkdir -p $(dirname $destPath) mkdir -p $(dirname $destPath)
cp main $destPath cp $output $destPath
echo -e "\n${COL_BOLD}[core] $platform: successfully built.${COL_OFF}" echo -e "\n${COL_BOLD}[core] $platform: successfully built.${COL_OFF}"
} }

View file

@ -11,12 +11,18 @@ destDirPart1="../dist"
destDirPart2="pmctl" destDirPart2="pmctl"
function check { function check {
# output
output="pmctl"
# get version # get version
version=$(grep "info.Set" main.go | cut -d'"' -f4) version=$(grep "info.Set" main.go | cut -d'"' -f4)
# build versioned file name # build versioned file name
filename="pmctl_v${version//./-}" filename="pmctl_v${version//./-}"
# platform # platform
platform="${GOOS}_${GOARCH}" platform="${GOOS}_${GOARCH}"
if [[ $GOOS == "windows" ]]; then
filename="${filename}.exe"
output="${output}.exe"
fi
# build destination path # build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
@ -29,19 +35,25 @@ function check {
} }
function build { function build {
# output
output="pmctl"
# get version # get version
version=$(grep "info.Set" main.go | cut -d'"' -f4) version=$(grep "info.Set" main.go | cut -d'"' -f4)
# build versioned file name # build versioned file name
filename="pmctl_v${version//./-}" filename="pmctl_v${version//./-}"
# platform # platform
platform="${GOOS}_${GOARCH}" platform="${GOOS}_${GOARCH}"
if [[ $GOOS == "windows" ]]; then
filename="${filename}.exe"
output="${output}.exe"
fi
# build destination path # build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
# check if file exists # check if file exists
if [[ -f $destPath ]]; then if [[ -f $destPath ]]; then
echo "[pmctl] $platform already built in version $version, skipping..." echo "[pmctl] $platform already built in version $version, skipping..."
exit 0 return
fi fi
# build # build
@ -51,7 +63,7 @@ function build {
exit 1 exit 1
fi fi
mkdir -p $(dirname $destPath) mkdir -p $(dirname $destPath)
cp pmctl $destPath cp $output $destPath
echo -e "\n${COL_BOLD}[pmctl] $platform: successfully built.${COL_OFF}" echo -e "\n${COL_BOLD}[pmctl] $platform: successfully built.${COL_OFF}"
} }