archbuild/makechrootpkg: Delete subvolumes in roots
The systemd package creates a subvolume at /var/lib/machines (through tmpfiles), if it can. We need to delete this subvolume before we can delete the parent subvolume. Look through the root for inodes with the number 256. These identify subvolume roots.
This commit is contained in:
parent
c53a3e8017
commit
eec7fcf965
|
@ -52,9 +52,7 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
|
|||
|
||||
lock 9 "$copy.lock" "Locking chroot copy '$copy'"
|
||||
|
||||
if is_btrfs "${copy}"; then
|
||||
{ type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null
|
||||
fi
|
||||
subvolume_delete_recursive "${copy}"
|
||||
rm -rf --one-file-system "${copy}"
|
||||
done
|
||||
exec 9>&-
|
||||
|
|
|
@ -20,3 +20,23 @@ check_root() {
|
|||
is_btrfs() {
|
||||
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
|
||||
}
|
||||
|
||||
##
|
||||
# usage : subvolume_delete_recursive( $path )
|
||||
#
|
||||
# Find all btrfs subvolumes under and including $path and delete them.
|
||||
##
|
||||
subvolume_delete_recursive() {
|
||||
local subvol
|
||||
|
||||
is_btrfs "$1" || return 0
|
||||
|
||||
while IFS= read -d $'\0' -r subvol; do
|
||||
if ! btrfs subvolume delete "$subvol" &>/dev/null; then
|
||||
error "Unable to delete subvolume %s" "$subvol"
|
||||
return 1
|
||||
fi
|
||||
done < <(find "$1" -xdev -depth -inum 256 -print0)
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -97,10 +97,8 @@ create_chroot() {
|
|||
|
||||
stat_busy "Creating clean working copy [$copy]"
|
||||
if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
|
||||
if [[ -d $copydir ]]; then
|
||||
btrfs subvolume delete "$copydir" >/dev/null ||
|
||||
die "Unable to delete subvolume %s" "$copydir"
|
||||
fi
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue