X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=mk-deb-chroot;h=3d43fefe183168efbe8cbcb259222ab73762f385;hb=bf7327ad43be743b85805a98eb40056cdeff75a1;hp=26c020cab08fdbffccbbea65eade7114ca17f4dc;hpb=1a75d04704ae89bfe0f29d03e0c697d94a98468a;p=dev-env-setup.git diff --git a/mk-deb-chroot b/mk-deb-chroot index 26c020c..3d43fef 100755 --- a/mk-deb-chroot +++ b/mk-deb-chroot @@ -14,13 +14,30 @@ if [ -e /opt/chroot/$chrootdir ]; then exit fi -echo "adding retries for debootstrap to not fail" -echo 'APT::Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries echo "Creating chroot dir '$chrootdir'" # Create coriolis chroot dir in /opt -mkdir /opt/chroot/$chrootdir +mkdir -p /opt/chroot/$chrootdir + +# argh apt with broken proxies and unreliable ISPs, getting fed up with it +if [ -e /tmp/brokenproxy ]; then + echo "Temp file containing apt proxy fix configuration already exists, skipping!" +else + cat </tmp/brokenproxy +APT::Acquire::Retries "20"; +APT::Get::Fix-Broken "true"; +Acquire::http::Pipeline-Depth "0"; +Acquire::http::No-Cache=True; +Acquire::BrokenProxy=true; +EOF +fi + +if [ -e /etc/apt/apt.conf.d/80-retries ]; then + echo "Host system apt.conf.d already has 80-retries, skipping!" +else + cp /tmp/brokenproxy /etc/apt/apt.conf.d/80-retries +fi # Install debootstrap and schroot if [ -e /etc/debian_version ]; then @@ -31,7 +48,8 @@ elif [ -e /etc/arch-release ]; then pacman -S --needed debootstrap schroot fi -# Install debian/buster chroot using debootstrap +# Install debian/buster chroot using debootstrap, +# any /etc/ config must be done after this point! /usr/sbin/debootstrap buster /opt/chroot/$chrootdir \ http://ftp.uk.debian.org/debian echo "$chrootdir" > /opt/chroot/$chrootdir/etc/debian_chroot @@ -41,36 +59,50 @@ mkdir -p /etc/schroot/$chrootdir cp /etc/schroot/default/copyfiles /etc/schroot/$chrootdir touch /etc/schroot/$chrootdir/nssdatabases +# Copy over brokenproxy apt script to the new chroot environment +cp /tmp/brokenproxy /opt/chroot/$chrootdir/etc/apt/apt.conf.d/80-retries + # create special fstab not bind-mounting /home -cat </etc/schroot/$chrootdir/fstab +schroot_fstab=" # /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 </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 <>/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 <>/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' @@ -79,19 +111,20 @@ 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 \ + python3-setuptools-scm # yeah systemd in a chroot? not very funny joke. apt-get remove -y systemd