diff options
-rwxr-xr-x | ch | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -37,7 +37,7 @@ __genchroot() { sudo btrfs subvolume snapshot "$chrootdir/root" "$copydir" } -__chrootalias() { +__chrootalias_resolve() { chroot="" chroot_arch="" arg_arch=${1%%+*} @@ -79,6 +79,10 @@ __chrootalias() { chrootdir="$CHROOTS/$chroot" copydir="$chrootdir/$arg_copy" +} + +__chrootalias_resolve_create() { + __chrootalias_resolve "$1" # create chroot if necessary if [[ ! -d "$chrootdir/root" ]]; then @@ -107,7 +111,7 @@ chkill() { return fi - __chrootalias "$1" || return + __chrootalias_resolve "$1" || return for dir in "$CHROOTS/$chroot/"*/; do sudo btrfs subvolume delete "$dir" done @@ -115,20 +119,20 @@ chkill() { } chshell() { - __chrootalias "$1" || return + __chrootalias_resolve_create "$1" || return [ -d "$copydir" ] || __genchroot sudo arch-nspawn "$copydir" "${2:-/bin/bash}" "${@:3}" } chbuild() { - __chrootalias "$1" || return + __chrootalias_resolve_create "$1" || return linux${chroot_arch} sudo makechrootpkg -l "${copydir##*/}" -r "$chrootdir" -n -- -f "${@:2}" chshell "$1" pacman --noconfirm -Rcs namcap __cleanup_logs "$PWD" } chinstall() { - __chrootalias $1 || return; shift + __chrootalias_resolve_create $1 || return; shift for file in "$@"; do files+=(-I "$(readlink -f "$file")") done @@ -137,7 +141,7 @@ chinstall() { } chclean() { - __chrootalias $1 || return + __chrootalias_resolve_create $1 || return for copy in $chrootdir/*/; do if [[ $copy = */root/ ]]; then continue @@ -149,12 +153,12 @@ chclean() { } chrshell() { - __chrootalias $1 || return + __chrootalias_resolve_create $1 || return sudo arch-nspawn "$chrootdir/root" "${2:-/bin/bash}" "${@:3}" } chupdate() { - __chrootalias $1 || return + __chrootalias_resolve_create $1 || return echo ":: Updating $chroot" sudo arch-nspawn "$chrootdir/root" pacman -Syu --noconfirm echo ":: Cleaning up ..." |