#!/usr/bin/env bash # Copyright (C) 2022 Seshan Ravikumar # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # This script builds a basic rootfs that is universal across all variants. set -e # Crash when a command fails echo "* Starting $SINEWARE_PRETTY_NAME build on $(date) *" echo "Go get your noodles, this may take a while!" # Source the global build config source /buildmeta/buildconfig.sh # Source the local build config source /build-scripts/build-configuration.sh echo "* Build Step: Getting Ready *" mkdir -pv /tools mkdir -pv /build/rootfs && cd /build echo "* Build Step: Gathering Initial Components *" cd /build #wget ${SINEWARE_BIN_URL}/openwrt/${SINEWARE_BIN_OPENWRT} if [[ "$PROLINUX_ARCH" == "aarch64" ]]; then echo "* aarch64 build" tar xvf /artifacts/aarch64/sineware-buildroot.tar.gz -C ${ROOTFS} else tar xvf /artifacts/sineware-buildroot.tar.gz -C ${ROOTFS} fi # ~~ Build the Toolchain, environment variables were set in build-configuration # /build-scripts/toolchain/build.sh echo "* Build Step: Preparing Directories *" mkdir -pv $ROOTFS/root/.config mkdir -pv $ROOTFS/data $ROOTFS/config ls -l ls -l $ROOTFS echo "* Build Step: Adding files to rootfs *" cp -rv /build-scripts/files/etc/* $ROOTFS/etc/ cp -rv /build-scripts/files/sineware.ini $ROOTFS/sineware.ini cp -rv /build-scripts/files/99-wildcard.network $ROOTFS/etc/systemd/network/ cp -rv /build-scripts/files/prolinuxd $ROOTFS/sbin/prolinuxd cp -rv /build-scripts/files/prolinuxd.service $ROOTFS/etc/systemd/system/prolinuxd.service cp -rv /build-scripts/files/weston.ini $ROOTFS/root/.config/weston.ini cp -rv /build-scripts/files/bg.png $ROOTFS/root/.config/bg.png tar xvf /artifacts/prolinuxd-java-*.tar -C $ROOTFS/opt/ mv $ROOTFS/opt/prolinuxd-java* $ROOTFS/opt/prolinuxd 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/bash <<"EOT" echo "* chroot: Hello from inside the chroot!" ls -l echo "prolinux-live" > /etc/hostname echo "* chroot: Installing packages..." pacman -Syy --noconfirm pacman -S neofetch htop iproute2 iputils wget pciutils usbutils gzip sudo nano lvm2 grub openssh clamav networkmanager --noconfirm # ProLinuxd pacman -S cage weston xorg-xwayland libxtst libxrender noto-fonts jre-openjdk --noconfirm echo "* chroot: system configuration..." systemctl enable systemd-resolved.service systemctl enable NetworkManager.service systemctl enable prolinuxd.service systemctl disable getty@tty1 echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers useradd -m -G wheel plu echo "plu:1234" | chpasswd timedatectl set-ntp true echo "* chroot: cleaning pacman cache..." pacman -Sc --noconfirm echo "* chroot: exiting chroot..." EOT sleep 4 umount --recursive $ROOTFS/proc/ umount --recursive $ROOTFS/sys/ umount --recursive $ROOTFS/dev/ rm $ROOTFS/etc/resolv.conf echo "* Build Step: Final touches... *" # Sineware Components /build-scripts/components/insert-name/build.sh # Clean up echo "* Build Step: Creating rootfs archive *" echo "This ${SINEWARE_PRETTY_NAME} build was completed on $(date)" > ./sineware-release cd $ROOTFS if [[ "$PROLINUX_ARCH" == "aarch64" ]]; then tar -czvf /artifacts/aarch64/sineware.tar.gz . else tar -czvf /artifacts/sineware.tar.gz . fi du -h $ROOTFS sleep 2 echo "* Done! *"