This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
/
sb-prehook
executable file
·52 lines (47 loc) · 1.52 KB
/
sb-prehook
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/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