Skip to content

Commit

Permalink
cleanup code, move tmp dirs into ./tmpdir
Browse files Browse the repository at this point in the history
  • Loading branch information
YukariChiba committed Jul 17, 2024
1 parent 4c7449d commit ed56548
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
isofs/
rootfs/
tmpdir/
*.img
*.iso
*.tar.xz
Expand Down
3 changes: 1 addition & 2 deletions utils/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

_logtxt "#### cleaning up env"

$RUNAS rm -r rootfs || true
$RUNAS rm -r isofs || true
$RUNAS rm -r tmpdir || true

30 changes: 12 additions & 18 deletions utils/collect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ _logtxt "#### collecting result"
mkdir -p results

if [[ $PROFILE == liveimage* ]]; then
mkdir -p ./isofs/live/sfs/
$RUNAS mksquashfs ./rootfs ./isofs/live/sfs/root.sfs
echo "root" | $RUNAS tee ./isofs/live/live.list
if [ -f ./isofs/limine-bios-cd.bin ]; 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
if [ -f ./tmpdir/isofs/limine-bios-cd.bin ]; then
BIOS_ARG="-b limine-bios-cd.bin"
fi
$RUNAS xorriso -as mkisofs \
Expand All @@ -19,30 +19,24 @@ if [[ $PROFILE == liveimage* ]]; then
-efi-boot-part --efi-boot-image --protective-msdos-label \
-V "EWE_ISO" \
-A "eweOS Live ISO" \
isofs
tmpdir/isofs

if [ ! -z "$BIOS_ARG" ]; then
_logtxt "#### Install BIOS boot for ISO"
# limine install bios
$RUNAS mkdir -p ./rootfs/results
$RUNAS mount --bind results ./rootfs/results
$RUNAS arch-chroot rootfs bash -c "limine bios-install /results/eweos-$TARGET_ARCH-$PROFILE.iso"
_logtxt "#### wait 3 sec to release mountpoint"
sleep 3
$RUNAS umount ./rootfs/proc || true
$RUNAS umount ./rootfs/results
$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
fi

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

if [[ $PROFILE == tarball* ]]; then
# wait for arch-chroot to release mountpoint
sleep 5
# failsafe
$RUNAS umount ./rootfs/sys/firmware/efi/efivars || true
$RUNAS umount ./rootfs/sys || true
$RUNAS tar cJf results/eweos-$TARGET_ARCH-$PROFILE.tar.xz -C ./rootfs .
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
popd
Expand Down
15 changes: 12 additions & 3 deletions utils/function_def.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ function _logtxt() {
}

function crsh(){
cp $1 ./rootfs/config.sh && chmod +x ./rootfs/config.sh
$RUNAS arch-chroot rootfs bash -c "/config.sh"
$RUNAS rm ./rootfs/config.sh
cp $1 ./tmpdir/rootfs/config.sh && chmod +x ./tmpdir/rootfs/config.sh
$RUNAS arch-chroot tmpdir/rootfs bash -c "/config.sh"
$RUNAS rm ./tmpdir/rootfs/config.sh
}

function umount_chroot(){
_logtxt "#### wait 3 sec to release mountpoint on $1"
sleep 3
$RUNAS umount $1/proc || true
$RUNAS umount $1/boot || true
$RUNAS umount $1/sys/firmware/efi/efivars || true
$RUNAS umount $1/sys || true
}
17 changes: 7 additions & 10 deletions utils/hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

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

if [ -d profiles/$PROFILE/files ]; then
_logtxt "#### copying files"
$RUNAS cp -r profiles/$PROFILE/files ./rootfs/.files
$RUNAS cp -r profiles/$PROFILE/files ./tmpdir/rootfs/.files
fi

function concat_config() {
Expand All @@ -35,12 +35,9 @@ if [ -f "./profiles/$PROFILE/config.sh" ]; then
fi
crsh $chrconf

if [ -d ./rootfs/.files ]; then
if [ -d ./tmpdir/rootfs/.files ]; then
_logtxt "#### remove unused files"
$RUNAS rm -r ./rootfs/.files
$RUNAS rm -r ./tmpdir/rootfs/.files
fi

_logtxt "#### wait 3 sec to release mountpoint"
sleep 3
$RUNAS umount ./rootfs/boot || true
$RUNAS umount ./rootfs/proc || true
umount_chroot ./tmpdir/rootfs
6 changes: 3 additions & 3 deletions utils/install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/env sh

mkdir -p rootfs
mkdir -p tmpdir/rootfs

_logtxt "#### bootstrapping system"

$RUNAS pacstrap -G -M -c -C ./pacman.ewe.conf ./rootfs `cat profiles/$PROFILE/packages.txt | xargs`
$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 ./rootfs `cat profiles/$PROFILE/packages.$TARGET_ARCH.txt | xargs`
$RUNAS pacstrap -G -M -c -C ./pacman.ewe.conf ./tmpdir/rootfs `cat profiles/$PROFILE/packages.$TARGET_ARCH.txt | xargs`
fi

0 comments on commit ed56548

Please sign in to comment.