[arch-projects] [DEVTOOLS][PATCH 6/6] makechrootpkg: Remove btrfs copy after successful build

Jan Steffens jan.steffens at gmail.com
Sat Mar 2 01:32:53 EST 2013


On Sat, Mar 2, 2013 at 5:21 AM, Sébastien Luttringer <seblu at seblu.net> wrote:
> Avoid to manually cleanup of subvolumes when a build was successful.
> Really useful with random copy directory.
>
> Signed-off-by: Sébastien Luttringer <seblu at seblu.net>
> ---
>  makechrootpkg.in | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/makechrootpkg.in b/makechrootpkg.in
> index 0e2d5c0..3f160bc 100644
> --- a/makechrootpkg.in
> +++ b/makechrootpkg.in
> @@ -23,6 +23,7 @@ chrootdir=
>  passeddir=
>  declare -a install_pkgs
>  declare -i ret=0
> +no_purge=false
>
>  default_copy=$USER
>  [[ -n $SUDO_USER ]] && default_copy=$SUDO_USER
> @@ -58,10 +59,11 @@ usage() {
>         echo '           Useful for maintaining multiple copies.'
>         echo "           Default: $default_copy or random for btrfs"
>         echo '-n         Run namcap on the package'
> +       echo "-p         Don't purge the chroot copy after succesful build (btrfs only)"
>         exit 1
>  }
>
> -while getopts 'hcudr:I:l:n' arg; do
> +while getopts 'hcudr:I:l:np' arg; do
>         case "$arg" in
>                 h) usage ;;
>                 c) clean_first=true ;;
> @@ -71,6 +73,7 @@ while getopts 'hcudr:I:l:n' arg; do
>                 I) install_pkgs+=("$OPTARG") ;;
>                 l) copy="$OPTARG" ;;
>                 n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;
> +               p) no_purge=true ;;
>                 *) makepkg_args="$makepkg_args -$arg $OPTARG" ;;
>         esac
>  done
> @@ -321,4 +324,8 @@ done
>
>  if (( ret != 0 )); then
>         die "Build failed, check $copydir/build"
> +elif [[ "$chroottype" == btrfs ]] && ! $no_purge; then
> +       btrfs subvolume delete "$copydir" >/dev/null ||
> +               error "Unable to delete subvolume $copydir"
> +       rm "$copydir.lock"
>  fi
> --
> Sébastien "Seblu" Luttringer
>

NACK.

I disagree with making this the default.
Copydirs named just with numbers are unhelpful on multiuser build servers.
Chroots for failed builds are not removed, leading to clutter when
builds fail. Copies aren't cheap enough to just leave them around,
especially when additional dependencies are installed. Maybe this
could be done if we had some kind of old copy garbage collection.

Failing that, I'd rather have a single option (e.g. named -T for
"temporary") combining both a random copydir, named using:
  [[ -z $copy ]] && copy=$default_copy
  copydir="$(mktemp -u "$chrootdir/$copy-XXXXXX")"
and unconditionally removing the copydir after the build, whether it
failed or not.
The default behavior of makechrootpkg (without the option) remains.


More information about the arch-projects mailing list