repo-build 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/bash
  2. if [[ "$1" != "" ]];then
  3. override=true;
  4. else
  5. override=false;
  6. fi;
  7. root="$(readlink -f $(dirname $BASH_SOURCE)/..)";
  8. . $root/etc/repo.conf
  9. . $root/etc/packages.conf
  10. rm -f $root/repo/latest/i686/*.pkg.tar.xz;
  11. rm -f $root/repo/latest/x86-64/*.pkg.tar.xz;
  12. for val in "${packages[@]}"; do
  13. unset package;
  14. declare -A package;
  15. eval "package=($val)";
  16. name=${package[name]};
  17. echo "Checking $name";
  18. echo -e "\tChecking for updates";
  19. cd $root/src/$name/source;
  20. case ${package[type]} in
  21. git)
  22. git reset --hard > /dev/null;
  23. git clean -f -d > /dev/null;
  24. git fetch --tags > /dev/null;
  25. expect -c "
  26. set timeout 1
  27. log_user 0
  28. spawn git pull
  29. expect \"Already up-to-date.\" {
  30. exit 1
  31. }
  32. log_user 1
  33. expect eof {
  34. exit 0
  35. }
  36. }";
  37. rc=$?;
  38. if [[ $rc == 0 ]];then
  39. build=true;
  40. else
  41. build=false;
  42. fi;
  43. ;;
  44. svn)
  45. svn revert . -R;
  46. if [[ "$(svn info -r HEAD | grep -i "Last Changed Rev")" != "$(svn info | grep -i "Last Changed Rev")" ]];then
  47. svn update;
  48. build=true;
  49. else
  50. build=false;
  51. fi;
  52. ;;
  53. script)
  54. if [[ "${package[script]}" != "" ]];then
  55. ${package[script]};
  56. rc=$?;
  57. if [[ $rc == 0 ]];then
  58. build=false;
  59. else
  60. build=true;
  61. fi;
  62. else
  63. echo -e "\tNo Script configured";
  64. build=false;
  65. fi;
  66. ;;
  67. *)
  68. echo -e "\tType '${package[type]}' not implemented.";
  69. build=false;
  70. esac;
  71. if $build;then
  72. echo -e "\tUpdated";
  73. else
  74. echo -e "\tUp to Date";
  75. fi;
  76. cd $root/src/$name;
  77. if ! ls $name-*-i686.pkg.tar.xz &> /dev/null || ! ls $name-*-x86-64.pkg.tar.xz &> /dev/null || $build || $override;then
  78. echo -e "\tBuilding";
  79. ./build.sh
  80. ls $name-*-i686.pkg.tar.xz | while read item; do
  81. cp $item $root/repo/updates/i686/$item;
  82. done;
  83. ls $name-*-x86-64.pkg.tar.xz | while read item; do
  84. cp $item $root/repo/updates/x86-64/$item;
  85. done;
  86. fi;
  87. ls $name-*-i686.pkg.tar.xz | while read item; do
  88. cp $item $root/repo/latest/i686/$item;
  89. done;
  90. ls $name-*-x86-64.pkg.tar.xz | while read item; do
  91. cp $item $root/repo/latest/x86-64/$item;
  92. done;
  93. echo -e "\tDone"
  94. done;
  95. echo "Building Repository";
  96. cd $root/repo/latest/
  97. ls -l $root/repo/latest/ | egrep '^d' | awk '{print $9}' | while read arch; do
  98. if [ -d "$root/repo/latest/$arch" ];then
  99. echo -e "\t$arch";
  100. cd $root/repo/latest/$arch;
  101. rm -f $reponame.db.*;
  102. echo -e "\tUsing key $repokey";
  103. repo-add -v -f -k $repokey -s $reponame.db.tar.gz *.pkg.tar.xz;
  104. rm -f $reponame.db.tar.gz.old;
  105. fi;
  106. done;
  107. cd $root;