summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Steffens <jan.steffens@gmail.com>2011-03-13 15:19:20 +0100
committerJan Steffens <jan.steffens@gmail.com>2011-03-22 19:47:48 +0100
commit0af05a48abb1d35380f4f4259deb163eb3b7b174 (patch)
tree6ded82b231c23421b76147e870f96d07b1385568
parent174ff59dba8c24f544e354cd43f3b68aea91d265 (diff)
downloaddevtools-0af05a48abb1d35380f4f4259deb163eb3b7b174.tar.xz
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.
-rwxr-xr-xarchbuild1
-rwxr-xr-xmakechrootpkg14
-rwxr-xr-xmkarchroot4
3 files changed, 17 insertions, 2 deletions
diff --git a/archbuild b/archbuild
index 9dd4888..19b734b 100755
--- a/archbuild
+++ b/archbuild
@@ -45,6 +45,7 @@ if ${clean_first} || [ ! -d "${chroots}/${repo}-${arch}" ]; then
exec 9>${copy}.lock
flock 9
+ { type -P btrfs && btrfs subvolume delete ${copy}; } &>/dev/null
rm -rf ${copy}
done
exec 9>&-
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
diff --git a/mkarchroot b/mkarchroot
index 5c6548e..f385731 100755
--- a/mkarchroot
+++ b/mkarchroot
@@ -181,6 +181,10 @@ else
exit 1
fi
+ if { type -P btrfs && btrfs subvolume create "${working_dir}"; } &>/dev/null; then
+ chmod 0755 "${working_dir}"
+ fi
+
mkdir -p "${working_dir}/var/lib/pacman/sync"
mkdir -p "${working_dir}/etc/"