repo-build 2.8 KB

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