From 91a919a36c4114f5cc58aad3146df761fddf3b60 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 22:33:18 -0800 Subject: [PATCH] enhance script enhance with some stuff --- environment-setup/foxbunto_env_setup.sh | 126 ++++++++++++++++++++---- 1 file changed, 105 insertions(+), 21 deletions(-) diff --git a/environment-setup/foxbunto_env_setup.sh b/environment-setup/foxbunto_env_setup.sh index 8c07e65..bed0156 100644 --- a/environment-setup/foxbunto_env_setup.sh +++ b/environment-setup/foxbunto_env_setup.sh @@ -1,34 +1,77 @@ -echo “Setting up Foxbuntu build environment…” - +#!/bin/bash +# one line installer +# cd ~ && wget https://raw.githubusercontent.com/noon92/femtofox/refs/heads/main/environment-setup/foxbunto_env_setup.sh -O foxbunto_env_setup.sh && bash foxbunto_env_setup.sh +cd ~ +if [ -f /etc/os-release ]; then + . /etc/os-release + if [ "$VERSION_ID" != "22.04" ] || [ "$NAME" != "Ubuntu" ]; then + echo "This script is intended for Ubuntu 22.04, exiting..." + exit 1 + fi +else + echo "This script is intended for Ubuntu 22.04, exiting..." + exit 1 +fi +if [ "$EUID" -eq 0 ]; then + echo "Please run this script without sudo." + exit 1 +fi +echo +echo "==========================================" +echo " Foxbuntu Build Environment" +echo "==========================================" +echo +echo "Setting up new Foxbuntu build environment..." +echo +echo "This script will install the necessary packages to build the Foxbuntu image." +echo "It will also set up a chroot environment to install additional packages. This will all take some time." +echo +echo "You will need to answer some questions during the start of the script." +echo "Please make sure you have a stable internet connection and enough disk space. (20GB)" +echo "Choose the default of [0] if unknown, and [1] for Ubuntu when prompted." +echo "When the Kernel build GUI appears, just exit without making any changes." +echo +echo "Press Enter to continue, or Ctrl+C to cancel." +read +# get the luckfox build environment +if [ -d ~/femtofox ]; then + echo "WARNING: ~/femtofox exists, this script will overwrite it." + echo "Press Ctrl+C to cancel, or Enter to continue." + read + sudo rm -rf ~/femtofox +fi +if [ -d ~/luckfox-pico ]; then + echo "WARNING: ~/luckfox-pico exists, this script will overwrite it." + echo "Press Ctrl+C to cancel, or Enter to continue." + read + sudo rm -rf ~/luckfox-pico +fi + +# get updates and packages sudo apt update - sudo apt-get install -y git ssh make gcc gcc-multilib g++-multilib module-assistant expect g++ gawk texinfo libssl-dev bison flex fakeroot cmake unzip gperf autoconf device-tree-compiler libncurses5-dev pkg-config bc python-is-python3 passwd openssl openssh-server openssh-client vim file cpio rsync git clone https://github.com/LuckfoxTECH/luckfox-pico.git - cd ~/luckfox-pico +echo "### Choose [1] Ubuntu ### Choose [1] Ubuntu ###" sudo ./build.sh lunch sudo ./build.sh + +# get the femtofox environment cd ~ git clone https://github.com/noon92/femtofox.git ~/femtofox/foxbuntu/updatefs.sh cd ~/luckfox-pico/ -sudo ./build.sh kernelconfig -sudo ./build.sh - -cd ~/luckfox-pico/output/image - -sudo wget https://gist.github.com/Spiritdude/da36d2cf064e49094c870e0a8b9f972f/archive/8f05ce57f5dede06a45f25298982fab543d95084.zip - -sudo unzip -j ./8f05ce57f5dede06a45f25298982fab543d95084.zip -sudo rm ./8f05ce57f5dede06a45f25298982fab543d95084.zip -sudo chmod +x ./blkenvflash - +# get the blkenvflash imagemaker v2.2 +sudo wget https://gist.githubusercontent.com/Spiritdude/da36d2cf064e49094c870e0a8b9f972f/raw/8f05ce57f5dede06a45f25298982fab543d95084/blkenvflash -O ~/luckfox-pico/output/image/blkenvflash +sudo chmod +x ~/luckfox-pico/output/image/blkenvflash +# build the kernel +echo "### exit no changes ### exit no changes ###" +sudo ./build.sh # SETUP CHROOT - sudo mkdir -p ~/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/lib/modules/5.10.160 sudo cp ~/luckfox-pico/sysdrv/out/kernel_drv_ko/* ~/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/lib/modules/5.10.160 @@ -41,7 +84,7 @@ sudo cp /usr/bin/qemu-arm-static ~/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/ echo "Entering chroot and running commands..." sudo mount --bind /proc ~/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/proc && sudo mount --bind /sys ~/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/sys && sudo mount --bind /dev ~/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/dev && sudo mount --bind /dev/pts ~/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/dev/pts -sudo chroot ~/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106 /bin/bash < /root/.bash_history && history -c +sudo apt clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* && rm -rf /var/tmp/* && find /var/log -type f -exec truncate -s 0 {} + && : > /root/.bash_history && history -c exit EOF @@ -120,5 +201,8 @@ echo "Building image..." sudo ~/luckfox-pico/build.sh cd ~/luckfox-pico/output/image && sudo ~/luckfox-pico/output/image/blkenvflash ~/luckfox-pico/foxbuntu.img echo "foxbuntu.img build completed." - - +cd ~/luckfox-pico +ls -ls foxbuntu.img +echo "use dd, raspi-imager (apply no custom settings), balenaEtcher(ignore error), to burn the image to a microSD card" +# End of script +exit 0