diff options
author | Joshua Ismael Haase Hernández <hahj87@gmail.com> | 2011-06-24 17:17:17 -0500 |
---|---|---|
committer | Joshua Ismael Haase Hernández <hahj87@gmail.com> | 2011-06-24 17:17:17 -0500 |
commit | ad11f4aee0e7af9dcba780d464edef34cc937d4a (patch) | |
tree | 4d167c0b2bafd016949da3cbf50a2f36f6a840f3 | |
parent | f245468672503e4066b46307aff3c39c23983904 (diff) | |
parent | 73f49edd89a1bb4ed023b81bfcf113d4a6956887 (diff) |
Merge http://projects.parabolagnulinux.org/libretools
-rwxr-xr-x | fullpkg | 22 | ||||
-rwxr-xr-x | mipsrelease | 2 | ||||
-rwxr-xr-x | toru | 138 |
3 files changed, 124 insertions, 38 deletions
@@ -5,7 +5,6 @@ source /etc/makepkg.conf source /etc/abs.conf source /etc/libretools.conf -source /usr/bin/libremessages # Avoid /libretools dir doesn't exist errors if [ -z $XDG_CONFIG_HOME ]; then @@ -187,13 +186,17 @@ function find_deps { # Increase build level declare -i next_level=$level+1 + +# Pass the offline flag to children + [[ "$OFFLINE" -eq true ]] && extra+=" -o" for _dep in ${deps[@]}; do for _repo in ${REPOS[@]}; do # try to find $_dep on each repo from dirname if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then pushd "${ABSROOT}/${_repo}/${_dep}" > /dev/null - $0 -c -d ${build_dir} -l ${next_level} + + $0 -c -d ${build_dir} -l ${next_level} ${extra} # Circular deps must fail [ $? -eq 20 ] && return 20 @@ -288,7 +291,7 @@ function _pkg_build () { } msg "Updating pacman db and packages" - sudo pacman -Syu --noconfirm || true + sudo pacman -Sy || true } echo "built:$(basename $PWD)" >> $build_dir/log @@ -301,10 +304,10 @@ function _pkg_build () { esac # Package was built or failed: take it out of $buildorder - remove_buildorder "${build_packages[0]}" $buildorder + remove_buildorder "${build_packages[0]}" $buildorder || true # Take package out from queue - remove_queue + remove_queue || true # Set build_packages before next cycle run build_packages=($(sort -gr $buildorder | cut -d: -f2)) @@ -400,11 +403,12 @@ if [ ${build_only} == 'n' ]; then usage && exit 1 } +fi + # Add mips64el if missing from arch=() and it isn't an 'any' package - if ! grep mips64el PKGBUILD >/dev/null; then - plain "Adding mips64el arch" - sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD" - fi +if ! grep mips64el PKGBUILD >/dev/null; then + warning "Adding mips64el arch" + sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD" fi # If the queue file isn't writable go into offline mode diff --git a/mipsrelease b/mipsrelease index a21eaec..22d0866 100755 --- a/mipsrelease +++ b/mipsrelease @@ -37,7 +37,7 @@ repo-add ${PKGDEST}/stage3.db.tar.gz $@ # Get all needed sources source PKGBUILD fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel}) -makepkg --source +makepkg --source -f mkdir -p ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null @@ -4,30 +4,23 @@ ## 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 +# * Use lastsync to store processed packages ## 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 +# * 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 -[ ! -w / ] && { - error "This script must be run as root." - exit 1 -} +#[ ! -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() { @@ -40,26 +33,73 @@ lastsync() { touch ${lastsyncfile} } -# Adds a field=value on the package description -addfield() { +## +# 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 +} + +# Outputs an ordered package-fullpkgver array +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 + + bsdtar -tf /var/lib/pacman/sync/$1.db | \ + cut -d'/' -f1 | \ + sort -V -u +} + + +extract_pkgname() { + echo "$@" | tr " " "\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+$/\1/" +} + +extract_fullpkgver() { + echo "$@" | tr " " "\n" | sed "s/^.\+-\([^-]\+-[^-]\+\)$/\1/" } + # Updates the database by finding all PKGBUILDS +# Workflow: +# * Find all PKGBUILDs on the ABS repo specified +# * Get all packages already on package repos +# * Compare them # Args: update() { +# The PKGBUILDs found + local pkgbuilds=() +# The list of pkgname-fullpkgver + 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 [ ! -e ${lastsyncfile} -o "${force}" = "y" ]; then - msg "Forcing upgrade" + 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 - msg "Found $((${#pkgbuilds[*]}-1)) packages to update" + $quiet || msg "Found $((${#pkgbuilds[*]}-1)) packages to update" [ ${#pkgbuilds[*]} -eq 1 ] && { - msg2 "There's nothing to be done. Phew!" + $quiet || msg2 "There's nothing to be done. Phew!" exit 0 } @@ -71,28 +111,70 @@ update() { _pkgbase=$(basename "${_pkgpath}") _pkgrepo=$(basename $(dirname "${_pkgpath}")) - msg2 "Updating ${_pkgrepo}/${_pkgbase}" - source ${_pkgbuild} for _pkg in ${pkgname[@]}; do +# Fill the list of packages to find + packages_to_sync+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel)) done - unset pkgbase pkgname pkgver pkgrel source + 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 + +# 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)) + + $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)) + + msg2 "$pkg $oldver => $ver" + } done - lastsync +# lastsync } ## MAIN -command=${1:-update}; shift -force=${1:-n}; shift -dirs=${@} +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) + +[[ -z ${TMPDIR} ]] && exit 1 + +${commands[0]} ${@} -${command} ${dirs[@]} +rm -rf ${TMPDIR} exit $? |