build.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. cargo auditable build --release || die "Cargo build (release) failed."
  44. cargo audit --deny warnings bin \
  45. target/release/letmein \
  46. target/release/letmeind \
  47. target/release/letmeinfwd \
  48. || die "Cargo audit failed."
  49. check_dynlibs target/release/letmein
  50. check_dynlibs target/release/letmeind
  51. check_dynlibs target/release/letmeinfwd
  52. # vim: ts=4 sw=4 expandtab