From d4542c336a6cbfb43497055f19a85e7713f2eed7 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 25 Jun 2023 16:38:32 +0200 Subject: 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 --- Makefile | 11 ++- port | 14 --- ports/bin/camellia_path_check | 1 - ports/dash | 22 ----- ports/dash/port | 18 ++++ ports/dash/sha256sums | 1 + ports/doom | 151 -------------------------------- ports/doom/files/doomgeneric_camellia.c | 128 +++++++++++++++++++++++++++ ports/doom/patches/0-wad-dir.patch | 8 ++ ports/doom/port | 32 +++++++ ports/doom/sha256sums | 2 + ports/ed | 68 -------------- ports/lua | 20 ----- ports/lua/port | 15 ++++ ports/lua/sha256sums | 1 + ports/oed/files/Makefile | 32 +++++++ ports/oed/files/config.h | 5 ++ ports/oed/port | 13 +++ ports/oed/sha256sums | 1 + ports/post | 21 +++++ ports/pre | 69 +++++++++++++++ ports/sltar | 19 ---- src/user/app/init/init.c | 7 ++ src/user/lib/signal.c | 2 +- 24 files changed, 363 insertions(+), 298 deletions(-) delete mode 100755 port delete mode 100755 ports/bin/camellia_path_check delete mode 100644 ports/dash create mode 100755 ports/dash/port create mode 100644 ports/dash/sha256sums delete mode 100644 ports/doom create mode 100644 ports/doom/files/doomgeneric_camellia.c create mode 100644 ports/doom/patches/0-wad-dir.patch create mode 100755 ports/doom/port create mode 100644 ports/doom/sha256sums delete mode 100644 ports/ed delete mode 100644 ports/lua create mode 100755 ports/lua/port create mode 100644 ports/lua/sha256sums create mode 100644 ports/oed/files/Makefile create mode 100644 ports/oed/files/config.h create mode 100755 ports/oed/port create mode 100644 ports/oed/sha256sums create mode 100644 ports/post create mode 100644 ports/pre delete mode 100644 ports/sltar diff --git a/Makefile b/Makefile index 586f401..764f7f0 100644 --- a/Makefile +++ b/Makefile @@ -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 * diff --git a/port b/port deleted file mode 100755 index 053bf3b..0000000 --- a/port +++ /dev/null @@ -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 deleted file mode 100644 index 7ef03dd..0000000 --- a/ports/doom +++ /dev/null @@ -1,151 +0,0 @@ -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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include "doomgeneric.h" -#include "doomkeys.h" - -static struct framebuf fb; -static hid_t kb; - -static const char keymap_lower[] = { - '\0', '\0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', '\t', - 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\r', '\0', 'a', 's', - 'd', 'f', 'g', 'h', 'j', 'k', 'l', '\0', '\'', '`', '\0', '\\', 'z', 'x', 'c', 'v', - 'b', 'n', 'm', ',', '.', '/', '\0', '*', '\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '7', '8', '9', '-', '4', '5', '6', '+', '1', - '2', '3', '0', '.', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', -}; - -static char kb_backbuf[256]; -static ring_t kb_backlog = {kb_backbuf, sizeof kb_backbuf, 0, 0}; - -static void kb_thread(void *arg) { - (void)arg; - char buf[sizeof kb_backbuf]; - for (;;) { - int ret = _sys_read(kb, buf, sizeof buf, 0); - if (ret <= 0) break; - ring_put(&kb_backlog, buf, ret); - } -} - -void DG_Init(void) { - if (fb_setup(&fb, "/kdev/video/") < 0) { - puts("DG_Init: fb_setup error"); - abort(); - } - kb = _sys_open("/kdev/ps2/kb", 12, 0); - if (kb < 0) { - puts("DG_Init: can't open keyboard"); - abort(); - } - thread_create(0, kb_thread, NULL); -} - -void DG_DrawFrame(void) { - size_t doomw = DOOMGENERIC_RESX; - size_t doomh = DOOMGENERIC_RESY; - size_t doompitch = doomw * 4; - for (int y = 0; y < DOOMGENERIC_RESY; y++) { - memcpy(fb.b + fb.pitch * y, ((char*)DG_ScreenBuffer) + doompitch * y, doompitch); - } - - struct rect d; - dirty_mark(&d, 0, 0); - dirty_mark(&d, doomw, doomh); - dirty_flush(&d, &fb); -} - -static uint32_t timer = 0; -void DG_SleepMs(uint32_t ms) { - timer += ms; - _sys_sleep(ms); -} - -uint32_t DG_GetTicksMs(void) { - /* if it's stupid and it works... */ - return timer; -} - -int DG_GetKey(int *pressed, unsigned char *key) { - uint8_t c; - int read = ring_get(&kb_backlog, (char*)&c, 1); - bool extended = c == 0xe0;; - if (read == 0) return 0; - if (extended) ring_get(&kb_backlog, (char*)&c, 1); - bool down = !(c & 0x80); - - c &= 0x7f; - if (!extended) { - switch (c) { - case 0x01: - c = KEY_ESCAPE; - break; - case 0x2a: case 0x36: - c = KEY_RSHIFT; - break; - case 0x1d: - c = KEY_FIRE; - break; - default: - c = keymap_lower[c & 0x7f]; - switch (c) { - case ' ': c = KEY_USE; break; - } - } - } else { - switch (c) { - case 0x48: c = KEY_UPARROW; break; - case 0x50: c = KEY_DOWNARROW; break; - case 0x4B: c = KEY_LEFTARROW; break; - case 0x4D: c = KEY_RIGHTARROW; break; - default: c = '\0'; break; - } - } - *pressed = down; - *key = c; - return 1; -} - -void DG_SetWindowTitle(const char *title) { - (void)title; -} -EOF -} - -prep() { - [ -d doomgeneric ] || (fetch) - cd doomgeneric/doomgeneric -} - -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/files/doomgeneric_camellia.c b/ports/doom/files/doomgeneric_camellia.c new file mode 100644 index 0000000..3fe6032 --- /dev/null +++ b/ports/doom/files/doomgeneric_camellia.c @@ -0,0 +1,128 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "doomgeneric.h" +#include "doomkeys.h" + +static struct framebuf fb; +static hid_t kb; + +static const char keymap_lower[] = { + '\0', '\0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', '\t', + 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\r', '\0', 'a', 's', + 'd', 'f', 'g', 'h', 'j', 'k', 'l', '\0', '\'', '`', '\0', '\\', 'z', 'x', 'c', 'v', + 'b', 'n', 'm', ',', '.', '/', '\0', '*', '\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '7', '8', '9', '-', '4', '5', '6', '+', '1', + '2', '3', '0', '.', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', +}; + +static char kb_backbuf[256]; +static ring_t kb_backlog = {kb_backbuf, sizeof kb_backbuf, 0, 0}; + +static void kb_thread(void *arg) { + (void)arg; + char buf[sizeof kb_backbuf]; + for (;;) { + int ret = _sys_read(kb, buf, sizeof buf, 0); + if (ret <= 0) break; + ring_put(&kb_backlog, buf, ret); + } +} + +void DG_Init(void) { + if (fb_setup(&fb, "/kdev/video/") < 0) { + puts("DG_Init: fb_setup error"); + abort(); + } + kb = _sys_open("/kdev/ps2/kb", 12, 0); + if (kb < 0) { + puts("DG_Init: can't open keyboard"); + abort(); + } + thread_create(0, kb_thread, NULL); +} + +void DG_DrawFrame(void) { + size_t doomw = DOOMGENERIC_RESX; + size_t doomh = DOOMGENERIC_RESY; + size_t doompitch = doomw * 4; + for (int y = 0; y < DOOMGENERIC_RESY; y++) { + memcpy(fb.b + fb.pitch * y, ((char*)DG_ScreenBuffer) + doompitch * y, doompitch); + } + + struct rect d; + dirty_mark(&d, 0, 0); + dirty_mark(&d, doomw, doomh); + dirty_flush(&d, &fb); +} + +static uint32_t timer = 0; +void DG_SleepMs(uint32_t ms) { + timer += ms; + _sys_sleep(ms); +} + +uint32_t DG_GetTicksMs(void) { + /* if it's stupid and it works... */ + return timer; +} + +int DG_GetKey(int *pressed, unsigned char *key) { + uint8_t c; + int read = ring_get(&kb_backlog, (char*)&c, 1); + bool extended = c == 0xe0;; + if (read == 0) return 0; + if (extended) ring_get(&kb_backlog, (char*)&c, 1); + bool down = !(c & 0x80); + + c &= 0x7f; + if (!extended) { + switch (c) { + case 0x01: + c = KEY_ESCAPE; + break; + case 0x2a: case 0x36: + c = KEY_RSHIFT; + break; + case 0x1d: + c = KEY_FIRE; + break; + default: + c = keymap_lower[c & 0x7f]; + switch (c) { + case ' ': c = KEY_USE; break; + } + } + } else { + switch (c) { + case 0x48: c = KEY_UPARROW; break; + case 0x50: c = KEY_DOWNARROW; break; + case 0x4B: c = KEY_LEFTARROW; break; + case 0x4D: c = KEY_RIGHTARROW; break; + default: c = '\0'; break; + } + } + *pressed = down; + *key = c; + return 1; +} + +void DG_SetWindowTitle(const char *title) { + (void)title; +} + +int main(int argc, char **argv) { + doomgeneric_Create(argc, argv); + for (;;) { + doomgeneric_Tick(); + } +} 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) { -- cgit v1.2.3