mk.sh 2.4KB

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. build() {
  30. ffoom init_path >& /dev/null \
  31. || die "-----" \
  32. "fastfoo not installed or ffoom is not available for $(id -un)." \
  33. "In the latter case try running (only) \`make\` under normal" \
  34. "user and repeating the \`make install\` again." \
  35. "-----"
  36. local ffoo_init=$(ffoom init_path)
  37. local srcpath dstpath
  38. find -type f -name '*.in' \
  39. | while read srcpath;
  40. do
  41. dstpath=${srcpath%.in}
  42. perl -pe "s|__FFOO_INIT__|$ffoo_init|;
  43. s|__FFOO_INI_PATH__|$FFOO_INI_PATH_GLOBAL:\\\$HOME/$FFOO_INI_PATH_USER|;
  44. s|__VERSION__|$VERSION|;" < $srcpath > $dstpath
  45. echo $dstpath >> built.list
  46. done
  47. }
  48. clean() {
  49. test -f built.list && {
  50. cat built.list | xargs rm -f
  51. rm -f built.list
  52. } || :
  53. }
  54. dist() {
  55. local dirname=eecc-${VERSION}
  56. mkdir -p $dirname
  57. cp -R bin \
  58. config.mk \
  59. Makefile \
  60. README \
  61. LICENSE \
  62. setup \
  63. test \
  64. utils \
  65. $dirname
  66. tar -cf $dirname.tar $dirname
  67. gzip $dirname.tar
  68. rm -rf $dirname
  69. echo $dirname.tar.gz >> built.list
  70. }
  71. install() {
  72. mkdir -vp $bindir
  73. list_of_bins | xargs cp -vrt $bindir
  74. list_of_installed_bins | xargs chmod -v 755
  75. test -f .autoclean && clean || :
  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 -vf
  88. }
  89. case $1 in
  90. build|clean|dist|install|install_manpages|manpages|uninstall)
  91. $1
  92. ;;
  93. test)
  94. run_test
  95. ;;
  96. *)
  97. echo "usage: $(basename $0) build|clean|dist|install|test|uninstall" >&2
  98. esac