#! /bin/sh -e ### ### Construct a fresh build-chroot base ### ### (c) 2018 Mark Wooding ### ###----- Licensing notice --------------------------------------------------- ### ### This file is part of the distorted.org.uk chroot maintenance tools. ### ### distorted-chroot is free software: you can redistribute it and/or ### modify it under the terms of the GNU General Public License as ### published by the Free Software Foundation; either version 2 of the ### License, or (at your option) any later version. ### ### distorted-chroot is distributed in the hope that it will be useful, ### but WITHOUT ANY WARRANTY; without even the implied warranty of ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ### General Public License for more details. ### ### You should have received a copy of the GNU General Public License ### along with distorted-chroot. If not, write to the Free Software ### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ### USA. . state/config.sh # @@@config@@@ ## Convert the PROXY configuration setting into something that will affect ## `debootstrap'. case $PROXY in nil) ;; *) http_proxy=$PROXY; export PROXY ;; esac ## Parse the command-line. badp=nil forcep=nil while getopts "f" opt; do case $opt in f) forcep=t ;; *) badp=t ;; esac done shift $(( $OPTIND - 1 )) case $# in 2) ;; *) badp=t ;; esac case $badp in t) echo >&2 "usage: $0 [-f] DIST ARCH"; exit 2 ;; esac d=$1 a=$2 case $d-$a in *-*-*) echo >&2 "$0: bad chroot name \`$arg'"; exit 2 ;; esac if [ ! -d /dev/$VG/ ]; then echo >&2 "$0: no volume group \`$VG'"; exit 2; fi ## Decide whether we need to do special things for installing a foreign ## architecture. qemup=nil dbsopts= for fa in $FOREIGN_ARCHS; do case $fa in "$a") qemup=t dbsopts=--foreign eval qarch=\$${a}_QEMUARCH qhost=\$${a}_QEMUHOST break ;; esac done ## Construct the logical volume and lay a filesystem onto it. lv=$LVPREFIX$d-$a mnt=$HERE/mnt/$lv mkdir -p $mnt if mountpoint -q $mnt; then umount $mnt; fi if [ -b /dev/$VG/$lv ]; then case $forcep in nil) echo >&2 "$0: volume \`$lv' already exists"; exit 2 ;; t) lvremove -f $VG/$lv ;; esac fi lvcreate --yes $LVSZ -n$lv $VG mkfs -j -L$d-$a /dev/$VG/$lv mount -orelatime,data=writeback,commit=3600,barrier=0 /dev/$VG/$lv $mnt/ mkdir -m755 $mnt/fs/ chmod 750 $mnt/ ## Install the base system. want=$BASE_PACKAGES case $qemup in t) want="$want $FOREIGN_BASE_PACKAGES" ;; nil) want="$want $NATIVE_BASE_PACKAGES" ;; esac pkgs=; for p in $want; do pkgs=${pkgs:+$pkgs,}$p; done eatmydata debootstrap $dbsopts --arch=$a --variant=minbase \ --include=$pkgs $d $mnt/fs/ $DEBMIRROR ## If this is a cross-installation, then install the necessary `qemu' and ## complete the installation. case $qemup in t) install $LOCAL/cross/$d-$qhost/QEMU/qemu-$qarch-static \ $mnt/fs/usr/bin/ chroot $mnt/fs/ /debootstrap/debootstrap --second-stage ln -sf /usr/local.schroot/cross/$d-$qhost/QEMU/qemu-$qarch-static \ $mnt/fs/usr/bin/ ;; esac ## Set up `/usr/local'. rm -rf $mnt/fs/usr/local/; ln -s local.schroot/$a $mnt/fs/usr/local ## Install the `apt' configuration. rm -rf $mnt/fs/etc/apt/apt.conf $mnt/fs/etc/apt/sources.list for c in $LOCAL/etc/apt/apt.conf.d/*; do ln -s /usr/local.schroot/${c#$LOCAL/} $mnt/fs/etc/apt/apt.conf.d/ done ln -s /usr/local.schroot/etc/apt/sources.$d $mnt/fs/etc/apt/sources.list cat >$mnt/fs/etc/apt/apt.conf.d/20arch <$mnt/fs/usr/sbin/policy-rc.d <&2 "policy-rc.d: Services disabled by policy." exit 101 EOF chmod +x $mnt/fs/usr/sbin/policy-rc.d ## Hack the dynamic linker to prefer libraries in `/usr' over `/usr/local'. cat >$mnt/fs/etc/ld.so.conf.d/libc.conf <$mnt/fs/etc/ld.so.conf.d/zzz-local.conf </dev/null 2>&1 --no-rename --help then no_rename=--no-rename else no_rename= fi dpkg-divert --package install-cross-tools \$no_rename \ --divert /usr/bin/qemu-$qarch-static.$a --add /usr/bin/qemu-$qarch-static" ## Install faster native tools. $STATE/bin/install-cross-tools $d $a ## Install `build-essential', which had been delayed from earlier. schroot -uroot -csource:$LVPREFIX$d-$a -- \ eatmydata apt-get -y install build-essential ;; esac ## Set the chroot's package state up properly. schroot -uroot -csource:$LVPREFIX$d-$a -- eatmydata sh -e -c ' apt-get update apt-get -y upgrade locale-gen ldconfig apt-get -y autoremove apt-get clean' ###----- That's all, folks --------------------------------------------------