[buildd-tools-devel] Bug#587757: Bug#587757: Bug#587757: schroot - Fails to end btrfs-snapshot sessions

Roger Leigh rleigh at codelibre.net
Thu Jul 1 21:27:15 UTC 2010


tags 587757 +patch
thanks

On Thu, Jul 01, 2010 at 04:14:13PM +0200, Bastian Blank wrote:
> On Thu, Jul 01, 2010 at 02:07:32PM +0100, Roger Leigh wrote:
> > On Thu, Jul 01, 2010 at 02:42:10PM +0200, Bastian Blank wrote:
> > > It is completely irrelevant that the source subvolume does not longer
> > > exist to do the cleanup, it only matters for the session setup.
> > Completely agreed.  I'll relax this sanity check (I thought I already
> > had, but I must have been mistaken).
> 
> And the same for the second check for the directory.

Could you possibly try out the attached replacement 00check
script to see if this improves things for you?

This also updates the checks for some of the other chroot
types as well to fix similar issues which would prevent
cleanup.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
-------------- next part --------------
#!/bin/sh
# Copyright ? 2005-2010  Roger Leigh <rleigh at debian.org>
#
# schroot is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# schroot is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see
# <http://www.gnu.org/licenses/>.
#
#####################################################################

set -e

# Plain chroots should not be able to use scripts, but check anyway to
# be safe.
if [ $CHROOT_TYPE = "plain" ]; then
    exit 1
fi

if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then
    . "$CHROOT_SCRIPT_CONFIG"
elif [ "$2" = "ok" ]; then
    echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist"
    exit 1
fi

# Skip if run at inappropriate point.
if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ] && [ "$(basename "$0")" = "99check" ]; then
    exit 0;
elif [ $1 = "setup-stop" ] && [ "$(basename "$0")" = "00check" ]; then
    exit 0;
fi

if [ "$VERBOSE" = "verbose" ]; then
     env | sort
fi

case "$CHROOT_TYPE" in
    directory)
	if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then
	    if [ ! -d "$CHROOT_DIRECTORY" ]; then
		echo "Directory '$CHROOT_DIRECTORY' does not exist"
		exit 1
	    fi
	fi
	;;
    file | loopback)
	if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then
	    if [ ! -f "$CHROOT_FILE" ]; then
	    	echo "File '$CHROOT_FILE' does not exist"
		exit 1
	    fi
	fi
	;;
    block-device | lvm-snapshot)
	case "$HOST_OS" in
	    freebsd* | k*bsd*-gnu) :
		DEVTYPE="-c"
		;;
	    *):
		DEVTYPE="-b"
		;;
	esac

	if [ $1 = "setup-start" ] && [ ! "$DEVTYPE" "$CHROOT_DEVICE" ]; then
	    echo "Device '$CHROOT_DEVICE' does not exist"
	    exit 1
	fi
	if [ $1 = "setup-recover" ] && [ $CHROOT_TYPE = "block-device" ] \
	    && [ ! "$DEVTYPE" "$CHROOT_DEVICE" ]; then
	    echo "Device '$CHROOT_DEVICE' does not exist"
	    exit 1
	fi
	;;
    btrfs-snapshot)
	if [ $1 = "setup-start" ] \
	    && [ ! -d "$CHROOT_BTRFS_SOURCE_SUBVOLUME" ]; then
	    echo "Btrfs source subvolume directory '$CHROOT_BTRFS_SOURCE_SUBVOLUME' does not exist"
	    exit 1
	fi
	if [ $1 = "setup-start" ] \
	    && [ ! -d "$CHROOT_BTRFS_SNAPSHOT_DIRECTORY" ]; then
	    echo "Btrfs snapshot directory '$CHROOT_BTRFS_SNAPSHOT_DIRECTORY' does not exist"
	    exit 1
	fi
	;;
    *)
	echo "Unknown chroot type $CHROOT_TYPE"
	exit 1
	;;
esac

if [ "$CHROOT_UNION_TYPE" != "none" ]; then
    if [ ! -d "$CHROOT_UNION_OVERLAY_DIRECTORY" ] \
	&& [ $1 = "setup-recover" ];
    then
	echo "Directory '$CHROOT_UNION_OVERLAY_DIRECTORY' does not exist"
	exit 1
    fi
    if [ ! -d "$CHROOT_UNION_UNDERLAY_DIRECTORY" ] \
	&& [ $1 = "setup-recover" ];
    then
	echo "Directory '$CHROOT_UNION_UNDERLAY_DIRECTORY' does not exist"
	exit 1
    fi
fi

# A basic safety check, so that the root filesystem doesn't get
# toasted by accident.
if [ -z "$CHROOT_PATH" ] \
    || [ "$CHROOT_PATH" = "/" ] \
    || ( [ -z "$CHROOT_UNION_TYPE" ] \
         && [ "$CHROOT_DIRECTORY" = "/" ] ) \
    || [ "$CHROOT_UNION_OVERLAY_DIRECTORY" = "/" ]
then
    echo "Invalid chroot mount path or directory"
    exit 1
fi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20100701/aaf47e2c/attachment.pgp>


More information about the Buildd-tools-devel mailing list