Skip to content

Commit

Permalink
add multi-layer sfs generation
Browse files Browse the repository at this point in the history
  • Loading branch information
YukariChiba committed Jul 17, 2024
1 parent ed56548 commit a22cafb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
14 changes: 10 additions & 4 deletions utils/collect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ mkdir -p results

if [[ $PROFILE == liveimage* ]]; then
mkdir -p ./tmpdir/isofs/live/sfs/
$RUNAS mksquashfs ./tmpdir/rootfs ./tmpdir/isofs/live/sfs/root.sfs
echo "root" | $RUNAS tee ./tmpdir/isofs/live/live.list
for sfsdir in $(ls ./tmpdir/layers/); do
$RUNAS mksquashfs ./tmpdir/layers/$sfsdir ./tmpdir/isofs/live/sfs/$sfsdir.sfs
done
cat <<EOF | $RUNAS tee ./tmpdir/isofs/live/live.list
base
packages
live
EOF
if [ -f ./tmpdir/isofs/limine-bios-cd.bin ]; then
BIOS_ARG="-b limine-bios-cd.bin"
fi
Expand All @@ -24,18 +30,18 @@ if [[ $PROFILE == liveimage* ]]; then
if [ ! -z "$BIOS_ARG" ]; then
_logtxt "#### Install BIOS boot for ISO"
# limine install bios
mount_overlay packages base
$RUNAS mkdir -p ./tmpdir/rootfs/results
$RUNAS mount --bind ./results ./tmpdir/rootfs/results
$RUNAS arch-chroot ./tmpdir/rootfs bash -c "limine bios-install /results/eweos-$TARGET_ARCH-$PROFILE.iso"
$RUNAS umount ./tmpdir/rootfs/results
umount_chroot ./tmpdir/rootfs
umount_overlay
fi

sha256sum results/eweos-$TARGET_ARCH-$PROFILE.iso > results/eweos-$TARGET_ARCH-$PROFILE.iso.sha256
fi

if [[ $PROFILE == tarball* ]]; then
umount_chroot ./tmpdir/rootfs
$RUNAS tar cJf results/eweos-$TARGET_ARCH-$PROFILE.tar.xz -C ./tmpdir/rootfs .
pushd results
sha256sum eweos-$TARGET_ARCH-$PROFILE.tar.xz > eweos-$TARGET_ARCH-$PROFILE.tar.xz.sha256
Expand Down
27 changes: 27 additions & 0 deletions utils/function_def.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,30 @@ function umount_chroot(){
$RUNAS umount $1/sys/firmware/efi/efivars || true
$RUNAS umount $1/sys || true
}

function mount_overlay(){
# mount overlay only for liveimage, use rootfs as usual for other images
if [[ $PROFILE == liveimage* ]]; then
mkdir -p ./tmpdir/overlay_workdir
upperlayer=$1
mkdir -p ./tmpdir/layers/$upperlayer ./tmpdir/rootfs
shift 1
if [ $# -eq 0 ]; then
$RUNAS mount --bind ./tmpdir/layers/$upperlayer ./tmpdir/rootfs
else
LOWERLAYERS=""
for layer in "$@"
do
mkdir -p ./tmpdir/layers/$layer
LOWERLAYERS+="$PWD/tmpdir/layers/${layer}:"
done
$RUNAS mount -t overlay overlay -o lowerdir=${LOWERLAYERS%:},upperdir=$PWD/tmpdir/layers/$upperlayer,workdir=$PWD/tmpdir/overlay_workdir ./tmpdir/rootfs
fi
fi
}

function umount_overlay(){
$RUNAS sync
umount_chroot ./tmpdir/rootfs
$RUNAS umount ./tmpdir/rootfs || true
}
13 changes: 6 additions & 7 deletions utils/hooks.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/bin/env sh

if [[ $PROFILE == liveimage* ]]; then
_logtxt "#### creating boot partition"
mkdir -p tmpdir/isofs
$RUNAS mkdir -p ./tmpdir/rootfs/boot
$RUNAS mount --bind ./tmpdir/isofs ./tmpdir/rootfs/boot
fi
mount_overlay live packages base

mkdir -p tmpdir/isofs
$RUNAS mkdir -p ./tmpdir/rootfs/boot
$RUNAS mount --bind ./tmpdir/isofs ./tmpdir/rootfs/boot

if [ -d profiles/$PROFILE/files ]; then
_logtxt "#### copying files"
Expand Down Expand Up @@ -40,4 +39,4 @@ if [ -d ./tmpdir/rootfs/.files ]; then
$RUNAS rm -r ./tmpdir/rootfs/.files
fi

umount_chroot ./tmpdir/rootfs
umount_overlay
13 changes: 12 additions & 1 deletion utils/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@

mkdir -p tmpdir/rootfs

_logtxt "#### bootstrapping system"
_logtxt "#### bootstrapping base system"

mount_overlay base

$RUNAS pacstrap -G -M -c -C ./pacman.ewe.conf ./tmpdir/rootfs base linux linux-firmware

umount_overlay

_logtxt "#### bootstrapping packages"

mount_overlay packages base

$RUNAS pacstrap -G -M -c -C ./pacman.ewe.conf ./tmpdir/rootfs `cat profiles/$PROFILE/packages.txt | xargs`

if [ -f profiles/$PROFILE/packages.$TARGET_ARCH.txt ]; then
$RUNAS pacstrap -G -M -c -C ./pacman.ewe.conf ./tmpdir/rootfs `cat profiles/$PROFILE/packages.$TARGET_ARCH.txt | xargs`
fi

umount_overlay

0 comments on commit a22cafb

Please sign in to comment.