install_wadtools.sh 1003 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. #set -x
  6. # Set superuser privileges command if not set
  7. if [[ -z $su ]]; then
  8. export su="sudo"
  9. fi
  10. $su apt-get install -y build-essential cmake
  11. application=wadtools
  12. repository="https://github.com/makise-homura/wadtools.git"
  13. export compile=
  14. mkdir -p ~/src
  15. cd ~/src || return
  16. if [ ! -d $application ]; then
  17. git clone $repository
  18. cd $application || return
  19. export compile=true
  20. else
  21. cd $application || return
  22. #git pull
  23. pwd
  24. git fetch
  25. LOCAL=$(git rev-parse HEAD)
  26. REMOTE=$(git rev-parse @{u})
  27. if [ ! $LOCAL = $REMOTE ]; then
  28. pwd
  29. echo "Need to pull"
  30. git pull
  31. export compile=true
  32. fi
  33. fi
  34. if [ "$compile" = "true" ]; then
  35. cd ~/src/$application || return
  36. mkdir -p build
  37. cd build || return
  38. cc ../wadbuild.c -o wadbuild
  39. cc ../wadxtract.c -o wadxtract
  40. cc ../wadfindthing.c -o wadfindthing
  41. #cc ../wadpack.c -o wadpack # compiling error
  42. #doas cp wadbuild wadxtract wadpack wadfindthing /usr/local/bin
  43. fi