Skip to content

Commit

Permalink
add tarball support
Browse files Browse the repository at this point in the history
  • Loading branch information
YukariChiba committed Jan 12, 2024
1 parent 49a37d4 commit ee877a5
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 71 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ isofs/
rootfs/
*.img
*.iso
*.tar.xz
*.tar.gz
*.sha256
pacman.ewe.conf
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions config/tarball/set_hostname.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo "eweos-diskimage" >/etc/hostname
9 changes: 9 additions & 0 deletions config/tarball/set_motd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cat <<EOF >/etc/motd
Welcome to eweOS!
* Mainpage: https://os.ewe.moe
* Wiki: https://os-wiki.ewe.moe
* Packages: https://os.ewe.moe/pkglist
EOF
11 changes: 11 additions & 0 deletions gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

TARGET_ARCH=${2:-x86_64}
PROFILE=${1:-tarball-minimal}

. utils/log.sh
. utils/pacman-config.sh
. utils/function_crsh.sh
. utils/cleanup.sh
. utils/install.sh
. utils/collect.sh
70 changes: 0 additions & 70 deletions gen_iso.sh

This file was deleted.

2 changes: 1 addition & 1 deletion profiles/liveimage-minimal/packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ base
greetd
tinyramfs
linux
efistub-tools
limine
neofetch
vim
sudo
Expand Down
6 changes: 6 additions & 0 deletions profiles/tarball/packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
base
linux
neofetch
vim
sudo
dinit
10 changes: 10 additions & 0 deletions utils/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/env sh

_logtxt "#### cleaning up env"

sudo rm -r rootfs || true
sudo rm -r isofs || true
rm bootfs.img || true

mkdir -p rootfs
mkdir -p isofs
32 changes: 32 additions & 0 deletions utils/collect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/env sh

_logtxt "#### collecting result"

if [[ $PROFILE == liveimage* ]]; then
sudo mksquashfs ./rootfs ./isofs/root.sfs
sudo xorriso -as mkisofs \
-o eweos-$TARGET_ARCH-$PROFILE.iso \
-J -v -d -N \
-x eweos-$TARGET_ARCH-$PROFILE.iso \
-partition_offset 16 \
-no-pad \
-hide-rr-moved \
-no-emul-boot \
-append_partition 2 0xef bootfs.img \
-appended_part_as_gpt \
-eltorito-platform efi \
-e --interval:appended_partition_2:all:: \
-V "EWE_ISO" \
-A "eweOS Live ISO" \
-iso-level 3 \
-partition_cyl_align all \
isofs
sha256sum eweos-$TARGET_ARCH-$PROFILE.iso > eweos-$TARGET_ARCH-$PROFILE.iso.sha256
fi

if [[ $PROFILE == tarball* ]]; then
# wait for arch-chroot to release mountpoint
sleep 5
sudo tar cJf eweos-$TARGET_ARCH-$PROFILE.tar.xz -C ./rootfs .
sha256sum eweos-$TARGET_ARCH-$PROFILE.tar.xz > eweos-$TARGET_ARCH-$PROFILE.tar.xz.sha256
fi
7 changes: 7 additions & 0 deletions utils/function_crsh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/env sh

function crsh(){
cp $1 ./rootfs/config.sh && chmod +x ./rootfs/config.sh
sudo arch-chroot rootfs bash -c "/config.sh"
sudo rm ./rootfs/config.sh
}
41 changes: 41 additions & 0 deletions utils/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/erv sh


mkdir -p rootfs

if [[ $PROFILE == liveimage* ]]; then
_logtxt "#### creating boot partition"
mkdir -p isofs
dd if=/dev/zero of=bootfs.img bs=1M count=48
mkfs.vfat ./bootfs.img
sudo mkdir -p ./rootfs/boot
sudo mount ./bootfs.img ./rootfs/boot
fi

_logtxt "#### bootstrapping system"

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

function concat_config() {
for configsh in $1; do
echo "echo \"#### setting up [`basename $configsh`]\"" >> $chrconf
cat $configsh >> $chrconf
done
}

_logtxt "#### setting up system"

chrconf=`mktemp`
echo "#!/bin/bash" > $chrconf
concat_config "./config/common/*.sh"
if [[ $PROFILE == liveimage* ]]; then
concat_config "./config/liveimage/*.sh"
fi
if [[ $PROFILE == tarball* ]]; then
concat_config "./config/tarball/*.sh"
fi
if [ -f "./profiles/$PROFILE/config.sh" ]; then
cat ./profiles/$PROFILE/config.sh >> $chrconf
fi
crsh $chrconf
sudo umount ./rootfs/boot || true
3 changes: 3 additions & 0 deletions utils/log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function _logtxt() {
echo "$(tput bold)${1}$(tput sgr0)"
}
13 changes: 13 additions & 0 deletions utils/pacman-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/env sh

_logtxt "#### setting up pacman.conf"

if [ ! -f "pacman.ewe.conf" ]; then
if [ "`cat /etc/os-release | grep ^ID || true`" != "ID=ewe" ]; then
wget https://raw.githubusercontent.com/eweOS/packages/pacman/pacman.conf -O pacman.ewe.conf
else
sudo pacman -Sy --noconfirm arch-install-scripts util-linux
cp /etc/pacman.conf ./pacman.ewe.conf
fi
fi
sed -i "s/Architecture = .*/Architecture = $TARGET_ARCH/g" pacman.ewe.conf

0 comments on commit ee877a5

Please sign in to comment.