From patchwork Fri May 10 02:58:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 1103 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 9873FE368B69 for ; Fri, 10 May 2019 02:58:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,LOCAL_FAKEBUSINESS=0.5, MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,T_DKIMWL_WL_HIGH=-0.01, T_DMARC_POLICY_NONE=0.01 autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.2] [127.0.0.10] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Fri, 10 May 2019 02:58:57 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 74FDF12833B50B; Fri, 10 May 2019 02:58:53 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Fri, 10 May 2019 02:58:53 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 41A9D2BF35; Fri, 10 May 2019 02:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1557457133; bh=qE9/pi+b0WZgWjWt2Z4yqZwnPVowkAhq0iAXOJi0y3c=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc; b=oUZp9iO0q3ZEW0/4oFNbm1NbDPvJGkUgZrTnSKBDd/cuIzFDy1ZwdLqx8I53U05ec zwr8qY7ChsMWcy2sWTUAvowUZLKZP9lw01r0oYL2LWcC1vzSzZJOGZJ7Gyk3zUfIYR 1NxxTH20/TRJfhtj1Xh1it9LCmVEn4HBnBP95bRW2I/B6e9O/iBGkKL3EM3Pd/H8Mq JU8GLWHarwyjgZcxZujFAOkEcahSaYzZnGn9M2yTUP3y7C0sV5PeXlfONmKmKaiYMm E00HbjpWtznp3qSq3WiIRdlV9gxdr6Bc8aK8rahzilkMAR5xVdNcobMQOIRvcr5Q3+ 6SvwdVU+W9ypuurVOTgd1KWdIxYDtZi0GNtlEk9wmDIGzghKuEZzoSQ6d6CsFmFbb4 Yb180+syvih4bQxZkX1jgOls/iZ0f/qTLjue4BAPXsTCCbe/7Hy2InhiG4SE4S01ri UaBDQRRZeWqQDm02DX0LTDjSV+zALdvQWWBtuYix50KvM7/eFcuImUDs0zeJFWdZN7 gdxQoU/dRoGqnYvLK4+16iISVk2mCZO0qgraxLoJCn7ULnV0EMNQ2szyMyiLXWXVi5 9oAhlsqNGv+wra1fPyGhO0Bgnd5SV6JWvaVgpTeYEOf9WYeHFxjBkzNrTynDMBkbwa DV17jitFxoADeJbX9eSx4jm8= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 061EC2BF2A for ; Fri, 10 May 2019 02:58:49 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Fri, 10 May 2019 02:58:48 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id CEE9E12833B509; Fri, 10 May 2019 02:58:44 +0000 (UTC) Received: from localhost.localdomain (ool-3f8fe826.dyn.optonline.net [63.143.232.38]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: eschwartz) by orion.archlinux.org (Postfix) with ESMTPSA id 4F77712833B508; Fri, 10 May 2019 02:58:44 +0000 (UTC) To: arch-projects@archlinux.org Date: Thu, 9 May 2019 22:58:26 -0400 Message-Id: <20190510025826.19515-1-eschwartz@archlinux.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [arch-projects] [devtools] [PATCH] Revert "makechrootpkg: sync_chroot: Make more general." X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Eli Schwartz via arch-projects Reply-To: Arch Linux projects development discussion Cc: Eli Schwartz Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" This reverts commit 6d1992909cc46e293027ff488ae2632047603e66. It has never worked. In commit c86823a2d4a4152c71faa1c3bab227756232996f it was noted that it compared the device numbers for [[ $1 = $1 ]] which was a useless check and always returned true, for *any* btrfs filesystem. Now that the function is corrected to compare [[ $1 = $2 ]] the check is still useless, but this time because it always returns false -- btrfs subvolumes on the same filesystem do *not* share device numbers. So let's go back to the original working implementation that only matters in terms of makechrootpkg, and just checks if makechrootpkg's root working directory is btrfs (in which case we know it will be a subvolume because mkarchroot will create it that way). This restores our special support for the btrfs filesystem. Signed-off-by: Eli Schwartz --- lib/archroot.sh | 8 -------- makechrootpkg.in | 32 +++++++++++++------------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/lib/archroot.sh b/lib/archroot.sh index 2c03c82..06d4519 100644 --- a/lib/archroot.sh +++ b/lib/archroot.sh @@ -37,14 +37,6 @@ is_subvolume() { [[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs && "$(stat -c %i "$1")" == 256 ]] } -## -# usage : is_same_fs( $path_a, $path_b ) -# return : whether $path_a and $path_b are on the same filesystem -## -is_same_fs() { - [[ "$(stat -c %d "$1")" == "$(stat -c %d "$2")" ]] -} - ## # usage : subvolume_delete_recursive( $path ) # diff --git a/makechrootpkg.in b/makechrootpkg.in index dc647b3..52e834b 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -75,37 +75,31 @@ load_vars() { return 0 } -# Usage: sync_chroot $rootdir $copydir [$copy] +# Usage: sync_chroot $chrootdir $copydir [$copy] sync_chroot() { - local rootdir=$1 + local chrootdir=$1 local copydir=$2 local copy=${3:-$2} - if [[ "$rootdir" -ef "$copydir" ]]; then + if [[ "$chrootdir/root" -ef "$copydir" ]]; then error 'Cannot sync copy with itself: %s' "$copydir" return 1 fi # Get a read lock on the root chroot to make # sure we don't clone a half-updated chroot - slock 8 "$rootdir.lock" \ - "Locking clean chroot [%s]" "$rootdir" - - stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$rootdir" "$copy" - if is_subvolume "$rootdir" && is_same_fs "$rootdir" "$(dirname -- "$copydir")" && ! mountpoint -q "$copydir"; then - if is_subvolume "$copydir"; then - subvolume_delete_recursive "$copydir" || - die "Unable to delete subvolume %s" "$copydir" - else - # avoid change of filesystem in case of an umount failure - rm --recursive --force --one-file-system "$copydir" || - die "Unable to delete %s" "$copydir" - fi - btrfs subvolume snapshot "$rootdir" "$copydir" >/dev/null || + slock 8 "$chrootdir/root.lock" \ + "Locking clean chroot [%s]" "$chrootdir/root" + + 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" + btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null || die "Unable to create subvolume %s" "$copydir" else mkdir -p "$copydir" - rsync -a --delete -q -W -x "$rootdir/" "$copydir" + rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir" fi stat_done @@ -388,7 +382,7 @@ main() { lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy" if [[ ! -d $copydir ]] || $clean_first; then - sync_chroot "$chrootdir/root" "$copydir" "$copy" + sync_chroot "$chrootdir" "$copydir" "$copy" fi $update_first && arch-nspawn "$copydir" \