ari's enigmail/pEp-on-linux build system this _also_ lives in https://pep.foundation/dev/repos/enigmailpEp/ in linux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9KB

  1. #!/bin/bash
  2. set -euo pipefail
  3. if [[ "$#" -ne 5 ]] ; then
  4. echo "prepareEnigmailTree.sh enigmail_source_dir pepmda_executable pep_system.db gpg_executable targetOSmount"
  5. echo "put pepmda, pep_system.db, gpg_executable and deps into enigmail source dir s.t. "
  6. echo "the resulting enigmail.xpi contains everything to run on targetOS (vanilla installation)"
  7. exit 1
  8. fi
  9. enigDist="$1"
  10. mda="$2"
  11. systemDB="$3"
  12. gpg="$4"
  13. target="$5"
  14. chrpath(){
  15. patchelf --set-rpath "${2-\$ORIGIN}" $1
  16. }
  17. getMissingDeps(){
  18. # "recursively obtain missing dependencies of $1"
  19. ldd "$1" | grep -v ' (linux-vdso|linux-gate)' | grep -v '(/ld.so|ld-linux.*.so)' | grep -Po '(?<==> ).*(?= \(0x)' |
  20. while read dep ; do
  21. cpdep="${enigDist}/lib/`basename $dep`"
  22. if [[ -n "$dep" ]] && ! [[ -e "$target/$dep" ]] && ! [[ -e "$cpdep" ]]; then
  23. cp "$dep" "$cpdep"
  24. targetname="${enigDist}/lib/"`basename $dep`
  25. chrpath "$targetname"
  26. getMissingDeps "$targetname"
  27. fi
  28. done
  29. }
  30. # these are figured out by looking at
  31. # - find $mda/{bin,lib} -exec strings {} \; | grep -P '.*\.so.*' | sort | uniq
  32. # - running pep-json-server ; PID=$! ; cat /proc/$PID/maps
  33. mkdir -p "${enigDist}/"{bin,lib,share/pEp}
  34. cpmda="${enigDist}/bin/"`basename "$mda"`
  35. cp "$systemDB" "${enigDist}/share/pEp"
  36. cp "$mda" "$cpmda"
  37. getMissingDeps "$cpmda"
  38. find "${enigDist}/"{bin,lib} -exec strings {} \; | grep -P '\.so\.' | sort | uniq |
  39. while read dep ; do
  40. dep=`basename "$dep"`
  41. depAlreadyCopied=`find "$enigDist" "$target" -name "$dep"`
  42. if [[ -z "$depAlreadyCopied" ]] ; then
  43. set -x
  44. find /lib /lib64 /usr/lib ${LD_LIBRARY_PATH//:/ } -name "$dep" -exec cp {} "${enigDist}/lib" \;
  45. getMissingDeps "${enigDist}/lib/${dep}"
  46. set +x
  47. fi
  48. done
  49. # $cpmda need to have their RPATH changed again (after change in getMissingDeps)
  50. # since getMissingDeps assumes object to be in lib, not in bin
  51. chrpath "$cpmda" '$ORIGIN/../lib'