-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·63 lines (52 loc) · 1.76 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
#!/bin/sh
# -*- coding: utf-8 -*-
basedir="$(realpath "$0" | xargs dirname)"
info()
{
echo "--- $*"
}
error()
{
echo "=== ERROR: $*" >&2
}
warning()
{
echo "=== WARNING: $*" >&2
}
die()
{
error "$*"
exit 1
}
check_dynlibs()
{
local bin="$1"
local ldd_out="$(ldd "$bin")"
[ -z "$ldd_out" ] && die "ldd failed"
printf '%s' "$ldd_out" | while read line; do
printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'linux-vdso\.so' && continue
printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'libgcc_s\.so' && continue
printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'libm\.so' && continue
printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'libc\.so' && continue
printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'ld-linux-.*\.so' && continue
printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'ld-android\.so' && continue
printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'libarmmem-.*\.so' && continue
printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'libdl\.so' && continue
die "Found unknown dynamically linked library '$line' in '$bin'"
done
}
[ -f "$basedir/Cargo.toml" ] || die "basedir sanity check failed"
cd "$basedir" || die "cd basedir failed."
export LETMEIN_CONF_PREFIX="/opt/letmein"
cargo build || die "Cargo build (debug) failed."
cargo test || die "Cargo test failed."
cargo auditable build --release || die "Cargo build (release) failed."
cargo audit bin --deny warnings \
target/release/letmein \
target/release/letmeind \
target/release/letmeinfwd \
|| die "Cargo audit failed."
check_dynlibs target/release/letmein
check_dynlibs target/release/letmeind
check_dynlibs target/release/letmeinfwd
# vim: ts=4 sw=4 expandtab