repo-build 2.7 KB

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