-
Notifications
You must be signed in to change notification settings - Fork 18
/
build-package-deb.sh
executable file
·87 lines (76 loc) · 2.12 KB
/
build-package-deb.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
version="$1"
dist="$2"
arch="$3"
package_file_prefix="jfbview_${version}~${dist}_${arch}"
if [ "$EUID" -eq 0 ]; then
sudo=
else
sudo='sudo'
fi
if grep -qi ubuntu /etc/os-release; then
libjpeg=libjpeg8
libjpeg_dev=libjpeg8-dev
else
libjpeg=libjpeg62-turbo
libjpeg_dev=libjpeg62-turbo-dev
fi
function install_build_deps() {
export DEBIAN_FRONTEND=noninteractive
$sudo apt-get -qq update
$sudo apt-get -qq install -y \
build-essential cmake file pkg-config \
libncurses-dev libncursesw5-dev ${libjpeg_dev} \
libharfbuzz-dev libfreetype6-dev zlib1g-dev libopenjp2-7-dev \
> /dev/null # -qq doesn't actually silence apt-get install.
}
function build_package() {
cd "$(dirname "$0")/.."
mkdir -p build upload
cmake -H. -Bbuild \
-DPACKAGE_FORMAT=DEB \
-DLIBJPEG_PACKAGE_NAME=${libjpeg} \
-DPACKAGE_FILE_PREFIX="$package_file_prefix" \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release
cmake --build build --target package
mv build/*.deb upload/
}
function install_test_deps() {
export DEBIAN_FRONTEND=noninteractive
$sudo apt-get -qq install -y \
libgtest-dev \
> /dev/null # -qq doesn't actually silence apt-get install.
# In earlier Debian-based releases (Debian Stretch or older, Ubuntu Xenial or
# older), libgtest-dev doesn't actually ship the gtest libraries in compiled
# form. Instead, we have to compile them ourselves. The following is derived
# from https://stackoverflow.com/a/44649433/3401268.
if dpkg -L libgtest-dev | grep -q 'libgtest\.a$'; then
gtest_root_flag=()
else
cd "$(dirname "$0")/.."
mkdir -p vendor/gtest
( \
cd vendor/gtest && \
cmake /usr/src/gtest && \
cmake --build . \
)
gtest_root_flag=("-DGTEST_ROOT=${PWD}/vendor/gtest")
fi
}
function run_tests() {
cd "$(dirname "$0")/.."
mkdir -p build_tests
cmake -H. -Bbuild_tests \
"${gtest_root_flag[@]}" \
-DBUILD_TESTING=ON \
-DCMAKE_BUILD_TYPE=Debug
cmake --build build_tests
env CTEST_OUTPUT_ON_FAILURE=1 \
cmake --build build_tests --target test
}
set -ex
install_build_deps
install_test_deps
run_tests
build_package