From 00d67a5051e5d4163acffa80b7ef85f81f7e548f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 28 Nov 2012 15:20:59 -0500 Subject: take (some) advantage of chroottools, fix some compatability things mkarchroot/archroot's option parsing is a little less flexible (but a lot more understandable) than it was before. --- src/chroot-tools/librechroot | 51 +++++--------------------------------------- 1 file changed, 5 insertions(+), 46 deletions(-) (limited to 'src/chroot-tools/librechroot') diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 48e6cdc..8830c39 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -27,53 +27,12 @@ cmd=${0##*/} -lock_open_write() { - local fd=$1 - local path=$2 - local msg=$3 - - # Only reopen the FD if it wasn't handed to us - if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then - eval "exec $fd>${path}.lock" - fi - - if ! flock -n $fd; then - stat_busy "$msg" - flock $fd - stat_done - fi -} - -lock_open_read() { - local fd=$1 - local path=$2 - local msg=$3 - - # Only reopen the FD if it wasn't handed to us - if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then - eval "exec $fd>${path}.lock" - fi - - if ! flock -sn $fd; then - stat_busy "$msg" - flock -s $fd - stat_done - fi -} - -lock_close() { - local fd=$1 - eval "exec $fd>&-" -} - clean_pacman() { msg "Cleaning chroot with pacman: ${copydir}" cp -a "$(dirname $0)/chcleanup" "${copydir}/clean" mkdir -p "$copydir/build" - mkarchroot -r "cd /build; /clean" "${copydir}" - - #mkarchroot "${copydir}" base base-devel sudo "${CHROOTEXTRAPKG[@]}" + archroot "${copydir}" -r "cd /build; /clean" } clean_repo() { @@ -120,12 +79,12 @@ sync() { update() { msg "Updating chroot: ${copydir}" - mkarchroot -u "${copydir}" + archroot "${copydir}" -u } enter() { msg "Entering chroot: ${copydir}" - mkarchroot -r "bash" "${copydir}" + archroot "${copydir}" -r "bash" } usage() { @@ -183,11 +142,11 @@ main() { fi # Keep this lock as long as we are running - # Note that '9' is the same FD number as in mkarchroot + # Note that '9' is the same FD number as in (mk)archroot lock_open_write 9 "$copydir" "Locking chroot copy '$copy'" if [[ ! -d $rootdir ]]; then - libremkchroot -d "$CHROOTDIR" "$CHROOT" + libremkchroot "$CHROOT" fi if [[ ! -d $copydir ]] && [[ $mode != sync ]]; then -- cgit v1.2.3-54-g00ecf