3 ### Construct a fresh build-chroot base
5 ### (c) 2018 Mark Wooding
8 ###----- Licensing notice ---------------------------------------------------
10 ### This file is part of the distorted.org.uk chroot maintenance tools.
12 ### distorted-chroot is free software: you can redistribute it and/or
13 ### modify it under the terms of the GNU General Public License as
14 ### published by the Free Software Foundation; either version 2 of the
15 ### License, or (at your option) any later version.
17 ### distorted-chroot is distributed in the hope that it will be useful,
18 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ### General Public License for more details.
22 ### You should have received a copy of the GNU General Public License
23 ### along with distorted-chroot. If not, write to the Free Software
24 ### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 . state/config.sh # @@@config@@@
29 case $PROXY in nil) ;; *) http_proxy=$PROXY; export PROXY ;; esac
32 while getopts "f" opt; do
38 shift $(( $OPTIND - 1 ))
39 case $# in 2) ;; *) badp=t ;; esac
40 case $badp in t) echo >&2 "usage: $0 [-f] DIST ARCH"; exit 2 ;; esac
43 case $d-$a in *-*-*) echo >&2 "$0: bad chroot name \`$arg'"; exit 2 ;; esac
44 if [ ! -d /dev/$VG/ ]; then echo >&2 "$0: no volume group \`$VG'"; exit 2; fi
47 for fa in $FOREIGN_ARCHS; do
50 qemup=t qbsopts=--foreign
51 eval qhost=\$${a}_QEMUARCH qhost=\$${a}_QEMUHOST
60 if mountpoint -q $mnt; then umount $mnt; fi
61 if [ -b /dev/$VG/$lv ]; then
63 nil) echo >&2 "$0: volume \`$lv' already exists"; exit 2 ;;
64 t) lvremove -f $VG/$lv ;;
67 lvcreate --yes $LVSZ -n$lv $VG
68 mkfs -j -L$d-$a /dev/$VG/$lv
69 mount -orelatime,data=writeback,commit=3600,barrier=0 /dev/$VG/$lv $mnt/
72 pkgs=ccache,eatmydata,fakeroot,libfile-fcntllock-perl,locales,tzdata
73 eatmydata debootstrap $dbsopts --arch=$a --variant=minbase \
74 --include=$pkgs $d $mnt/fs/ $DEBMIRROR
78 install $LOCAL/cross/$d-$qhost/QEMU/qemu-$qarch-static \
80 chroot $mnt/fs/ /debootstrap/debootstrap --second-stage
81 ln -sf /usr/local.schroot/cross/$d-$qhost/QEMU/qemu-$qarch-static \
87 rm -rf local/; ln -s local.schroot/$a local
90 rm -rf apt.conf sources.list
91 ln -s /usr/local.schroot/config/apt/conf.d/10sbuild apt.conf.d/
92 ln -s /usr/local.schroot/config/apt/conf.d/90local apt.conf.d/
93 ln -s /usr/local.schroot/config/apt/sources.$d sources.list
95 cat >apt.conf.d/20arch <<EOF
104 cp /etc/locale.gen /etc/timezone ./
105 tz=$(cat timezone); ln -sf /usr/share/zoneinfo/$tz localtime
106 ln -sf /proc/mounts mtab
108 cd $mnt/fs/etc/default/
109 cp /etc/default/locale .
112 cat >policy-rc.d <<EOF
114 echo >&2 "policy-rc.d: Services disabled by policy."
119 cd $mnt/fs/etc/ld.so.conf.d/
121 # libc default configuration
123 cat >zzz-local.conf <<EOF
125 ### Local hack to make /usr/local/ late.
134 schroot -uroot -csource:$LVPREFIX$d-$a -- eatmydata sh -e -c "
135 if dpkg-divert >/dev/null 2>&1 --no-rename --help
136 then no_rename=--no-rename
140 dpkg-divert --package install-cross-tools \$no_rename \
141 --divert /usr/bin/$qemu.$a --add /usr/bin/$qemu"
142 $STATE/bin/install-cross-tools $d $a
146 schroot -uroot -csource:$LVPREFIX$d-$a -- eatmydata sh -e -c '
151 apt-get -y autoremove
154 ###----- That's all, folks --------------------------------------------------