mirror of
https://github.com/safing/portmaster
synced 2025-09-04 19:49:15 +00:00
Update pack scripts
This commit is contained in:
parent
a98673cd88
commit
8b04580f3e
3 changed files with 116 additions and 65 deletions
|
@ -3,14 +3,16 @@
|
||||||
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
||||||
cd "$baseDir"
|
cd "$baseDir"
|
||||||
|
|
||||||
COL_OFF="\033[00m"
|
COL_OFF="\033[0m"
|
||||||
COL_BOLD="\033[01;01m"
|
COL_BOLD="\033[01;01m"
|
||||||
COL_RED="\033[31m"
|
COL_RED="\033[31m"
|
||||||
|
COL_GREEN="\033[32m"
|
||||||
|
COL_YELLOW="\033[33m"
|
||||||
|
|
||||||
destDirPart1="../../dist"
|
destDirPart1="../../dist"
|
||||||
destDirPart2="core"
|
destDirPart2="core"
|
||||||
|
|
||||||
function check {
|
function prep {
|
||||||
# output
|
# output
|
||||||
output="main"
|
output="main"
|
||||||
# get version
|
# get version
|
||||||
|
@ -25,46 +27,47 @@ function check {
|
||||||
fi
|
fi
|
||||||
# build destination path
|
# build destination path
|
||||||
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
|
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
|
||||||
|
}
|
||||||
|
|
||||||
|
function check {
|
||||||
|
prep
|
||||||
|
|
||||||
# check if file exists
|
# check if file exists
|
||||||
if [[ -f $destPath ]]; then
|
if [[ -f $destPath ]]; then
|
||||||
echo "[core] $platform $version already built"
|
echo "[core] $platform v$version already built"
|
||||||
else
|
else
|
||||||
echo -e "${COL_BOLD}[core] $platform $version${COL_OFF}"
|
echo -e "${COL_BOLD}[core] $platform v$version${COL_OFF}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function build {
|
function build {
|
||||||
# output
|
prep
|
||||||
output="main"
|
|
||||||
# get version
|
|
||||||
version=$(grep "info.Set" main.go | cut -d'"' -f4)
|
|
||||||
# build versioned file name
|
|
||||||
filename="portmaster-core_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
|
# 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 v$version, skipping..."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# build
|
# build
|
||||||
./build main.go
|
./build main.go
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo -e "\n${COL_BOLD}[core] $platform: ${COL_RED}BUILD FAILED.${COL_OFF}"
|
echo -e "\n${COL_BOLD}[core] $platform v$version: ${COL_RED}BUILD FAILED.${COL_OFF}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
mkdir -p $(dirname $destPath)
|
mkdir -p $(dirname $destPath)
|
||||||
cp $output $destPath
|
cp $output $destPath
|
||||||
echo -e "\n${COL_BOLD}[core] $platform: successfully built.${COL_OFF}"
|
echo -e "\n${COL_BOLD}[core] $platform v$version: ${COL_GREEN}successfully built.${COL_OFF}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function reset {
|
||||||
|
prep
|
||||||
|
|
||||||
|
# delete if file exists
|
||||||
|
if [[ -f $destPath ]]; then
|
||||||
|
rm $destPath
|
||||||
|
echo "[core] $platform v$version deleted."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_all {
|
function check_all {
|
||||||
|
@ -79,6 +82,12 @@ function build_all {
|
||||||
GOOS=darwin GOARCH=amd64 build
|
GOOS=darwin GOARCH=amd64 build
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reset_all {
|
||||||
|
GOOS=linux GOARCH=amd64 reset
|
||||||
|
GOOS=windows GOARCH=amd64 reset
|
||||||
|
GOOS=darwin GOARCH=amd64 reset
|
||||||
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"check" )
|
"check" )
|
||||||
check_all
|
check_all
|
||||||
|
@ -86,6 +95,9 @@ case $1 in
|
||||||
"build" )
|
"build" )
|
||||||
build_all
|
build_all
|
||||||
;;
|
;;
|
||||||
|
"reset" )
|
||||||
|
reset_all
|
||||||
|
;;
|
||||||
* )
|
* )
|
||||||
echo ""
|
echo ""
|
||||||
echo "build list:"
|
echo "build list:"
|
||||||
|
|
|
@ -3,14 +3,16 @@
|
||||||
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
||||||
cd "$baseDir"
|
cd "$baseDir"
|
||||||
|
|
||||||
COL_OFF="\033[00m"
|
COL_OFF="\033[0m"
|
||||||
COL_BOLD="\033[01;01m"
|
COL_BOLD="\033[01;01m"
|
||||||
COL_RED="\033[31m"
|
COL_RED="\033[31m"
|
||||||
|
COL_GREEN="\033[32m"
|
||||||
|
COL_YELLOW="\033[33m"
|
||||||
|
|
||||||
destDirPart1="../../dist"
|
destDirPart1="../../dist"
|
||||||
destDirPart2="start"
|
destDirPart2="start"
|
||||||
|
|
||||||
function check {
|
function prep {
|
||||||
# output
|
# output
|
||||||
output="portmaster-start"
|
output="portmaster-start"
|
||||||
# get version
|
# get version
|
||||||
|
@ -25,46 +27,47 @@ function check {
|
||||||
fi
|
fi
|
||||||
# build destination path
|
# build destination path
|
||||||
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
|
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
|
||||||
|
}
|
||||||
|
|
||||||
|
function check {
|
||||||
|
prep
|
||||||
|
|
||||||
# check if file exists
|
# check if file exists
|
||||||
if [[ -f $destPath ]]; then
|
if [[ -f $destPath ]]; then
|
||||||
echo "[start] $platform $version already built"
|
echo "[start] $platform $version already built"
|
||||||
else
|
else
|
||||||
echo -e "${COL_BOLD}[start] $platform $version${COL_OFF}"
|
echo -e "${COL_BOLD}[start] $platform v$version${COL_OFF}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function build {
|
function build {
|
||||||
# output
|
prep
|
||||||
output="portmaster-start"
|
|
||||||
# get version
|
|
||||||
version=$(grep "info.Set" main.go | cut -d'"' -f4)
|
|
||||||
# build versioned file name
|
|
||||||
filename="portmaster-start_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
|
# check if file exists
|
||||||
if [[ -f $destPath ]]; then
|
if [[ -f $destPath ]]; then
|
||||||
echo "[start] $platform already built in version $version, skipping..."
|
echo "[start] $platform already built in v$version, skipping..."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# build
|
# build
|
||||||
./build
|
./build
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo -e "\n${COL_BOLD}[start] $platform: ${COL_RED}BUILD FAILED.${COL_OFF}"
|
echo -e "\n${COL_BOLD}[start] $platform v$version: ${COL_RED}BUILD FAILED.${COL_OFF}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
mkdir -p $(dirname $destPath)
|
mkdir -p $(dirname $destPath)
|
||||||
cp $output $destPath
|
cp $output $destPath
|
||||||
echo -e "\n${COL_BOLD}[start] $platform: successfully built.${COL_OFF}"
|
echo -e "\n${COL_BOLD}[start] $platform v$version: ${COL_GREEN}successfully built.${COL_OFF}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function reset {
|
||||||
|
prep
|
||||||
|
|
||||||
|
# delete if file exists
|
||||||
|
if [[ -f $destPath ]]; then
|
||||||
|
rm $destPath
|
||||||
|
echo "[start] $platform v$version deleted."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_all {
|
function check_all {
|
||||||
|
@ -79,6 +82,12 @@ function build_all {
|
||||||
GOOS=darwin GOARCH=amd64 build
|
GOOS=darwin GOARCH=amd64 build
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reset_all {
|
||||||
|
GOOS=linux GOARCH=amd64 reset
|
||||||
|
GOOS=windows GOARCH=amd64 reset
|
||||||
|
GOOS=darwin GOARCH=amd64 reset
|
||||||
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"check" )
|
"check" )
|
||||||
check_all
|
check_all
|
||||||
|
@ -86,6 +95,9 @@ case $1 in
|
||||||
"build" )
|
"build" )
|
||||||
build_all
|
build_all
|
||||||
;;
|
;;
|
||||||
|
"reset" )
|
||||||
|
reset_all
|
||||||
|
;;
|
||||||
* )
|
* )
|
||||||
echo ""
|
echo ""
|
||||||
echo "build list:"
|
echo "build list:"
|
||||||
|
|
75
pack
75
pack
|
@ -3,33 +3,60 @@
|
||||||
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
baseDir="$( cd "$(dirname "$0")" && pwd )"
|
||||||
cd "$baseDir"
|
cd "$baseDir"
|
||||||
|
|
||||||
# first check what will be built
|
COL_OFF="\033[0m"
|
||||||
|
COL_BOLD="\033[01;01m"
|
||||||
|
COL_RED="\033[31m"
|
||||||
|
COL_GREEN="\033[32m"
|
||||||
|
COL_YELLOW="\033[33m"
|
||||||
|
|
||||||
function packAll() {
|
function safe_execute {
|
||||||
for i in ./cmds/* ; do
|
echo -e "\n[....] $*"
|
||||||
if [ -e $i/pack ]; then
|
$*
|
||||||
$i/pack $1
|
if [[ $? -eq 0 ]]; then
|
||||||
fi
|
echo -e "[${COL_GREEN} OK ${COL_OFF}] $*"
|
||||||
done
|
else
|
||||||
|
echo -e "[${COL_RED}FAIL${COL_OFF}] $*" >/dev/stderr
|
||||||
|
echo -e "[${COL_RED}CRIT${COL_OFF}] ABORTING..." >/dev/stderr
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
echo ""
|
function check {
|
||||||
echo "pack list:"
|
./cmds/portmaster-core/pack check
|
||||||
echo ""
|
./cmds/portmaster-start/pack check
|
||||||
|
}
|
||||||
|
|
||||||
packAll check
|
function build {
|
||||||
|
safe_execute ./cmds/portmaster-core/pack build
|
||||||
|
safe_execute ./cmds/portmaster-start/pack build
|
||||||
|
}
|
||||||
|
|
||||||
# confirm
|
function reset {
|
||||||
|
./cmds/portmaster-core/pack reset
|
||||||
|
./cmds/portmaster-start/pack reset
|
||||||
|
}
|
||||||
|
|
||||||
echo ""
|
case $1 in
|
||||||
read -p "press [Enter] to start packing" x
|
"check" )
|
||||||
echo ""
|
check
|
||||||
|
;;
|
||||||
# build
|
"build" )
|
||||||
|
build
|
||||||
set -e
|
;;
|
||||||
packAll build
|
"reset" )
|
||||||
|
reset
|
||||||
echo ""
|
;;
|
||||||
echo "finished packing."
|
* )
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "build list:"
|
||||||
|
echo ""
|
||||||
|
check
|
||||||
|
echo ""
|
||||||
|
read -p "press [Enter] to start building" x
|
||||||
|
echo ""
|
||||||
|
build
|
||||||
|
echo ""
|
||||||
|
echo "finished building."
|
||||||
|
echo ""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
Loading…
Add table
Reference in a new issue