2024-05-19 19:04:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
docker_scripts_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
scripts_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
|
|
|
|
. ${scripts_path}/vars.sh
|
|
|
|
|
|
|
|
# Exports
|
|
|
|
export PATH=${build_path}/toolchain/${toolchain_bin_path}:${PATH}
|
|
|
|
export GCC_COLORS=auto
|
|
|
|
export CROSS_COMPILE=${toolchain_cross_compile}
|
|
|
|
export ARCH=arm64
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
export DEBCONF_NONINTERACTIVE_SEEN=true
|
|
|
|
|
|
|
|
# CD into our rootfs mount, and starts the fun!
|
|
|
|
cd ${build_path}/rootfs
|
|
|
|
debootstrap --no-check-gpg --foreign --arch=${deb_arch} --include=apt-transport-https ${deb_release} ${build_path}/rootfs ${deb_mirror}
|
|
|
|
cp /usr/bin/qemu-aarch64-static usr/bin/
|
|
|
|
chroot ${build_path}/rootfs /debootstrap/debootstrap --second-stage
|
|
|
|
|
2024-05-30 22:42:12 +00:00
|
|
|
# Copy over our kernel modules and kernel from the FS image
|
|
|
|
# Note that in the future, we wanna use our own kernel, but the current GPL is way too old!!!!!
|
|
|
|
mv -f "${build_path}/fw-extract/rootfs/lib/modules" "${build_path}/rootfs/lib"
|
2024-05-19 19:04:59 +00:00
|
|
|
cp "${build_path}/fw-extract/kernel.bin" "${build_path}/rootfs/boot/uImage"
|
|
|
|
|
2024-05-30 22:42:12 +00:00
|
|
|
# Now, for the old kernel we built, pull in btrfs + depends modules (we do depmod in bootstrap)
|
|
|
|
cp "${build_path}/kernel/kernel-modules/lib/modules/4.19.152-alpine-unvr/kernel/lib/zstd/zstd_compress.ko" "${build_path}/rootfs/lib/modules/4.19.152-alpine-unvr/extra/"
|
|
|
|
cp "${build_path}/kernel/kernel-modules/lib/modules/4.19.152-alpine-unvr/kernel/fs/btrfs/btrfs.ko" "${build_path}/rootfs/lib/modules/4.19.152-alpine-unvr/extra/"
|
|
|
|
|
2024-05-19 19:04:59 +00:00
|
|
|
# Copy over our overlay if we have one
|
|
|
|
if [[ -d ${root_path}/overlay/${fs_overlay_dir}/ ]]; then
|
|
|
|
echo "Applying ${fs_overlay_dir} overlay"
|
|
|
|
cp -R ${root_path}/overlay/${fs_overlay_dir}/* ./
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Apply our part UUIDs to fstab
|
|
|
|
sed -i "s|BOOTUUIDPLACEHOLDER|$(blkid -o value -s UUID ${build_path}/boot.ext4)|g" ${build_path}/rootfs/etc/fstab
|
|
|
|
sed -i "s|ROOTUUIDPLACEHOLDER|$(blkid -o value -s UUID ${build_path}/rootfs.ext4)|g" ${build_path}/rootfs/etc/fstab
|
|
|
|
|
|
|
|
# Hostname
|
|
|
|
echo "${distrib_name}" > ${build_path}/rootfs/etc/hostname
|
|
|
|
echo "127.0.1.1 ${distrib_name}" >> ${build_path}/rootfs/etc/hosts
|
|
|
|
|
|
|
|
# Console settings
|
|
|
|
echo "console-common console-data/keymap/policy select Select keymap from full list
|
|
|
|
console-common console-data/keymap/full select us
|
|
|
|
" > ${build_path}/rootfs/debconf.set
|
|
|
|
|
|
|
|
# Copy over stuff for ulcmd, this is hacky, but that's this ENTIRE repo for you
|
2024-05-19 20:15:09 +00:00
|
|
|
mv "${build_path}/fw-extract/rootfs/usr/bin/ulcmd" "${build_path}/rootfs/usr/bin/ulcmd" # LCD controller
|
|
|
|
mv "${build_path}/fw-extract/rootfs/usr/share/firmware" "${build_path}/rootfs/usr/share/" # LCD panel firmwares
|
|
|
|
mkdir -p "${build_path}/rootfs/usr/lib/ubnt-fw/" # Home for ulcmd libraries
|
2024-05-19 19:04:59 +00:00
|
|
|
for file in libgrpc++.so.1 libgrpc.so.10 libprotobuf.so.23 \
|
|
|
|
libssl.so.1.1 libcrypto.so.1.1 libabsl*.so.20200923 libatomic.so.1; do
|
2024-05-19 20:15:09 +00:00
|
|
|
cp -H ${build_path}/fw-extract/rootfs/usr/lib/aarch64-linux-gnu/${file} "${build_path}/rootfs/usr/lib/ubnt-fw/"
|
2024-05-19 19:04:59 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Kick off bash setup script within chroot
|
|
|
|
cp ${docker_scripts_path}/bootstrap/001-bootstrap ${build_path}/rootfs/bootstrap
|
|
|
|
chroot ${build_path}/rootfs /bootstrap
|
|
|
|
rm ${build_path}/rootfs/bootstrap
|
|
|
|
|
|
|
|
# Final cleanup
|
2024-05-27 17:30:17 +00:00
|
|
|
rm ${build_path}/rootfs/usr/bin/qemu-aarch64-static
|