summaryrefslogtreecommitdiff
path: root/toru
diff options
context:
space:
mode:
authorNicolas Reynolds <fauno@kiwwwi.com.ar>2011-06-20 23:09:02 -0300
committerNicolas Reynolds <fauno@kiwwwi.com.ar>2011-06-20 23:09:02 -0300
commit59b03ff6bb15a5163604ad8ba344a8fd2f664826 (patch)
treeb780564f9857e372ba81091973d96b2ded99f14e /toru
parent7d2a691276f60e10c59204631f06fa9c5d6a1c25 (diff)
parent702cc20bd94cdb2939e0c163e8e9671c920c5b19 (diff)
Merge branch 'master' of ssh://vparabola/srv/git/projects/libretools
Conflicts: fullpkg
Diffstat (limited to 'toru')
-rwxr-xr-xtoru97
1 files changed, 74 insertions, 23 deletions
diff --git a/toru b/toru
index 9716744..1ae336b 100755
--- a/toru
+++ b/toru
@@ -2,46 +2,97 @@
# Queries the ABS
# License: GPL3
-# TODO
+## TODO
# * Add license text
-# * Use libremessages
+# * Add everything
+# * Compare pacman sync against ABS (db-functions could be useful)
+# * Create symlinks from pkgbase to pkgname[@] for easy package finding
+
+## GOALS
+# * Have a searchable database of PKGBUILD metadata
+# * Have an interface for source-only builds
+# * Possibility to hook up ABS dirs besides ABSROOT
+# * Tell updates and non available binary packages
source /etc/abs.conf
source /etc/libretools.conf
+[ ! -w / ] && {
+ error "This script must be run as root."
+ exit 1
+}
+
+# This is the syncfile, stores the last date as content and mtime
+lastsyncfile=${ABSROOT}/toru.lastsync
+
TMPDIR=$(mktemp -d)
[[ -z ${TMPDIR} ]] && exit 1
-update() {
- pushd ${ABSROOT} >/dev/null
+# Stores the lastsync date
+lastsync() {
+ [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && {
+ error "The sync date can't be saved. ${lastsyncfile} isn't writable."
+ return 1
+ }
-# Find all the PKGBUILDs newer than the last update
- find * -type f -name 'PKGBUILD' -newer ${ABSROOT}/toru >> ${TMPDIR}/update.list
+ date +%s > ${lastsyncfile}
+ touch ${lastsyncfile}
+}
+
+# Adds a field=value on the package description
+addfield() {
+}
- while read _pkgbuild; do
- pushd $(dirname ${_pkgbuild}) >/dev/null
+# Updates the database by finding all PKGBUILDS
+# Args:
+update() {
+# Find all the PKGBUILDs newer than the last update
+# Update newer, otherwise everything
+ if [ ! -e ${lastsyncfile} -o "${force}" = "y" ]; then
+ msg "Forcing upgrade"
+ pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD'))
+ else
+ pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile}))
+ fi
+
+# Inform how many PKGBUILDS were found and quit immediately if none
+ msg "Found $((${#pkgbuilds[*]}-1)) packages to update"
+ [ ${#pkgbuilds[*]} -eq 1 ] && {
+ msg2 "There's nothing to be done. Phew!"
+ exit 0
+ }
+
+ for _pkgbuild in ${pkgbuilds[@]}; do
+
+# The repo name is guessed
+# You *must* use repo/pkgbase structure
+ _pkgpath=$(dirname "${_pkgbuild}")
+ _pkgbase=$(basename "${_pkgpath}")
+ _pkgrepo=$(basename $(dirname "${_pkgpath}"))
+
+ msg2 "Updating ${_pkgrepo}/${_pkgbase}"
+
+ source ${_pkgbuild}
+
+ for _pkg in ${pkgname[@]}; do
+ done
- unset pkgbase pkgname pkgver pkgrel
+ unset pkgbase pkgname pkgver pkgrel source
- source PKGBUILD
+ done
- for _pkg in ${pkgbase:-${pkgname[@]}}; do
- dir="${TMPDIR}/packages/${_pkg}-${pkgver}-${pkgver}"
- mkdir -p "${dir}"
+ lastsync
- echo "${ABSROOT}/${_pkgbuild}" >> "${dir}/path"
+}
- done
- popd >/dev/null
- done < ${TMPDIR}/update.list
- popd >/dev/null
+## MAIN
+command=${1:-update}; shift
+force=${1:-n}; shift
+dirs=${@}
- last_update
-}
+${command} ${dirs[@]}
-last_update() {
- touch ${ABSROOT}/toru
-}
+exit $?