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