diff options
author | dzwdz | 2023-06-25 16:38:32 +0200 |
---|---|---|
committer | dzwdz | 2023-06-25 16:38:32 +0200 |
commit | d4542c336a6cbfb43497055f19a85e7713f2eed7 (patch) | |
tree | 9f4a68974c3392b0ea546ecc94324911e86f0528 | |
parent | fffd37f1680664bf055d8f5603ed1967718a6492 (diff) |
ports: reimplement the ports system from scratch
side stuff:
* removed sltar since it wasn't working anyways
* made signal() no longer panic, as that broke certain ports (oops)
* doom now ships with the FreeDOOM WADs
* /usr/ was aliased to /init/usr/, more directories were added to /bin/
to improve compat with ports
-rw-r--r-- | Makefile | 11 | ||||
-rwxr-xr-x | port | 14 | ||||
-rwxr-xr-x | ports/bin/camellia_path_check | 1 | ||||
-rw-r--r-- | ports/dash | 22 | ||||
-rwxr-xr-x | ports/dash/port | 18 | ||||
-rw-r--r-- | ports/dash/sha256sums | 1 | ||||
-rw-r--r-- | ports/doom/files/doomgeneric_camellia.c (renamed from ports/doom) | 33 | ||||
-rw-r--r-- | ports/doom/patches/0-wad-dir.patch | 8 | ||||
-rwxr-xr-x | ports/doom/port | 32 | ||||
-rw-r--r-- | ports/doom/sha256sums | 2 | ||||
-rw-r--r-- | ports/ed | 68 | ||||
-rw-r--r-- | ports/lua | 20 | ||||
-rwxr-xr-x | ports/lua/port | 15 | ||||
-rw-r--r-- | ports/lua/sha256sums | 1 | ||||
-rw-r--r-- | ports/oed/files/Makefile | 32 | ||||
-rw-r--r-- | ports/oed/files/config.h | 5 | ||||
-rwxr-xr-x | ports/oed/port | 13 | ||||
-rw-r--r-- | ports/oed/sha256sums | 1 | ||||
-rw-r--r-- | ports/post | 21 | ||||
-rw-r--r-- | ports/pre | 69 | ||||
-rw-r--r-- | ports/sltar | 19 | ||||
-rw-r--r-- | src/user/app/init/init.c | 7 | ||||
-rw-r--r-- | src/user/lib/signal.c | 2 |
23 files changed, 240 insertions, 175 deletions
@@ -31,13 +31,14 @@ ifndef QEMU_DISPLAY QFLAGS += -display none endif +PORTS = define from_sources $(patsubst src/%,out/obj/%.o,$(shell find $(1) -type f,l -name '*.[csS]')) endef -.PHONY: all portdeps boot check clean +.PHONY: all portdeps boot check clean ports all: portdeps out/boot.iso check portdeps: out/libc.a out/libm.a src/user/lib/include/__errno.h @@ -116,13 +117,19 @@ $(foreach bin,$(USERBINS),$(eval $(call userbin_template,$(bin)))) out/obj/user/app/ext2fs/ext2/example.c.o: @touch $@ +# portdeps is phony, so ports/% is automatically "phony" too +ports: $(patsubst %,ports/%,$(PORTS)) +ports/%: portdeps + +$@/port install + out/initrd/%: sysroot/% @mkdir -p $(@D) @cp $< $@ out/initrd.tar: $(patsubst sysroot/%,out/initrd/%,$(shell find sysroot/ -type f)) \ $(patsubst %,out/initrd/bin/amd64/%,$(USERBINS)) \ - $(shell find out/initrd/) + $(shell find out/initrd/) \ + ports @cd out/initrd; tar chf ../initrd.tar * @@ -1,14 +0,0 @@ -#!/bin/sh -set -eu -export REPO="$PWD" -export PREFIX="$REPO/out/initrd/usr/" -export PATH="$REPO/ports/bin/:$REPO/toolchain/prefix/bin/:$PATH" - -if [ $1 = deepclean ]; then - rm -rf ports/out/ - exit -fi - -mkdir -p ports/out/$1/ $PREFIX/bin -cd ports/out/$1/ -sh $REPO/ports/$1 $2 diff --git a/ports/bin/camellia_path_check b/ports/bin/camellia_path_check deleted file mode 100755 index 96b4b06..0000000 --- a/ports/bin/camellia_path_check +++ /dev/null @@ -1 +0,0 @@ -#!/bin/sh
\ No newline at end of file diff --git a/ports/dash b/ports/dash deleted file mode 100644 index aa15435..0000000 --- a/ports/dash +++ /dev/null @@ -1,22 +0,0 @@ -set -eu -camellia_path_check - -VERSION=dash-0.5.12 - -fetch() { - wget -nc https://gondor.apana.org.au/~herbert/dash/files/dash-0.5.12.tar.gz - echo "6a474ac46e8b0b32916c4c60df694c82058d3297d8b385b74508030ca4a8f28a dash-0.5.12.tar.gz" | sha256sum --check - tar xf ${VERSION}.tar.gz -} - -prep() { - [ -d ${VERSION} ] || (fetch) - cd ${VERSION} - [ -e Makefile ] || ./configure CC=x86_64-camellia-gcc "CFLAGS=-Wno-error=format -Wno-error=unused-but-set-variable" --prefix"=$PREFIX" --host=x86_64-camellia -} - -case $1 in - install) (prep; make; make install) ;; - clean) (prep; make clean) ;; - *) echo "usage: $0 install|clean"; false ;; -esac diff --git a/ports/dash/port b/ports/dash/port new file mode 100755 index 0000000..6a17372 --- /dev/null +++ b/ports/dash/port @@ -0,0 +1,18 @@ +#!/bin/sh +. ports/pre + +pkg=dash +tarball=dash-0.5.12.tar.gz +tarball_dir=dash-0.5.12 +url=http://gondor.apana.org.au/~herbert/dash/files/${tarball} + +relink() { + rm $tarball_dir/dash +} + +configure() { + test -e $tarball_dir/Makefile && return + (cd $tarball_dir && ./configure --host=x86_64-camellia) +} + +. ports/post diff --git a/ports/dash/sha256sums b/ports/dash/sha256sums new file mode 100644 index 0000000..b109276 --- /dev/null +++ b/ports/dash/sha256sums @@ -0,0 +1 @@ +6a474ac46e8b0b32916c4c60df694c82058d3297d8b385b74508030ca4a8f28a dash-0.5.12.tar.gz diff --git a/ports/doom b/ports/doom/files/doomgeneric_camellia.c index 7ef03dd..3fe6032 100644 --- a/ports/doom +++ b/ports/doom/files/doomgeneric_camellia.c @@ -1,19 +1,3 @@ -set -eu -camellia_path_check - -fetch() { - git clone https://github.com/ozkl/doomgeneric - cd doomgeneric - # TODO use a newer commit - git -c advice.detachedHead=false checkout ee3ee581912dacd38af06e81da2374c1267453e8 - - cd doomgeneric - rm doomgeneric # a leftover OS X binary - sed s/xlib/camellia/ -i Makefile - sed s/-lX11// -i Makefile - echo note: you need to supply your own WADs - - cat <<\EOF > doomgeneric_camellia.c #include <camellia/syscalls.h> #include <shared/ring.h> #include <stdbool.h> @@ -135,17 +119,10 @@ int DG_GetKey(int *pressed, unsigned char *key) { void DG_SetWindowTitle(const char *title) { (void)title; } -EOF -} -prep() { - [ -d doomgeneric ] || (fetch) - cd doomgeneric/doomgeneric +int main(int argc, char **argv) { + doomgeneric_Create(argc, argv); + for (;;) { + doomgeneric_Tick(); + } } - -case $1 in - install) (prep; make "CC=x86_64-camellia-gcc" && cp doomgeneric $PREFIX/bin/doom && cp *.WAD $PREFIX/) ;; - clean) (prep; make clean) ;; - deepclean) (rm -rf doomgeneric) ;; - *) echo "usage: $0 install|clean"; false ;; -esac diff --git a/ports/doom/patches/0-wad-dir.patch b/ports/doom/patches/0-wad-dir.patch new file mode 100644 index 0000000..85db2e6 --- /dev/null +++ b/ports/doom/patches/0-wad-dir.patch @@ -0,0 +1,8 @@ +--- config.h.orig 2023-06-24 22:10:06.945656877 +0200 ++++ config.h 2023-06-24 22:11:54.456841542 +0200 +@@ -97,4 +97,4 @@ + #undef ORIGCODE + + /* Define to the directory where all game files are located */ +-#define FILES_DIR "." ++#define FILES_DIR "/usr/share/games/doom/" diff --git a/ports/doom/port b/ports/doom/port new file mode 100755 index 0000000..c747b77 --- /dev/null +++ b/ports/doom/port @@ -0,0 +1,32 @@ +#!/bin/sh +. ports/pre + +pkg=doom +tarball=ozkl-doomgeneric-613f870.tar.gz +tarball_dir=ozkl-doomgeneric-613f870/doomgeneric +url=https://github.com/ozkl/doomgeneric/tarball/613f870b6fa83ede448a247de5a2571092fa729d + +extra_files=https://github.com/freedoom/freedoom/releases/download/v0.12.1/freedoom-0.12.1.zip + +post_patch() { + sed s/xlib/camellia/ -i $tarball_dir/Makefile + sed s/-lX11// -i $tarball_dir/Makefile +} + +post_unpack() { + unzip $downdir/freedoom-0.12.1.zip +} + +install() { + # no make install target + build + mkdir -p $DESTDIR/usr/bin/ $DESTDIR/usr/share/games/doom/ + cp $tarball_dir/doomgeneric $DESTDIR/usr/bin/doom + cp freedoom-0.12.1/freedoom1.wad $DESTDIR/usr/share/games/doom/ +} + +relink() { + rm $tarball_dir/doomgeneric +} + +. ports/post diff --git a/ports/doom/sha256sums b/ports/doom/sha256sums new file mode 100644 index 0000000..fc1594e --- /dev/null +++ b/ports/doom/sha256sums @@ -0,0 +1,2 @@ +07bd8aaf2f3c8b5cb9642de60689834524651fe50d87cf00eed1cd7c716e4dd7 ozkl-doomgeneric-613f870.tar.gz +f42c6810fc89b0282de1466c2c9c7c9818031a8d556256a6db1b69f6a77b5806 freedoom-0.12.1.zip diff --git a/ports/ed b/ports/ed deleted file mode 100644 index 8a83ae4..0000000 --- a/ports/ed +++ /dev/null @@ -1,68 +0,0 @@ -set -eu -camellia_path_check - -fetch() { - # TODO shallow clone, once 7.1 gets tagged - # better yet, use a tarball - git clone https://github.com/ibara/oed - cd oed - git -c advice.detachedHead=false checkout fc1497fa466ff10c7437f07a00ba888242618ce5 -} - -configure() { - cd oed - cat <<\EOF > Makefile -# This Makefile automatically generated by configure. - -CC = x86_64-camellia-gcc -CFLAGS = -g -O2 -I. -D_GNU_SOURCE - -PREFIX = /usr/local -MANDIR = /usr/local/man - -PROG = ed -OBJS = buf.o glbl.o io.o main.o re.o sub.o undo.o \ - regcomp.o regerror.o regexec.o regfree.o \ - reallocarray.o strlcat.o strlcpy.o - -all: ${PROG} - -${PROG}: ${OBJS} - ${CC} ${LDFLAGS} -o ${PROG} ${OBJS} - -install: - install -d ${DESTDIR}${PREFIX}/bin - install -d ${DESTDIR}${MANDIR}/man1 - install -c -s -m 755 ${PROG} ${DESTDIR}${PREFIX}/bin - install -c -m 644 ed.1 ${DESTDIR}${MANDIR}/man1/${PROG}.1 - -test: - @echo "No tests" - -clean: - rm -f ${PROG} ${OBJS} - -distclean: clean - rm -f Makefile config.h -EOF - cat <<\EOF > config.h -/* This file automatically generated by configure. */ - -extern void *reallocarray(void *, size_t, size_t); -extern size_t strlcat(char *, const char *, size_t); -extern size_t strlcpy(char *, const char *, size_t); -EOF -} - -prep() { - [ -d oed ] || (fetch) - [ -e oed/Makefile ] || (configure) - cd oed -} - -case $1 in - install) (prep; make; make install "PREFIX=$PREFIX" "MANDIR=$PREFIX/man/") ;; - clean) (prep; make clean) ;; - deepclean) (rm -rf oed) ;; - *) echo "usage: $0 install|clean"; false ;; -esac diff --git a/ports/lua b/ports/lua deleted file mode 100644 index 46f995f..0000000 --- a/ports/lua +++ /dev/null @@ -1,20 +0,0 @@ -set -eu -camellia_path_check - -VERSION=lua-5.4.4 - -fetch() { - wget http://www.lua.org/ftp/${VERSION}.tar.gz - tar xf ${VERSION}.tar.gz -} - -prep() { - [ -d ${VERSION} ] || (fetch) - cd ${VERSION} -} - -case $1 in - install) (prep; make generic "CC=x86_64-camellia-gcc" "MYCFLAGS=-Werror" && make install "INSTALL_TOP=$PREFIX") ;; - clean) (prep; make clean) ;; - *) echo "usage: $0 install|clean"; false ;; -esac diff --git a/ports/lua/port b/ports/lua/port new file mode 100755 index 0000000..d059caa --- /dev/null +++ b/ports/lua/port @@ -0,0 +1,15 @@ +#!/bin/sh +. ports/pre + +pkg=lua +tarball=lua-5.4.4.tar.gz +tarball_dir=lua-5.4.4 +url=https://www.lua.org/ftp/${tarball} + +MAKEFLAGS="$MAKEFLAGS INSTALL_TOP=$DESTDIR/usr/ PLAT=generic" + +relink() { + rm $tarball_dir/lua +} + +. ports/post diff --git a/ports/lua/sha256sums b/ports/lua/sha256sums new file mode 100644 index 0000000..28770c7 --- /dev/null +++ b/ports/lua/sha256sums @@ -0,0 +1 @@ +164c7849653b80ae67bec4b7473b884bf5cc8d2dca05653475ec2ed27b9ebf61 lua-5.4.4.tar.gz diff --git a/ports/oed/files/Makefile b/ports/oed/files/Makefile new file mode 100644 index 0000000..929fddb --- /dev/null +++ b/ports/oed/files/Makefile @@ -0,0 +1,32 @@ +# This Makefile automatically generated by configure. + +CC = x86_64-camellia-gcc +CFLAGS = -g -O2 -I. -D_GNU_SOURCE + +PREFIX = /usr/local +MANDIR = /usr/local/man + +PROG = ed +OBJS = buf.o glbl.o io.o main.o re.o sub.o undo.o \ + regcomp.o regerror.o regexec.o regfree.o \ + reallocarray.o strlcat.o strlcpy.o + +all: ${PROG} + +${PROG}: ${OBJS} + ${CC} ${LDFLAGS} -o ${PROG} ${OBJS} + +install: + install -d ${DESTDIR}${PREFIX}/bin + install -d ${DESTDIR}${MANDIR}/man1 + install -c -s -m 755 ${PROG} ${DESTDIR}${PREFIX}/bin + install -c -m 644 ed.1 ${DESTDIR}${MANDIR}/man1/${PROG}.1 + +test: + @echo "No tests" + +clean: + rm -f ${PROG} ${OBJS} + +distclean: clean + rm -f Makefile config.h diff --git a/ports/oed/files/config.h b/ports/oed/files/config.h new file mode 100644 index 0000000..bad56a1 --- /dev/null +++ b/ports/oed/files/config.h @@ -0,0 +1,5 @@ +/* This file automatically generated by configure. */ + +extern void *reallocarray(void *, size_t, size_t); +extern size_t strlcat(char *, const char *, size_t); +extern size_t strlcpy(char *, const char *, size_t); diff --git a/ports/oed/port b/ports/oed/port new file mode 100755 index 0000000..425407e --- /dev/null +++ b/ports/oed/port @@ -0,0 +1,13 @@ +#!/bin/sh +. ports/pre + +pkg=oed +tarball=oed-7.1.tar.gz +tarball_dir=oed-oed-7.1 +url=https://github.com/ibara/oed/archive/refs/tags/$tarball + +relink() { + rm $tarball_dir/ed +} + +. ports/post diff --git a/ports/oed/sha256sums b/ports/oed/sha256sums new file mode 100644 index 0000000..2e15fde --- /dev/null +++ b/ports/oed/sha256sums @@ -0,0 +1 @@ +227ad4e6e9d2adb3a4b743c8ad3a50bcda63dea146d41bd6cbd8b79f495b057b oed-7.1.tar.gz diff --git a/ports/post b/ports/post new file mode 100644 index 0000000..f0638e6 --- /dev/null +++ b/ports/post @@ -0,0 +1,21 @@ +#!/bin/sh +set -eu +ensure_pre_was_loaded + +portdir=$repodir/ports/$pkg/ +workdir=$repodir/ports/out/$pkg/ +downdir=$repodir/ports/out/downloads/ + +mkdir -p $workdir $downdir +cd $workdir + +case ${1:-help} in + fetch) fetch ;; + build) build ;; + clean) clean ;; + install) install ;; + + relink) relink ;; + + *) echo "bad usage, see ports/post"; false ;; +esac diff --git a/ports/pre b/ports/pre new file mode 100644 index 0000000..0c00ef3 --- /dev/null +++ b/ports/pre @@ -0,0 +1,69 @@ +#!/bin/sh +set -eu +repodir=$(pwd) +PATH="$repodir/toolchain/prefix/bin/:$PATH" +CC=x86_64-camellia-gcc +DESTDIR="$repodir/out/initrd/" +MAKEFLAGS="CC=$CC DESTDIR=$DESTDIR" +extra_files= + +ensure_pre_was_loaded() { true; } + +fetch() { + test -e $downdir/$tarball || curl -L $url > $downdir/$tarball + for file in $extra_files; do + echo ${file##*/} + test -e $downdir/${file##*/} || curl -L $file > $downdir/${file##*/} + done + checksum +} + +checksum() { + (cd $downdir; sha256sum --check $portdir/sha256sums) +} + +post_unpack() { true; } +unpack() { + test -d $tarball_dir && return + fetch + tar xf $downdir/$tarball + patch + post_unpack +} + +post_patch() { true; } +patch() { + if test -d $portdir/files/; then + cp $portdir/files/* $tarball_dir/ + fi + if test -d $portdir/patches/; then + for patch in $portdir/patches/*; do + echo $patch + command patch -d $tarball_dir/ <$patch + done + fi + post_patch +} + +configure() { + true +} + +_make() { + configure + (cd $tarball_dir && make $MAKEFLAGS $*) +} + +build() { + unpack + _make +} + +clean() { + _make clean +} + +install() { + build + _make install +} diff --git a/ports/sltar b/ports/sltar deleted file mode 100644 index 3a9f559..0000000 --- a/ports/sltar +++ /dev/null @@ -1,19 +0,0 @@ -set -eu -camellia_path_check - -fetch() { - git clone https://github.com/Gottox/sltar - cd sltar - git -c advice.detachedHead=false checkout 8b5dae8e7f39401255176f806358dd04453d7831 -} - -prep() { - [ -d sltar ] || (fetch) - cd sltar -} - -case $1 in - install) (prep; make CC=x86_64-camellia-gcc "INCS=" "LIBS=" && make install "PREFIX=$PREFIX") ;; - clean) (prep; make clean) ;; - *) echo "usage: $0 install|clean"; false ;; -esac diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c index b9219ec..9528a28 100644 --- a/src/user/app/init/init.c +++ b/src/user/app/init/init.c @@ -47,11 +47,18 @@ int main(void) { MOUNT_AT("/") { fs_whitelist((const char*[]){"/kdev/ps2/kb", NULL}); } ps2_drv(); } + MOUNT_AT("/usr/") { + fs_union((const char*[]){ + "/init/usr/", + NULL + }); + } MOUNT_AT("/bin/") { fs_union((const char*[]){ "/init/bin/amd64/", "/init/bin/sh/", "/init/usr/bin/", + "/init/usr/local/bin/", NULL }); } diff --git a/src/user/lib/signal.c b/src/user/lib/signal.c index 41340e7..3200263 100644 --- a/src/user/lib/signal.c +++ b/src/user/lib/signal.c @@ -86,7 +86,7 @@ int sigsuspend(const sigset_t *mask) { int signal(int sig, void (*func)(int)) { (void)sig; (void)func; - __libc_panic("unimplemented"); + return errno = ENOSYS, SIG_ERR; } int kill(pid_t pid, int sig) { |