From 6033c0d7a587ea65d124a84146eba8e8cfff4095 Mon Sep 17 00:00:00 2001 From: Nicolas Reynolds Date: Wed, 7 Sep 2011 11:21:32 -0300 Subject: My build environment I run buildenv from my current user to bind mount all the needed files on the clean chroot. It's like having the current user home and makepkg.conf under a clean environment. PKGBUILD edition is done outside the chroot. Chcleanup is the script to cleanup the installed packages, used by the mipsrelease hook to return the chroot to a clean state. The user is called 'abs', PKGDEST is /home/pkgdest and SRCDEST /home/srcdest. On libretools.conf: FULLBUILDCMD="sudo libremakepkg -cumL -M --noconfirm -M" --- buildenv | 26 ++++++++++++++++++++++++++ chcleanup | 7 +++++++ 2 files changed, 33 insertions(+) create mode 100755 buildenv create mode 100755 chcleanup diff --git a/buildenv b/buildenv new file mode 100755 index 0000000..1a9fff6 --- /dev/null +++ b/buildenv @@ -0,0 +1,26 @@ +#!/bin/bash + +trap "umount_all" 0 ERR TERM KILL + +umount_all() { + for mp in home/pkgdest home/srcdest home/abs; do + msg "Umounting /$mp" + umount $CHROOTDIR/$CHCOPY/$mp || error "Couldn't umount" + done +} + +source /etc/libretools.conf + +for mp in home/pkgdest home/srcdest home/abs var/lib/toru; do + msg "Binding /$mp" + mount -o bind /$mp $CHROOTDIR/$CHCOPY/$mp || exit 1 +done + +for etc in etc/makepkg.conf etc/abs.conf etc/mtab; do + msg "Copying config /$etc" + cp --remove-destination /$etc $CHROOTDIR/$CHCOPY/$etc || exit 1 +done + +$(dirname $0)/librechroot $CHCOPY + +exit $? diff --git a/chcleanup b/chcleanup new file mode 100755 index 0000000..83c9f3f --- /dev/null +++ b/chcleanup @@ -0,0 +1,7 @@ +#!/bin/bash + +[ ! -f ~/cleansystem ] && exit 1 + +sudo pacman --noconfirm -Rcs $(comm -23 <(pacman -Qq | sort) <(sort ~/cleansystem)) + +exit $? -- cgit v1.2.3 From d3056495cdab4c03e1a5a73c303b4cc25337597d Mon Sep 17 00:00:00 2001 From: Nicolas Reynolds Date: Wed, 7 Sep 2011 11:26:53 -0300 Subject: Instead of 'abs', now buildenv uses ${USER}. --- buildenv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildenv b/buildenv index 1a9fff6..dc41e19 100755 --- a/buildenv +++ b/buildenv @@ -3,7 +3,7 @@ trap "umount_all" 0 ERR TERM KILL umount_all() { - for mp in home/pkgdest home/srcdest home/abs; do + for mp in home/pkgdest home/srcdest home/${USER}; do msg "Umounting /$mp" umount $CHROOTDIR/$CHCOPY/$mp || error "Couldn't umount" done @@ -11,7 +11,7 @@ umount_all() { source /etc/libretools.conf -for mp in home/pkgdest home/srcdest home/abs var/lib/toru; do +for mp in home/pkgdest home/srcdest home/${USER} var/lib/toru; do msg "Binding /$mp" mount -o bind /$mp $CHROOTDIR/$CHCOPY/$mp || exit 1 done -- cgit v1.2.3 From 6082f831bbacb174c050915d3b301910fb2ea261 Mon Sep 17 00:00:00 2001 From: Nicolas Reynolds Date: Wed, 21 Sep 2011 13:26:21 -0300 Subject: Use SUDO_USER or specified user on $1 --- buildenv | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/buildenv b/buildenv index dc41e19..1cb07de 100755 --- a/buildenv +++ b/buildenv @@ -2,8 +2,10 @@ trap "umount_all" 0 ERR TERM KILL +user=${SUDO_USER:-${1}} + umount_all() { - for mp in home/pkgdest home/srcdest home/${USER}; do + for mp in home/pkgdest home/srcdest home/${user}; do msg "Umounting /$mp" umount $CHROOTDIR/$CHCOPY/$mp || error "Couldn't umount" done @@ -11,7 +13,7 @@ umount_all() { source /etc/libretools.conf -for mp in home/pkgdest home/srcdest home/${USER} var/lib/toru; do +for mp in home/pkgdest home/srcdest home/${user} var/lib/toru; do msg "Binding /$mp" mount -o bind /$mp $CHROOTDIR/$CHCOPY/$mp || exit 1 done -- cgit v1.2.3 From 46798e856bcfa70791e19e7729322ad2f425d157 Mon Sep 17 00:00:00 2001 From: Nicolas Reynolds Date: Tue, 1 Nov 2011 17:16:48 -0300 Subject: PKGBUILD path caching * Toru is overly complex * Moved path caching to toru-path. Run it without arguments to update the PKGBUILD paths cache * Updated fullpkg to check this new paths cache --- fullpkg | 20 +++++----------- toru | 42 ++++----------------------------- toru-path | 31 ++++++++++++++++++++++++ toru-utils | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+), 52 deletions(-) create mode 100755 toru-path create mode 100755 toru-utils diff --git a/fullpkg b/fullpkg index f242039..6b940f3 100755 --- a/fullpkg +++ b/fullpkg @@ -44,17 +44,8 @@ usage() { # Look in all caches but pick the first one # TODO move to a toru flag (-p?) where_is() { - local _repo - local _path - for _repo in ${REPOS[@]}; do - _path=$(grep "^${1}:" "${TORUPATH}/${_repo}.paths.cache" 2>/dev/null| \ - cut -d: -f2 2>/dev/null) - - [ -n "${_path}" ] && break - done - - echo ${_path} - + grep -m1 "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \ + cut -d: -f2 2>/dev/null } # Removes a package from the buildorder @@ -147,6 +138,8 @@ find_deps() { for _dep in ${deps[@]}; do + msg2 "Checking ${_dep}" + local found=false local pkgdir=$(where_is ${_dep}) @@ -160,9 +153,8 @@ find_deps() { # probable circular deps [ $? -eq 20 ] && return 20 popd > /dev/null - fi - - if ! (( found )); then + else + error "Not found" echo "dep_not_found:$_dep" >>$build_dir/log fi diff --git a/toru b/toru index d622510..55e4119 100755 --- a/toru +++ b/toru @@ -12,43 +12,7 @@ # * 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 - -if [ ! -w "$TORUPATH" ]; then - error "Toru's path isn't writable. Please check $TORUPATH" - exit 1 -fi - -# TODO move to common functions -# usage : in_array( $needle, $haystack ) -function in_array { - [[ $2 ]] || return 1 # Not found - - local needle=$1; shift - local item - - for item in "$@"; do - [[ ${item#@} = $needle ]] && return 0 # Found - done - - return 1 # Not Found -} - -# Stores the lastsync date -lastsync() { - local lastsyncfile - - lastsyncfile=$1 - - [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { - error "The sync date can't be saved. ${lastsyncfile} isn't writable." - return 1 - } - - date +%s > ${lastsyncfile} - touch ${lastsyncfile} -} +source $(dirname $0)/toru-utils # Saves contents on a named cache # $1 cache name (repo) @@ -267,7 +231,9 @@ update() { # See above FIXME # print_package_array "${updates[@]}" > ${TMPDIR}/updates - store_cache ${_repo}.updates ${TMPDIR}/updates + if [ -r ${TMPDIR}/updates ]; then + store_cache ${_repo}.updates ${TMPDIR}/updates + fi else $quiet || msg "Reading updates from cache..." diff --git a/toru-path b/toru-path new file mode 100755 index 0000000..82378a4 --- /dev/null +++ b/toru-path @@ -0,0 +1,31 @@ +#!/bin/bash + +source $(dirname $0)/toru-utils + +LASTSYNCFILE=${TORUPATH}/lastsync.paths + +# TODO pass other paths via flags +pkgbuilds=($(get_pkgbuilds ${ABSROOT})) +paths=() +# TODO create a --ignore flag +ignore=($@) + +msg "Updating path cache" +msg2 "${#pkgbuilds[@]} PKGBUILDs to update" +for _pkgbuild in ${pkgbuilds[@]}; do + $DEBUG && plain "$_pkgbuild" + source ${_pkgbuild} || { + error "${_pkgbuild} contains errors, skipping" + continue + } + + fullpath=$(dirname $(readlink -f ${_pkgbuild})) + + for _pkg in ${pkgname[@]}; do + paths+=(${_pkg}:${fullpath}) + done +done + +echo ${paths[@]} | tr ' ' "\n" | sort >> ${TORUPATH}/paths + +lastsync ${LASTSYNCFILE} diff --git a/toru-utils b/toru-utils new file mode 100755 index 0000000..e930273 --- /dev/null +++ b/toru-utils @@ -0,0 +1,80 @@ +#!/bin/bash +#!/bin/bash + + +source /etc/abs.conf +source /etc/libretools.conf + +if [ ! -w "$TORUPATH" ]; then + error "Toru's path isn't writable. Please check $TORUPATH" + exit 1 +fi + +LASTSYNCFILE=${TORUPATH}/lastsync +FORCE=false +QUIET=false +DEBUG=false + +# usage : in_array( $needle, $haystack ) +function in_array { + [[ $2 ]] || return 1 # Not found + + local needle=$1; shift + local item + + for item in "$@"; do + [[ ${item#@} = $needle ]] && return 0 # Found + done + + return 1 # Not Found +} + +# Stores the lastsync date +lastsync() { + local lastsyncfile + + lastsyncfile=$1 + + [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && { + error "The sync date can't be saved. ${lastsyncfile} isn't writable." + return 1 + } + + date +%s > ${lastsyncfile} + touch ${lastsyncfile} +} + + +# repo paths +get_pkgbuilds() { + pkgbuilds=() + + if [[ $FORCE = true || ! -e ${LASTSYNCFILE} ]]; then + + $QUIET || warning "Forcing upgrade" +# Get all PKGBUILDs + pkgbuilds=($(find $@ -mindepth 2 -maxdepth 3 -type f -name 'PKGBUILD')) + + else + +# Only find newer than lastsyncfile and read everything else from cache + pkgbuilds=($(find $@ -mindepth 2 -maxdepth 3 -type f -name 'PKGBUILD' -newer ${LASTSYNCFILE})) + + fi + +# Return all PKGBUILDs found + echo ${pkgbuilds[@]} +} + +# End inmediately but print a useful message +trap_exit() { + error "$@" + + exit 1 +} + +# Trap signals from makepkg +set -E +trap 'trap_exit "(prfullpkg:${level}) TERM signal caught. Exiting..."' TERM HUP QUIT +trap 'trap_exit "(prfullpkg:${level}) Aborted by user! Exiting..."' INT +trap 'trap_exit "(prfullpkg:${level}) An unknown error has occurred. Exiting..."' ERR -- cgit v1.2.3 From 22a9fdddd1f6fd02e1b8d8ca9022398cd64c68b2 Mon Sep 17 00:00:00 2001 From: Nicolas Reynolds Date: Thu, 24 Nov 2011 11:08:54 -0300 Subject: change CHCOPY to CHROOT --- buildenv | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/buildenv b/buildenv index 1cb07de..84a1fc2 100755 --- a/buildenv +++ b/buildenv @@ -7,7 +7,7 @@ user=${SUDO_USER:-${1}} umount_all() { for mp in home/pkgdest home/srcdest home/${user}; do msg "Umounting /$mp" - umount $CHROOTDIR/$CHCOPY/$mp || error "Couldn't umount" + umount $CHROOTDIR/$CHROOT/$mp || error "Couldn't umount" done } @@ -15,14 +15,14 @@ source /etc/libretools.conf for mp in home/pkgdest home/srcdest home/${user} var/lib/toru; do msg "Binding /$mp" - mount -o bind /$mp $CHROOTDIR/$CHCOPY/$mp || exit 1 + mount -o bind /$mp $CHROOTDIR/$CHROOT/$mp || exit 1 done for etc in etc/makepkg.conf etc/abs.conf etc/mtab; do msg "Copying config /$etc" - cp --remove-destination /$etc $CHROOTDIR/$CHCOPY/$etc || exit 1 + cp --remove-destination /$etc $CHROOTDIR/$CHROOT/$etc || exit 1 done -$(dirname $0)/librechroot $CHCOPY +$(dirname $0)/librechroot $CHROOT exit $? -- cgit v1.2.3 From 40fa0a4c04a34740b40c88a75b7ef1c816cda195 Mon Sep 17 00:00:00 2001 From: Nicolas Reynolds Date: Thu, 24 Nov 2011 11:09:23 -0300 Subject: Toru-path fixes --- toru-path | 6 ++---- toru-utils | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/toru-path b/toru-path index 82378a4..bdf2f23 100755 --- a/toru-path +++ b/toru-path @@ -7,8 +7,6 @@ LASTSYNCFILE=${TORUPATH}/lastsync.paths # TODO pass other paths via flags pkgbuilds=($(get_pkgbuilds ${ABSROOT})) paths=() -# TODO create a --ignore flag -ignore=($@) msg "Updating path cache" msg2 "${#pkgbuilds[@]} PKGBUILDs to update" @@ -21,8 +19,8 @@ for _pkgbuild in ${pkgbuilds[@]}; do fullpath=$(dirname $(readlink -f ${_pkgbuild})) - for _pkg in ${pkgname[@]}; do - paths+=(${_pkg}:${fullpath}) + for _pkg in ${pkgname[@]} ${provides[@]}; do + paths+=(${_pkg/[<>=]*}:${fullpath}) done done diff --git a/toru-utils b/toru-utils index e930273..bb0aef4 100755 --- a/toru-utils +++ b/toru-utils @@ -44,6 +44,12 @@ lastsync() { touch ${lastsyncfile} } +get_dbs() { + local _db + for _db in /var/lib/pacman/sync/*.db; do + bsdtar tf ${_db} | cut -d'/' -f1 | sort -u + done +} # repo paths get_pkgbuilds() { -- cgit v1.2.3 From 55abb1e683ace68905f987bdcd452df6e709a9e8 Mon Sep 17 00:00:00 2001 From: Nicolas Reynolds Date: Wed, 14 Dec 2011 14:47:14 -0300 Subject: Perform cleanup to avoid bogus paths --- toru-path | 3 +++ 1 file changed, 3 insertions(+) diff --git a/toru-path b/toru-path index bdf2f23..7500aed 100755 --- a/toru-path +++ b/toru-path @@ -22,8 +22,11 @@ for _pkgbuild in ${pkgbuilds[@]}; do for _pkg in ${pkgname[@]} ${provides[@]}; do paths+=(${_pkg/[<>=]*}:${fullpath}) done + + unset pkgname provides done +# TODO remove old paths echo ${paths[@]} | tr ' ' "\n" | sort >> ${TORUPATH}/paths lastsync ${LASTSYNCFILE} -- cgit v1.2.3 From 0e9e94d70a0442e2c0aebdfb282269e90d688712 Mon Sep 17 00:00:00 2001 From: Nicolas Reynolds Date: Sat, 21 Jan 2012 11:04:56 -0300 Subject: noupdate check --- fullpkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fullpkg b/fullpkg index 7e75afc..a282926 100755 --- a/fullpkg +++ b/fullpkg @@ -340,7 +340,7 @@ if [ ${level} -eq 0 ]; then touch "${build_dir}"/{log,BUILDORDER} buildorder="${build_dir}/BUILDORDER" - if ! noupdate; then + if ! $noupdate; then msg "Updating pacman db" sudo pacman -Sy --noconfirm || true -- cgit v1.2.3 From 0985429b68d8da1016bf4a84b2a2d32fb8c3027c Mon Sep 17 00:00:00 2001 From: Nicolas Reynolds Date: Sat, 21 Jan 2012 11:16:42 -0300 Subject: Merging fullpkg --- fullpkg | 8 -------- fullpkg-find | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fullpkg b/fullpkg index 227f329..fe74432 100755 --- a/fullpkg +++ b/fullpkg @@ -19,14 +19,6 @@ usage() { } -# Finds a PKGBUILD on toru's path cache -# Look in all caches but pick the first one -# TODO move to a toru flag (-p?) -where_is() { - grep -m1 "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \ - cut -d: -f2 2>/dev/null -} - while getopts 'haA:l:nm:' arg; do case "$arg" in h) usage ;; diff --git a/fullpkg-find b/fullpkg-find index 25565ae..d253913 100644 --- a/fullpkg-find +++ b/fullpkg-find @@ -11,6 +11,14 @@ guess_repo() { basename $(dirname $(pwd)) } +# Finds a PKGBUILD on toru's path cache +# Look in all caches but pick the first one +# TODO move to a toru flag (-p?) +where_is() { + grep -m1 "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \ + cut -d: -f2 2>/dev/null +} + # return : full version spec, including epoch (if necessary), pkgver, pkgrel # usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel ) get_fullver() { @@ -71,6 +79,7 @@ find_deps() { for _dep in ${deps[@]}; do local found=false +# TODO change for where_is or toru-path local pkgdir=$(toru -p ${_dep}) if [ -n "$pkgdir" -a -d "${pkgdir}" ]; then -- cgit v1.2.3