linux-qubasis

linux oasis port as a qubes template

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

commit c6127f6c228e43943ec03974196095e4264e6eea
parent 3828b9f51c8f2724a23a385f94099f865a5b7be0
Author: Jul <jul@9o.is>
Date:   Fri, 22 Aug 2025 22:33:03 +0800

add ninja curl for syncing sources

Diffstat:
Mninja/rules.ninja | 2+-
Mninja/sync.sh | 57++++++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/ninja/rules.ninja b/ninja/rules.ninja @@ -4,7 +4,7 @@ rule gen generator = 1 rule sync - command = cd $basedir && sh $basedir/ninja/sync.sh $gendir $in $out >/dev/null + command = cd $basedir && downloads=$builddir/downloads sh $basedir/ninja/sync.sh $gendir $in $out >/dev/null description = SYNC $gendir generator = 1 pool = console diff --git a/ninja/sync.sh b/ninja/sync.sh @@ -1,5 +1,4 @@ -set -e - +set -eu if [ "$#" != 3 ] ; then echo 'usage: sync.sh gendir in out' >&2 @@ -17,6 +16,42 @@ if [ ! "${method-}" ]; then exit 1 fi +if [ ! "${rel-}" ]; then + printf "Error sync $dir: missing sync rel\n" >&2 + exit 1 +fi + +sync_curl() { + local repo="$1" + local url="$2" + local sha256="$3" + local rel="$4" + local file="$downloads/${url##*/}" + + if [ -e "$repo" ]; then + rm -rf "$repo" + fi + + if [ ! -e "$file" ]; then + mkdir -p "$downloads" + curl -OL --progress-bar --output-dir "$downloads" "$url" + + printf "$sha256 $file" > "$file.sha256" + sha256sum --check "$file.sha256" >/dev/null + fi + + if ! grep -qE "^$repo$" .git/info/exclude; then + printf "%s\n" "$repo" >> .git/info/exclude + fi + + mkdir "$repo" + tar -xzf "$file" -C "$repo" --strip-components=1 + + if [ -d patch ] ; then + git apply --whitespace=nowarn --directory "$repo" patch/*.patch + fi +} + sync_git() { local repo="$1" local ref="$2" @@ -35,14 +70,22 @@ sync_git() { } case $method in - git) - if [ ! "${ref-}" ]; then - printf "Error sync $dir: missing git ref\n" >&2 + curl) + if [ ! "${url-}" ]; then + printf "Error sync $dir: missing curl url\n" >&2 exit 1 fi - if [ ! "${rel-}" ]; then - printf "Error sync $dir: missing git rel\n" >&2 + if [ ! "${sha256-}" ]; then + printf "Error sync $dir: missing curl sha256\n" >&2 + exit 1 + fi + + sync_curl $dir/repo "$url" $sha256 $rel + ;; + git) + if [ ! "${ref-}" ]; then + printf "Error sync $dir: missing git ref\n" >&2 exit 1 fi