From 0af05a48abb1d35380f4f4259deb163eb3b7b174 Mon Sep 17 00:00:00 2001 From: Jan Steffens Date: Sun, 13 Mar 2011 15:19:20 +0100 Subject: Use Btrfs snapshots for chroot copies, when available This is much faster than using Rsync to clone. Rsync stays available when the chroots are not on a Btrfs. --- makechrootpkg | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'makechrootpkg') diff --git a/makechrootpkg b/makechrootpkg index 1f6f20a..5bf492f 100755 --- a/makechrootpkg +++ b/makechrootpkg @@ -127,8 +127,18 @@ if [ ! -d "$copydir" -o "$clean_first" -eq "1" ]; then fi echo -n 'creating clean working copy...' - mkdir -p "$copydir" - rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir" + use_rsync=false + if type -P btrfs >/dev/null; then + [ -d $copydir ] && btrfs subvolume delete "$copydir" &>/dev/null + btrfs subvolume snapshot "$chrootdir/root" "$copydir" &>/dev/null || use_rsync=true + else + use_rsync=true + fi + + if $use_rsync; then + mkdir -p "$copydir" + rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir" + fi echo 'done' # Drop the read lock again -- cgit v1.2.3-24-g4f1b