From patchwork Fri May 5 22:40:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Shumaker X-Patchwork-Id: 158 Return-Path: Delivered-To: patchwork@archlinux.org Received: from nymeria.archlinux.org by nymeria.archlinux.org (Dovecot) with LMTP id 0VPfM5X/DFkhHwAAtiB/HQ for ; Sat, 06 May 2017 00:41:25 +0200 Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 532AD404ED; Sat, 6 May 2017 00:41:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on nymeria.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.5 tests=BAYES_00,RCVD_IN_DNSWL_MED shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.1 Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Sat, 6 May 2017 00:41:24 +0200 (CEST) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id D0C1E20856; Fri, 5 May 2017 22:41:17 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=none Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id A5904207A3 for ; Fri, 5 May 2017 22:41:16 +0000 (UTC) Received: from nymeria.archlinux.org (nymeria.archlinux.org [IPv6:2a00:1828:2000:547::2]) by luna.archlinux.org (Postfix) with ESMTPS for ; Fri, 5 May 2017 22:41:16 +0000 (UTC) Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 9245040484 for ; Sat, 6 May 2017 00:41:13 +0200 (CEST) Received: from mav.lukeshu.com (mav.lukeshu.com [IPv6:2001:19f0:5c00:8069:5400:ff:fe26:6a86]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS for ; Sat, 6 May 2017 00:41:13 +0200 (CEST) Received: from build64-par (unknown [IPv6:2601:803:202:9275:21f:e2ff:fe4d:191b]) by mav.lukeshu.com (Postfix) with ESMTPSA id CA07D83CF3 for ; Fri, 5 May 2017 18:41:11 -0400 (EDT) From: Luke Shumaker To: arch-projects@archlinux.org Date: Fri, 5 May 2017 18:40:59 -0400 Message-Id: <20170505224110.28990-3-lukeshu@parabola.nu> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170505224110.28990-1-lukeshu@parabola.nu> References: <20170505224110.28990-1-lukeshu@parabola.nu> Subject: [arch-projects] [devtools][PATCH 02/13] makechrootpkg: sync_chroot: make usage easier to understand. X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Arch Linux projects development discussion Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" X-UID: 376 Status: X-Keywords: Content-Length: 1673 Also, shorten the "Synchronizing" message to only include the full path to the copy if it was specified. The capslocked variable names in the Usage comment were references to things in Parabola's tools, that didn't make much sense here out of context. --- makechrootpkg.in | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 88c2cdc..d92d6ab 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -98,16 +98,11 @@ load_vars() { return 0 } -# Usage: sync_chroot $CHROOTDIR/$CHROOT <$CHROOTCOPY|$copydir> +# Usage: sync_chroot $chrootdir $copydir [$copy] sync_chroot() { local chrootdir=$1 - local copy=$2 - local copydir='' - if [[ ${copy:0:1} = / ]]; then - copydir=$copy - else - copydir="$chrootdir/$copy" - fi + local copydir=$2 + local copy=${3:-$2} if [[ "$chrootdir/root" -ef "$copydir" ]]; then error 'Cannot sync copy with itself: %s' "$copydir" @@ -119,7 +114,7 @@ sync_chroot() { slock 8 "$chrootdir/root.lock" \ "Locking clean chroot [%s]" "$chrootdir/root" - stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copydir" + stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copy" if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then subvolume_delete_recursive "$copydir" || die "Unable to delete subvolume %s" "$copydir" @@ -379,7 +374,7 @@ main() { lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy" if [[ ! -d $copydir ]] || $clean_first; then - sync_chroot "$chrootdir" "$copy" + sync_chroot "$chrootdir" "$copydir" "$copy" fi $update_first && arch-nspawn "$copydir" \