summaryrefslogtreecommitdiff
path: root/network/netqmail/tests/makechroot
diff options
context:
space:
mode:
authorDuncan Roe <duncan_roe@optusnet.com.au>2017-06-22 17:26:08 +0700
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2017-06-24 08:32:21 +0700
commit888ec031aca7e4f81a72497f9ebc0259e07621cb (patch)
tree0fcfcba8c18643f6a6111d70b341326312acc27e /network/netqmail/tests/makechroot
parenta8e78c52c72b342c5436f5ff39148a3f2e68f7ee (diff)
downloadslackbuilds-888ec031aca7e4f81a72497f9ebc0259e07621cb.tar.gz
network/netqmail: Added (the qmail MTA).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network/netqmail/tests/makechroot')
-rw-r--r--network/netqmail/tests/makechroot74
1 files changed, 74 insertions, 0 deletions
diff --git a/network/netqmail/tests/makechroot b/network/netqmail/tests/makechroot
new file mode 100644
index 0000000000..06435ef2d3
--- /dev/null
+++ b/network/netqmail/tests/makechroot
@@ -0,0 +1,74 @@
+#!/bin/sh
+#set -x
+
+# A function to make a file local (not hard-linked to the real file)
+# One should run this on any file that the test might modify
+make_local()
+{
+ while [ $# -gt 0 ]
+ do
+ cp -a $CHROOT/$1 $CHROOT/$1.new
+ mv $CHROOT/$1.new $CHROOT/$1
+ shift
+ done
+}
+
+CHROOT=${CHROOT:-/tmp/t5}
+VERBOSE_ADDCHROOT=${VERBOSE_ADDCHROOT:-true}
+export VERBOSE_ADDCHROOT
+PKGDIR=${PKGDIR:-/usr/packages}
+[ -n "$MKCHROOT_IGNORE_LN_ERRORS" ] && LNE='2>/dev/null' || LNE=
+
+# These are options
+INSTALL_DAEMONTOOLS=${INSTALL_DAEMONTOOLS:-no}
+STRIP_INITTAB_SV=${STRIP_INITTAB_SV:-yes}
+STRIP_QMAIL_USERS_GROUPS=${STRIP_QMAIL_USERS_GROUPS:-yes}
+
+[ ! -d $CHROOT/proc/1 ] || umount $CHROOT/proc
+rm -rf $CHROOT
+mkchroot $CHROOT
+addchroot $CHROOT tar pkgtools
+mkdir -p $CHROOT$PKGDIR
+eval ln $PKGDIR/netqmail* $PKGDIR/daemontools* $CHROOT$PKGDIR $LNE \|\| \
+ cp -a $PKGDIR/netqmail* $PKGDIR/daemontools* $CHROOT$PKGDIR
+addchroot $CHROOT ucspi-tcp mkchroot
+
+# Set up Slackware install DB for mkchroot
+for i in packages scripts
+do
+ mkdir $CHROOT/var/log/$i
+ (cd /var/log/$i; ls -1 | while read j; do [ -d $j ] ||
+ eval ln $j $CHROOT/var/log/$i $LNE \|\| cp -a $j $CHROOT/var/log/$i; done)
+done
+
+addchroot $CHROOT etc
+make_local etc/{group,gshadow,passwd,shadow}
+addchroot $CHROOT sysvinit
+addchroot $CHROOT sysvinit-scripts
+make_local etc/inittab
+[ $STRIP_INITTAB_SV != yes ] ||
+{
+ cat $CHROOT/etc/inittab | grep -E -v '^SV:' >$CHROOT/etc/inittab.new
+ mv $CHROOT/etc/inittab.new $CHROOT/etc/inittab
+}
+addchroot $CHROOT sed util-linux gzip network-scripts shadow ncurses
+mkdir $CHROOT/root $CHROOT/proc
+[ $INSTALL_DAEMONTOOLS = no ] || addchroot $CHROOT daemontools
+
+[ $STRIP_QMAIL_USERS_GROUPS != yes ] ||
+{
+ mount -tproc proc $CHROOT/proc
+
+ for i in alias qmail{d,l,p,q,r,s}
+ do
+ grep -q ^$i: $CHROOT/etc/passwd && chroot $CHROOT userdel $i
+ done
+ for i in nofiles qmail
+ do
+ grep -q ^$i: $CHROOT/etc/group && chroot $CHROOT groupdel $i
+ done
+ umount $CHROOT/proc
+}
+
+# inst_check needs these
+addchroot $CHROOT procps-ng gawk net-tools