diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-28 21:47:22 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-28 21:47:22 -0500 |
commit | 9b4d435d076e4e07366a54b747e013234ee7a6a7 (patch) | |
tree | e19af6a63b3c15f2df235f30e48a4a67b05cf5d0 | |
parent | f3c7196d1a286142bedd406fe7ae6a2ef75b56f4 (diff) |
fix several bugs
-rw-r--r-- | lib/common.sh | 2 | ||||
-rw-r--r-- | mkarchroot.in | 20 |
2 files changed, 15 insertions, 7 deletions
diff --git a/lib/common.sh b/lib/common.sh index 1ef677c..d6fbe7c 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -116,6 +116,7 @@ lock_open_write() { # Only reopen the FD if it wasn't handed to us if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then + mkdir -p "${path%/*}" eval "exec $fd>${path}.lock" fi @@ -136,6 +137,7 @@ lock_open_read() { # Only reopen the FD if it wasn't handed to us if [[ $(readlink -f /dev/fd/$fd) != "${path}.lock" ]]; then + mkdir -p "${path%/*}" eval "exec $fd>${path}.lock" fi diff --git a/mkarchroot.in b/mkarchroot.in index c26e6a0..e62c1cf 100644 --- a/mkarchroot.in +++ b/mkarchroot.in @@ -44,7 +44,7 @@ usage() { ################################################################################ -while getopts 'fnC:M:c:' arg; do +while getopts 'fC:M:nc:N' arg; do case "${arg}" in f) FORCE='y' ;; C) pac_conf="$OPTARG" ;; @@ -52,8 +52,8 @@ while getopts 'fnC:M:c:' arg; do n) NOCOPY='y' ;; c) cache_dir="$OPTARG" ;; N) NONETWORK='y' ;; - h|?) usage 0 ;; - *) error "invalid argument '${arg}'"; usage ;; + h) usage 0 ;; + *) error "invalid argument '${arg}'"; usage 1;; esac done @@ -179,9 +179,12 @@ copy_hostconf () { sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i ${working_dir}/etc/pacman.conf } +trap_unmount_err () { + error "Error unmounting" +} + trap_chroot_umount () { - trap 'trap_abort' INT QUIT TERM HUP - trap 'trap_exit' EXIT + trap 'trap_unmount_err' INT QUIT TERM HUP EXIT for cache_dir in ${cache_dirs[@]}; do umount "${working_dir}/${cache_dir}" @@ -200,10 +203,13 @@ trap_chroot_umount () { umount "${working_dir}/dev" umount "${working_dir}/run" fi + + trap 'trap_abort' INT QUIT TERM HUP + trap 'trap_exit' EXIT } chroot_lock () { - lock_open_write 9 "${working_dir}.lock" "Locking chroot" + lock_open_write 9 "${working_dir}" "Locking chroot" } chroot_run() { @@ -270,7 +276,7 @@ else if [[ $FORCE = 'y' ]]; then pacargs="$pacargs --force" fi - if ! pacstrap -GMcd "${working_dir}" ${pacargs} "$PKGS"; then + if ! pacstrap -GMcd "${working_dir}" ${pacargs} "${PKGS[@]}"; then die 'Failed to install all packages' fi fi |