summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml3
-rw-r--r--gen.lua2
-rw-r--r--ninja.lua14
-rwxr-xr-xpkg/ffmpeg/scripts/sources.sh (renamed from pkg/ffmpeg/scripts/sources.rc)5
-rw-r--r--pkg/git/fetch.rc17
-rw-r--r--pkg/git/fetch.sh18
-rw-r--r--pkg/openbsd/fetch.sh30
-rw-r--r--pkg/openbsd/gen.lua11
-rw-r--r--pkg/tz/gen.lua2
-rw-r--r--pkg/tz/tzdata.lua2
-rw-r--r--rules.ninja14
-rw-r--r--scripts/commit.rc19
-rw-r--r--scripts/commit.sh16
-rw-r--r--scripts/configheader.rc18
-rw-r--r--scripts/fetch-curl.rc45
-rw-r--r--scripts/fetch-curl.sh40
-rw-r--r--scripts/fetch-git.rc15
-rw-r--r--scripts/fetch-git.sh13
-rw-r--r--scripts/hash.rc24
-rw-r--r--scripts/hash.sh18
-rw-r--r--scripts/probe.rc7
-rw-r--r--scripts/probe.sh7
-rw-r--r--scripts/tree.rc30
-rw-r--r--scripts/tree.sh19
24 files changed, 185 insertions, 204 deletions
diff --git a/.travis.yml b/.travis.yml
index 786a506c..69115681 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,14 +6,13 @@ git:
addons:
apt:
packages:
- - 9base
- libwayland-dev
- lua5.2
- nasm
- pax
install:
- git clone --depth=1 https://github.com/michaelforney/oasis-toolchain /tmp/toolchain
-- PATH=$PATH:/usr/lib/plan9/bin:/tmp/toolchain/bin
+- PATH=$PATH:/tmp/toolchain/bin
script:
- git submodule update --init pkg/samurai/src
- make -C pkg/samurai/src
diff --git a/gen.lua b/gen.lua
index 759143a5..5153ce5f 100644
--- a/gen.lua
+++ b/gen.lua
@@ -29,7 +29,7 @@ subgen 'src'
file('.perms', '644', '$outdir/root.perms')
build('gitinit', '$builddir/root.stamp')
-build('gittree', '$builddir/root.tree', {'$outdir/root.index', '|', 'scripts/tree.rc', '||', '$builddir/root.stamp'})
+build('gittree', '$builddir/root.tree', {'$outdir/root.index', '|', 'scripts/tree.sh', '||', '$builddir/root.stamp'})
build('gitarchive', '$builddir/root.tar', {'|', '$builddir/root.tree'})
build('gitcommit', '$builddir/root.commit', {'|', '$builddir/root.tree'})
build('phony', 'commit', '$builddir/root.commit')
diff --git a/ninja.lua b/ninja.lua
index e07c574a..137c9974 100644
--- a/ninja.lua
+++ b/ninja.lua
@@ -360,8 +360,14 @@ function waylandproto(proto, client, server, code)
cc(code, {'pkg/wayland/headers'})
end
-function fetch(method, args)
- build('fetch'..method, '$dir/fetch', {'|', '$dir/rev'}, {args=args})
+function fetch(method)
+ local script
+ if method == 'local' then
+ script = '$dir/fetch.sh'
+ else
+ script = 'scripts/fetch-'..method..'.sh'
+ end
+ build('fetch'..method, '$dir/fetch', {'|', '$dir/rev', script})
if next(pkg.inputs.fetch) then
build('phony', table.keys(pkg.inputs.fetch), '$dir/fetch')
end
@@ -404,7 +410,7 @@ function file(path, mode, src)
local out = '$builddir/root.hash/'..path
mode = tonumber(mode, 8)
local perm = string.format('10%04o %s', mode, path)
- build('githash', out, {src, '|', 'scripts/hash.rc', '||', '$builddir/root.stamp'}, {
+ build('githash', out, {src, '|', 'scripts/hash.sh', '||', '$builddir/root.stamp'}, {
args=perm,
})
table.insert(pkg.inputs.index, out)
@@ -426,7 +432,7 @@ function sym(path, target)
return
end
local out = '$builddir/root.hash/'..path
- build('githash', out, {'|', 'scripts/hash.rc', '||', '$builddir/root.stamp'}, {
+ build('githash', out, {'|', 'scripts/hash.sh', '||', '$builddir/root.stamp'}, {
args=string.format('120000 %s %s', path, target),
})
table.insert(pkg.inputs.index, out)
diff --git a/pkg/ffmpeg/scripts/sources.rc b/pkg/ffmpeg/scripts/sources.sh
index d963e714..eac0e495 100755
--- a/pkg/ffmpeg/scripts/sources.rc
+++ b/pkg/ffmpeg/scripts/sources.sh
@@ -1,7 +1,6 @@
-#!/bin/rc
+#!/bin/sh
-flag e +
-flag x +
+set -ex
../src/configure >/dev/null
awk '{print $2}' config.asm >vars.txt
diff --git a/pkg/git/fetch.rc b/pkg/git/fetch.rc
deleted file mode 100644
index bec188d5..00000000
--- a/pkg/git/fetch.rc
+++ /dev/null
@@ -1,17 +0,0 @@
-flag e +
-
-@ . ./scripts/fetch-git.rc $*
-
-cd $1
-shift
-
-if([ -e src/man ])
- rm -rf src/man
-
-if(! sha256sum -c sha256 >[2]/dev/null) {
- curl -L -O -K url
- sha256sum -c sha256
-}
-
-archive=`{awk '{print $2}' sha256}
-xzcat $archive | pax -r -s ',^\.,src/man,'
diff --git a/pkg/git/fetch.sh b/pkg/git/fetch.sh
new file mode 100644
index 00000000..289daf1f
--- /dev/null
+++ b/pkg/git/fetch.sh
@@ -0,0 +1,18 @@
+set -e
+
+(. ./scripts/fetch-git.sh "$@")
+
+cd "$1"
+shift
+
+if [ -e src/man ] ; then
+ rm -rf src/man
+fi
+
+if ! sha256sum -c sha256 2>/dev/null ; then
+ curl -L -O -K url
+ sha256sum -c sha256
+fi
+
+read -r checksum archive <sha256
+xzcat "$archive" | pax -r -s ',^\.,src/man,'
diff --git a/pkg/openbsd/fetch.sh b/pkg/openbsd/fetch.sh
new file mode 100644
index 00000000..8350bd3a
--- /dev/null
+++ b/pkg/openbsd/fetch.sh
@@ -0,0 +1,30 @@
+set -e
+
+dir=$1
+shift
+
+cd "$dir"
+
+if [ -e src ] ; then
+ rm -rf src
+fi
+
+if ! sha256sum -c sha256 2>/dev/null ; then
+ curl -L -K url -O
+ sha256sum -c sha256
+fi
+
+zcat src.tar.gz | pax -r -s '/^/src\//' \
+ 'bin/pax/*' \
+ 'include/*' \
+ 'lib/libc/*' \
+ 'lib/libcrypto/arc4random/*' \
+ 'usr.bin/diff/*' \
+ 'usr.bin/doas/*' \
+ 'usr.bin/fmt/*' \
+ 'usr.bin/nc/*' \
+ 'usr.bin/patch/*' \
+ 'usr.bin/yacc/*'
+zcat sys.tar.gz | pax -r -s '/^/src\//' 'sys/sys/*'
+
+git apply -v --whitespace=nowarn --directory "$dir/src" patch/*
diff --git a/pkg/openbsd/gen.lua b/pkg/openbsd/gen.lua
index 4104ec0e..fb08788f 100644
--- a/pkg/openbsd/gen.lua
+++ b/pkg/openbsd/gen.lua
@@ -87,13 +87,4 @@ exe('yacc', [[usr.bin/yacc/(
file('bin/yacc', '755', '$outdir/yacc')
man{'usr.bin/yacc/yacc.1'}
-fetch('curl', paths[[
- -s '/^/src\//' '(
- bin/pax
- include
- lib/(libc/(crypt gen net stdlib string) libcrypto/arc4random)
- usr.bin/(diff doas fmt nc patch yacc)
- )/*'
- ';'
- -s '/^/src\//' 'sys/sys/*'
-]])
+fetch 'local'
diff --git a/pkg/tz/gen.lua b/pkg/tz/gen.lua
index 6fa350eb..d97a55fa 100644
--- a/pkg/tz/gen.lua
+++ b/pkg/tz/gen.lua
@@ -19,7 +19,7 @@ local tzdata = {
rule('tzdata', 'lua $dir/tzdata.lua $repo $outdir/zoneinfo $in >$out.tmp && mv $out.tmp $out')
build('tzdata', '$outdir/tzdata.index', {
expand{'$srcdir/', tzdata},
- '|', '$dir/tzdata.lua', 'scripts/hash.rc',
+ '|', '$dir/tzdata.lua', 'scripts/hash.sh',
'||', '$builddir/root.stamp',
})
table.insert(pkg.inputs.index, '$outdir/tzdata.index')
diff --git a/pkg/tz/tzdata.lua b/pkg/tz/tzdata.lua
index 9777e10c..903af2cf 100644
--- a/pkg/tz/tzdata.lua
+++ b/pkg/tz/tzdata.lua
@@ -4,7 +4,7 @@ local function execute(cmd)
end
end
-local hash = 'rc ./scripts/hash.rc %s %s share/zoneinfo/%s %s'
+local hash = 'sh ./scripts/hash.sh %s %s share/zoneinfo/%s %s'
local repo = arg[1]
local outdir = arg[2]
for i = 3, #arg do
diff --git a/rules.ninja b/rules.ninja
index 8d02c75d..89fb5b87 100644
--- a/rules.ninja
+++ b/rules.ninja
@@ -40,7 +40,7 @@ rule muse
command = muse $museflags -o $out $in
rule probe
- command = rc ./scripts/probe.rc $var $cc $cflags $ldflags -o /dev/null -x c $in >$out.tmp && mv $out.tmp $out
+ command = sh ./scripts/probe.sh $var $cc $cflags $ldflags -o /dev/null -x c $in >$out.tmp && mv $out.tmp $out
# misc tools
rule touch
@@ -80,14 +80,14 @@ rule waylandproto
command = wayland-scanner $type <$in >$out.tmp && mv $out.tmp $out
rule githash
- command = rc ./scripts/hash.rc $repo $args $in >$out.tmp && mv $out.tmp $out
+ command = sh ./scripts/hash.sh $repo $args $in >$out.tmp && mv $out.tmp $out
rule gittree
- command = rc ./scripts/tree.rc $repo $repo_tag $in $out
+ command = sh ./scripts/tree.sh $repo $repo_tag $in $out
restat = 1
rule gitcommit
- command = rc ./scripts/commit.rc $repo $repo_branch $repo_tag $out
+ command = sh ./scripts/commit.sh $repo $repo_branch $repo_tag $out
rule gitarchive
command = git -C $repo archive -o $$PWD/$out $repo_tag
@@ -96,19 +96,19 @@ rule gitinit
command = git init $repo_flags $repo && touch $out
rule fetchcurl
- command = rc ./scripts/fetch-curl.rc $dir $args && touch $out
+ command = sh ./scripts/fetch-curl.sh $dir && touch $out
restat = 1
generator = 1
pool = console
rule fetchgit
- command = rc ./scripts/fetch-git.rc $dir $args && touch $out
+ command = sh ./scripts/fetch-git.sh $dir && touch $out
restat = 1
generator = 1
pool = console
rule fetchlocal
- command = rc ./$dir/fetch.rc $dir $args && touch $out
+ command = sh ./$dir/fetch.sh $dir && touch $out
restat = 1
generator = 1
pool = console
diff --git a/scripts/commit.rc b/scripts/commit.rc
deleted file mode 100644
index 870d7ab3..00000000
--- a/scripts/commit.rc
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/rc
-
-flag e +
-
-repo=$1
-branch=$2
-tag=$3
-out=$4
-
-fn checkstatus {}
-
-if(git -C $repo show-ref -q --verify refs/heads/$branch)
- parent=(-p $branch)
-if not parent=()
-
-message='oasis built by '`{id -un}
-commit=`{echo $message | git -C $repo commit-tree $tag $parent} ; checkstatus
-git -C $repo update-ref refs/heads/$branch $commit
-echo $commit > $out.tmp && mv $out.tmp $out
diff --git a/scripts/commit.sh b/scripts/commit.sh
new file mode 100644
index 00000000..b4959f48
--- /dev/null
+++ b/scripts/commit.sh
@@ -0,0 +1,16 @@
+set -e
+
+repo=$1
+branch=$2
+tag=$3
+out=$4
+
+if git -C "$repo" show-ref -q --verify "refs/heads/$branch" ; then
+ set -- -p "$branch"
+else
+ set --
+fi
+
+commit=$(git -C "$repo" commit-tree -m "oasis built by $(id -un)" "$@" "$tag")
+git -C "$repo" update-ref "refs/heads/$branch" "$commit"
+echo "$commit" >"$out.tmp" && mv "$out.tmp" "$out"
diff --git a/scripts/configheader.rc b/scripts/configheader.rc
deleted file mode 100644
index c1655f91..00000000
--- a/scripts/configheader.rc
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/rc
-
-flag e +
-
-fn checkstatus {}
-
-posix_defines=`{mktemp}
-checkstatus
-
-fn sigexit {
- status=() rm $posix_defines
-}
-
-awk '{if($1 == "#define") print $2 ; if($2 == "#undef") print $3}' include/config-posix.h >$posix_defines
-defines=`{awk '{if($1 == "#undef") print $2}' $1 | grep -F -x -v -f $posix_defines}
-checkstatus
-
-printf '#undef %s\n' $defines
diff --git a/scripts/fetch-curl.rc b/scripts/fetch-curl.rc
deleted file mode 100644
index a525bcdf..00000000
--- a/scripts/fetch-curl.rc
+++ /dev/null
@@ -1,45 +0,0 @@
-flag e +
-
-if(~ $#* 0) {
- echo 'usage: fetch-curl.rc dir [paxflags...]' >[1=2]
- exit 2
-}
-
-cd $1
-shift
-
-if([ -e src ]) rm -rf src
-
-if(! sha256sum -c sha256 >[2]/dev/null) {
- curl -L -K url -O
- sha256sum -c sha256
-}
-
-for(archive in `{awk '{print $2}' sha256}) {
- switch($archive) {
- case *.tar.gz *.tgz
- tool=zcat
- case *.tar.bz2
- tool=bzcat
- case *.tar.xz
- tool=xzcat
- case *
- tool=()
- }
- flags=()
- while(! ~ $1 '' ';') {
- flags=($flags $1)
- shift
- }
- if(~ $#flags 0)
- flags=(-s '/^\.\|[^\/]*/src/' '*/*')
- shift
- if(! ~ $#tool 0) $tool $archive | pax -r $flags
-}
-
-if([ -d patch ]) {
- if(prefix=`{git rev-parse --show-prefix >[2]/dev/null}) dir=$prefix^src
- if not dir=src
- git apply -v '--whitespace=nowarn' --directory $dir patch/*
-}
-status=()
diff --git a/scripts/fetch-curl.sh b/scripts/fetch-curl.sh
new file mode 100644
index 00000000..86f7598e
--- /dev/null
+++ b/scripts/fetch-curl.sh
@@ -0,0 +1,40 @@
+set -e
+
+if [ "$#" != 1 ] ; then
+ echo 'usage: fetch-curl.sh dir' >&2
+ exit 2
+fi
+
+dir=$1
+shift
+
+cd "$dir"
+
+if [ -e src ] ; then
+ rm -rf src
+fi
+
+if ! sha256sum -c sha256 2>/dev/null ; then
+ curl -L -K url -O
+ sha256sum -c sha256
+fi
+
+while read -r checksum archive ; do
+ case $archive in
+ *.tar.gz|*.tgz)
+ tool=zcat ;;
+ *.tar.bz2)
+ tool=bzcat ;;
+ *.tar.xz)
+ tool=xzcat ;;
+ *)
+ tool=
+ esac
+ if [ -n "$tool" ] ; then
+ "$tool" "$archive" | pax -r -s '/^\.\|[^\/]*/src/' '*/*'
+ fi
+done <sha256
+
+if [ -d patch ] ; then
+ git apply -v --whitespace=nowarn --directory "$dir/src" patch/*
+fi
diff --git a/scripts/fetch-git.rc b/scripts/fetch-git.rc
deleted file mode 100644
index 14f28afc..00000000
--- a/scripts/fetch-git.rc
+++ /dev/null
@@ -1,15 +0,0 @@
-flag e +
-
-if(! ~ $#* 1) {
- echo 'usage: fetch-git.rc dir' >[1=2]
- exit 2
-}
-
-cd $1
-
-git submodule update --init --checkout src
-if([ -d patch ]) {
- patches=patch/*
- git -C src am '--whitespace=nowarn' ../$patches
-}
-status=()
diff --git a/scripts/fetch-git.sh b/scripts/fetch-git.sh
new file mode 100644
index 00000000..eea32d1c
--- /dev/null
+++ b/scripts/fetch-git.sh
@@ -0,0 +1,13 @@
+set -e
+
+if [ "$#" != 1 ] ; then
+ echo 'usage: fetch-git.sh dir' >&2
+ exit 2
+fi
+
+cd "$1"
+
+git submodule update --init --checkout src
+if [ -d patch ] ; then
+ git -C src am --whitespace=nowarn "$PWD"/patch/*
+fi
diff --git a/scripts/hash.rc b/scripts/hash.rc
deleted file mode 100644
index 90151183..00000000
--- a/scripts/hash.rc
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/rc
-
-flag e +
-
-repo=$1
-mode=$2
-name=$3
-shift 3
-
-fn checkstatus {}
-
-hash=`{
- switch($mode) {
- case 12????
- printf %s $1 | git -C $repo hash-object -w --stdin
- case 10????
- git -C $repo hash-object -w --stdin <$1
- case *
- status=1
- }
-}
-checkstatus
-
-printf '%s %s\t%s\n' $mode $hash $name
diff --git a/scripts/hash.sh b/scripts/hash.sh
new file mode 100644
index 00000000..15861d27
--- /dev/null
+++ b/scripts/hash.sh
@@ -0,0 +1,18 @@
+set -e
+
+repo=$1
+mode=$2
+name=$3
+shift 3
+
+case "$mode" in
+12????)
+ hash=$(printf %s "$1" | git -C "$repo" hash-object -w --stdin) ;;
+10????)
+ hash=$(git -C "$repo" hash-object -w --stdin <"$1") ;;
+*)
+ echo "invalid mode: $mode"
+ exit 1
+esac
+
+printf '%s %s\t%s\n' "$mode" "$hash" "$name"
diff --git a/scripts/probe.rc b/scripts/probe.rc
deleted file mode 100644
index aba1099d..00000000
--- a/scripts/probe.rc
+++ /dev/null
@@ -1,7 +0,0 @@
-flag e +
-
-var=$1
-shift
-if($* >[2]/dev/null)
- echo '#define '$var' 1'
-status=()
diff --git a/scripts/probe.sh b/scripts/probe.sh
new file mode 100644
index 00000000..70867cdb
--- /dev/null
+++ b/scripts/probe.sh
@@ -0,0 +1,7 @@
+set -e
+
+var=$1
+shift
+if "$@" 2>/dev/null ; then
+ echo "#define $var 1"
+fi
diff --git a/scripts/tree.rc b/scripts/tree.rc
deleted file mode 100644
index c14e87e0..00000000
--- a/scripts/tree.rc
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/rc
-
-flag e +
-
-repo=$1
-tag=$2
-index=$3
-out=$4
-ifs='
-'
-
-fn checkstatus {}
-
-GIT_INDEX_FILE=`{pwd}^/$out.index {
- checkstatus
- git -C $repo read-tree --empty
- git -C $repo update-index --index-info <$index
- tree=`{git -C $repo write-tree} ; checkstatus
- rm $out.index
-}
-git -C $repo update-ref refs/tags/$tag $tree
-
-if([ -e $out ]) {
- oldtree=`{cat $out} ; checkstatus
- if(~ $tree $oldtree)
- exit 0
-}
-
-echo $tree >$out.tmp
-mv $out.tmp $out
diff --git a/scripts/tree.sh b/scripts/tree.sh
new file mode 100644
index 00000000..15ae6991
--- /dev/null
+++ b/scripts/tree.sh
@@ -0,0 +1,19 @@
+set -e
+
+repo=$1
+tag=$2
+index=$3
+out=$4
+
+export GIT_INDEX_FILE="$PWD/$out.index"
+git -C "$repo" read-tree --empty
+git -C "$repo" update-index --index-info <"$index"
+tree=$(git -C "$repo" write-tree)
+git -C "$repo" update-ref "refs/tags/$tag" "$tree"
+
+printf '%s\n' "$tree" >"$out.tmp"
+if cmp -s "$out" "$out.tmp" ; then
+ rm "$out.tmp"
+else
+ mv "$out.tmp" "$out"
+fi