author | Cédric Krier <ced@b2ck.com> |
Mon, 11 Sep 2017 21:38:10 +0200 | |
changeset 375 | a41e4382ea6e |
parent 365 | f2e13e08ea13 |
permissions | -rwxr-xr-x |
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 |
365
f2e13e08ea13
Make it convenient to run the tests with new env vars in sudo
Paul Crowley <paul@lshift.net>
parents:
327
diff
changeset
|
6 |
|
f2e13e08ea13
Make it convenient to run the tests with new env vars in sudo
Paul Crowley <paul@lshift.net>
parents:
327
diff
changeset
|
7 |
for clause in $@ ; do |
f2e13e08ea13
Make it convenient to run the tests with new env vars in sudo
Paul Crowley <paul@lshift.net>
parents:
327
diff
changeset
|
8 |
export $clause |
f2e13e08ea13
Make it convenient to run the tests with new env vars in sudo
Paul Crowley <paul@lshift.net>
parents:
327
diff
changeset
|
9 |
done |
f2e13e08ea13
Make it convenient to run the tests with new env vars in sudo
Paul Crowley <paul@lshift.net>
parents:
327
diff
changeset
|
10 |
|
282
1239880543cf
Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents:
274
diff
changeset
|
11 |
cd $(hg root) |
264
cd7f901d3902
Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
12 |
|
267
4f24892b33fe
Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents:
266
diff
changeset
|
13 |
DEBVERSION=sid |
4f24892b33fe
Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents:
266
diff
changeset
|
14 |
|
4f24892b33fe
Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents:
266
diff
changeset
|
15 |
PRISTINE=/var/local/cache/pristine/$DEBVERSION |
264
cd7f901d3902
Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
16 |
|
271 | 17 |
if [ ! -e $PRISTINE ] ; then |
274 | 18 |
echo "Missing:" $PRISTINE |
19 |
echo "Debian pristine image not found, try running these commands as root:" |
|
20 |
echo mkdir -p /var/local/cache/pristine |
|
21 |
echo debootstrap $DEBVERSION $PRISTINE http://ftp.uk.debian.org/debian/ |
|
271 | 22 |
exit -1 |
23 |
fi |
|
24 |
||
282
1239880543cf
Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents:
274
diff
changeset
|
25 |
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
|
26 |
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
|
27 |
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
|
28 |
MOUNT=$BUILDDIR/env/mount |
271 | 29 |
if [ -e $MOUNT ] ; then |
30 |
echo "Removing old filesystem" |
|
31 |
# FIXME: evil hack! |
|
32 |
chroot $MOUNT /etc/init.d/ssh stop || true |
|
33 |
umount $MOUNT/proc || true |
|
34 |
umount $MOUNT || true |
|
35 |
rm -rf $MOUNT |
|
36 |
fi |
|
37 |
if [ -e $BACKING ] ; then |
|
38 |
echo "Copying deb files into cache" |
|
308
e1f71a2eafb6
Make directory for cacheing .deb files if it doesn't exist
Paul Crowley <paul@lshift.net>
parents:
283
diff
changeset
|
39 |
mkdir -p $BUILDDIR/aptcache/$DEBVERSION |
282
1239880543cf
Some improvements to the chroot test, try to make it work with Debian
Paul Crowley <paul@lshift.net>
parents:
274
diff
changeset
|
40 |
cp $BACKING/var/cache/apt/archives/* $BUILDDIR/aptcache/$DEBVERSION || true |
271 | 41 |
echo "Deleting old filesystem backing store" |
42 |
rm -rf $BACKING |
|
43 |
fi |
|
267
4f24892b33fe
Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents:
266
diff
changeset
|
44 |
mkdir $BACKING $MOUNT |
264
cd7f901d3902
Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
45 |
|
265
6629144cf111
More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents:
264
diff
changeset
|
46 |
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
|
47 |
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
|
48 |
echo "pristine" > $BACKING/etc/debian_chroot |
283
01eca64f77ab
Break out all the stuff that needs to be different for Debian into separate files
Paul Crowley <paul@lshift.net>
parents:
282
diff
changeset
|
49 |
|
01eca64f77ab
Break out all the stuff that needs to be different for Debian into separate files
Paul Crowley <paul@lshift.net>
parents:
282
diff
changeset
|
50 |
SCRIPTS=dev/chroot-test |
01eca64f77ab
Break out all the stuff that needs to be different for Debian into separate files
Paul Crowley <paul@lshift.net>
parents:
282
diff
changeset
|
51 |
|
01eca64f77ab
Break out all the stuff that needs to be different for Debian into separate files
Paul Crowley <paul@lshift.net>
parents:
282
diff
changeset
|
52 |
cp -v $SCRIPTS/policy-rc.d $BACKING/etc/policy-rc.d |
264
cd7f901d3902
Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
53 |
|
266
7cc208cbf2be
Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents:
265
diff
changeset
|
54 |
mkdir -p $BACKING/var/cache/apt/archives |
271 | 55 |
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
|
56 |
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
|
57 |
|
283
01eca64f77ab
Break out all the stuff that needs to be different for Debian into separate files
Paul Crowley <paul@lshift.net>
parents:
282
diff
changeset
|
58 |
cp -av $SCRIPTS/action $BACKING |
01eca64f77ab
Break out all the stuff that needs to be different for Debian into separate files
Paul Crowley <paul@lshift.net>
parents:
282
diff
changeset
|
59 |
. $SCRIPTS/copy-installables |
327
6f2a3f251d3b
Copy in and use environment vars to control test
Paul Crowley <paul@lshift.net>
parents:
311
diff
changeset
|
60 |
env | grep '^CHROOT_TEST_' > $BACKING/action/env || true |
266
7cc208cbf2be
Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents:
265
diff
changeset
|
61 |
|
7cc208cbf2be
Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents:
265
diff
changeset
|
62 |
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
|
63 |
|
6629144cf111
More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents:
264
diff
changeset
|
64 |
#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
|
65 |
#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
|
66 |
mount -t proc proc $MOUNT/proc |
264
cd7f901d3902
Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
67 |
|
cd7f901d3902
Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
68 |
chroot $MOUNT ./action/go |
310
38c222727017
Say something when all goes well.
Paul Crowley <paul@lshift.net>
parents:
308
diff
changeset
|
69 |
echo "Completed successfully" |