linux-qubasis

linux oasis port as a qubes template

git clone https://9o.is/git/linux-qubasis.git

commit 4f5f554c2e948e2e669daff6a092f771126d6f48
parent 42d398c118c36fdad8a0bd53169df095c78bce4b
Author: Jul <jul@9o.is>
Date:   Tue, 16 Sep 2025 19:47:02 +0800

mount block devices in example template

Diffstat:
Mninja/functions.sh | 38++++++++++++++++++++++++++++++++++----
Mpkg/ubase/gen.sh | 2++
Apkg/ubase/mount.swap | 29+++++++++++++++++++++++++++++
Atpl/example/etc/fstab | 9+++++++++
Atpl/example/etc/rc.init | 17+++++++++++++++++
Atpl/example/etc/rc.shutdown | 13+++++++++++++
Mtpl/example/gen.sh | 33++++++++++++++++++++++++---------
7 files changed, 128 insertions(+), 13 deletions(-)

diff --git a/ninja/functions.sh b/ninja/functions.sh @@ -65,7 +65,13 @@ yacc() { } bin() { - _ninja_fspec /bin/$1 reg 0755 $1 + _fn=${1##*/} + _out=$outdir/$_fn + _ninja_fspec /bin/$_fn reg 0755 $_out + + case $1 in + \$*) build copy $_out $1;; + esac } dir() { @@ -77,7 +83,15 @@ sym() { } reg() { - _ninja_fspec $2 reg ${3-0644} $1 + _out=$outdir/${1##*/} + _ninja_fspec $2 reg ${3-0644} $_out +} + +etc() { + _ninja_prefix _src $etcdir $1 + _out=$outdir/_files/etc/$1 + _ninja_fspec /etc/$1 ${3-reg} ${2-0644} $_out + build copy $_out $_src } man() { @@ -292,6 +306,7 @@ _ninja_setv_init() { pkgdir='$pkgdir' yaccdir='$yaccdir' objdir='$objdir' + etcdir='$etcdir' unset -f host @@ -306,6 +321,7 @@ _ninja_setv_init() { setv dir $basedir/$gendir setv outdir $builddir/$gendir setv rootdir $outdir/root + setv etcdir $dir/etc ;; esac } @@ -334,7 +350,7 @@ _ninja_prefix() { _ninja_sync() { for _v in $*; do case $_v in - \$srcdir/*) + $srcdir/*|$etcdir/*) _ninja_buffer_sync="$_ninja_buffer_sync $_v" esac done @@ -617,6 +633,20 @@ _ninja_flush_sync() { root) build phony $tgtdir/sync $_subgens ;; + tpl) + build phony $tgtdir/sync $outdir/_synced + + for src in $_ninja_buffer_sync; do + build copy $outdir/_sync/${src#$etcdir/} $src + done + + if [ "$_ninja_buffer_sync" ]; then + _ninja_dedup _ninja_buffer_sync $_ninja_buffer_sync + build phony "$_ninja_buffer_sync" $outdir/_synced + else + build touch $outdir/_synced + fi + ;; pkg) _patches= _fetchdir=$outdir/_fetch @@ -686,7 +716,7 @@ _ninja_flush_fspec() { dep='| $basedir/ninja/fspec.sh $hostdir/fspec-hash' if [ $type = reg ]; then - build fspec $out $outdir/${path##*/} $dep + build fspec $out $src $dep else build fspec $out $dep fi diff --git a/pkg/ubase/gen.sh b/pkg/ubase/gen.sh @@ -101,3 +101,5 @@ exes " watch 1 who 1 " + +bin $dir/mount.swap diff --git a/pkg/ubase/mount.swap b/pkg/ubase/mount.swap @@ -0,0 +1,29 @@ +#!/bin/sh + +usage() { + printf 'Usage: %s <fsname>\n' $0 + exit 1 +} + +if [ $# -eq 0 ]; then + printf '%s: missing arguments\n' $0 + usage +fi + +while getopts "o:" opt; do + case $opt in + o) ;; # not handled for now + *) usage;; + esac +done + +shift $((OPTIND - 1)) + +fsname=$1 + +if [ ! -e $fsname ]; then + printf '%s: %s not found' $0 $fsname + exit 1 +fi + +swapon $fsname diff --git a/tpl/example/etc/fstab b/tpl/example/etc/fstab @@ -0,0 +1,9 @@ +/dev/mapper/dmroot / ext4 defaults,discard,noatime 1 1 +/dev/xvdb /rw auto noauto,defaults,discard,nosuid,nodev 1 2 +/dev/xvdc1 swap swap defaults 0 0 +none /dev/pts devpts nosuid,noexec,relatime 0 0 +none /dev/shm tmpfs nodev,nosuid,noexec 0 0 +none /proc proc nodev,noexec,nosuid,relatime 0 0 +none /run tmpfs nodev,noexec,nosuid,mode=755 0 0 +none /sys sysfs nodev,noexec,nosuid,relatime 0 0 +none /tmp tmpfs nodev,nosuid,relatime 0 0 diff --git a/tpl/example/etc/rc.init b/tpl/example/etc/rc.init @@ -0,0 +1,17 @@ +#!/bin/rc + +path=/bin + +umask 022 + +mount -t proc none /proc +mount -t devtmpfs devtmpfs /dev + +mkdir /dev/pts +mkdir /dev/shm + +mount -a + +rc +swapoff /dev/xvdc1 +exec shutdown diff --git a/tpl/example/etc/rc.shutdown b/tpl/example/etc/rc.shutdown @@ -0,0 +1,13 @@ +#!/bin/rc + +path=/bin + +args=() +switch($1) { + case poweroff + args=-p + case reboot + args=-r +} + +exec /bin/shutdown $args diff --git a/tpl/example/gen.sh b/tpl/example/gen.sh @@ -1,20 +1,35 @@ template oasis-example black 12M -dir /dev -dir /tmp dir /bin +dir /dev +dir /etc +dir /home +dir /lib +dir /mnt +dir /proc +dir /root 0700 +dir /run dir /share -dir /share/misc -dir /share/man -dir /share/man/man1 -dir /share/man/man5 -dir /share/man/man8 +dir /sys +dir /tmp +dir /var + +# qubes +dir /rw +dir /mnt/removable +dir /lib/modules +sym ../bin /sbin +sym ../ /usr -dir /sbin -sym ../bin/sh /sbin/init +etc rc.init 0755 +etc rc.shutdown 0755 +etc fstab +pkg sinit pkg oksh +pkg rc pkg sbase +pkg ubase pkg mandoc \ apropos \