ftp.debian.org not being reliable redirection, changing to
[dev-env-setup.git] / mk-deb-chroot
index 19515712d9c0ce0c4ece768431c0d0205cd03c66..53d2131ce907dae6ab004fbbea75dc0bd7b8191b 100755 (executable)
@@ -23,7 +23,8 @@ mkdir -p /opt/chroot/$chrootdir
 # Install debootstrap and schroot via apt
 apt install -y debootstrap schroot
 # Install debian/buster chroot using debootstrap
-/usr/sbin/debootstrap buster /opt/chroot/$chrootdir http://ftp.debian.org/debian
+/usr/sbin/debootstrap buster /opt/chroot/$chrootdir \
+                      https://ftp.uk.debian.org/debian
 # Mount all chroot mount points from fstab
 mount /opt/chroot/$chrootdir/dev
 mount /opt/chroot/$chrootdir/dev/pts
@@ -31,6 +32,7 @@ mount /opt/chroot/$chrootdir/proc
 mount /opt/chroot/$chrootdir/sys
 mount /opt/chroot/$chrootdir/tmp
 echo "$chrootdir" > /opt/chroot/$chrootdir/etc/debian_chroot
+
 # Install apt dependencies in the chroot
 chroot /opt/chroot/$chrootdir /bin/bash << EOF
 echo Installing necessary apt dependencies in the chroot
@@ -39,9 +41,12 @@ 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 python-dev 
+python3-setuptools python3-dev
 
 # yeah systemd in a chroot? not very funny joke.
 apt-get remove -y systemd
@@ -50,10 +55,15 @@ apt-get remove -y systemd
 echo '$SUDO_USER ALL=NOPASSWD: ALL' >> /etc/sudoers.d/$chrootdir
 
 # Create user with same UID in the chroot
-useradd -m -p `python -c 'import crypt; print crypt.crypt("1234","Fx")'` -s /bin/bash $SUDO_USER -k /etc/skel
+useradd -m -p `python3 -c 'import crypt; print (crypt.crypt("1234","Fx"))'` \
+                -s /bin/bash $SUDO_USER -k /etc/skel
 echo -e "
 Added user ${SUDO_USER} with \e[1;91mpassword: 1234\e[0m"
 
+# add deb-src to sources
+echo deb-src http://ftp.debian.org/debian buster main > \
+        /etc/apt/sources.list.d/bustersrc.list
+
 echo -e "
 \e[1;91mPlease use command 'passwd ${SUDO_USER}' to change this immediately after this script is run for security purposes.\e[0m
 "