3 then echo "Please run as root"
7 then echo "need arg $1 for chroot to make"
11 echo "creating chroot '$chrootdir'"
13 # Create coriolis chroot dir in /opt
14 mkdir
-p /opt
/chroot
/$chrootdir
15 # Install debootstrap and schroot via apt
16 apt
install -y debootstrap schroot
17 # Install debian/buster chroot using debootstrap
18 /usr
/sbin
/debootstrap buster
/opt
/chroot
/$chrootdir \
19 http
://ftp.uk.debian.org
/debian
20 echo "$chrootdir" > /opt
/chroot
/$chrootdir/etc
/debian_chroot
23 mkdir
-p /etc
/schroot
/$chrootdir
24 cp /etc
/schroot
/default
/copyfiles
/etc
/schroot
/$chrootdir
25 touch /etc
/schroot
/$chrootdir/nssdatabases
27 # create special fstab not bind-mounting /home
28 cat <<EOF >/etc/schroot/$chrootdir/fstab
29 # <file system> <mount point> <type> <options> <dump> <pass>
30 /proc /proc none rw,bind 0 0
31 /sys /sys none rw,bind 0 0
32 /dev /dev none rw,bind 0 0
33 /dev/pts /dev/pts none rw,bind 0 0
34 /tmp /tmp none rw,bind 0 0
37 # Add chroot config to schroot.conf
38 cat <<EOF >>/etc/schroot/schroot.conf
40 description=Debian Buster for $chrootdir
41 directory=/opt/chroot/$chrootdir
42 groups=sbuild-security,$SUDO_USER,users
47 echo "Adding the following $chrootdir section to /etc/schroot/schroot.conf:
50 description=Debian Buster for $chrootdir
51 directory=/opt/chroot/$chrootdir
52 groups=sbuild-security,$SUDO_USER,users
55 This enables you to chroot into $chrootdir as an unprivileged user by running
56 'schroot -c $chrootdir /bin/bash'
59 # Install apt dependencies in the chroot
61 schroot
-c $chrootdir /bin
/bash
<< EOF
62 echo Installing necessary apt dependencies in the chroot
65 apt-get install -y automake binutils-dev build-essential \
66 ccache cmake gcc git \
73 python3-setuptools python3-dev
75 # yeah systemd in a chroot? not very funny joke.
76 apt-get remove -y systemd
78 # add sudo no password
79 echo '$SUDO_USER ALL=NOPASSWD: ALL' >> /etc/sudoers.d/$chrootdir
81 # Create user with same UID in the chroot
82 useradd -m -p `python3 -c 'import crypt; print (crypt.crypt("1234","Fx"))'` \
83 -s /bin/bash $SUDO_USER -k /etc/skel
85 Added user ${SUDO_USER} with \e[1;91mpassword: 1234\e[0m"
87 # add deb-src to sources
88 echo deb-src http://ftp.debian.org/debian buster main > \
89 /etc/apt/sources.list.d/bustersrc.list
92 \e[1;91mPlease use command 'passwd ${SUDO_USER}' to change this immediately after this script is run for security purposes.\e[0m
95 # Add convenience variable to chroot user .bash_profile
96 echo -e 'export PATH=/usr/lib/ccache:"\044PATH"\nexport DISPLAY=:0.0\n' > /home/$SUDO_USER/.bash_profile
97 chown $SUDO_USER /home/$SUDO_USER/.bash_profile
98 chgrp $SUDO_USER /home/$SUDO_USER/.bash_profile
100 echo -e "Added 'export PATH=/usr/lib/ccache:\"\044PATH\"\nexport DISPLAY=:0.0' to /home/$SUDO_USER/.bash_profile to speed up rebuilds"