#!/bin/bash if [[ "$1" != "" ]];then override=true; else override=false; fi; root="$(readlink -f $(dirname $BASH_SOURCE)/..)"; . $root/etc/repo.conf . $root/etc/packages.conf rm -f $root/repo/latest/i686/*.pkg.tar.xz; rm -f $root/repo/latest/x86-64/*.pkg.tar.xz; for val in "${packages[@]}"; do unset package; declare -A package; eval "package=($val)"; name=${package[name]}; echo "Checking $name"; echo -e "\tChecking for updates"; cd $root/src/$name/source; case ${package[type]} in git) git reset --hard > /dev/null; git clean -f -d > /dev/null; git fetch --tags > /dev/null; expect -c " set timeout 1 log_user 0 spawn git pull expect \"Already up-to-date.\" { exit 1 } log_user 1 expect eof { exit 0 } }"; rc=$?; if [[ $rc == 0 ]];then build=true; else build=false; fi; ;; svn) svn revert . -R; if [[ "$(svn info -r HEAD | grep -i "Last Changed Rev")" != "$(svn info | grep -i "Last Changed Rev")" ]];then svn update; build=true; else build=false; fi; ;; script) if [[ "${package[script]}" != "" ]];then ${package[script]}; rc=$?; if [[ $rc == 0 ]];then build=false; else build=true; fi; else echo -e "\tNo Script configured"; build=false; fi; ;; *) echo -e "\tType '${package[type]}' not implemented."; build=false; esac; if $build;then echo -e "\tUpdated"; else echo -e "\tUp to Date"; fi; cd $root/src/$name; if ! ls $name-*-i686.pkg.tar.xz &> /dev/null || ! ls $name-*-x86-64.pkg.tar.xz &> /dev/null || $build || $override;then echo -e "\tBuilding"; ./build.sh ls $name-*-i686.pkg.tar.xz | while read item; do cp $item $root/repo/updates/i686/$item; done; ls $name-*-x86-64.pkg.tar.xz | while read item; do cp $item $root/repo/updates/x86-64/$item; done; fi; ls $name-*-i686.pkg.tar.xz | while read item; do cp $item $root/repo/latest/i686/$item; done; ls $name-*-x86-64.pkg.tar.xz | while read item; do cp $item $root/repo/latest/x86-64/$item; done; echo -e "\tDone" done; echo "Building Repository"; cd $root/repo/latest/ ls -l $root/repo/latest/ | egrep '^d' | awk '{print $9}' | while read arch; do if [ -d "$root/repo/latest/$arch" ];then echo -e "\t$arch"; cd $root/repo/latest/$arch; rm -f $reponame.db.*; echo -e "\tUsing key $repokey"; repo-add -v -f -k $repokey -s $reponame.db.tar.gz *.pkg.tar.xz; rm -f $reponame.db.tar.gz.old; fi; done; cd $root;