#!/usr/bin/env bash set -e echo "* Build Step: Creating the initramfs image... *" echo "* On platform: $(uname -m)" export ROOTFS=/build/rootfs export BUSYBOX_PKG=busybox-1.32.1 source /buildmeta/buildconfig.sh mkdir -pv /build/rootfs ls -l /artifacts cd /build #mkdir -pv $ROOTFS/{usr/sbin,usr/bin,sbin,bin,dev,etc,mnt/root,mnt/live,proc,sys,lib/modules} # #wget https://busybox.net/downloads/${BUSYBOX_PKG}.tar.bz2 #tar xvf ${BUSYBOX_PKG}.tar.bz2 # #pushd . #cd $BUSYBOX_PKG #cp -v /build-scripts/files/busybox-config .config ## todo switch to musl (needed for dns too) ## or add glibc #LDFLAGS="--static" make -j$(nproc) #mv ./busybox $ROOTFS/bin #chroot $ROOTFS /bin/busybox --install -s #popd if [[ "$PROLINUX_ARCH" == "aarch64" ]]; then wget https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/aarch64/alpine-minirootfs-3.15.0-aarch64.tar.gz cd $ROOTFS tar xvf /build/alpine-minirootfs-3.15.0-aarch64.tar.gz else wget https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-minirootfs-3.15.0-x86_64.tar.gz cd $ROOTFS tar xvf /build/alpine-minirootfs-3.15.0-x86_64.tar.gz fi mkdir -pv mnt/root mnt/live mnt/data cd .. echo "* Build Step: Entering chroot... *" mount -t proc /proc $ROOTFS/proc/ mount -t sysfs /sys $ROOTFS/sys/ mount --rbind /dev $ROOTFS/dev/ cp /etc/resolv.conf $ROOTFS/etc/resolv.conf chroot $ROOTFS /bin/sh <<"EOT" apk update apk add lvm2 bash util-linux EOT umount --recursive $ROOTFS/proc/ umount --recursive $ROOTFS/sys/ umount --recursive $ROOTFS/dev/ rm $ROOTFS/etc/resolv.conf cp /build-scripts/files/init $ROOTFS/ cp /build-scripts/files/bootsplash.ppm $ROOTFS/ cp /build-scripts/files/bootsplash-pinephone.ppm $ROOTFS/ if [[ "$PROLINUX_ARCH" == "aarch64" ]]; then cd $ROOTFS find . -print0 | cpio --null --create --verbose --format=newc | gzip --best > /artifacts/aarch64/sineware-initramfs.cpio.gz echo "Done!" else echo "* Adding Kernel Modules" pushd . cd $ROOTFS if test -f "/artifacts/linux-modules.tar.gz"; then tar xvf /artifacts/linux-modules.tar.gz fi popd cd $ROOTFS find . -print0 | cpio --null --create --verbose --format=newc | gzip --best > /artifacts/sineware-initramfs.cpio.gz echo "Done!" fi