linux-qubasis

linux oasis port as a qubes template

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

commit 4ef890505a39bd5a87cac157676cbc0834bdff67
parent 9ff2e6da1bf78e09863e7534b3e1292c5b051493
Author: Jul <jul@9o.is>
Date:   Fri, 14 Nov 2025 03:08:06 -0500

refactor: remove unused files

Diffstat:
Dconfig.def.sh | 13-------------
Dconfigure | 26--------------------------
Dninja/functions.sh | 554-------------------------------------------------------------------------------
Dninja/rsp.awk | 35-----------------------------------
Dninja/rules.ninja | 105-------------------------------------------------------------------------------
5 files changed, 0 insertions(+), 733 deletions(-)

diff --git a/config.def.sh b/config.def.sh @@ -1,13 +0,0 @@ -PREFIX= -MANDIR=${PREFIX}/share/man - -BUILDDIR='out' -GZMAN=true - -TARGET_ARCH='x86_64' -TARGET_PLATFORM="$TARGET_ARCH-linux-musl" -TARGET_CFLAGS='-Os -fPIE -pipe -Wall -Werror -Wextra -pedantic' -TARGET_LDFLAGS='-s -static-pie' - -HOST_CFLAGS='-O2 -pipe' -HOST_LDFLAGS= diff --git a/configure b/configure @@ -1,26 +0,0 @@ -#!/bin/sh -set -eu - -export basedir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) - -require() { - if ! which $1 >/dev/null 2>&1; then - echo "Error: host dependency not found in path: $1" - exit 1 - fi -} - -if [ ! -f "$basedir"/config.sh ]; then - cp "$basedir"/config.def.sh "$basedir"/config.sh -fi - -. "$basedir"/config.sh -. "$basedir"/ninja/functions.sh - -require $TARGET_PLATFORM-cc -require $TARGET_PLATFORM-ld -require $TARGET_PLATFORM-ar -require $TARGET_PLATFORM-as -require $TARGET_PLATFORM-objcopy - -maingen ${1-.} ${2-} diff --git a/ninja/functions.sh b/ninja/functions.sh @@ -1,554 +0,0 @@ -error() { - printf "Error gen $_ninja_gendir: %s\n" "$*" - exit 1 -} - -setv() { - _v1=$1; shift; - _vs= - for _v in $*; do - _vs="$_vs $_v" - done - printf '%s = %s\n' "$_v1" "$_vs" >> "$_ninja_writepath" - eval "$_v1='\$$_v1'" -} - -bind() { - _v1=$1; shift; - setv " $_v1" "$*" -} - -include_ninja() { - printf 'include %s\n' $1 >> "$_ninja_writepath" -} - -default() { - _ninja_prefix _v $tgtdir $1 - printf 'default %s\n' $_v >> "$_ninja_writepath" -} - -rule() { - _desc='$out' - - case "$1" in - -o) - _desc=$2 - shift 2 - ;; - esac - - _rule=$1 - _cmd="$2" - - printf 'rule %s\n' $_rule >> "$_ninja_writepath" - bind command "$_cmd" - bind description "$_rule $_desc" - - _dep='' - for _v in $_cmd; do - case "$_v" in - *$dir/* | *$hostdir/* | *$outdir/* | *$srcdir/*) - _dep="$_dep \$${_v#*$}" - ;; - esac - done - - if [ "$_dep" ]; then - _dep="'|'$_dep" - fi - - eval "$_rule() { _out="'$1'"; shift; build $_rule \""'$_out'"\" "'$*'" $_dep; }" -} - -build() { - _v1=$1 - _ninja_prefix _v2 $outdir $2 - shift 2 - - _ninja_prefix _vs $srcdir $* - - _vss= - for _v in $_vs; do - case $_v in - $srcdir/*) _vss="$_vss $_v" - esac - done - - if [ "$_vss" ]; then - _ninja_save srcs $_vss - fi - - printf 'build %s: %s %s\n' "$_v2" "$_v1" "$_vs" >> "$_ninja_writepath" -} - -phony() { - _ninja_prefix _out $tgtdir $1 - shift - build phony "$_out" $* -} - -gen() { build gen $*; } -cc() { build cc $*; } -ar() { build ar $*; } -rsp() { build rsp $*; } -fetch_git() { build fetch_git $*; } -fetch_curl() { build fetch_curl $*; } -sha256sum() { build sha256sum $*; } -extract() { build extract $*; } -extract_decompress() { build extract_decompress $*; } -fspec() { build fspec $*; } -fspec_tar() { build fspec_tar $*; } -qubes_fspec() { build qubes_fspec $*; } -qubes_install() { build qubes_install $*; } -link() { build link $*; } -copy() { build copy $*; } -cat() { build cat $*; } -touch() { build touch $*; } -gzip() { build gzip $*; } -awk() { build awk $*; } -sed() { build sed $*; } -cpp() { build cpp $*; } -patch() { build patch $*; } - -cflags() { - setv cflags '$cflags' "$*" -} - -ldflags() { - setv ldflags '$ldflags' "$*" -} - -man() { - _src=$1 - _sec=${2-} - _out=${_src##*/} - - if [ $_sec ]; then - _out=${_out%.*}.$_sec - else - _sec=${_src##*.} - fi - - if [ "${GZMAN-}" = true ]; then - gzip $_out.gz $_src - else - copy $_out $_src - fi -} - -exe() { - _out=$1; shift - _ninja_compile $* - - if [ "$_objs" ] && [ "$_deps" ]; then - _rspfile=$outdir/_rsp/$_out - - awk $_rspfile $_deps '|' $basedir/ninja/rsp.awk - bind expr '-f $basedir/ninja/rsp.awk' - - link $_out $_objs $_libs '|' $_rspfile - bind ldlibs @$_rspfile - elif [ "$_objs" ]; then - link $_out $_objs $_libs - fi - - _ninja_save build $outdir/$_out -} - -lib() { - _out=$1; shift - _ninja_compile $* - - if [ "$_objs" ]; then - ar $_out $_objs $_libs - rsp $_out.d $outdir/$_out $_libs - fi - - _ninja_save build $outdir/$_out -} - -dep() { - _ninja_prefix _srcs $basedir/pkg $* - _ninja_save deps $_srcs -} - -include() { - __prefix= - __src_prefix=$srcdir - - while [ $# -gt 0 ]; do - case "$1" in - --prefix) - __prefix=$2/ - shift 2 - ;; - --src-prefix) - __src_prefix=$srcdir/$2 - shift 2 - ;; - *) - break - ;; - esac - done - - _ninja_prefix _srcs $__src_prefix $* - - for _src in $_srcs; do - case $_src in - \$srcdir/*) - _out=$outdir/include/${__prefix}${_src##*/} - copy $_out $_src - ;; - *) - _out=$_src - ;; - esac - - _ninja_save headers $_out - done -} - -fetch() { - _fetchdir=$outdir/_fetch - - case $1 in - git) - fetch_git $_fetchdir/fetched - ;; - curl) - _url=$2 - _sha256=$3 - shift 3 - _srcs=$* - _name=${_url##*/} - - fetch_curl $_fetchdir/$_name - bind url $_url - - sha256sum $_fetchdir/checked $_fetchdir/$_name - bind sha256 $_sha256 - - case $_name in - *.tar.gz|*.tgz) - _archive=${_name%.t*gz}.tar - _tool=gzip - _extract_rule=extract_decompress - ;; - *.tar.xz) - _archive=${_name%.xz} - _tool=xz - _extract_rule=extract_decompress - ;; - *.tar.bz2) - _archive=${_name%.bz2} - _tool=bzip2 - _extract_rule=extract_decompress - ;; - *) - _archive=$_name - _extract_rule=extract - ;; - esac - - $_extract_rule $_fetchdir/fetched $_fetchdir/$_name '|' $hostdir/pax $_fetchdir/checked ${_tool_dep-} - bind tool $_tool - bind srcs $_srcs - - if ! grep -qE "^$_ninja_gendir/repo$" "$_ninja_basedir"/.git/info/exclude; then - printf "%s/repo\n" "$_ninja_gendir" >> "$_ninja_basedir"/.git/info/exclude - fi - ;; - *) - error unknown fetch method $1 - ;; - esac - - if [ -d "$_ninja_dir"/patch ]; then - _patches= - for _v in "$_ninja_dir"/patch/*.patch; do - _out=$_fetchdir/${_v##*/} - _in=$dir/${_v#"$_ninja_dir"/} - patch $_out $_in '|' $_fetchdir/fetched $_patches - _patches="$_patches $_out" - done - _ninja_save srcs $_patches - fi -} - -subninja() { - ( - _ninja_subninja=$1 - _ninja_init "$_ninja_gendir" - - setv outdir $outdir/$1 - setv tgtdir $gendir/$1 - - $1 - _ninja_complete - ) - - printf 'subninja $ninjadir/%s.ninja\n' "$_ninja_gendir-$1" >> "$_ninja_writepath" -} - -subgen() { - _prefix= - - if [ $_ninja_type != root ]; then - _prefix="$_ninja_gendir/" - fi - - printf 'subninja $ninjadir/%s.ninja\n' $1 >> "$_ninja_writepath" - - _ninja_save build $tgtdir/$_prefix$1/build - _ninja_save configure $tgtdir/$_prefix$1/configure - _ninja_queue_subgen="$_ninja_queue_subgen $_prefix$1" -} - -maingen() { - _ninja_init $1 - _ninja_setv_init $1 - . "$_ninja_dir"/gen.sh - _ninja_complete - - if [ "$_ninja_queue_subgen" ] && [ ! ${2-} ]; then - set -- $_ninja_queue_subgen - _v1=$1; shift; - _ninja_queue_subgen="$*" - maingen $_v1 - fi -} - -template() { - if [ $# -lt 3 ]; then - _ninja_template="$1 $2" - return - fi - - case $3 in - *M) _ninja_template="$1 $2 $(( ${3%M} * 1048576 ))";; - *) error image size "'$3'" must be suffixed by "'M'";; - esac -} - -## -## Internal ninja functions and variables -## - -_ninja_queue_subgen= - -_ninja_init() { - _ninja_initglobals $1 - _ninja_targets_init - mkdir -p "${_ninja_writepath%/*}" - printf '' > "$_ninja_writepath" -} - -_ninja_complete() { - _ninja_run_host - _ninja_target deps - _ninja_target headers - _ninja_target srcs _fetch/srcs - _ninja_target build _fetch/build - - _ninja_save configure $ninjadir/$_ninja_file - _ninja_target configure - gen $ninjadir/$_ninja_file '|' $basedir/config.sh $basedir/ninja/functions.sh $dir/gen.sh - - if [ $_ninja_type == root ]; then - default build - fi - - mv "$_ninja_writepath" "${_ninja_writepath%.*}" - - if [ $_ninja_type = root ]; then - ln -sf "$_ninja_ninjadir"/$_ninja_file "$_ninja_basedir"/build.ninja - fi -} - -_ninja_initglobals() { - _ninja_basedir="${_ninja_basedir-$basedir}" - _ninja_dir="$_ninja_basedir"/$1 - _ninja_outdir="$_ninja_basedir"/$BUILDDIR/$1 - _ninja_ninjadir="$_ninja_basedir"/$BUILDDIR/ninja - - DIR="$_ninja_dir" - SRCDIR="$_ninja_dir/repo" - - case $1 in - .) - _ninja_type=root - _ninja_file=root.ninja - ;; - pkg/*) - _ninja_type=${1%%/*} - _ninja_gendir=$1 - _ninja_name=${1#*/} - - if [ ${_ninja_subninja-} ]; then - _ninja_file=$1-$_ninja_subninja.ninja - else - _ninja_file=$1.ninja - fi - ;; - *) - error invalid gendir $1 - ;; - esac - - _ninja_writepath="$_ninja_ninjadir"/$_ninja_file.tmp - - _ninja_buffer_objs= - _ninja_template= -} - -_ninja_targets_init() { - _ninja_tgtsdir="$_ninja_outdir/${_ninja_subninja-}/_targets" - - rm -rf "$_ninja_tgtsdir" - mkdir -p "$_ninja_tgtsdir" -} - -_ninja_save() { - _tgt=$1; shift - - if [ "$*" ]; then - printf '%s\n' "$@" >> "$_ninja_tgtsdir/$_tgt" - fi -} - -_ninja_target_exists() { - test -e "$_ninja_tgtsdir/$1" -} - -_ninja_target() { - _tgt=$1 - _empty=${2-} - _vs= - - if _ninja_target_exists $_tgt; then - _vs="$(command cat "$_ninja_tgtsdir/$_tgt" | uniq | xargs)" - fi - - if [ "$_vs" ]; then - phony $_tgt $_vs - elif [ $_empty ]; then - touch $_empty - phony $_tgt $outdir/$_empty - fi -} - -_ninja_setv_init() { - setv gendir $1 - setv tgtdir '$gendir' - - unset -f host - - case $_ninja_type in - pkg) - setv dir $basedir/$gendir - setv outdir $builddir/$gendir - setv srcdir $dir/repo - setv objdir $outdir/_obj - ;; - esac -} - -_ninja_prefix() { - _var=$1; shift - _prefix=$1; shift - _vs= - - for _v in $*; do - case $_v in - \$* | \|* | /*) ;; - *) _v=$_prefix/$_v;; - esac - - if [ "$_vs" ]; then - _vs="$_vs $_v" - else - _vs=$_v - fi - done - - eval "$_var='$_vs'" -} - -_ninja_compile() { - _srcs= - _objs= - _libs= - _deps= - _hdrs= - - for _src in $*; do - case $_src in - *.[cS]) _srcs="$_srcs $_src";; - *.o) _objs="$_objs $_src";; - *.a) _libs="$_libs $_src";; - *.a.d) _deps="$_deps $_src";; - *.h) _hdrs="$_hdrs $_src";; - *) error unknown file to compile: $_src;; - esac - done - - for _src in $_srcs; do - case $_src in - \$*) _obj=$objdir/${_src#\$*/}.o;; - *) _obj=$objdir/$_src.o;; - esac - - if _ninja_has $_obj $_ninja_buffer_objs; then - _objs="$_objs $_obj" - continue - fi - - if _ninja_target_exists deps; then - _src="$_src || \$tgtdir/deps $_hdrs" - elif [ "$_hdrs" ]; then - _src="$_src || $_hdrs" - fi - - cc $_obj $_src - _objs="$_objs $_obj" - _ninja_buffer_objs="$_ninja_buffer_objs $_obj" - done -} - -_ninja_run_host() { - if [ ! ${_ninja_subninja-} ] && command -v host >/dev/null 2>&1; then - ( - _ninja_subninja=host - _ninja_init $_ninja_gendir - - setv outdir $builddir/host - setv tgtdir $gendir/host - setv objdir $outdir/_obj/$_ninja_name - setv ar ar - setv as as - setv cc cc - setv ld ld - setv objcopy objcopy - setv cflags $HOST_CFLAGS - setv ldflags $HOST_LDFLAGS - - host - _ninja_complete - ) - - printf 'subninja $ninjadir/%s-host.ninja\n' $_ninja_gendir >> "$_ninja_writepath" - fi -} - -_ninja_has() { - _v1=$1; shift - - for _v in $*; do - if [ $_v = $_v1 ]; then - return 0 - fi - done - - return 1 -} diff --git a/ninja/rsp.awk b/ninja/rsp.awk @@ -1,35 +0,0 @@ -function line() { - if (match($0, /\.d$/)) - read($0) - else - libs[++n] = $0 -} - -function read(name) { - for (;;) { - ret = getline < name - if (ret < 0) { - print "failed to read line from " name > "/proc/self/fd/2" - exit(1) - } - if (ret == 0) - break - line() - } - close(name) -} - -{line()} - -END { - for (i = n; i > 0; --i) { - lib = libs[i] - if (lib in seen) - continue - seen[lib] = 1 - uniq[++m] = lib - } - for (i = m; i > 0; --i) - print uniq[i] -} - diff --git a/ninja/rules.ninja b/ninja/rules.ninja @@ -1,105 +0,0 @@ -rule gen - command = sh $basedir/configure $gendir skipsubgen - description = CONFIGURE $gendir - generator = 1 - -rule sync - command = sh $basedir/ninja/sync.sh $gendir $in $out >/dev/null - description = SYNC $gendir - generator = 1 - pool = console - -rule cc - command = $cc -MD -MF $out.d $cflags -c -o $out $in - depfile = $out.d - deps = gcc - description = CC $out - -rule link - command = $cc $ldflags -o $out $in $ldlibs - description = LINK $out - -rule ar - command = rm -f $out && $ar crs $out $in - description = AR $out - -rule cpp - command = $cc -MD -MF $out.d $cflags -E -P -o $out $in - depfile = $out.d - deps = gcc - description = CPP $out - -rule copy - command = ln -f $in $out - description = COPY $out - -rule touch - command = touch $out - description = TOUCH $out - -rule cat - command = cat $in >$out - description = CAT $out - -rule gzip - command = gzip -c -9 <$in >$out - description = GZIP $out - -rule awk - command = awk $expr $in >$out - description = AWK $out - -rule rsp - command = ln -f $rspfile $out - description = RSP $out - rspfile = $out.tmp - rspfile_content = $in_newline - -rule fspec - command = sh $basedir/ninja/fspec.sh $out $path $type $mode $uid $gid $in $target >/dev/null - description = FSPEC $out - -rule fspec_tar - command = $hostdir/fspec-tar <$outdir/_fspec/ALL | zstd >$out - description = FSPEC-TAR $out - -rule fetch_curl - command = rm -f $out && curl -L# -o $out $url - description = FETCH CURL $out - generator = 1 - pool = console - -rule fetch_git - command = git submodule update --init --checkout $srcdir && touch $out - description = FETCH GIT $gendir - generator = 1 - pool = console - -rule sha256sum - command = test '$sha256' = "$$(sha256sum $in | awk '{print $$1}')" && touch $out - description = SHA256SUM $in - -rule extract - command = rm -rf $srcdir && $hostdir/pax -r -s ',^[^/]*,$srcdir,' $srcs <$in && touch $out - description = EXTRACT $srcdir - -rule extract_decompress - command = rm -rf $srcdir && $tool -c -d <$in | $hostdir/pax -r -s ',^[^/]*,$srcdir,' $srcs && touch $out - description = EXTRACT/DECOMPRESS $srcdir - -rule patch - command = git -C $srcdir am --3way --keep-non-patch --no-gpg-sign --whitespace=nowarn ../../../$in >/dev/null && touch $out - description = PATCH $in - -rule sed - command = sed $expr $in >$out - description = SED $out - -rule qubes_install - command = sh $basedir/ninja/qubes-install.sh $template $label $size $tar && touch $out - description = QUBES-INSTALL $template - pool = console - -rule qubes_fspec - command = sh $basedir/ninja/qubes-fspec.sh $template $path $tar && touch $out - description = QUBES-FSPEC $template