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
22 # Install apt dependencies in the chroot
23 chroot
/opt
/chroot
/$chrootdir /bin
/bash
<< EOF
24 echo Installing necessary apt dependencies in the chroot
27 apt-get install -y automake binutils-dev build-essential \
28 ccache cmake gcc git \
35 python3-setuptools python3-dev
37 # yeah systemd in a chroot? not very funny joke.
38 apt-get remove -y systemd
40 # add sudo no password
41 echo '$SUDO_USER ALL=NOPASSWD: ALL' >> /etc/sudoers.d/$chrootdir
43 # Create user with same UID in the chroot
44 useradd -m -p `python3 -c 'import crypt; print (crypt.crypt("1234","Fx"))'` \
45 -s /bin/bash $SUDO_USER -k /etc/skel
47 Added user ${SUDO_USER} with \e[1;91mpassword: 1234\e[0m"
49 # add deb-src to sources
50 echo deb-src http://ftp.debian.org/debian buster main > \
51 /etc/apt/sources.list.d/bustersrc.list
54 \e[1;91mPlease use command 'passwd ${SUDO_USER}' to change this immediately after this script is run for security purposes.\e[0m
57 # Add convenience variable to chroot user .bash_profile
58 echo -e 'export PATH=/usr/lib/ccache:"\044PATH"\nexport DISPLAY=:0.0\n' > /home/$SUDO_USER/.bash_profile
59 chown $SUDO_USER /home/$SUDO_USER/.bash_profile
60 chgrp $SUDO_USER /home/$SUDO_USER/.bash_profile
62 echo -e "Added 'export PATH=/usr/lib/ccache:\"\044PATH\"\nexport DISPLAY=:0.0' to /home/$SUDO_USER/.bash_profile to speed up rebuilds"
65 # Add chroot config to schroot.conf
66 cat <<EOF >>/etc/schroot/schroot.conf
68 description=Debian Buster for $chrootdir
69 directory=/opt/chroot/$chrootdir
70 groups=sbuild-security,$SUDO_USER,users
74 echo "Adding the following $chrootdir section to /etc/schroot/schroot.conf:
77 description=Debian Buster for $chrootdir
78 directory=/opt/chroot/$chrootdir
79 groups=sbuild-security,$SUDO_USER,users
82 This enables you to chroot into $chrootdir as an unprivileged user by running
83 'schroot -c $chrootdir /bin/bash'