Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 53 lines (47 sloc) 1.52 KB
#!/bin/bash
# Copyright (c) Paul Tagliamonte <paultag@ubuntu.com>, 2012, under the terms
# and conditions of the Expat license.
echo "I: Pre-hook running."
SBUILD=/var/sbuild
VARIANT=$1
DIST=$2
sb-endsession $VARIANT $DIST
if [ ! -h $SBUILD/$DIST ]; then
if [ -d $SBUILD/$DIST ]; then
# If it's a directory, it's likely because of what's going on
# below.
sudo umount $SBUILD/$DIST 2>/dev/null
sudo rm -rf $SBUILD/$DIST
else
# If for some reason, there's something there.
rm -f $SBUILD/$DIST
fi
# Get into a consistant state.
ln -s $SBUILD/$DIST.d/$DIST-default $SBUILD/$DIST
fi
if [ "x$SBUILD_DO_OVERLAY" != "x" ]; then
if [ -h $SBUILD/$DIST.overlay.d ]; then
if [ ! -d `readlink $SBUILD/$DIST.overlay.d` ]; then
mkdir -p `readlink $SBUILD/$DIST.overlay.d`
fi
fi
if [ ! -d $SBUILD/$DIST.overlay.d/$DIST-$VARIANT ]; then
echo "I: Making new overlay."
mkdir -p $SBUILD/$DIST.overlay.d/$DIST-$VARIANT
echo "I: Made overlay."
fi
echo "I: Shimming the old chroot out of the way. This will get gnarly."
echo "I: You might need to auth..."
rm -f $SBUILD/$DIST
mkdir $SBUILD/$DIST
echo "Mounting."
sudo unionfs-fuse \
-o cow,max_files=32768 \
-o allow_other,use_ino,suid,dev,nonempty \
"$SBUILD/$DIST.overlay.d/$DIST-$VARIANT=RW:$SBUILD/$DIST.d/$DIST-$VARIANT=RO" \
$SBUILD/$DIST
if [ $? -ne 0 ]; then
echo "WARNING! UNGOOD RESULT!"
exit 1
fi
fi