dev/chroot-test/run-test
author Paul Crowley <paul@lshift.net>
Sat, 18 Dec 2010 00:04:05 +0000
changeset 282 1239880543cf
parent 274 ec60311ce2a6
child 283 01eca64f77ab
permissions -rwxr-xr-x
Some improvements to the chroot test, try to make it work with Debian
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     1
#!/bin/sh
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     2
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     3
# Must be root to run this
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     4
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     5
set -e
282
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
     6
cd $(hg root)
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     7
267
4f24892b33fe Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents: 266
diff changeset
     8
DEBVERSION=sid
4f24892b33fe Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents: 266
diff changeset
     9
4f24892b33fe Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents: 266
diff changeset
    10
PRISTINE=/var/local/cache/pristine/$DEBVERSION
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    11
271
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    12
if [ ! -e $PRISTINE ] ; then
274
ec60311ce2a6 dev/chroot-test fixups
Paul Crowley <paul@lshift.net>
parents: 272
diff changeset
    13
    echo "Missing:" $PRISTINE
ec60311ce2a6 dev/chroot-test fixups
Paul Crowley <paul@lshift.net>
parents: 272
diff changeset
    14
    echo "Debian pristine image not found, try running these commands as root:"
ec60311ce2a6 dev/chroot-test fixups
Paul Crowley <paul@lshift.net>
parents: 272
diff changeset
    15
    echo mkdir -p /var/local/cache/pristine
ec60311ce2a6 dev/chroot-test fixups
Paul Crowley <paul@lshift.net>
parents: 272
diff changeset
    16
    echo debootstrap $DEBVERSION $PRISTINE http://ftp.uk.debian.org/debian/
271
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    17
    exit -1
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    18
fi
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    19
282
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    20
BUILDDIR=$(pwd)/build
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    21
mkdir -p $BUILDDIR/env
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    22
BACKING=$BUILDDIR/env/backing
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    23
MOUNT=$BUILDDIR/env/mount
271
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    24
if [ -e $MOUNT ] ; then
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    25
    echo "Removing old filesystem"
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    26
    # FIXME: evil hack!
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    27
    chroot $MOUNT /etc/init.d/ssh stop || true
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    28
    umount $MOUNT/proc || true
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    29
    umount $MOUNT || true
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    30
    rm -rf $MOUNT
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    31
fi
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    32
if [ -e $BACKING ] ; then
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    33
    echo "Copying deb files into cache"
282
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    34
    cp $BACKING/var/cache/apt/archives/* $BUILDDIR/aptcache/$DEBVERSION || true
271
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    35
    echo "Deleting old filesystem backing store"
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    36
    rm -rf $BACKING
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    37
fi
267
4f24892b33fe Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents: 266
diff changeset
    38
mkdir $BACKING $MOUNT
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    39
265
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    40
touch $BACKING/please-trash-this-system
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    41
mkdir -p $BACKING/etc
266
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    42
echo "pristine" > $BACKING/etc/debian_chroot
282
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    43
cp -v dev/chroot-test/policy-rc.d $BACKING/etc/policy-rc.d
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    44
266
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    45
mkdir -p $BACKING/var/cache/apt/archives
271
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    46
echo "Copying deb files out of cache"
282
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    47
cp $BUILDDIR/aptcache/$DEBVERSION/* $BACKING/var/cache/apt/archives || true
266
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    48
282
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    49
cp -av dev/chroot-test/action $BACKING
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    50
if [ -e debian/rules ] ; then
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    51
    ./dev/debian-build/dbuild 
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    52
    cp build/debian/*.deb $BACKING/action
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    53
else
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    54
    hg st -mac0n -X '*.hg' -X 'dev/**' \
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    55
        | cpio -p -0 -d $BACKING/action/mercurial-server
1239880543cf Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents: 274
diff changeset
    56
fi
266
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    57
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    58
unionfs-fuse -o cow -o allow_other,suid,dev $BACKING=RW:$PRISTINE=RO $MOUNT
265
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    59
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    60
#mount --bind /dev "$MOUNT/dev"
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    61
#mount --bind /dev/pts "$MOUNT/dev/pts"
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    62
mount -t proc proc $MOUNT/proc
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    63
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    64
chroot $MOUNT ./action/go
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    65