summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolás Reynolds <apoyosis@correo.inta.gob.ar>2011-06-17 16:25:14 -0300
committerNicolás Reynolds <apoyosis@correo.inta.gob.ar>2011-06-17 16:25:14 -0300
commitc4dd603dfa1ae48767675945af5182774fb44471 (patch)
tree69ba2b41d83d9ae688fbe1750cc5b2a27f3a1a23
parentfc39fd1e991a4fc6a5aceafc619ca552ad72b582 (diff)
Toru's outline and TODO
-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 $?