repo-build 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 -1 $name-*-i686.pkg.tar.xz 2> /dev/null | wc -l) == 0 ] || [ $(ls -1 $name-*-x86-64.pkg.tar.xz 2> /dev/null | wc -l) == 0 ] || $build || $override;then
  78. echo -e "\tBuilding";
  79. if $build || $override;then
  80. rm -f $name-*-i686.pkg.tar.xz $name-*-x86_64.pkg.tar.xz;
  81. fi;
  82. cd $root/src/$name/source;
  83. tar -zcvf $root/src/$name/$name.tar.gz *;
  84. cd $root/src/$name;
  85. updpkgsums;
  86. makepkg -c -f --config $root/etc/makepkg-i686.conf;
  87. makepkg -c -f --config $root/etc/makepkg-x86_64.conf;
  88. echo -e "\tBuilt.";
  89. cp $name-*-i686.pkg.tar.xz $root/repo/updates/i686;
  90. cp $name-*-x86-64.pkg.tar.xz $root/repo/updates/x86_64;
  91. fi;
  92. cp $name-*-i686.pkg.tar.xz $root/repo/latest/i686;
  93. cp $name-*-x86-64.pkg.tar.xz $root/repo/latest/x86_64;
  94. echo -e "\tDone"
  95. done;
  96. echo "Building Repository";
  97. cd $root/repo/latest/
  98. ls -l $root/repo/latest/ | egrep '^d' | awk '{print $9}' | while read arch; do
  99. if [ -d "$root/repo/latest/$arch" ];then
  100. echo -e "\t$arch";
  101. cd $root/repo/latest/$arch;
  102. rm -f $reponame.db.*;
  103. echo -e "\tUsing key $repokey";
  104. repo-add -v -f -k $repokey -s $reponame.db.tar.gz *.pkg.tar.xz;
  105. rm -f $reponame.db.tar.gz.old;
  106. fi;
  107. done;
  108. cd $root;