summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-06-18 03:12:52 -0500
committerJoshua Ismael Haase Hernández <hahj87@gmail.com>2011-06-18 03:12:52 -0500
commit4a3896facc8ca6c4da82b9f3b6cad5b2558fe25c (patch)
tree52ded4d35bbc2ca60c22bf9d9e1740345d776222
parent85c6658b23798eca85a4614cfb79719e79aae334 (diff)
parentc4dd603dfa1ae48767675945af5182774fb44471 (diff)
Merge branch 'master' of vparabola:~/projects/libretools
-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 $?