chroot attempt 0

This commit is contained in:
Ward from fusion-voyager-3 2024-08-01 15:23:17 +03:00
parent 9ef074d5f3
commit 80f4eeebe5
16 changed files with 256 additions and 7 deletions

2
.github/push-iso vendored
View File

@ -1 +1 @@
5
6

View File

@ -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

52
build.sh Executable file
View File

@ -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"

45
chroot_scripts/0-chroot.sh Executable file
View File

@ -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

66
chroot_scripts/1-baseos.sh Executable file
View File

@ -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 <<EOF
# CONFIGURATION FILE FOR SETUPCON
# Consult the console-setup(5) manual page.
ACTIVE_CONSOLES="/dev/tty[1-6]"
CHARMAP="UTF-8"
CODESET="guess"
FONTFACE="Terminus"
FONTSIZE="16x32"
VIDEOMODE=
# The following is an example how to use a braille font
# FONT='lat9w-08.psf.gz brl-8x8.psf'
EOF
dpkg-reconfigure --frontend=noninteractive console-setup

View File

@ -0,0 +1,19 @@
#! /bin/bash
set -e
export DEBIAN_FRONTEND="noninteractive"
touch /etc/chroot_scripts/live_list
for live_list in /etc/chroot_scripts/live-lists/*.list
do
for pkg in $(cat $live_list)
do
echo $pkg >> /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" " ")

View File

@ -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

View File

@ -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" " ")

13
chroot_scripts/5-run-hooks.sh Executable file
View File

@ -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

View File

@ -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"

View File

@ -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 \

View File

@ -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-*

5
info.sh Executable file
View File

@ -0,0 +1,5 @@
#! /bin/bash
export LIVE_BOOT_PATH="$(pwd)/LIVE_BOOT"
export ROOTFS_PATH="$LIVE_BOOT_DIR/rootfs"
export LIVE_HOSTNAME="pikaos"

1
live-lists/desktop.list Executable file
View File

@ -0,0 +1 @@
gnome-core

1
pool-lists/booster.list Executable file
View File

@ -0,0 +1 @@
booster

1
rem-lists/live-boot.list Executable file
View File

@ -0,0 +1 @@
live-boot