iglunix-autobuild/chroot_prepare_iglunix
2021-03-29 19:57:25 +02:00

131 lines
2.9 KiB
Bash
Executable file

#! /bin/bash
if [ "$#" -ne 1 ]; then
echo "You must enter exactly the container id of the docker in which the compilation took place. (the client not the volunteers)"
echo "This can be false, then the builds fodler will be used."
echo "The builds folder is a folder where llvm, musl, musl-dev, bmake can reside which will can be used instead of the automatic docker cp mechanism."
exit -1
fi
#Unmount the mounts
sudo umount root/tmp/
sudo umount root/proc/
sudo umount root/sys/
sudo mount --make-rprivate root/dev/
sudo umount -l root/dev/
#Delete everything!
#umout has problems :(
# Just delete a couple of this ot clean it..
#sudo rm -r -f ./root
if true; then
sudo rm -rf ./root/lib
sudo rm -rf ./root/bin
sudo rm -rf ./root/sbin
sudo rm -rf ./root/usr
sudo rm -rf ./root/iglunix
sudo rm -rf ./root/etc
fi
mkdir root
mkdir root/bin
mkdir root/sbin
mkdir root/usr
mkdir root/usr/sbin
mkdir root/etc
docker cp $1:/iglunix/pkgs/llvm/out/llvm.11.0.1.tar.xz ./root/llvm.tar.xz
docker cp $1:/iglunix/pkgs/musl/out/musl-dev.1.2.2.tar.xz ./root/musl-dev.tar.xz
docker cp $1:/iglunix/pkgs/musl/out/musl.1.2.2.tar.xz ./root/musl.tar.xz
docker cp $1:/iglunix/pkgs/bmake/out/bmake.20210110.tar.xz ./root/bmake.tar.xz
cp ./builds/* ./root/
cd ./root
ROOT=$(pwd)
tar -xf musl.tar.xz -C ./
tar -xf musl-dev.tar.xz -C ./
tar -xf llvm.tar.xz -C ./
tar -xf bmake.tar.xz -C ./
#---
rm ./busybox-x86_64
wget -nc -q https://busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-x86_64
chmod +x ./busybox-x86_64
mv busybox-x86_64 ./bin/busybox
rm ./toybox-x86_64
wget -nc -q http://landley.net/toybox/bin/toybox-x86_64
chmod +x ./toybox-x86_64
mv toybox-x86_64 ./bin/toybox
echo ""
#---
git clone https://github.com/iglunix/iglunix.git
#----
# Mount some things, we'll need it later
mkdir proc
mkdir sys
mkdir dev
mkdir tmp
echo "mounted tmp, proc, sysfs, rbind"
# We'll need to compile mksh
# But we don't have tools to get the sources from inside the chroot yet..
cd ..
echo "Starting chroot_fetch"
./chroot_fetch
echo "Need to compile a lex file in om4, because of a circular dependency with flex"
#For the other attempt at fixing this circular dependency see inside_chroot
cd ${ROOT}/iglunix/pkgs/om4/src/om4-*/
lex ./tokenizer.l
sudo chroot ${ROOT} /bin/busybox --install -s
echo "installed busybox"
printf "export PATH=/usr/sbin:/usr/bin:/sbin:/bin:\nexport JOBS=16\n" > ${ROOT}/etc/iglupkg.conf
echo "---------------------------------"
echo " Kayboard configuration"
echo "---------------------------------"
echo "Copying host keymap"
cp /etc/vconsole.conf ${ROOT}/etc/vconsole.conf
echo "---------------------------------"
echo "Starting networking configuration"
echo "---------------------------------"
RANDOM=$$
HOSTNAME="iglunix-$RANDOM"
echo "Hostname: ${HOSTNAME}"
mkdir ${ROOT}/etc
echo "$HOSTNAME" > ${ROOT}/etc/hostname
echo "Finished prepare_chroot_lazy"