From 80f4eeebe5ac11c356374f1b9b3fbbbdc012ba8a Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Thu, 1 Aug 2024 15:23:17 +0300 Subject: [PATCH] chroot attempt 0 --- .github/push-iso | 2 +- .github/workflows/push-iso.yml | 3 ++ build.sh | 52 +++++++++++++++++++ chroot_scripts/0-chroot.sh | 45 +++++++++++++++++ chroot_scripts/1-baseos.sh | 66 +++++++++++++++++++++++++ chroot_scripts/2-install-live-lists.sh | 19 +++++++ chroot_scripts/3-download-pool.sh | 20 ++++++++ chroot_scripts/4-uninstall-rem-lists.sh | 19 +++++++ chroot_scripts/5-run-hooks.sh | 13 +++++ generate_roofs_from_docker.sh | 8 ++- get_iso_build_dep.sh | 2 +- hooks/999-cleanup-apt-cache.chroot | 6 +++ info.sh | 5 ++ live-lists/desktop.list | 1 + pool-lists/booster.list | 1 + rem-lists/live-boot.list | 1 + 16 files changed, 256 insertions(+), 7 deletions(-) create mode 100755 build.sh create mode 100755 chroot_scripts/0-chroot.sh create mode 100755 chroot_scripts/1-baseos.sh create mode 100755 chroot_scripts/2-install-live-lists.sh create mode 100755 chroot_scripts/3-download-pool.sh create mode 100755 chroot_scripts/4-uninstall-rem-lists.sh create mode 100755 chroot_scripts/5-run-hooks.sh create mode 100755 hooks/999-cleanup-apt-cache.chroot create mode 100755 info.sh create mode 100755 live-lists/desktop.list create mode 100755 pool-lists/booster.list create mode 100755 rem-lists/live-boot.list diff --git a/.github/push-iso b/.github/push-iso index 7ed6ff8..1e8b314 100644 --- a/.github/push-iso +++ b/.github/push-iso @@ -1 +1 @@ -5 +6 diff --git a/.github/workflows/push-iso.yml b/.github/workflows/push-iso.yml index 8ce8b76..be76947 100644 --- a/.github/workflows/push-iso.yml +++ b/.github/workflows/push-iso.yml @@ -35,3 +35,6 @@ jobs: - name: Generate Image ROOTFS from PikaOS Docker image run: ./generate_roofs_from_docker.sh + + - name: Build ISO + run: ./build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..7901f9b --- /dev/null +++ b/build.sh @@ -0,0 +1,52 @@ +#! /bin/bash + +set -e + +source ./info.sh + +if [[ -z $ROOTFS_PATH ]] +then + echo "Error: ROOTFS PATH is not set!" + exit 1 +fi + +# Mount + +sudo mount --bind /dev "$ROOTFS_PATH/dev" +sudo mount -t tmpfs run "$ROOTFS_PATH/run" -o mode=0755,nosuid,nodev +sudo mount -t proc proc "$ROOTFS_PATH/proc" -o nosuid,nodev,noexec +sudo mount -t sysfs sys "$ROOTFS_PATH/sys" -o nosuid,nodev,noexec,ro + +# Setup Chroot scripts + +cp -rvf ./chroot_scripts "$ROOTFS_PATH/" +cp -rvf ./hooks "$ROOTFS_PATH/chroot_scripts/" +cp -rvf ./live-lists "$ROOTFS_PATH/chroot_scripts/" +cp -rvf ./pool-lists "$ROOTFS_PATH/chroot_scripts/" +cp -rvf ./rem-lists "$ROOTFS_PATH/chroot_scripts/" +cp -rvf ./info.sh "$ROOTFS_PATH/chroot_scripts/" + +# Run chroot_script inside ROOTFS + +chroot "$ROOTFS_PATH" bash -c "/chroot_scripts/0-chroot.sh" +rm -rfv "$ROOTFS_PATH/chroot_scripts" + +# Unmount + +umount "$ROOTFS_PATH/dev" || sudo umount -lf "$ROOTFS_PATH/dev" || true +umount "$ROOTFS_PATH/run" || sudo umount -lf "$ROOTFS_PATH/run" || true +umount "$ROOTFS_PATH/proc" || sudo umount -lf "$ROOTFS_PATH/proc" || true +umount "$ROOTFS_PATH/sys" || sudo umount -lf "$ROOTFS_PATH/sys" || true + +# Generate Squashfs image + +sudo mksquashfs \ + "$ROOTFS_PATH" \ + "$LIVE_BOOT_PATH/live/filesystem.squashfs" \ + -e boot + +# Copy Kernel to live +cp "$ROOTFS_PATH/boot"/vmlinuz-* \ + "$LIVE_BOOT_PATH/live/vmlinuz" && \ +cp "$ROOTFS_PATH/boot"/initrd.img-* \ + "$LIVE_BOOT_PATH/live/initrd" diff --git a/chroot_scripts/0-chroot.sh b/chroot_scripts/0-chroot.sh new file mode 100755 index 0000000..152cd45 --- /dev/null +++ b/chroot_scripts/0-chroot.sh @@ -0,0 +1,45 @@ +#! /bin/bash + +set -e + +export DEBIAN_FRONTEND="noninteractive" + +# Update APT Caches + +apt-get update -y +apt-get install pika-sources -y + +# Add canary repo + +tee /etc/apt/sources.list.d/canary.sources <<'EOF' +X-Repolib-Name: PikaOS Canary System Sources +Enabled: yes +Types: deb +URIs: https://ppa.pika-os.com/ +Suites: pika +Components: canary +Signed-By: /etc/apt/keyrings/pika-keyring.gpg.key +EOF + +# Upgrade system with new cache + +apt-get full-upgrade --yes --option Dpkg::Options::="--force-confnew" + +# Install Absolute Live Boot Basics + +apt-get install --yes --option Dpkg::Options::="--force-confnew" --no-install-recommends \ + live-boot \ + systemd-sysv \ + iwd \ + curl openssh-client \ + xserver-xorg-core \ + xserver-xorg \ + xinit xterm \ + nano + +# Run chroot steps +/etc/chroot_scripts/1-baseos.sh +/etc/chroot_scripts/2-install-live-lists.sh +/etc/chroot_scripts/3-download-pool.sh +/etc/chroot_scripts/4-uninstall-rem-lists.sh +/etc/chroot_scripts/5-run-hooks.sh diff --git a/chroot_scripts/1-baseos.sh b/chroot_scripts/1-baseos.sh new file mode 100755 index 0000000..f69133a --- /dev/null +++ b/chroot_scripts/1-baseos.sh @@ -0,0 +1,66 @@ +#! /bin/bash + +set -e + +export DEBIAN_FRONTEND="noninteractive" + +# Install PikaOS Basics + +apt-get install --yes --option Dpkg::Options::="--force-confnew" \ + pika-baseos \ + console-setup \ + console-setup-linux \ + sudo \ + nano \ + vim-tiny \ + pika-audio-pipewire \ + dialog \ + locales \ + locales-all + +# Setup Locales + +## Uncomment en_US.UTF-8 for inclusion in generation +sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen + +## Generate locale +locale-gen + +## Setup locale config +update-locale LANG="en_US.UTF-8" + +tee /etc/default/keyboard <<'EOF' +XKBMODEL="pc105" +XKBLAYOUT="us" +XKBVARIANT="" +XKBOPTIONS="" +BACKSPACE="guess" +KEYMAP=us +EOF + +cp -fv /etc/default/keyboard /etc/vconsole.conf + +localectl set-locale LANG="en_US.UTF-8" + +# Setup console-setup + +cat > /etc/default/console-setup <> /etc/chroot_scripts/live_list + done +done + +apt-get install --yes --no-install-recommends --option Dpkg::Options::="--force-confnew" $(cat /etc/chroot_scripts/live_list | tr "\n" " ") + + diff --git a/chroot_scripts/3-download-pool.sh b/chroot_scripts/3-download-pool.sh new file mode 100755 index 0000000..b1af445 --- /dev/null +++ b/chroot_scripts/3-download-pool.sh @@ -0,0 +1,20 @@ +#! /bin/bash + +set -e + +export DEBIAN_FRONTEND="noninteractive" + +touch /etc/chroot_scripts/pool_list + +for pool_list in /etc/chroot_scripts/pool-lists/*.list +do + for pkg in $(cat $pool_list) + do + echo $pkg >> /etc/chroot_scripts/pool_list + done +done + +mkdir -p /cdrom/pool/main/ +pushd /cdrom/pool/main/ +apt-get download --yes $(cat /etc/chroot_scripts/pool_list | tr "\n" " ") +popd \ No newline at end of file diff --git a/chroot_scripts/4-uninstall-rem-lists.sh b/chroot_scripts/4-uninstall-rem-lists.sh new file mode 100755 index 0000000..d39fc64 --- /dev/null +++ b/chroot_scripts/4-uninstall-rem-lists.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +set -e + +export DEBIAN_FRONTEND="noninteractive" + +touch /etc/chroot_scripts/rem_list + +for rem_list in /etc/chroot_scripts/rem-lists/*.list +do + for pkg in $(cat $rem_list) + do + echo $pkg >> /etc/chroot_scripts/rem_list + done +done + +apt-get purge --yes --option Dpkg::Options::="--force-confnew" $(cat /etc/chroot_scripts/rem_list | tr "\n" " ") + + diff --git a/chroot_scripts/5-run-hooks.sh b/chroot_scripts/5-run-hooks.sh new file mode 100755 index 0000000..82c5421 --- /dev/null +++ b/chroot_scripts/5-run-hooks.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +set -e + +export DEBIAN_FRONTEND="noninteractive" + +export ORIGINAL_WORKINGDIR=$(pwd) + +for hook in /etc/chroot_scripts/hooks/* +do + $hook + cd $ORIGINAL_WORKINGDIR +done \ No newline at end of file diff --git a/generate_roofs_from_docker.sh b/generate_roofs_from_docker.sh index c5584a7..9541099 100755 --- a/generate_roofs_from_docker.sh +++ b/generate_roofs_from_docker.sh @@ -2,9 +2,9 @@ set -e -mkdir -p "./LIVE_BOOT/rootfs" +source ./info.sh -ROOTFS_PATH="./LIVE_BOOT/rootfs" +mkdir -p "$ROOTFS_PATH" # Pull and mount docker image @@ -26,6 +26,4 @@ rm -rfv $ROOTFS_PATH/etc/dpkg/dpkg.cfg.d/*docker* # Setup hostname -echo "pikaos" | tee "$ROOTFS_PATH/etc/hostname" - -ls $ROOTFS_PATH/ +echo $LIVE_HOSTNAME | tee "$ROOTFS_PATH/etc/hostname" diff --git a/get_iso_build_dep.sh b/get_iso_build_dep.sh index 602d9f6..78f6643 100755 --- a/get_iso_build_dep.sh +++ b/get_iso_build_dep.sh @@ -4,7 +4,7 @@ set -e export DEBIAN_FRONTEND="noninteractive" -apt-get install -y --option Dpkg::Options::="--force-confnew" \ +apt-get install -y --no-install-recommends --option Dpkg::Options::="--force-confnew" \ debootstrap \ squashfs-tools \ xorriso \ diff --git a/hooks/999-cleanup-apt-cache.chroot b/hooks/999-cleanup-apt-cache.chroot new file mode 100755 index 0000000..411f7c4 --- /dev/null +++ b/hooks/999-cleanup-apt-cache.chroot @@ -0,0 +1,6 @@ +#!/bin/sh +# Description: Cleanup apt cache files that add ~100MB to the .iso and aren't needed + +rm -f /var/lib/apt/lists/*_Packages +rm -f /var/lib/apt/lists/*_Sources +rm -f /var/lib/apt/lists/*_Translation-* diff --git a/info.sh b/info.sh new file mode 100755 index 0000000..90bd4e2 --- /dev/null +++ b/info.sh @@ -0,0 +1,5 @@ +#! /bin/bash + +export LIVE_BOOT_PATH="$(pwd)/LIVE_BOOT" +export ROOTFS_PATH="$LIVE_BOOT_DIR/rootfs" +export LIVE_HOSTNAME="pikaos" diff --git a/live-lists/desktop.list b/live-lists/desktop.list new file mode 100755 index 0000000..0d13549 --- /dev/null +++ b/live-lists/desktop.list @@ -0,0 +1 @@ +gnome-core diff --git a/pool-lists/booster.list b/pool-lists/booster.list new file mode 100755 index 0000000..413635d --- /dev/null +++ b/pool-lists/booster.list @@ -0,0 +1 @@ +booster diff --git a/rem-lists/live-boot.list b/rem-lists/live-boot.list new file mode 100755 index 0000000..0a4e05d --- /dev/null +++ b/rem-lists/live-boot.list @@ -0,0 +1 @@ +live-boot