cp-scripts-to-chroot.sh: New script for copying this repo's scripts over to specified...
[dev-env-setup.git] / mk-deb-chroot
index c432d3f2ac35fed378e2657bd3ec85872b80760f..1c67729b66736ed8105f688c9894aa096a2ee780 100755 (executable)
@@ -63,35 +63,46 @@ cp /etc/schroot/default/copyfiles /etc/schroot/$chrootdir
 touch /etc/schroot/$chrootdir/nssdatabases
 
 # create special fstab not bind-mounting /home
-cat <<EOF >/etc/schroot/$chrootdir/fstab
+schroot_fstab="
 # <file system> <mount point>   <type>  <options>       <dump>  <pass>
 /proc           /proc           none    rw,bind         0       0
 /sys            /sys            none    rw,bind         0       0
 /dev            /dev            none    rw,bind         0       0
 /dev/pts        /dev/pts        none    rw,bind         0       0
 /tmp            /tmp            none    rw,bind         0       0
+"
+
+cat <<EOF >/etc/schroot/$chrootdir/fstab
+$schroot_fstab
 EOF
 
-if grep -x "\[$chrootdir\]" /etc/schroot/schroot.conf; then
-    echo "Found [$chrootdir] section in /etc/schroot/schroot.conf"
-else
-    # Add chroot config to schroot.conf
-    cat <<EOF >>/etc/schroot/schroot.conf
+echo "Adding the following fstab mounts to /etc/schroot/$chrootdir/fstab:
+
+$schroot_fstab
+
+These rules are for the virtual filesystems used by linux in the chroot env
+"
+
+schroot_profile="
 [$chrootdir]
 description=Debian Buster for $chrootdir
 directory=/opt/chroot/$chrootdir
 groups=sbuild-security,$SUDO_USER,users
 type=directory
 profile=$chrootdir
+"
+
+if grep -x "\[$chrootdir\]" /etc/schroot/schroot.conf; then
+    echo "Found [$chrootdir] section in /etc/schroot/schroot.conf"
+else
+    # Add chroot config to schroot.conf
+    cat <<EOF >>/etc/schroot/schroot.conf
+$schroot_profile
 EOF
 
     echo "Adding the following $chrootdir section to /etc/schroot/schroot.conf:
 
-[$chrootdir]
-description=Debian Buster for $chrootdir
-directory=/opt/chroot/$chrootdir
-groups=sbuild-security,$SUDO_USER,users
-type=directory
+$schroot_profile
 
 This enables you to chroot into $chrootdir as an unprivileged user by running
 'schroot -c $chrootdir /bin/bash'
@@ -100,19 +111,19 @@ fi
 
 # Install apt dependencies in the chroot
 cd /tmp
-schroot -c $chrootdir /bin/bash << EOF
+schroot -c $chrootdir /bin/bash --directory=/tmp << EOF
 echo Installing necessary apt dependencies in the chroot
 apt-get update -y
 apt-get upgrade -y
 apt-get install -y automake binutils-dev build-essential \
-ccache cmake gcc git \
-libtool \
-sysvinit-core \
-sysvinit-utils \
-sudo \
-python2.7 \
-python3 python3-pip \
-python3-setuptools python3-dev
+        ccache cmake gcc git \
+        libtool \
+        sysvinit-core \
+        sysvinit-utils \
+        sudo \
+        python2.7 \
+        python3 python3-pip \
+        python3-setuptools python3-dev
 
 # yeah systemd in a chroot? not very funny joke.
 apt-get remove -y systemd