Skip to content

Commit

Permalink
Fix pack script for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed May 22, 2019
1 parent 1962333 commit 7bbfdf2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
16 changes: 14 additions & 2 deletions pack_core
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ destDirPart1="dist"
destDirPart2="core"

function check {
# output
output="main"
# get version
version=$(grep "info.Set" main.go | cut -d'"' -f4)
# build versioned file name
filename="portmaster_v${version//./-}"
# platform
platform="${GOOS}_${GOARCH}"
if [[ $GOOS == "windows" ]]; then
filename="${filename}.exe"
output="${output}.exe"
fi
# build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename

Expand All @@ -29,19 +35,25 @@ function check {
}

function build {
# output
output="main"
# get version
version=$(grep "info.Set" main.go | cut -d'"' -f4)
# build versioned file name
filename="portmaster_v${version//./-}"
# platform
platform="${GOOS}_${GOARCH}"
if [[ $GOOS == "windows" ]]; then
filename="${filename}.exe"
output="${output}.exe"
fi
# build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename

# check if file exists
if [[ -f $destPath ]]; then
echo "[core] $platform already built in version $version, skipping..."
exit 0
return
fi

# build
Expand All @@ -51,7 +63,7 @@ function build {
exit 1
fi
mkdir -p $(dirname $destPath)
cp main $destPath
cp $output $destPath
echo -e "\n${COL_BOLD}[core] $platform: successfully built.${COL_OFF}"
}

Expand Down
16 changes: 14 additions & 2 deletions pmctl/pack
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ destDirPart1="../dist"
destDirPart2="pmctl"

function check {
# output
output="pmctl"
# get version
version=$(grep "info.Set" main.go | cut -d'"' -f4)
# build versioned file name
filename="pmctl_v${version//./-}"
# platform
platform="${GOOS}_${GOARCH}"
if [[ $GOOS == "windows" ]]; then
filename="${filename}.exe"
output="${output}.exe"
fi
# build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename

Expand All @@ -29,19 +35,25 @@ function check {
}

function build {
# output
output="pmctl"
# get version
version=$(grep "info.Set" main.go | cut -d'"' -f4)
# build versioned file name
filename="pmctl_v${version//./-}"
# platform
platform="${GOOS}_${GOARCH}"
if [[ $GOOS == "windows" ]]; then
filename="${filename}.exe"
output="${output}.exe"
fi
# build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename

# check if file exists
if [[ -f $destPath ]]; then
echo "[pmctl] $platform already built in version $version, skipping..."
exit 0
return
fi

# build
Expand All @@ -51,7 +63,7 @@ function build {
exit 1
fi
mkdir -p $(dirname $destPath)
cp pmctl $destPath
cp $output $destPath
echo -e "\n${COL_BOLD}[pmctl] $platform: successfully built.${COL_OFF}"
}

Expand Down

0 comments on commit 7bbfdf2

Please sign in to comment.