123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/bash
  2. # eecc - Eclectic Engineer's Control Center
  3. # See LICENSE file for copyright and license details.
  4. tmp=$(mktemp)
  5. sed -e 's/ = /=/' < config.mk > $tmp
  6. . $tmp
  7. rm -f $tmp
  8. bindir=${DESTDIR}${PREFIX}/bin
  9. list_of_bins() {
  10. echo bin/eeabrt
  11. echo bin/eedmenu
  12. echo bin/eeget
  13. echo bin/eeiam
  14. echo bin/eeini
  15. echo bin/eeln
  16. echo bin/eemk
  17. echo bin/eepush
  18. echo bin/eerevert
  19. echo bin/eewatch
  20. echo bin/eewww
  21. }
  22. list_of_installed_bins() {
  23. list_of_bins | sed -e "s/bin/$(sed -e 's/\//\\\//g' <<<$bindir)/"
  24. }
  25. die() {
  26. for l in "$@"; do echo "$l" >&2; done
  27. exit 9
  28. }
  29. clean() {
  30. test -f built.list && {
  31. cat built.list | xargs rm -f
  32. rm -f built.list
  33. } || :
  34. }
  35. dist() {
  36. local dirname=eecc-${VERSION}
  37. mkdir -p $dirname
  38. cp -R bin \
  39. config.mk \
  40. Makefile \
  41. README \
  42. LICENSE \
  43. setup \
  44. test \
  45. utils \
  46. $dirname
  47. tar -cf $dirname.tar $dirname
  48. gzip $dirname.tar
  49. rm -rf $dirname
  50. echo $dirname.tar.gz >> built.list
  51. }
  52. install() {
  53. mkdir -p $bindir
  54. list_of_bins | xargs cp -vrt $bindir
  55. list_of_installed_bins | xargs chmod 755
  56. test -f .autoclean && clean || :
  57. }
  58. eecc() {
  59. ffoom init_path >& /dev/null \
  60. || die "-----" \
  61. "fastfoo not installed or ffoom is not available for $(id -un)." \
  62. "In the latter case try running (only) \`make\` under normal" \
  63. "user and repeating the \`make install\` again." \
  64. "-----"
  65. local ffoo_init=$(ffoom init_path)
  66. local srcpath dstpath
  67. find -type f -name '*.in' \
  68. | while read srcpath;
  69. do
  70. dstpath=${srcpath%.in}
  71. perl -pe "s|__FFOO_INIT__|$ffoo_init|;
  72. s|__FFOO_INI_PATH__|$FFOO_INI_PATH_GLOBAL:\\\$HOME/$FFOO_INI_PATH_USER|;
  73. s|__VERSION__|$VERSION|;" < $srcpath > $dstpath
  74. echo $dstpath >> built.list
  75. done
  76. }
  77. run_test() {
  78. pushd test
  79. find -maxdepth 1 -type f \! -name '*.in' | while read test;
  80. do
  81. chmod 0755 $test
  82. $test || exit $?
  83. done
  84. popd
  85. }
  86. uninstall() {
  87. list_of_installed_bins | xargs rm -f
  88. }
  89. case $1 in
  90. clean|dist|install|install_manpages|manpages|eecc|uninstall)
  91. $1
  92. ;;
  93. test)
  94. run_test
  95. ;;
  96. *)
  97. echo "usage: $(basename $0) clean|dist|install|eecc|test|uninstall" >&2
  98. esac