build-whynot.lib 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. GIT="git --no-pager"
  2. GITPARAM="--color=always"
  3. RSYNC="rsync -a --info=NAME --delete --exclude=.git --exclude=.gitignore"
  4. export LC_ALL="C"
  5. declare -a git_repositories
  6. echo $git_repositories
  7. function in_git_repositories {
  8. for entry in "${git_repositories[@]}"; do
  9. [[ "$entry" == "$1" ]] && echo "found";
  10. done
  11. }
  12. function mod_install {
  13. group=$1
  14. shift
  15. #echo $group
  16. declare excluded
  17. excluded_string=""
  18. while (( "$#" )); do
  19. if [ ${1:0:10} == '--exclude=' ]; then
  20. excluded=(${excluded[@]} ${1#--exclude=*})
  21. excluded_string="$excluded_string $1"
  22. shift
  23. else
  24. break
  25. fi
  26. done
  27. #echo "excluded files:" ${excluded[@]}
  28. function in_excluded {
  29. for entry in "${excluded[@]}"; do
  30. [[ "$entry" == "$1" ]] && echo "found";
  31. done
  32. }
  33. declare sync_list
  34. if [ "$#" == "0" ]; then
  35. sync_list=("$group"/*)
  36. else
  37. sync_list=(${@})
  38. fi
  39. #echo "sync_list:" ${sync_list[@]}
  40. for mod in ${sync_list[@]}; do
  41. #echo "mod:" $mod
  42. if [ -d "$mod" ] && [ -z "$(in_excluded "$(basename $mod)")" ]; then
  43. echo "Process repo $mod"
  44. cd "$mod"
  45. GIT_REPO="$(git remote -v | grep '\(fetch\)' )"
  46. #echo "GIT REPO: $GIT_REPO"
  47. if [ -z "$(in_git_repositories "$GIT_REPO")" ]; then
  48. echo '' >> "$LOG"
  49. echo "$GIT_REPO" >> "$LOG"
  50. git branch -vv | grep '^[*]' >> "$LOG"
  51. git_repositories=(${git_repositories[@]} "$GIT_REPO")
  52. fi
  53. echo "Mod: $mod" >> "$LOG"
  54. cd - >/dev/null
  55. $RSYNC $excluded_string "$SRC"/"$mod" "$DST"/"$group"/
  56. fi
  57. done
  58. }
  59. function set_package {
  60. LOG="$DST"/"$1"/mod_sources.txt
  61. cp "$DST"/build.sh "$DST"/"$1"/
  62. rm "$LOG" 2>/dev/null
  63. git_repositories=( )
  64. }
  65. rm "$LOG" 2>/dev/null