diff options
author | Joshua Ismael Haase Hernández <hahj87@gmail.com> | 2011-06-27 16:41:39 -0500 |
---|---|---|
committer | Joshua Ismael Haase Hernández <hahj87@gmail.com> | 2011-06-27 16:41:39 -0500 |
commit | eb5cbeea0dc649d18ea4d6330c0787fc5a962b52 (patch) | |
tree | 1e18c56ee5a2f407e99095050692402bd5cb5c0f /toru | |
parent | eba54d82f4e932ff2c3bf09fcc695085dc83bf19 (diff) |
fixes and tabs -> spaces
Diffstat (limited to 'toru')
-rwxr-xr-x | toru | 192 |
1 files changed, 96 insertions, 96 deletions
@@ -1,4 +1,4 @@ -#!/bin/bash + #!/bin/bash # Queries the ABS # License: GPL3 @@ -13,8 +13,8 @@ # * Possibility to hook up ABS dirs besides ABSROOT (low priority) # * Tell updates and non available binary packages (working on this) -source /etc/abs.conf -source /etc/libretools.conf + source /etc/abs.conf + source /etc/libretools.conf #[ ! -w / ] && { # error "This script must be run as root." @@ -23,53 +23,53 @@ source /etc/libretools.conf # Stores the lastsync date -lastsync() { - [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { - error "The sync date can't be saved. ${lastsyncfile} isn't writable." - return 1 - } + 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} -} + date +%s > ${lastsyncfile} + touch ${lastsyncfile} + } ## # usage : get_full_version( $epoch, $pkgver, $pkgrel ) # return : full version spec, including epoch (if necessary), pkgver, pkgrel ## -get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 - else - echo $1:$2-$3 - fi -} + get_full_version() { + if [[ $1 -eq 0 ]]; then + # zero epoch case, don't include it in version + echo $2-$3 + else + echo $1:$2-$3 + fi + } # Outputs an ordered package-fullpkgver array -print_package_array() { - echo "$@" | tr " " "\n" | sort -V -u -} + print_package_array() { + echo "$@" | tr " " "\n" | sort -V -u + } # Gets repo.db contents # $1 repo -get_db_contents() { - [ ! -r /var/lib/pacman/sync/$1.db ] && return 0 + get_db_contents() { + [ ! -r /var/lib/pacman/sync/$1.db ] && return 0 - bsdtar -tf /var/lib/pacman/sync/$1.db | \ - cut -d'/' -f1 | \ - sort -V -u -} + bsdtar -tf /var/lib/pacman/sync/$1.db | \ + cut -d'/' -f1 | \ + sort -V -u + } -extract_pkgname() { - echo "$@" | tr " " "\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+$/\1/" -} + extract_pkgname() { + echo "$@" | tr " " "\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+$/\1/" + } -extract_fullpkgver() { - echo "$@" | tr " " "\n" | sed "s/^.\+-\([^-]\+-[^-]\+\)$/\1/" -} + extract_fullpkgver() { + echo "$@" | tr " " "\n" | sed "s/^.\+-\([^-]\+-[^-]\+\)$/\1/" + } # Updates the database by finding all PKGBUILDS @@ -78,103 +78,103 @@ extract_fullpkgver() { # * Get all packages already on package repos # * Compare them # Args: -update() { + update() { # The PKGBUILDs found - local pkgbuilds=() + local pkgbuilds=() # The list of pkgname-fullpkgver - local packages_to_sync=() - local packages_in_sync=() - local needed_updates=() - local old_versions=() + local packages_to_sync=() + local packages_in_sync=() + local needed_updates=() + local old_versions=() # Find all the PKGBUILDs newer than the last update # Update newer, otherwise everything - if [ $force ] || [ ! -e ${lastsyncfile} ]; then - $quiet || msg "Forcing upgrade" - pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD')) - else - pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile})) - fi + if [ $force ] || [ ! -e ${lastsyncfile} ]; then + $quiet || 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 - $quiet || msg "Found $((${#pkgbuilds[*]}-1)) packages to update" - [ ${#pkgbuilds[*]} -eq 1 ] && { - $quiet || msg2 "There's nothing to be done. Phew!" - exit 0 - } + $quiet || msg "Found $((${#pkgbuilds[*]}-1)) packages to update" + [ ${#pkgbuilds[*]} -eq 1 ] && { + $quiet || msg2 "There's nothing to be done. Phew!" + exit 0 + } - for _pkgbuild in ${pkgbuilds[@]}; do + 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}")) + _pkgpath=$(dirname "${_pkgbuild}") + _pkgbase=$(basename "${_pkgpath}") + _pkgrepo=$(basename $(dirname "${_pkgpath}")) - source ${_pkgbuild} + source ${_pkgbuild} - for _pkg in ${pkgname[@]}; do + for _pkg in ${pkgname[@]}; do # Fill the list of packages to find - packages_to_sync+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel)) - done + packages_to_sync+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel)) + done - unset pkgbase pkgname pkgver pkgrel source epoch - done + unset pkgbase pkgname pkgver pkgrel source epoch + done # Get repo database contents - packages_in_sync=($(get_db_contents ${_pkgrepo})) - print_package_array "${packages_to_sync[@]}" > ${TMPDIR}/packages_to_sync - print_package_array "${packages_in_sync[@]}" > ${TMPDIR}/packages_in_sync + packages_in_sync=($(get_db_contents ${_pkgrepo})) + print_package_array "${packages_to_sync[@]}" > ${TMPDIR}/packages_to_sync + print_package_array "${packages_in_sync[@]}" > ${TMPDIR}/packages_in_sync # We've orderer the files! - needed_updates=($(comm --nocheck-order -32 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) - old_versions=($(comm --nocheck-order -31 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) + needed_updates=($(comm --nocheck-order -32 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) + old_versions=($(comm --nocheck-order -31 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync)) - $quiet || msg "This packages are available to update" - for _update in ${needed_updates[@]}; do - pkg=$(extract_pkgname $_update) + $quiet || msg "This packages are available to update" + for _update in ${needed_updates[@]}; do + pkg=$(extract_pkgname $_update) - $quiet && echo $pkg - $quiet || { - ver=$(extract_fullpkgver $_update) - oldver=$(extract_fullpkgver $(grep -w $pkg ${TMPDIR}/packages_in_sync)) + $quiet && echo $pkg + $quiet || { + ver=$(extract_fullpkgver $_update) + oldver=$(extract_fullpkgver $(grep -w $pkg ${TMPDIR}/packages_in_sync)) - msg2 "$pkg $oldver => $ver" - } + msg2 "$pkg $oldver => $ver" + } - done + done # lastsync -} + } ## MAIN -commands=() -repos=() -quiet=false -force=false -while getopts 'hqfu' arg; do - case $arg in - h) usage; exit 0 ;; - q) quiet=true ;; - f) force=true ;; - u) commands+=(update);; - esac - - shift $((OPTIND-1)) -done + commands=() + repos=() + quiet=false + force=false + while getopts 'hqfu' arg; do + case $arg in + h) usage; exit 0 ;; + q) quiet=true ;; + f) force=true ;; + u) commands+=(update);; + esac + + shift $((OPTIND-1)) + done # This is the syncfile, stores the last date as content and mtime #lastsyncfile=${ABSROOT}/toru.lastsync -TMPDIR=$(mktemp -d) + TMPDIR=$(mktemp -d) -[[ -z ${TMPDIR} ]] && exit 1 + [[ -z ${TMPDIR} ]] && exit 1 -${commands[0]} ${@} + ${commands[0]} ${@} -rm -rf ${TMPDIR} + rm -rf ${TMPDIR} -exit $? + exit $? |