build.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. # Part of Zombie Navigator
  3. # Copyright © 2015 Zombie Navigator Developers
  4. dir="`dirname "$0"`"
  5. dir="`cd "$dir";pwd`"
  6. cd "$dir/src"
  7. buildsDir="$dir/builds"
  8. buildTmpDir="$dir/.build"
  9. mkdir -p "$buildsDir"
  10. # Create .xpi
  11. if ! which jpm >/dev/null 2>&1 ; then
  12. echo "Please install jpm somewhere in PATH" >&2
  13. exit 1
  14. fi
  15. cd ..
  16. cp -rf src "$buildTmpDir"
  17. cd "$buildTmpDir"
  18. find . -type f \( -name '*.js' -or -name '*.html' \) -execdir sh -c 'egrep -v "^\s*$|vim:" "$1" > "$1.tmp" && mv -f "$1.tmp" "$1"' -- {} \;
  19. find . -type f -name '*.css' -execdir sh -c 'egrep -v "^\s*$|vim:" "$1" | tr -d "\t\n" | perl -pe "s/\s*([{:>+])\s*/\1/g ; s/;}/}/g" > "$1.tmp" && mv -f "$1.tmp" "$1"' -- {} \;
  20. find . -type f -name '*.json' -execdir sh -c 'egrep -v "^\s*$" "$1" | sed "s/^ *//" | tr -d "\n" > "$1.tmp" && mv -f "$1.tmp" "$1"' -- {} \;
  21. du -a -h --apparent-size --max-depth 3 || du -ahd3
  22. echo "Please ignore JPM warnings about the 'sember' (if any)" >&2
  23. echo "Because we use '~' for prereleases (for consistence with GNU/Linux conventions)" >&2
  24. jpm xpi || {
  25. echo "[ERROR] JPM: Failed" >&2
  26. exit 1
  27. }
  28. if which advzip >/dev/null 2>&1 ; then
  29. # AdvanceCOMP available
  30. echo "Recompressing..." >&2
  31. advzip -z -4 -i 200 ./*.xpi
  32. else
  33. echo "NOTE: Skipping recompression (AdvanceCOMP needed)..." >&2
  34. fi
  35. echo "Saving the archive..." >&2
  36. targetDir="$buildsDir/`date +%s`"
  37. mkdir -p "$targetDir"
  38. mv -b -v ./*.xpi "$targetDir"/ || mv -n -v ./*.xpi "$targetDir"/
  39. cd ..
  40. rm -rf "$buildTmpDir"
  41. echo "Done?" >&2
  42. # vim: ts=4 noet ai