-
Notifications
You must be signed in to change notification settings - Fork 111
/
build.sh
executable file
·65 lines (56 loc) · 1.25 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
ARCH="armhf"
# Common directory variables
SYSCONFDIR="${SYSCONFDIR:-/etc}"
SRC_DIR="$(pwd)"
BUILD_DIR_TEMPLATE="_build_${ARCH}"
BUILD_DIR="${BUILD_DIR:-${SRC_DIR}/${BUILD_DIR_TEMPLATE}}"
# Debian package information
PACKAGE_NAME="${PACKAGE_NAME:-fdm-materials}"
RELEASE_VERSION="${RELEASE_VERSION:-999.999.999}"
build()
{
mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}" || return
echo "Building with cmake"
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCPACK_PACKAGE_VERSION="${RELEASE_VERSION}" -DCPACK_PACKAGE_NAME="${PACKAGE_NAME}" -DCPACK_PACKAGE_ARCH="${ARCH}" -DEMBEDDED=ON
}
create_debian_package()
{
make package
}
cleanup()
{
rm -rf "${BUILD_DIR:?}"
}
usage()
{
echo "Usage: ${0} [OPTIONS]"
echo " -c Explicitly cleanup the build directory"
echo " -h Print this usage"
echo "NOTE: This script requires root permissions to run."
}
while getopts ":hc" options; do
case "${options}" in
c)
cleanup
exit 0
;;
h)
usage
exit 0
;;
:)
echo "Option -${OPTARG} requires an argument."
exit 1
;;
?)
echo "Invalid option: -${OPTARG}"
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
cleanup
build
create_debian_package