build.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/sh
  2. # -*- coding: utf-8 -*-
  3. basedir="$(realpath "$0" | xargs dirname)"
  4. info()
  5. {
  6. echo "--- $*"
  7. }
  8. error()
  9. {
  10. echo "=== ERROR: $*" >&2
  11. }
  12. warning()
  13. {
  14. echo "=== WARNING: $*" >&2
  15. }
  16. die()
  17. {
  18. error "$*"
  19. exit 1
  20. }
  21. check_dynlibs()
  22. {
  23. local bin="$1"
  24. local ldd_out="$(ldd "$bin")"
  25. [ -z "$ldd_out" ] && die "ldd failed"
  26. printf '%s' "$ldd_out" | while read line; do
  27. printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'linux-vdso\.so' && continue
  28. printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'libgcc_s\.so' && continue
  29. printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'libm\.so' && continue
  30. printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'libc\.so' && continue
  31. printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'ld-linux-.*\.so' && continue
  32. printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'ld-android\.so' && continue
  33. printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'libarmmem-.*\.so' && continue
  34. printf '%s' "$line" | awk '{ print $1; }' | grep -qe 'libdl\.so' && continue
  35. die "Found unknown dynamically linked library '$line' in '$bin'"
  36. done
  37. }
  38. [ -f "$basedir/Cargo.toml" ] || die "basedir sanity check failed"
  39. cd "$basedir" || die "cd basedir failed."
  40. export LETMEIN_CONF_PREFIX="/opt/letmein"
  41. cargo build || die "Cargo build (debug) failed."
  42. cargo test || die "Cargo test failed."
  43. if which cargo-auditable >/dev/null 2>&1; then
  44. cargo auditable build --release || die "Cargo build (release) failed."
  45. cargo audit --deny warnings bin \
  46. target/release/letmein \
  47. target/release/letmeind \
  48. target/release/letmeinfwd \
  49. || die "Cargo audit failed."
  50. else
  51. cargo build --release || die "Cargo build (release) failed."
  52. fi
  53. check_dynlibs target/release/letmein
  54. check_dynlibs target/release/letmeind
  55. check_dynlibs target/release/letmeinfwd
  56. # vim: ts=4 sw=4 expandtab