2018-04-26 15:50:46 +02:00
#!/bin/bash
2020-05-07 17:11:46 +02:00
# For some reason, building chroots for buster from stretch requires libdebian-installer4 0.119 instead of 0.110, c.f. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=904699 ... installed it by manually downloading and dpkg -i the .deb
2020-02-07 23:24:00 +01:00
readonly DISTRIB=buster
2018-04-26 15:50:46 +02:00
readonly INIT_DIR=$PWD
2020-05-11 03:33:27 +02:00
readonly ARCHS="amd64"
2020-05-07 17:11:46 +02:00
#readonly ARCHS="i386 armhf armel arm64"
2020-05-11 03:33:27 +02:00
#readonly ARCHS="arm64"
2018-04-26 15:50:46 +02:00
function main()
{
for ARCH in $ARCHS
do
2020-05-07 17:11:46 +02:00
build_chroot $ARCH
2018-04-26 15:50:46 +02:00
done
}
2020-05-07 17:11:46 +02:00
function build_chroot()
2018-04-26 15:50:46 +02:00
{
local ARCH=$1
local CHROOT=chroot-${DISTRIB}-${ARCH}
2018-04-26 18:17:56 +02:00
echo ""
echo "Starting build for $ARCH"
echo ""
2018-04-26 15:50:46 +02:00
cd /tmp/
cdebootstrap --arch=${ARCH} --foreign ${DISTRIB} ./$CHROOT http://deb.debian.org/debian/
cp /usr/bin/qemu-arm-static $CHROOT/usr/bin/
cp /usr/bin/qemu-aarch64-static $CHROOT/usr/bin/
cp /etc/resolv.conf $CHROOT/etc/resolv.conf
2020-02-07 23:24:00 +01:00
chroot $CHROOT apt update
chroot $CHROOT apt dist-upgrade
2020-05-11 03:33:27 +02:00
chroot $CHROOT apt install -y build-essential debhelper cmake wget devscripts git
2018-04-26 18:36:13 +02:00
if [ "$ARCH" == "amd64" ];
then
2020-05-11 04:24:44 +02:00
# This is for building yunohost-admin
chroot $CHROOT apt install -y npm nodejs
2020-08-31 16:24:03 +02:00
# Don't ask me why, but stupid nodejs wants to look for stuff inside /lib instead of /usr/lib ...
# This only happens when building those chroot ... I don't know why ...
chroot $CHROOT ln -s /usr/lib/nodejs /lib/nodejs
chroot $CHROOT npm install -g npm
2018-04-26 18:36:13 +02:00
fi
2018-04-26 15:50:46 +02:00
2020-02-07 23:24:00 +01:00
chroot $CHROOT apt clean
2018-04-26 15:50:46 +02:00
cd $CHROOT
2020-02-12 21:28:58 +01:00
echo "Now creating tarball with the filesystem ..."
2018-04-26 15:50:46 +02:00
tar -czf $INIT_DIR/${DISTRIB}-${ARCH}.tgz ./*
2018-04-26 18:17:56 +02:00
echo ""
2020-05-07 17:11:46 +02:00
echo "Output chroot archive should be available as $INIT_DIR/${DISTRIB}-${ARCH}.tgz"
2018-04-26 18:17:56 +02:00
echo ""
2018-04-26 15:50:46 +02:00
}
main