linux-qubasis
linux oasis port as a qubes template
git clone https://9o.is/git/linux-qubasis.git
commit 8fba047e21e68dd2478e6b21d98d6d3567ead2c9 parent c185f1c77c0d4d1e38296a4f874c47dc06ac8b17 Author: Jul <jul@9o.is> Date: Mon, 17 Nov 2025 08:48:57 -0500 qubes fspec support with generated pkg files Diffstat:
| M | gen.sh | | | 2 | +- |
| A | pkg/files.sh | | | 19 | +++++++++++++++++++ |
| M | pkg/gen.sh | | | 4 | ++++ |
| M | pkg/genfn.sh | | | 17 | +++++++++++++++++ |
| D | pkg/netbsd-curses/files | | | 14 | -------------- |
| M | qubes/example/gen.sh | | | 1 | + |
| M | qubes/fspec.awk | | | 9 | ++++----- |
| M | qubes/gen.sh | | | 12 | +++++++----- |
| M | qubes/genfn.sh | | | 21 | +++++++++++---------- |
9 files changed, 64 insertions(+), 35 deletions(-)
diff --git a/gen.sh b/gen.sh @@ -3,7 +3,7 @@ set -eu . ./genfn.sh var ninja_required_version 1.8 -var builddir out +var builddir ./out var dir . var outdir $builddir var hostdir $outdir/host diff --git a/pkg/files.sh b/pkg/files.sh @@ -0,0 +1,19 @@ +outdir=$1 +shift + +while [ $# -gt 0 ]; do + case "$1" in + reg) + printf "reg $2 $3 $4\n" + shift 4 + ;; + sym) + printf "sym 0777 $2 $3\n" + shift 3 + ;; + *) + printf "%s: error parsing: unknown %s\n" $0 $1 + exit 1 + ;; + esac +done diff --git a/pkg/gen.sh b/pkg/gen.sh @@ -68,6 +68,10 @@ bind description 'EXTRACT $in' rule patch 'git -C $srcdir am -3 --keep-non-patch --no-gpg-sign --whitespace=nowarn ../../../$in >/dev/null && touch $out' bind description 'PATCH $in' +rule files 'sh ./pkg/files.sh $outdir $files >$out' +bind description 'GEN $out' +bind generator 1 + pkg ag pkg awk pkg b3sum diff --git a/pkg/genfn.sh b/pkg/genfn.sh @@ -3,6 +3,7 @@ pkg() { } init_pkg() { + FILE= OBJS= HDRS= SRCS= @@ -27,6 +28,11 @@ fini_pkg() { if [ "$SRCS" ]; then phony "$(printf '%s\n' $SRCS | sort | uniq | xargs)" $outdir/fetched "$PCHS" fi + + if [ "$FILE" ]; then + files files '|' ./pkg/files.sh $GEN_FILES + bind files $FILE + fi } run_host() { @@ -113,6 +119,8 @@ exe() { elif [ "$_objs" ]; then link $_out $_objs $_libs fi + + file reg 0755 '\$$bindir'/$_out $outdir/$_out } lib() { @@ -123,6 +131,8 @@ lib() { ar $libdir/$_out $_objs $_libs rsp $libdir/$_out.d $outdir/$_out $_libs fi + + file reg 0644 '\$$libdir'/$_out $libdir/$_out } compile() { @@ -271,7 +281,14 @@ man() { if [ $_sec ]; then _out=${_out%.*}.$_sec + else + _sec=${_out##*.} fi gzip $_out.gz $_src + file reg 0644 '\$$mandir'/man$_sec/$_out.gz $outdir/$_out.gz +} + +file() { + FILE="$FILE $*" } diff --git a/pkg/netbsd-curses/files b/pkg/netbsd-curses/files @@ -1,14 +0,0 @@ -reg 0644 terminfo.cdb $datadir/misc -reg 0644 libcurses.a $libdir -reg 0644 libterminfo.a $libdir -reg 0755 infocmp $bindir -reg 0755 tabs $bindir -reg 0755 tic $bindir -reg 0755 tput $bindir -reg 0755 tset $bindir -sym tset $bindir/reset -reg 0644 infocmp.1.gz $mandir/man1 -reg 0644 tabs.1.gz $mandir/man1 -reg 0644 tic.1.gz $mandir/man1 -reg 0644 tput.1.gz $mandir/man1 -reg 0644 tset.1.gz $mandir/man1 diff --git a/qubes/example/gen.sh b/qubes/example/gen.sh @@ -3,4 +3,5 @@ var prefix /usr pkgexclude $libdir/.* pkgexclude $includedir/.* +pkg mandoc pkg netbsd-curses diff --git a/qubes/fspec.awk b/qubes/fspec.awk @@ -21,8 +21,7 @@ function exclude(path) { } $1 == "reg" { - filename = $3; - path = eval_path($4 "/" filename); + path = eval_path($3); if (exclude(path)) { next @@ -31,7 +30,7 @@ $1 == "reg" { print prefix path; print "type=" $1; print "mode=" $2; - print "source=" pkgpath "/" filename; + print "source=" $4; print ""; print ""; } @@ -45,8 +44,8 @@ $1 == "sym" { print prefix path; print "type=" $1; - print "mode=0777"; - print "target=" $2; + print "mode=" $2; + print "target=" $4; print ""; print ""; } diff --git a/qubes/gen.sh b/qubes/gen.sh @@ -11,19 +11,21 @@ var includedir /include var statedir /var var qubesdir $dir +var pkgexclude rule touch 'touch $out' bind description 'TOUCH $out' -rule fspec_hash '$hostdir/fspec-hash <$in >$out' -bind description 'FSPEC HASH $out' +rule fspec_hash 'cat $in | $hostdir/fspec-hash >$out' +bind description 'FSPEC $out' rule fspec_tar '$hostdir/fspec-tar <$in | gzip -c -9 >$out' -bind description 'FSPEC TAR $out' +bind description 'TAR $out' -rule fspec 'awk -f $qubesdir/fspec.awk $fspecdirs $fspecvars $in >$out 2>/dev/null' +rule fspec 'awk -f $qubesdir/fspec.awk $fspecvars $in >$out 2>/dev/null' bind description 'FSPEC $out' -bind fspecdirs " +bind fspecvars " + -v pkgexclude=$pkgexclude -v prefix=$prefix -v bindir=$bindir -v datadir=$datadir diff --git a/qubes/genfn.sh b/qubes/genfn.sh @@ -28,29 +28,30 @@ fini_qvm() { } pkg() { - _in=./pkg/$1/files + _in=./out/pkg/$1/files _out=$outdir/fspec/$1.fspec - _deps="$(awk -v pkgexclude="${PKGEXCLUDE-}" " + GEN_FILES="$GEN_FILES $_in" + + if [ ! -e $_in ]; then + return + fi + + _deps="$(awk -v pkgexclude="$PKGEXCLUDE" " BEGIN { gsub(/\\//, \"\\\\/\", pkgexclude); gsub(/\\$/, \"\\\\$\", pkgexclude); } /^reg / { - path = \$4 \"/\" \$3; pattern = \"^(\" pkgexclude \")$\" - if (pkgexclude != \"\" && path ~ pattern) { next } - print \"\$pkgpath/\" \$3 + if (pkgexclude != \"\" && \$3 ~ pattern) { next } + print \$4 } - " $_in 2>/dev/null | xargs)" + " $_in | xargs)" fspec $_out $_in '|' $_deps - bind pkgpath out/pkg/$1 - bind fspecvars -v pkgpath=out/pkg/$1 -v pkgexclude=\'${pkgexclude-}\' - FSPECS="$FSPECS $_out" - GEN_FILES="$GEN_FILES $_in" } pkgexclude() {