#!/bin/bash # Queries the ABS # License: GPL3 ## TODO # * Add license text # * 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 # Stores the lastsync date lastsync() { [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { error "The sync date can't be saved. ${lastsyncfile} isn't writable." return 1 } date +%s > ${lastsyncfile} touch ${lastsyncfile} } # Adds a field=value on the package description addfield() { } # 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 source done lastsync } ## MAIN command=${1:-update}; shift force=${1:-n}; shift dirs=${@} ${command} ${dirs[@]} exit $?