deploy.sh 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. get_dst() {
  3. #
  4. # Find out target path for src file $2 of group $1
  5. #
  6. local grp=$1
  7. local src=$2
  8. echo "$(get_root $grp)/$(ini 1value "files:$grp:$src")"
  9. }
  10. get_root() {
  11. #
  12. # Find out target rooot for group $1
  13. #
  14. local grp="$1"
  15. local root=$(ini 1value "roots:$grp")
  16. test -n "$root" || die "missing in config.ini: roots:$grp"
  17. echo "$root"
  18. }
  19. install() {
  20. #
  21. # Install product
  22. #
  23. local dst group mode src
  24. ini values "lists:group" \
  25. | while read group;
  26. do
  27. mode=$(ini 1value "modes:$group")
  28. ini lskeys "files:$group" \
  29. | while read src;
  30. do
  31. dst=$(get_dst "$group" "$src")
  32. command -p install -DTvm $mode $src "$dst"
  33. done
  34. done
  35. test -f .autoclean && clean || :
  36. }
  37. uninstall() {
  38. #
  39. # Uninstall product
  40. #
  41. local dst group src
  42. ini values "lists:group" \
  43. | while read group;
  44. do
  45. ini lskeys "files:$group" \
  46. | while read src;
  47. do
  48. dst=$(get_dst "$group" "$src")
  49. rm -vf "$dst"
  50. done
  51. done
  52. }