2018-09-29 05:58:38 +08:00
|
|
|
#!/usr/bin/env bash
|
2015-08-05 16:01:48 +08:00
|
|
|
|
|
|
|
#
|
2018-09-29 05:58:38 +08:00
|
|
|
# Script to create installers for various platforms.
|
2015-08-05 16:01:48 +08:00
|
|
|
#
|
2013-01-12 07:57:19 +08:00
|
|
|
|
2015-08-01 17:34:28 +08:00
|
|
|
cd $(dirname $0)
|
|
|
|
|
2018-09-29 05:58:38 +08:00
|
|
|
usage () {
|
|
|
|
echo "Usage: $0 VERSION [PLATFORM]"
|
|
|
|
echo "Build Traccar installers."
|
|
|
|
echo
|
|
|
|
echo "Without PLATFORM provided, builds installers for all platforms."
|
|
|
|
echo
|
|
|
|
echo "Available platforms:"
|
|
|
|
echo " * linux-64"
|
|
|
|
echo " * linux-arm"
|
|
|
|
echo " * windows-64"
|
|
|
|
echo " * other"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2015-08-05 16:01:48 +08:00
|
|
|
if [[ $# -lt 1 ]]
|
|
|
|
then
|
2018-09-29 05:58:38 +08:00
|
|
|
usage
|
2015-01-17 13:52:49 +08:00
|
|
|
fi
|
|
|
|
|
2018-09-29 05:58:38 +08:00
|
|
|
info () {
|
|
|
|
echo -e "[\033[1;34mINFO\033[0m] "$1
|
|
|
|
}
|
|
|
|
|
|
|
|
ok () {
|
|
|
|
echo -e "[\033[1;32m OK \033[0m] "$1
|
|
|
|
}
|
|
|
|
|
|
|
|
warn () {
|
|
|
|
echo -e "[\033[1;31mWARN\033[0m] "$1
|
|
|
|
}
|
|
|
|
|
2015-08-09 07:11:18 +08:00
|
|
|
VERSION=$1
|
2018-09-29 05:58:38 +08:00
|
|
|
PLATFORM=${2:-all}
|
|
|
|
PREREQ=true
|
2013-01-12 07:57:19 +08:00
|
|
|
|
2015-08-09 07:11:18 +08:00
|
|
|
check_requirement () {
|
2018-09-29 05:58:38 +08:00
|
|
|
if ! eval $2 &>/dev/null
|
2015-08-09 07:11:18 +08:00
|
|
|
then
|
2018-09-29 05:58:38 +08:00
|
|
|
warn "$3"
|
|
|
|
PREREQ=false
|
|
|
|
else
|
|
|
|
ok "$@"
|
|
|
|
fi
|
2015-08-09 07:11:18 +08:00
|
|
|
}
|
2013-01-12 07:57:19 +08:00
|
|
|
|
2018-09-29 05:58:38 +08:00
|
|
|
info "Checking build requirements for platform: "$PLATFORM
|
|
|
|
check_requirement "Traccar server archive" "ls ../target/tracker-server.jar" "Missing traccar archive"
|
|
|
|
check_requirement "Zip" "which zip" "Missing zip binary"
|
|
|
|
check_requirement "Unzip" "which unzip" "Missing unzip binary"
|
|
|
|
if [ $PLATFORM != "other" ]; then
|
2019-04-29 11:38:12 +08:00
|
|
|
check_requirement "Jlink" "which jlink" "Missing jlink binary"
|
2018-09-29 05:58:38 +08:00
|
|
|
fi
|
|
|
|
if [ $PLATFORM = "all" -o $PLATFORM = "windows-64" ]; then
|
|
|
|
check_requirement "Inno Extractor" "which innoextract" "Missing innoextract binary"
|
2020-01-19 08:50:27 +08:00
|
|
|
check_requirement "Inno Setup" "ls i*setup-*.exe" "Missing Inno Setup (http://www.jrsoftware.org/isdl.php)"
|
2022-08-10 08:16:11 +08:00
|
|
|
check_requirement "Windows 64 Java" "ls OpenJDK*64_windows*.zip" "Missing Windows 64 JDK (https://adoptium.net/)"
|
2018-09-29 05:58:38 +08:00
|
|
|
check_requirement "Wine" "which wine" "Missing wine binary"
|
|
|
|
fi
|
2024-04-07 04:51:31 +08:00
|
|
|
if [ $PLATFORM = "all" -o $PLATFORM = "linux-64" -o $PLATFORM = "linux-arm" ]; then
|
2018-09-29 05:58:38 +08:00
|
|
|
check_requirement "Makeself" "which makeself" "Missing makeself binary"
|
|
|
|
fi
|
|
|
|
if [ $PLATFORM = "all" -o $PLATFORM = "linux-64" ]; then
|
2023-02-25 01:24:25 +08:00
|
|
|
check_requirement "Linux 64 Java" "ls OpenJDK*x64_linux*.tar.gz" "Missing Linux 64 JDK (https://adoptium.net/)"
|
2018-09-29 05:58:38 +08:00
|
|
|
fi
|
|
|
|
if [ $PLATFORM = "all" -o $PLATFORM = "linux-arm" ]; then
|
2024-04-07 04:51:31 +08:00
|
|
|
check_requirement "Linux ARM Java" "ls OpenJDK*aarch64_linux*.tar.gz" "Missing Linux ARM JDK (https://adoptium.net/)"
|
2023-02-25 01:24:25 +08:00
|
|
|
fi
|
2018-09-29 05:58:38 +08:00
|
|
|
if [ $PREREQ = false ]; then
|
|
|
|
info "Missing build requirements, aborting..."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
info "Building..."
|
|
|
|
fi
|
2015-02-21 17:00:42 +08:00
|
|
|
|
2015-08-09 07:11:18 +08:00
|
|
|
prepare () {
|
2024-04-07 03:40:21 +08:00
|
|
|
mkdir -p out/{conf,data,lib,logs,web,schema,templates}
|
2013-01-12 07:57:19 +08:00
|
|
|
|
2015-08-09 07:11:18 +08:00
|
|
|
cp ../target/tracker-server.jar out
|
|
|
|
cp ../target/lib/* out/lib
|
2016-07-09 14:58:41 +08:00
|
|
|
cp ../schema/* out/schema
|
2016-11-13 06:48:15 +08:00
|
|
|
cp -r ../templates/* out/templates
|
2024-04-07 03:40:21 +08:00
|
|
|
cp -r ../traccar-web/build/* out/web
|
2016-09-17 22:30:35 +08:00
|
|
|
cp traccar.xml out/conf
|
2016-09-17 20:26:16 +08:00
|
|
|
|
2018-09-29 05:58:38 +08:00
|
|
|
if [ $PLATFORM = "all" -o $PLATFORM = "windows-64" ]; then
|
2020-01-19 08:50:27 +08:00
|
|
|
innoextract i*setup-*.exe >/dev/null
|
2018-09-29 05:58:38 +08:00
|
|
|
info "If you got any errors here try Inno Setup version 5.5.5 (or check supported versions using 'innoextract -v')"
|
|
|
|
fi
|
2018-09-17 17:22:34 +08:00
|
|
|
}
|
2013-11-10 15:25:22 +08:00
|
|
|
|
2018-09-17 17:22:34 +08:00
|
|
|
cleanup () {
|
2018-09-29 05:58:38 +08:00
|
|
|
info "Cleanup"
|
2018-09-17 17:22:34 +08:00
|
|
|
rm -r out
|
2018-09-29 05:58:38 +08:00
|
|
|
if [ $PLATFORM = "all" -o $PLATFORM = "windows-64" ]; then
|
|
|
|
rm -r tmp
|
|
|
|
rm -r app
|
|
|
|
fi
|
2018-09-17 17:22:34 +08:00
|
|
|
}
|
2016-07-09 15:23:22 +08:00
|
|
|
|
2018-09-17 17:22:34 +08:00
|
|
|
package_other () {
|
2018-09-29 05:58:38 +08:00
|
|
|
info "Building Zip archive"
|
2018-09-17 17:22:34 +08:00
|
|
|
cp README.txt out
|
|
|
|
cd out
|
2018-09-29 05:58:38 +08:00
|
|
|
zip -q -r ../traccar-other-$VERSION.zip *
|
2018-09-17 17:22:34 +08:00
|
|
|
cd ..
|
|
|
|
rm out/README.txt
|
2018-09-29 05:58:38 +08:00
|
|
|
ok "Created Zip archive"
|
2018-09-17 17:22:34 +08:00
|
|
|
}
|
2013-03-02 08:18:34 +08:00
|
|
|
|
2018-09-17 17:22:34 +08:00
|
|
|
package_windows () {
|
2018-09-29 05:58:38 +08:00
|
|
|
info "Building Windows 64 installer"
|
2022-08-10 08:16:11 +08:00
|
|
|
unzip -q OpenJDK*64_windows*.zip
|
2023-02-15 07:26:46 +08:00
|
|
|
jlink --module-path jdk-*/jmods --add-modules java.se,jdk.charsets,jdk.crypto.ec,jdk.unsupported --output out/jre
|
2022-08-10 07:42:11 +08:00
|
|
|
rm -rf jdk-*
|
2018-09-29 05:58:38 +08:00
|
|
|
wine app/ISCC.exe traccar.iss >/dev/null
|
2018-09-17 17:22:34 +08:00
|
|
|
rm -rf out/jre
|
2018-09-29 05:58:38 +08:00
|
|
|
zip -q -j traccar-windows-64-$VERSION.zip Output/traccar-setup.exe README.txt
|
2016-09-17 22:30:35 +08:00
|
|
|
rm -r Output
|
2018-09-29 05:58:38 +08:00
|
|
|
ok "Created Windows 64 installer"
|
2016-09-17 20:26:16 +08:00
|
|
|
}
|
2013-02-09 17:01:47 +08:00
|
|
|
|
2018-09-29 05:58:38 +08:00
|
|
|
package_linux () {
|
2017-07-08 13:14:14 +08:00
|
|
|
cp setup.sh out
|
2018-09-17 17:22:34 +08:00
|
|
|
cp traccar.service out
|
2013-02-09 17:01:47 +08:00
|
|
|
|
2023-02-25 01:24:25 +08:00
|
|
|
tar -xf OpenJDK*$2_linux*.tar.gz
|
2023-02-15 07:26:46 +08:00
|
|
|
jlink --module-path jdk-*/jmods --add-modules java.se,jdk.charsets,jdk.crypto.ec,jdk.unsupported --output out/jre
|
2022-08-10 07:42:11 +08:00
|
|
|
rm -rf jdk-*
|
2020-10-27 15:11:17 +08:00
|
|
|
makeself --needroot --quiet --notemp out traccar.run "traccar" ./setup.sh
|
2018-09-17 17:22:34 +08:00
|
|
|
rm -rf out/jre
|
2018-09-15 07:29:01 +08:00
|
|
|
|
2022-08-10 07:42:11 +08:00
|
|
|
zip -q -j traccar-linux-$1-$VERSION.zip traccar.run README.txt
|
2013-01-12 07:57:19 +08:00
|
|
|
|
2018-09-29 05:58:38 +08:00
|
|
|
rm traccar.run
|
2018-09-17 17:22:34 +08:00
|
|
|
rm out/setup.sh
|
|
|
|
rm out/traccar.service
|
2015-08-09 07:11:18 +08:00
|
|
|
}
|
|
|
|
|
2018-09-29 05:58:38 +08:00
|
|
|
package_linux_64 () {
|
|
|
|
info "Building Linux 64 installer"
|
2023-02-25 01:24:25 +08:00
|
|
|
package_linux 64 x64
|
2018-09-29 05:58:38 +08:00
|
|
|
ok "Created Linux 64 installer"
|
|
|
|
}
|
|
|
|
|
|
|
|
package_linux_arm () {
|
|
|
|
info "Building Linux ARM installer"
|
2024-04-07 04:51:31 +08:00
|
|
|
package_linux arm aarch64
|
2018-09-29 05:58:38 +08:00
|
|
|
ok "Created Linux ARM installer"
|
|
|
|
}
|
|
|
|
|
2015-08-09 07:11:18 +08:00
|
|
|
prepare
|
2015-08-01 18:00:13 +08:00
|
|
|
|
2018-09-29 05:58:38 +08:00
|
|
|
case $PLATFORM in
|
|
|
|
all)
|
|
|
|
package_linux_64
|
|
|
|
package_linux_arm
|
|
|
|
package_windows
|
|
|
|
package_other
|
|
|
|
;;
|
|
|
|
|
|
|
|
linux-64)
|
|
|
|
package_linux_64
|
|
|
|
;;
|
|
|
|
|
|
|
|
linux-arm)
|
|
|
|
package_linux_arm
|
|
|
|
;;
|
|
|
|
|
|
|
|
windows-64)
|
|
|
|
package_windows
|
|
|
|
;;
|
|
|
|
|
|
|
|
other)
|
|
|
|
package_other
|
|
|
|
;;
|
|
|
|
esac
|
2015-08-05 16:01:48 +08:00
|
|
|
|
2015-08-09 07:11:18 +08:00
|
|
|
cleanup
|
2018-09-29 05:58:38 +08:00
|
|
|
|
|
|
|
ok "Done"
|