opkg

statically linked package installer
git clone anongit@rnpnr.xyz:opkg.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

Commit: 632b301e2380ce68b4ee93f2e6c5ac5fb8d1dde5
Parent: 5118426a3c351fb0cb5f32b75a3bc19bff3bf082
Author: Michael Forney
Date:   Tue, 10 Mar 2026 22:55:04 -0700

Store dist files in config.distdir

This makes it easy to remove old distfiles with `git clean -f dist`.

Diffstat:
M.gitignore | 1+
Mconfig.def.lua | 3+++
Adist/.gitignore | 15+++++++++++++++
Mpkg/curl/.gitignore | 1-
Mpkg/git/.gitignore | 1-
Mpkg/git/fetch.sh | 18++++++++++--------
Mpkg/hyx/.gitignore | 1-
Mpkg/less/.gitignore | 1-
Mpkg/linux-headers/.gitignore | 1-
Mpkg/linux-headers/fetch.sh | 18+++++++++---------
Mpkg/lpeg/.gitignore | 1-
Mpkg/lua/.gitignore | 1-
Mpkg/man-pages-posix/.gitignore | 1-
Mpkg/mandoc/.gitignore | 1-
Mpkg/openbsd/.gitignore | 2--
Mpkg/openbsd/fetch.sh | 20++++++++++----------
Mpkg/optipng/.gitignore | 1-
Mpkg/pcre/.gitignore | 1-
Mpkg/strace/.gitignore | 1-
Mpkg/transmission/.gitignore | 1-
Mrules.ninja | 2+-
Mscripts/fetch-curl.sh | 17++++++++++-------
Mscripts/fetch-git.sh | 6++++--
Msetup.lua | 18++++++++++++++++++
24 files changed, 81 insertions(+), 52 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,5 +1,6 @@ /config.lua /out +/paths.sh fetch local.ninja .*.swp diff --git a/config.def.lua b/config.def.lua @@ -9,6 +9,9 @@ C.builddir = 'out' -- install prefix (needed by some packages) C.prefix = '' +-- distfile directory +C.distdir = 'dist' + -- compress man pages C.gzman = true diff --git a/dist/.gitignore b/dist/.gitignore @@ -0,0 +1,15 @@ +/curl-8.5.0.tar.gz +/git-manpages-2.49.0.tar.gz +/hyx-2026.01.11.tar.xz +/less-643.tar.gz +/linux-6.19.tar.xz +/lpeg-1.1.0.tar.gz +/lua-5.2.4.tar.gz +/man-pages-posix-2017-a.tar.gz +/mandoc-1.14.6.tar.gz +/optipng-7.9.1.tar.gz +/pcre-8.45.tar.gz +/src.tar.gz +/strace-6.19.tar.xz +/sys.tar.gz +/transmission-3.00.tar.xz diff --git a/pkg/curl/.gitignore b/pkg/curl/.gitignore @@ -1,2 +1 @@ -/curl-8.5.0.tar.gz /src diff --git a/pkg/git/.gitignore b/pkg/git/.gitignore @@ -1,3 +1,2 @@ -/git-manpages-2.49.0.tar.gz /man /man.ninja diff --git a/pkg/git/fetch.sh b/pkg/git/fetch.sh @@ -2,17 +2,19 @@ set -e sh scripts/fetch-git.sh "$@" -cd "$1" +. ./paths.sh +dir=$1 shift -if [ -e src/man ] ; then - rm -rf src/man -fi +cd "$distdir" -if ! sh "$OLDPWD/scripts/checksum.sh" -c sha256 2>/dev/null ; then - curl -L -O -K url - sh "$OLDPWD/scripts/checksum.sh" -c sha256 +if ! sh "$basedir/scripts/checksum.sh" -c "$basedir/$dir/sha256" 2>/dev/null ; then + curl -L -O -K "$basedir/$dir/url" + sh "$basedir/scripts/checksum.sh" -c "$basedir/$dir/sha256" fi +cd "$basedir/$dir" +rm -rf src/man + read -r _ archive <sha256 -sh "$OLDPWD/scripts/extract.sh" "$archive" -s ',^\.,src/man,' +sh "$basedir/scripts/extract.sh" "$distdir/$archive" -s ',^\.,src/man,' diff --git a/pkg/hyx/.gitignore b/pkg/hyx/.gitignore @@ -1,2 +1 @@ -/hyx-2026.01.11.tar.xz /src diff --git a/pkg/less/.gitignore b/pkg/less/.gitignore @@ -1,2 +1 @@ -/less-643.tar.gz /src diff --git a/pkg/linux-headers/.gitignore b/pkg/linux-headers/.gitignore @@ -1,3 +1,2 @@ -/linux-6.19.tar.xz /src /tools.ninja diff --git a/pkg/linux-headers/fetch.sh b/pkg/linux-headers/fetch.sh @@ -1,21 +1,21 @@ set -e +. ./paths.sh dir=$1 shift -cd "$dir" +cd "$distdir" -if [ -e src ] ; then - rm -rf src +if ! sh "$basedir/scripts/checksum.sh" -c "$basedir/$dir/sha256" 2>/dev/null ; then + curl -L -K "$basedir/$dir/url" -O + sh "$basedir/scripts/checksum.sh" -c "$basedir/$dir/sha256" fi -if ! sh "$OLDPWD/scripts/checksum.sh" -c sha256 2>/dev/null ; then - curl -L -K url -O - sh "$OLDPWD/scripts/checksum.sh" -c sha256 -fi +cd "$basedir/$dir" +rm -rf src read -r _ archive <sha256 -sh "$OLDPWD/scripts/extract.sh" "$archive" -s ',^[^/]*,src,' \ +sh "$basedir/scripts/extract.sh" "$distdir/$archive" -s ',^[^/]*,src,' \ 'linux-*/Makefile' \ 'linux-*/arch/*/include/uapi/' \ 'linux-*/arch/*/entry/syscalls/' \ @@ -24,5 +24,5 @@ sh "$OLDPWD/scripts/extract.sh" "$archive" -s ',^[^/]*,src,' \ 'linux-*/scripts/unifdef.c' if [ -d patch ] ; then - git apply -v --whitespace=nowarn --directory "$dir/src" patch/* + git apply -v --whitespace=nowarn --directory "$dir/src" patch/*.patch fi diff --git a/pkg/lpeg/.gitignore b/pkg/lpeg/.gitignore @@ -1,2 +1 @@ -/lpeg-1.1.0.tar.gz /src diff --git a/pkg/lua/.gitignore b/pkg/lua/.gitignore @@ -1,2 +1 @@ -/lua-5.2.4.tar.gz /src diff --git a/pkg/man-pages-posix/.gitignore b/pkg/man-pages-posix/.gitignore @@ -1,2 +1 @@ -/man-pages-posix-2017-a.tar.gz /src diff --git a/pkg/mandoc/.gitignore b/pkg/mandoc/.gitignore @@ -1,2 +1 @@ -/mandoc-1.14.6.tar.gz /src diff --git a/pkg/openbsd/.gitignore b/pkg/openbsd/.gitignore @@ -1,4 +1,2 @@ /nc.ninja /src -/src.tar.gz -/sys.tar.gz diff --git a/pkg/openbsd/fetch.sh b/pkg/openbsd/fetch.sh @@ -1,20 +1,20 @@ set -e +. ./paths.sh dir=$1 shift -cd "$dir" +cd "$distdir" -if [ -e src ] ; then - rm -rf src +if ! sh "$basedir/scripts/checksum.sh" -c "$basedir/$dir/sha256" 2>/dev/null ; then + curl -L -K "$basedir/$dir/url" -O + sh "$basedir/scripts/checksum.sh" -c "$basedir/$dir/sha256" fi -if ! sh "$OLDPWD/scripts/checksum.sh" -c sha256 2>/dev/null ; then - curl -L -K url -O - sh "$OLDPWD/scripts/checksum.sh" -c sha256 -fi +cd "$basedir/$dir" +rm -rf src -sh "$OLDPWD/scripts/extract.sh" src.tar.gz -s ',^,src/,' \ +sh "$basedir/scripts/extract.sh" "$distdir/src.tar.gz" -s ',^,src/,' \ 'bin/pax/*' \ 'include/*' \ 'lib/libc/*' \ @@ -30,6 +30,6 @@ sh "$OLDPWD/scripts/extract.sh" src.tar.gz -s ',^,src/,' \ 'usr.bin/xargs/*' \ 'usr.bin/yacc/*' \ 'usr.sbin/acme-client/*' -sh "$OLDPWD/scripts/extract.sh" sys.tar.gz -s ',^,src/,' 'sys/sys/*' +sh "$basedir/scripts/extract.sh" "$distdir/sys.tar.gz" -s ',^,src/,' 'sys/sys/*' -git apply -v --whitespace=nowarn --directory "$dir/src" patch/* +git apply -v --whitespace=nowarn --directory "$dir/src" patch/*.patch diff --git a/pkg/optipng/.gitignore b/pkg/optipng/.gitignore @@ -1,2 +1 @@ -/optipng-7.9.1.tar.gz /src diff --git a/pkg/pcre/.gitignore b/pkg/pcre/.gitignore @@ -1,2 +1 @@ -/pcre-8.45.tar.gz /src diff --git a/pkg/strace/.gitignore b/pkg/strace/.gitignore @@ -1,3 +1,2 @@ /src -/strace-6.19.tar.xz /tools.ninja diff --git a/pkg/transmission/.gitignore b/pkg/transmission/.gitignore @@ -1,4 +1,3 @@ /libminiupnp.ninja /libnatpmp.ninja /src -/transmission-3.00.tar.xz diff --git a/rules.ninja b/rules.ninja @@ -125,7 +125,7 @@ rule fspec-tar command = $builddir/pkg/fspec-sync/host/fspec-tar <$in | zstd >$out rule fetch - command = cd $basedir && PAX=$$OLDPWD/$builddir/pkg/pax/host/pax sh $$OLDPWD/$script $gendir && touch $$OLDPWD/$out + command = PAX=$$PWD/$builddir/pkg/pax/host/pax sh $script $gendir && touch $out description = FETCH $gendir restat = 1 generator = 1 diff --git a/scripts/fetch-curl.sh b/scripts/fetch-curl.sh @@ -5,22 +5,25 @@ if [ "$#" != 1 ] ; then exit 2 fi +. ./paths.sh dir=$1 shift -cd "$dir" +cd "$distdir" -if [ -e src ] ; then - rm -rf src +if ! sh "$basedir/scripts/checksum.sh" -c "$basedir/$dir/sha256" 2>/dev/null ; then + curl -L -K "$basedir/$dir/url" -O + sh "$basedir/scripts/checksum.sh" -c "$basedir/$dir/sha256" fi -if ! sh "$OLDPWD/scripts/checksum.sh" -c sha256 2>/dev/null ; then - curl -L -K url -O - sh "$OLDPWD/scripts/checksum.sh" -c sha256 +cd "$basedir/$dir" + +if [ -e src ] ; then + rm -rf src fi while read -r _ archive ; do - sh "$OLDPWD/scripts/extract.sh" "$archive" -s ',^[^/]*,src,' + sh "$basedir/scripts/extract.sh" "$distdir/$archive" -s ',^[^/]*,src,' done <sha256 if [ -d patch ] ; then diff --git a/scripts/fetch-git.sh b/scripts/fetch-git.sh @@ -5,9 +5,11 @@ if [ "$#" != 1 ] ; then exit 2 fi -cd "$1" +. ./paths.sh +cd "$basedir/$1" git submodule update --init --checkout src if [ -d patch ] ; then - git -C src am --keep-non-patch --whitespace=nowarn "$PWD"/patch/*.patch + cd src + git am --keep-non-patch --whitespace=nowarn ../patch/*.patch fi diff --git a/setup.lua b/setup.lua @@ -20,6 +20,24 @@ config = dofile 'config.lua' if not config.prefix then config.prefix = '' end +if not config.distdir then + config.distdir = 'dist' +end + +local function shellpath(path, base) + if path == '.' then return base end + local abs = path:find('^/') + path = "'"..path:gsub([[']], [['\'']]).."'" + if abs then return path end + return base..'/'..path +end +local f = io.open('paths.sh', 'w') +f:write(string.format([[ +basedir=%s +builddir=%s +distdir=%s +]], shellpath(basedir, '$PWD'), shellpath(config.builddir, '$PWD'), shellpath(config.distdir, '$basedir'))) +f:close() local function gen(gendir) local dir = basedir..'/'..gendir