From 9588b0d3db20de913f4e3d35eed1ec4f3eca44cc Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 13 Jun 2022 22:29:53 +0200 Subject: [PATCH] Add ports to the Sortix repository. This change imports the ports collection from the former porttix and srctix repositories and converts them to port(5) files with metadata pointing to the upstream release tarballs with patches checked into this repository. Ports are now developed and versioned along with the operating system and are automatically built per the PACKAGES environment variable. The patches are licensed under the same license as the relevant ports. Tix has gained support for the new port(5) format. tix-port(8) is the new high level ports build even point that handles downloading pstream releases into the new mirror cache directory, applying the patches, building the port with the lower-level tix-build(8), and finally installing the binary package. The new tix-vars(8) program parses port(5) files and the new tix-rmdiff(8) program produces input for tix-rmpatch(8). The old doc/ directory is discontinued in favor of manual pages documenting the new ports system. The obsolete porttix-create(8) and srctix-create(8) programs are removed. --- .gitignore | 8 +- LICENSE | 5 +- Makefile | 80 +- build-aux/build-ports.sh | 189 ++- build-aux/clean-ports.sh | 56 +- build-aux/iso-grub-cfg.sh | 4 +- build-aux/iso-repository.sh | 16 +- build-aux/list-packages.sh | 108 ++ build-aux/upgrade-port.sh | 103 ++ build-aux/verify-coding-style.sh | 2 +- doc/.gitignore | 1 - doc/Makefile | 21 - doc/cross-compilation-sins | 268 ----- doc/obsolete-stuff | 342 ------ doc/portability-sins | 85 -- doc/porting-guide | 480 -------- doc/posix-divergence | 71 -- doc/welcome | 7 - ports/ag/ag.patch | 60 + ports/ag/ag.port | 15 + ports/ag/ag.rmpatch | 1 + ports/binutils/binutils.port | 18 + ports/binutils/binutils.post-install | 9 + ports/bison/bison.patch | 270 +++++ ports/bison/bison.port | 11 + ports/bison/bison.rmpatch | 4 + ports/bochs/bochs.patch | 239 ++++ ports/bochs/bochs.port | 13 + ports/bzip2/bzip2.execpatch | 1 + ports/bzip2/bzip2.patch | 129 +++ ports/bzip2/bzip2.port | 11 + ports/bzip2/bzip2.rmpatch | 3 + ports/cut/cut.patch | 100 ++ ports/cut/cut.port | 11 + ports/dash/dash.patch | 218 ++++ ports/dash/dash.port | 10 + ports/diffutils/diffutils.port | 11 + ports/e2fsprogs/e2fsprogs.patch | 1272 ++++++++++++++++++++ ports/e2fsprogs/e2fsprogs.port | 15 + ports/e2fsprogs/e2fsprogs.rmpatch | 1 + ports/ed/ed.patch | 64 ++ ports/ed/ed.port | 11 + ports/emacs/emacs.patch | 634 ++++++++++ ports/emacs/emacs.port | 17 + ports/emacs/emacs.post-install | 4 + ports/emacs/emacs.rmpatch | 8 + ports/ffmpeg/ffmpeg.patch | 198 ++++ ports/ffmpeg/ffmpeg.port | 15 + ports/flex/flex.patch | 65 ++ ports/flex/flex.port | 12 + ports/gawk/gawk.patch | 131 +++ ports/gawk/gawk.port | 11 + ports/gcc/gcc.port | 19 + ports/gcc/gcc.post-install | 6 + ports/gettext/gettext.patch | 700 +++++++++++ ports/gettext/gettext.port | 15 + ports/git/git.patch | 429 +++++++ ports/git/git.port | 22 + ports/grep/grep.patch | 138 +++ ports/grep/grep.port | 11 + ports/grep/grep.rmpatch | 1 + ports/grub/grub.execpatch | 2 + ports/grub/grub.patch | 869 ++++++++++++++ ports/grub/grub.port | 13 + ports/grub/grub.post-install | 10 + ports/grub/grub.rmpatch | 2 + ports/gzip/gzip.patch | 214 ++++ ports/gzip/gzip.port | 12 + ports/hello/hello.patch | 12 + ports/hello/hello.port | 11 + ports/libSDL/libSDL.execpatch | 1 + ports/libSDL/libSDL.patch | 12 + ports/libSDL/libSDL.port | 13 + ports/libavcodec/libavcodec.port | 6 + ports/libcairo/libcairo.patch | 90 ++ ports/libcairo/libcairo.port | 13 + ports/libcairo/libcairo.rmpatch | 45 + ports/libcurl/libcurl.patch | 233 ++++ ports/libcurl/libcurl.port | 13 + ports/libcurl/libcurl.rmpatch | 3 + ports/libcurses/libcurses.patch | 905 +++++++++++++++ ports/libcurses/libcurses.port | 11 + ports/libdbus/libdbus.patch | 176 +++ ports/libdbus/libdbus.port | 14 + ports/libevent/libevent.patch | 219 ++++ ports/libevent/libevent.port | 13 + ports/libexpat/libexpat.patch | 45 + ports/libexpat/libexpat.port | 14 + ports/libffi/libffi.patch | 68 ++ ports/libffi/libffi.port | 11 + ports/libfontconfig/libfontconfig.patch | 261 +++++ ports/libfontconfig/libfontconfig.port | 14 + ports/libfontconfig/libfontconfig.rmpatch | 208 ++++ ports/libfreetype/libfreetype.patch | 312 +++++ ports/libfreetype/libfreetype.port | 12 + ports/libfreetype/libfreetype.rmpatch | 48 + ports/libglib/libglib.patch | 407 +++++++ ports/libglib/libglib.port | 13 + ports/libglib/libglib.rmpatch | 585 ++++++++++ ports/libgmp/libgmp.patch | 60 + ports/libgmp/libgmp.port | 14 + ports/libiconv/libiconv.patch | 18 + ports/libiconv/libiconv.port | 11 + ports/libidn/libidn.patch | 169 +++ ports/libidn/libidn.port | 13 + ports/libidn/libidn.rmpatch | 27 + ports/libintl/libintl.port | 9 + ports/libjpeg/libjpeg.port | 17 + ports/liblua/liblua.port | 5 + ports/libmpc/libmpc.patch | 12 + ports/libmpc/libmpc.port | 11 + ports/libmpfr/libmpfr.patch | 12 + ports/libmpfr/libmpfr.port | 12 + ports/libogg/libogg.patch | 33 + ports/libogg/libogg.port | 12 + ports/libogg/libogg.rmpatch | 1 + ports/libpcre/libpcre.patch | 130 +++ ports/libpcre/libpcre.port | 15 + ports/libpixman/libpixman.patch | 12 + ports/libpixman/libpixman.port | 12 + ports/libpixman/libpixman.rmpatch | 1 + ports/libpng/libpng.patch | 35 + ports/libpng/libpng.port | 13 + ports/libreadline/libreadline.patch | 225 ++++ ports/libreadline/libreadline.port | 11 + ports/libssl/libssl.patch | 547 +++++++++ ports/libssl/libssl.port | 12 + ports/libstdc++/libstdc++.patch | 15 + ports/libstdc++/libstdc++.port | 13 + ports/libtheora/libtheora.patch | 91 ++ ports/libtheora/libtheora.port | 14 + ports/libtheora/libtheora.rmpatch | 73 ++ ports/libvorbis/libvorbis.patch | 12 + ports/libvorbis/libvorbis.port | 12 + ports/libvorbis/libvorbis.rmpatch | 4 + ports/libxkbcommon/libxkbcommon.patch | 40 + ports/libxkbcommon/libxkbcommon.port | 12 + ports/libxkbcommon/libxkbcommon.rmpatch | 2 + ports/libxml2/libxml2.patch | 356 ++++++ ports/libxml2/libxml2.port | 14 + ports/libxml2/libxml2.rmpatch | 3 + ports/libz/libz.port | 11 + ports/lua/lua.patch | 219 ++++ ports/lua/lua.port | 10 + ports/m4/m4.patch | 270 +++++ ports/m4/m4.port | 11 + ports/make/make.patch | 169 +++ ports/make/make.port | 11 + ports/make/make.post-install | 3 + ports/mdocml/mdocml.patch | 739 ++++++++++++ ports/mdocml/mdocml.port | 11 + ports/nano/nano.patch | 157 +++ ports/nano/nano.port | 10 + ports/nano/nano.rmpatch | 2 + ports/nasm/nasm.patch | 31 + ports/nasm/nasm.port | 12 + ports/nasm/nasm.rmpatch | 1 + ports/nyancat/nyancat.patch | 119 ++ ports/nyancat/nyancat.port | 11 + ports/patch/patch.patch | 187 +++ ports/patch/patch.port | 11 + ports/perl/perl.patch | 1033 +++++++++++++++++ ports/perl/perl.port | 25 + ports/perl/perl.post-install | 24 + ports/pkg-config/pkg-config.patch | 24 + ports/pkg-config/pkg-config.port | 12 + ports/pkg-config/pkg-config.rmpatch | 1 + ports/python/python.patch | 1216 ++++++++++++++++++++ ports/python/python.port | 20 + ports/python/python.post-install | 13 + ports/python/python.rmpatch | 3 + ports/qemu/qemu.patch | 1278 +++++++++++++++++++++ ports/qemu/qemu.port | 12 + ports/sed/sed.patch | 12 + ports/sed/sed.port | 11 + ports/sed/sed.rmpatch | 1 + ports/tar/tar.patch | 201 ++++ ports/tar/tar.port | 11 + ports/tar/tar.rmpatch | 1 + ports/texinfo/texinfo.patch | 141 +++ ports/texinfo/texinfo.port | 12 + ports/texinfo/texinfo.rmpatch | 3 + ports/video-player/video-player.patch | 357 ++++++ ports/video-player/video-player.port | 3 + ports/vim/vim.patch | 183 +++ ports/vim/vim.port | 13 + ports/wget/wget.patch | 320 ++++++ ports/wget/wget.port | 12 + ports/wget/wget.rmpatch | 4 + ports/xargs/xargs.patch | 188 +++ ports/xargs/xargs.port | 11 + ports/xorriso/xorriso.patch | 537 +++++++++ ports/xorriso/xorriso.port | 11 + ports/xorriso/xorriso.rmpatch | 2 + ports/xz/xz.patch | 49 + ports/xz/xz.port | 12 + share/man/man5/port.5 | 356 ++++++ share/man/man7/cross-development.7 | 17 +- share/man/man7/development.7 | 106 +- share/man/man7/following-development.7 | 34 + share/man/man7/portability.7 | 301 +++++ share/man/man7/porting.7 | 657 +++++++++++ tix/.gitignore | 5 +- tix/Makefile | 13 +- tix/porttix-create.c | 464 -------- tix/srctix-create.c | 304 ----- tix/tix-build.8 | 169 +++ tix/tix-build.c | 295 +++-- tix/tix-eradicate-libtool-la.8 | 25 + tix/tix-execdiff.8 | 47 + tix/tix-execdiff.c | 101 +- tix/tix-execpatch.8 | 43 + tix/tix-port | 527 +++++++++ tix/tix-port.8 | 262 +++++ tix/tix-rmdiff.8 | 39 + tix/tix-rmdiff.c | 149 +++ tix/tix-rmpatch.8 | 42 + tix/tix-vars.8 | 52 + tix/tix-vars.c | 91 ++ tix/util.h | 165 ++- 220 files changed, 23392 insertions(+), 2422 deletions(-) create mode 100755 build-aux/list-packages.sh create mode 100755 build-aux/upgrade-port.sh delete mode 100644 doc/.gitignore delete mode 100644 doc/Makefile delete mode 100644 doc/cross-compilation-sins delete mode 100644 doc/obsolete-stuff delete mode 100644 doc/portability-sins delete mode 100644 doc/porting-guide delete mode 100644 doc/posix-divergence delete mode 100644 doc/welcome create mode 100644 ports/ag/ag.patch create mode 100644 ports/ag/ag.port create mode 100644 ports/ag/ag.rmpatch create mode 100644 ports/binutils/binutils.port create mode 100755 ports/binutils/binutils.post-install create mode 100644 ports/bison/bison.patch create mode 100644 ports/bison/bison.port create mode 100644 ports/bison/bison.rmpatch create mode 100644 ports/bochs/bochs.patch create mode 100644 ports/bochs/bochs.port create mode 100644 ports/bzip2/bzip2.execpatch create mode 100644 ports/bzip2/bzip2.patch create mode 100644 ports/bzip2/bzip2.port create mode 100644 ports/bzip2/bzip2.rmpatch create mode 100644 ports/cut/cut.patch create mode 100644 ports/cut/cut.port create mode 100644 ports/dash/dash.patch create mode 100644 ports/dash/dash.port create mode 100644 ports/diffutils/diffutils.port create mode 100644 ports/e2fsprogs/e2fsprogs.patch create mode 100644 ports/e2fsprogs/e2fsprogs.port create mode 100644 ports/e2fsprogs/e2fsprogs.rmpatch create mode 100644 ports/ed/ed.patch create mode 100644 ports/ed/ed.port create mode 100644 ports/emacs/emacs.patch create mode 100644 ports/emacs/emacs.port create mode 100755 ports/emacs/emacs.post-install create mode 100644 ports/emacs/emacs.rmpatch create mode 100644 ports/ffmpeg/ffmpeg.patch create mode 100644 ports/ffmpeg/ffmpeg.port create mode 100644 ports/flex/flex.patch create mode 100644 ports/flex/flex.port create mode 100644 ports/gawk/gawk.patch create mode 100644 ports/gawk/gawk.port create mode 100644 ports/gcc/gcc.port create mode 100755 ports/gcc/gcc.post-install create mode 100644 ports/gettext/gettext.patch create mode 100644 ports/gettext/gettext.port create mode 100644 ports/git/git.patch create mode 100644 ports/git/git.port create mode 100644 ports/grep/grep.patch create mode 100644 ports/grep/grep.port create mode 100644 ports/grep/grep.rmpatch create mode 100644 ports/grub/grub.execpatch create mode 100644 ports/grub/grub.patch create mode 100644 ports/grub/grub.port create mode 100755 ports/grub/grub.post-install create mode 100644 ports/grub/grub.rmpatch create mode 100644 ports/gzip/gzip.patch create mode 100644 ports/gzip/gzip.port create mode 100644 ports/hello/hello.patch create mode 100644 ports/hello/hello.port create mode 100644 ports/libSDL/libSDL.execpatch create mode 100644 ports/libSDL/libSDL.patch create mode 100644 ports/libSDL/libSDL.port create mode 100644 ports/libavcodec/libavcodec.port create mode 100644 ports/libcairo/libcairo.patch create mode 100644 ports/libcairo/libcairo.port create mode 100644 ports/libcairo/libcairo.rmpatch create mode 100644 ports/libcurl/libcurl.patch create mode 100644 ports/libcurl/libcurl.port create mode 100644 ports/libcurl/libcurl.rmpatch create mode 100644 ports/libcurses/libcurses.patch create mode 100644 ports/libcurses/libcurses.port create mode 100644 ports/libdbus/libdbus.patch create mode 100644 ports/libdbus/libdbus.port create mode 100644 ports/libevent/libevent.patch create mode 100644 ports/libevent/libevent.port create mode 100644 ports/libexpat/libexpat.patch create mode 100644 ports/libexpat/libexpat.port create mode 100644 ports/libffi/libffi.patch create mode 100644 ports/libffi/libffi.port create mode 100644 ports/libfontconfig/libfontconfig.patch create mode 100644 ports/libfontconfig/libfontconfig.port create mode 100644 ports/libfontconfig/libfontconfig.rmpatch create mode 100644 ports/libfreetype/libfreetype.patch create mode 100644 ports/libfreetype/libfreetype.port create mode 100644 ports/libfreetype/libfreetype.rmpatch create mode 100644 ports/libglib/libglib.patch create mode 100644 ports/libglib/libglib.port create mode 100644 ports/libglib/libglib.rmpatch create mode 100644 ports/libgmp/libgmp.patch create mode 100644 ports/libgmp/libgmp.port create mode 100644 ports/libiconv/libiconv.patch create mode 100644 ports/libiconv/libiconv.port create mode 100644 ports/libidn/libidn.patch create mode 100644 ports/libidn/libidn.port create mode 100644 ports/libidn/libidn.rmpatch create mode 100644 ports/libintl/libintl.port create mode 100644 ports/libjpeg/libjpeg.port create mode 100644 ports/liblua/liblua.port create mode 100644 ports/libmpc/libmpc.patch create mode 100644 ports/libmpc/libmpc.port create mode 100644 ports/libmpfr/libmpfr.patch create mode 100644 ports/libmpfr/libmpfr.port create mode 100644 ports/libogg/libogg.patch create mode 100644 ports/libogg/libogg.port create mode 100644 ports/libogg/libogg.rmpatch create mode 100644 ports/libpcre/libpcre.patch create mode 100644 ports/libpcre/libpcre.port create mode 100644 ports/libpixman/libpixman.patch create mode 100644 ports/libpixman/libpixman.port create mode 100644 ports/libpixman/libpixman.rmpatch create mode 100644 ports/libpng/libpng.patch create mode 100644 ports/libpng/libpng.port create mode 100644 ports/libreadline/libreadline.patch create mode 100644 ports/libreadline/libreadline.port create mode 100644 ports/libssl/libssl.patch create mode 100644 ports/libssl/libssl.port create mode 100644 ports/libstdc++/libstdc++.patch create mode 100644 ports/libstdc++/libstdc++.port create mode 100644 ports/libtheora/libtheora.patch create mode 100644 ports/libtheora/libtheora.port create mode 100644 ports/libtheora/libtheora.rmpatch create mode 100644 ports/libvorbis/libvorbis.patch create mode 100644 ports/libvorbis/libvorbis.port create mode 100644 ports/libvorbis/libvorbis.rmpatch create mode 100644 ports/libxkbcommon/libxkbcommon.patch create mode 100644 ports/libxkbcommon/libxkbcommon.port create mode 100644 ports/libxkbcommon/libxkbcommon.rmpatch create mode 100644 ports/libxml2/libxml2.patch create mode 100644 ports/libxml2/libxml2.port create mode 100644 ports/libxml2/libxml2.rmpatch create mode 100644 ports/libz/libz.port create mode 100644 ports/lua/lua.patch create mode 100644 ports/lua/lua.port create mode 100644 ports/m4/m4.patch create mode 100644 ports/m4/m4.port create mode 100644 ports/make/make.patch create mode 100644 ports/make/make.port create mode 100755 ports/make/make.post-install create mode 100644 ports/mdocml/mdocml.patch create mode 100644 ports/mdocml/mdocml.port create mode 100644 ports/nano/nano.patch create mode 100644 ports/nano/nano.port create mode 100644 ports/nano/nano.rmpatch create mode 100644 ports/nasm/nasm.patch create mode 100644 ports/nasm/nasm.port create mode 100644 ports/nasm/nasm.rmpatch create mode 100644 ports/nyancat/nyancat.patch create mode 100644 ports/nyancat/nyancat.port create mode 100644 ports/patch/patch.patch create mode 100644 ports/patch/patch.port create mode 100644 ports/perl/perl.patch create mode 100644 ports/perl/perl.port create mode 100755 ports/perl/perl.post-install create mode 100644 ports/pkg-config/pkg-config.patch create mode 100644 ports/pkg-config/pkg-config.port create mode 100644 ports/pkg-config/pkg-config.rmpatch create mode 100644 ports/python/python.patch create mode 100644 ports/python/python.port create mode 100755 ports/python/python.post-install create mode 100644 ports/python/python.rmpatch create mode 100644 ports/qemu/qemu.patch create mode 100644 ports/qemu/qemu.port create mode 100644 ports/sed/sed.patch create mode 100644 ports/sed/sed.port create mode 100644 ports/sed/sed.rmpatch create mode 100644 ports/tar/tar.patch create mode 100644 ports/tar/tar.port create mode 100644 ports/tar/tar.rmpatch create mode 100644 ports/texinfo/texinfo.patch create mode 100644 ports/texinfo/texinfo.port create mode 100644 ports/texinfo/texinfo.rmpatch create mode 100644 ports/video-player/video-player.patch create mode 100644 ports/video-player/video-player.port create mode 100644 ports/vim/vim.patch create mode 100644 ports/vim/vim.port create mode 100644 ports/wget/wget.patch create mode 100644 ports/wget/wget.port create mode 100644 ports/wget/wget.rmpatch create mode 100644 ports/xargs/xargs.patch create mode 100644 ports/xargs/xargs.port create mode 100644 ports/xorriso/xorriso.patch create mode 100644 ports/xorriso/xorriso.port create mode 100644 ports/xorriso/xorriso.rmpatch create mode 100644 ports/xz/xz.patch create mode 100644 ports/xz/xz.port create mode 100644 share/man/man5/port.5 create mode 100644 share/man/man7/portability.7 create mode 100644 share/man/man7/porting.7 delete mode 100644 tix/porttix-create.c delete mode 100644 tix/srctix-create.c create mode 100644 tix/tix-build.8 create mode 100644 tix/tix-eradicate-libtool-la.8 create mode 100644 tix/tix-execdiff.8 create mode 100644 tix/tix-execpatch.8 create mode 100755 tix/tix-port create mode 100644 tix/tix-port.8 create mode 100644 tix/tix-rmdiff.8 create mode 100644 tix/tix-rmdiff.c create mode 100644 tix/tix-rmpatch.8 create mode 100644 tix/tix-vars.8 create mode 100644 tix/tix-vars.c diff --git a/.gitignore b/.gitignore index 8ca30efb..a7a83954 100644 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,12 @@ /*.so /*.a builds +mirror +ports/*/*/ +ports/*/*.version +release +repository sysroot sysroot.destdir sysroot-overlay sysroot-overlay-* -release -ports -repository diff --git a/LICENSE b/LICENSE index 9d8e6ef8..334e6252 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors. +Copyright 2011-2022 Jonas 'Sortie' Termansen and contributors. Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -26,7 +26,8 @@ software. There is no code under the GNU GPL or variants. The Sortix ports collection contains third party code which is licensed independently of the Sortix base systems. Such code may have licenses that impose restrictions, such as requiring also providing the corresponding source -code when providing compiled program code to others. +code when providing compiled program code to others. Patches to ports are +licensed under the same license as the relevant port. Official Sortix releases contain the binary packages from the ports collection and thus may contain code whose licenses impose restrictions. Official Sortix diff --git a/Makefile b/Makefile index 895c366c..dd4d37db 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ include build-aux/compiler.mak include build-aux/version.mak MODULES=\ -doc \ libc \ libm \ dispd \ @@ -43,11 +42,14 @@ ifndef SYSROOT_OVERLAY endif SORTIX_BUILDS_DIR?=builds +SORTIX_MIRROR_DIR?=mirror SORTIX_PORTS_DIR?=ports SORTIX_RELEASE_DIR?=release SORTIX_REPOSITORY_DIR?=repository SORTIX_ISO_COMPRESSION?=xz +SORTIX_PORTS_MIRROR?=https://pub.sortix.org/mirror + SORTIX_INCLUDE_SOURCE_GIT_REPO?=$(shell test -d .git && echo "file://`pwd`") SORTIX_INCLUDE_SOURCE_GIT_REPO:=$(SORTIX_INCLUDE_SOURCE_GIT_REPO) SORTIX_INCLUDE_SOURCE_GIT_ORIGIN?= @@ -225,15 +227,56 @@ endif grep -E '^/src(/.*)?$$' | \ LC_ALL=C sort > "$(SYSROOT)/tix/manifest/src" -.PHONY: sysroot-ports -sysroot-ports: sysroot-fsh sysroot-base-headers sysroot-system sysroot-source - @SORTIX_PORTS_DIR="$(SORTIX_PORTS_DIR)" \ +.PHONY: available-ports +available-ports: + @for port in $$(build-aux/list-packages.sh PACKAGES); do \ + build-aux/upgrade-port.sh ports/$$port/$$port.port available; \ + done + +.PHONY: upgrade-ports +upgrade-ports: + @for port in $$(build-aux/list-packages.sh PACKAGES); do \ + build-aux/upgrade-port.sh ports/$$port/$$port.port upgrade; \ + done + +.PHONY: mirror +mirror: + @SORTIX_MIRROR_DIR="$(SORTIX_MIRROR_DIR)" \ + SORTIX_PORTS_DIR="$(SORTIX_PORTS_DIR)" \ SORTIX_REPOSITORY_DIR="$(SORTIX_REPOSITORY_DIR)" \ + SORTIX_PORTS_MIRROR="$(SORTIX_PORTS_MIRROR)" \ SYSROOT="$(SYSROOT)" \ + BUILD="$(BUILD)" \ HOST="$(HOST)" \ MAKE="$(MAKE)" \ MAKEFLAGS="$(MAKEFLAGS)" \ - build-aux/build-ports.sh + build-aux/build-ports.sh download + +.PHONY: extract-ports +extract-ports: + @SORTIX_MIRROR_DIR="$(SORTIX_MIRROR_DIR)" \ + SORTIX_PORTS_DIR="$(SORTIX_PORTS_DIR)" \ + SORTIX_REPOSITORY_DIR="$(SORTIX_REPOSITORY_DIR)" \ + SORTIX_PORTS_MIRROR="$(SORTIX_PORTS_MIRROR)" \ + SYSROOT="$(SYSROOT)" \ + BUILD="$(BUILD)" \ + HOST="$(HOST)" \ + MAKE="$(MAKE)" \ + MAKEFLAGS="$(MAKEFLAGS)" \ + build-aux/build-ports.sh extract + +.PHONY: sysroot-ports +sysroot-ports: sysroot-fsh sysroot-base-headers sysroot-system sysroot-source + @SORTIX_MIRROR_DIR="$(SORTIX_MIRROR_DIR)" \ + SORTIX_PORTS_DIR="$(SORTIX_PORTS_DIR)" \ + SORTIX_REPOSITORY_DIR="$(SORTIX_REPOSITORY_DIR)" \ + SORTIX_PORTS_MIRROR="$(SORTIX_PORTS_MIRROR)" \ + SYSROOT="$(SYSROOT)" \ + BUILD="$(BUILD)" \ + HOST="$(HOST)" \ + MAKE="$(MAKE)" \ + MAKEFLAGS="$(MAKEFLAGS)" \ + build-aux/build-ports.sh build .PHONY: sysroot sysroot: sysroot-system sysroot-source sysroot-ports @@ -248,10 +291,13 @@ $(SORTIX_REPOSITORY_DIR)/$(HOST): $(SORTIX_REPOSITORY_DIR) clean-core: (for D in $(MODULES); do $(MAKE) clean -C $$D || exit $$?; done) +.PHONY: clean-mirror +clean-mirror: + rm -rf "$(SORTIX_MIRROR_DIR)" + .PHONY: clean-ports clean-ports: @SORTIX_PORTS_DIR="$(SORTIX_PORTS_DIR)" \ - HOST="$(HOST)" \ MAKE="$(MAKE)" \ MAKEFLAGS="$(MAKEFLAGS)" \ build-aux/clean-ports.sh @@ -277,11 +323,18 @@ clean-sysroot: .PHONY: clean clean: clean-core clean-ports +.PHONY: distclean-ports +distclean-ports: + @SORTIX_PORTS_DIR="$(SORTIX_PORTS_DIR)" \ + MAKE="$(MAKE)" \ + MAKEFLAGS="$(MAKEFLAGS)" \ + build-aux/clean-ports.sh distclean + .PHONY: mostlyclean -mostlyclean: clean-core clean-ports clean-builds clean-release clean-sysroot +mostlyclean: clean-core distclean-ports clean-builds clean-release clean-sysroot .PHONY: distclean -distclean: clean-core clean-ports clean-builds clean-release clean-repository clean-sysroot +distclean: clean-core distclean-ports clean-builds clean-release clean-mirror clean-repository clean-sysroot .PHONY: most-things most-things: sysroot iso @@ -340,7 +393,13 @@ $(LIVE_INITRD): sysroot mkdir -p $(LIVE_INITRD).d/home mkdir -p $(LIVE_INITRD).d/root -m 700 cp -RT "$(SYSROOT)/etc/skel" $(LIVE_INITRD).d/root - cp doc/welcome $(LIVE_INITRD).d/root + (echo "You can view the documentation for new users by typing:" && \ + echo && \ + echo " man user-guide" && \ + echo && \ + echo "You can view the installation instructions by typing:" && \ + echo && \ + echo " man installation") > $(LIVE_INITRD).d/root/welcome tix-collection $(LIVE_INITRD).d create --platform=$(HOST) --prefix= --generation=2 mkinitrd --format=sortix-initrd-2 $(LIVE_INITRD).d -o $(LIVE_INITRD) rm -rf $(LIVE_INITRD).d @@ -491,7 +550,8 @@ $(SORTIX_RELEASE_DIR)/$(RELEASE)/repository/$(HOST): .PHONY: release-repository release-repository: sysroot $(SORTIX_RELEASE_DIR)/$(RELEASE)/repository/$(HOST) for port in `LC_ALL=C ls "$(SYSROOT)/tix/tixinfo"`; do \ - cp $(SORTIX_REPOSITORY_DIR)/$(HOST)/$$port.tix.tar.xz $(SORTIX_RELEASE_DIR)/$(RELEASE)/repository/$(HOST); \ + cp $(SORTIX_REPOSITORY_DIR)/$(HOST)/$$port.tix.tar.xz $(SORTIX_RELEASE_DIR)/$(RELEASE)/repository/$(HOST) && \ + cp $(SORTIX_REPOSITORY_DIR)/$(HOST)/$$port.version $(SORTIX_RELEASE_DIR)/$(RELEASE)/repository/$(HOST); \ done .PHONY: release-scripts diff --git a/build-aux/build-ports.sh b/build-aux/build-ports.sh index 13922ea0..c7abd150 100755 --- a/build-aux/build-ports.sh +++ b/build-aux/build-ports.sh @@ -1,4 +1,5 @@ -#!/bin/sh -e +#!/bin/sh +set -e make_dir_path_absolute() { (cd "$1" && pwd) @@ -8,6 +9,18 @@ has_command() { which "$1" > /dev/null } +# Determine what's supposed to happen. +if [ $# = 0 ]; then + echo "$0: usage: $0 " >&2 + exit 1 +fi +OPERATION="$1" +case "$OPERATION" in +download|extract|build) ;; +*) echo "$0: error: Invalid operation: $OPERATION" >&2 + exit 1 +esac + # Detect if the environment isn't set up properly. if [ -z "$HOST" ]; then echo "$0: error: You need to set \$HOST" >&2 @@ -18,25 +31,37 @@ elif [ -z "$SYSROOT" ]; then elif [ -z "$SORTIX_PORTS_DIR" ]; then echo "$0: error: You need to set \$SORTIX_PORTS_DIR" >&2 exit 1 +elif [ -z "$SORTIX_MIRROR_DIR" ]; then + echo "$0: error: You need to set \$SORTIX_MIRROR_DIR" >&2 + exit 1 elif [ -z "$SORTIX_REPOSITORY_DIR" ]; then echo "$0: error: You need to set \$SORTIX_REPOSITORY_DIR" >&2 exit 1 elif ! [ -d "$SORTIX_PORTS_DIR" ]; then echo "Warning: No ports directory found, third party software will not be built" exit 0 -elif ! has_command tix-collection || - ! has_command tix-build || - ! has_command tix-install; then +elif ! has_command tix-rmdiff; then echo "$0: error: You need to have installed Tix locally to compile ports." >&2 exit 1 fi +# Create the mirror directory for downloaded archives. +mkdir -p "$SORTIX_MIRROR_DIR" + # Add the platform triplet to the binary repository path. SORTIX_REPOSITORY_DIR="$SORTIX_REPOSITORY_DIR/$HOST" mkdir -p "$SORTIX_REPOSITORY_DIR" +# Create the system root if absent. +if [ "$OPERATION" = build ]; then + mkdir -p "$SYSROOT" +fi + # Make paths absolute for later use. -SYSROOT=$(make_dir_path_absolute "$SYSROOT") +if [ "$OPERATION" = build ]; then + SYSROOT=$(make_dir_path_absolute "$SYSROOT") +fi +SORTIX_MIRROR_DIR=$(make_dir_path_absolute "$SORTIX_MIRROR_DIR") SORTIX_PORTS_DIR=$(make_dir_path_absolute "$SORTIX_PORTS_DIR") SORTIX_REPOSITORY_DIR=$(make_dir_path_absolute "$SORTIX_REPOSITORY_DIR") @@ -52,119 +77,71 @@ CXXFLAGS="$CXXFLAGS -Werror=format -Wno-error=format-contains-nul" export CFLAGS export CXXFLAGS -# Create the system root if absent. -mkdir -p "$SYSROOT" - -# Create the binary package repository. -mkdir -p "$SORTIX_REPOSITORY_DIR" - # Initialize Tix package management in the system root if absent. -[ -e "$SYSROOT/tix/collection.conf" ] || -tix-collection "$SYSROOT" create --platform=$HOST --prefix= --generation=2 - -# Detect all packages. -get_all_packages() { - for PACKAGE in $(ls "$SORTIX_PORTS_DIR"); do - ! [ -f "$SORTIX_PORTS_DIR/$PACKAGE/tixbuildinfo" ] || - echo $PACKAGE - done -} - -# Detect which packages are available if not specified. -if [ -z "${PACKAGES+x}" ]; then - PACKAGES=$(get_all_packages | sort -R) +if [ "$OPERATION" = build ]; then + if [ ! -e "$SYSROOT/tix/collection.conf" ]; then + tix-collection "$SYSROOT" create --platform=$HOST --prefix= --generation=2 + fi fi +PACKAGES="$("$(dirname -- "$0")"/list-packages.sh PACKAGES)" + # Simply stop if there is no packages available. if [ -z "$PACKAGES" ]; then exit 0 fi -# Detect the build-time dependencies for a package. -get_package_dependencies_raw() {( - PACKAGE_DIR=$(echo $1 | grep -Eo '^[^\.]*') - ! [ -f "$SORTIX_PORTS_DIR/$PACKAGE_DIR/tixbuildinfo" ] || - grep -E "^(pkg\.build-libraries|pkg\.alias-of)=.*" "$SORTIX_PORTS_DIR/$PACKAGE_DIR/tixbuildinfo" | \ - sed 's/^[^=]*=//' -)} - -# Detect the build-time dependencies for a package with missing optional -# dependencies removed. -get_package_dependencies() {( - PRINTED_ANY=false - for DEPENDENCY in $(get_package_dependencies_raw $1); do - if [ "$DEPENDENCY" != "${DEPENDENCY%\?}" ]; then - DEPENDENCY="${DEPENDENCY%\?}" - FOUND=false - for PACKAGE in $PACKAGES; do - if [ "$PACKAGE" = "$DEPENDENCY" ]; then - FOUND=true - break - fi - done - if ! $FOUND; then - continue - fi - fi - if $PRINTED_ANY; then printf ' '; fi - printf "%s" "$DEPENDENCY" - PRINTED_ANY=true - done - if $PRINTED_ANY; then echo; fi -)} - # Decide the order the packages are built in according to their dependencies. -DEPENDENCY_MAKEFILE=$(mktemp) -(for PACKAGE in $PACKAGES; do - echo "$PACKAGE: $(get_package_dependencies $PACKAGE)" - echo " @echo $PACKAGE" - done; - printf ".PHONY:" - for PACKAGE in $PACKAGES; do - printf " $PACKAGE" - done; - echo) > "$DEPENDENCY_MAKEFILE" +if [ "$OPERATION" = build ]; then + PACKAGES="$(echo "$PACKAGES" | tr ' ' '\n' | sort -R)" + DEPENDENCY_MAKEFILE=$(mktemp) + (for PACKAGE in $PACKAGES; do + DEPENDENCIES="$(PACKAGES="$PACKAGES" \ + "$(dirname -- "$0")"/list-packages.sh \ + --dependencies $PACKAGE)" + echo "$PACKAGE: $(echo "$DEPENDENCIES" | tr '\n' ' ' | sed -E 's/ +$/\n/')" + echo " @echo $PACKAGE" + done; + printf ".PHONY:" + for PACKAGE in $PACKAGES; do + printf " $PACKAGE" + done; + echo) > "$DEPENDENCY_MAKEFILE" -BUILD_LIST=$(unset MAKE; - unset MFLAGS; - unset MAKEFLAGS; - make -Bs -f "$DEPENDENCY_MAKEFILE" $PACKAGES) -rm -f "$DEPENDENCY_MAKEFILE" -PACKAGES="$BUILD_LIST" + BUILD_LIST=$(unset MAKE; + unset MFLAGS; + unset MAKEFLAGS; + make -Bs -f "$DEPENDENCY_MAKEFILE" $PACKAGES) + rm -f "$DEPENDENCY_MAKEFILE" + PACKAGES="$BUILD_LIST" +fi -# TODO: This adds another decompression and compression to the build time, this -# should be done as a tix post installation step. Also this might miss -# programs in unusual locations, so need a thorough search and strip. -strip_tix() { - DIR=$(mktemp -d) - tar -C "$DIR" -xf "$1" - $HOST-strip -d "$DIR/data/bin/"* 2>/dev/null || true - $HOST-strip -d "$DIR/data/lib/"* 2>/dev/null || true - $HOST-strip -d "$DIR/data/libexec"* 2>/dev/null || true - $HOST-strip -d "$DIR/data/libexec/git-core/"* 2>/dev/null || true - $HOST-strip -d "$DIR/data/sbin/"* 2>/dev/null || true - (cd "$DIR" && tar --numeric-owner --owner=0 --group=0 -cJf port.tar.tix.xz tix data) - cp "$DIR/port.tar.tix.xz" "$1" - rm -rf "$DIR" -} +unset CACHE_PACKAGE +unset END +if [ "$OPERATION" = download ]; then + END=download +elif [ "$OPERATION" = extract ]; then + END=extract +else + CACHE_PACKAGE=--cache-package +fi -# Build all the packages (if needed) and otherwise install them. +# Build and install all the packages. for PACKAGE in $PACKAGES; do - if ! [ -f "$SORTIX_REPOSITORY_DIR/$PACKAGE.tix.tar.xz" ]; then - SOURCE_PACKAGE=$(grep -E "^pkg.source-package=" "$SORTIX_PORTS_DIR/$PACKAGE/tixbuildinfo" | \ - sed 's/^[^=]*=//') - tix-build \ - --sysroot="$SYSROOT" \ - --host=$HOST \ - --prefix= \ - --destination="$SORTIX_REPOSITORY_DIR" \ - --generation=2 \ - ${SOURCE_PACKAGE:+--source-package "$SORTIX_PORTS_DIR/$SOURCE_PACKAGE"} \ - "$SORTIX_PORTS_DIR/$PACKAGE" - strip_tix "$SORTIX_REPOSITORY_DIR/$PACKAGE.tix.tar.xz" - fi - tix-install \ + SOURCE_PORT=$(tix-vars -d '' $SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.port \ + SOURCE_PORT) + tix-port \ + ${BUILD:+--build="$BUILD"} \ + $CACHE_PACKAGE \ --collection="$SYSROOT" \ - --reinstall \ - "$SORTIX_REPOSITORY_DIR/$PACKAGE.tix.tar.xz" + --destination="$SORTIX_REPOSITORY_DIR" \ + ${END:+--end="$END"} \ + --generation=2 \ + --host=$HOST \ + ${SORTIX_PORTS_MIRROR:+--mirror="$SORTIX_PORTS_MIRROR"} \ + --mirror-directory="$SORTIX_MIRROR_DIR" \ + --prefix= \ + ${SOURCE_PORT:+--source-port="$SORTIX_PORTS_DIR/$SOURCE_PORT/$SOURCE_PORT"} \ + --sysroot="$SYSROOT" \ + "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE" done diff --git a/build-aux/clean-ports.sh b/build-aux/clean-ports.sh index 3438e0b5..fe47d6cf 100755 --- a/build-aux/clean-ports.sh +++ b/build-aux/clean-ports.sh @@ -15,7 +15,7 @@ if [ -z "$SORTIX_PORTS_DIR" ]; then elif ! [ -d "$SORTIX_PORTS_DIR" ] || [ "$(ls "$SORTIX_PORTS_DIR") | wc -l" = 0 ]; then exit 0 -elif ! has_command tix-build; then +elif ! has_command tix-vars; then echo "$0: warning: Can't clean ports directory without Tix locally installed." >&2 exit 0 fi @@ -23,23 +23,41 @@ fi # Make paths absolute for later use. SORTIX_PORTS_DIR=$(make_dir_path_absolute "$SORTIX_PORTS_DIR") -# Detect all packages. -get_all_packages() { - for PACKAGE in $(ls "$SORTIX_PORTS_DIR"); do - ! [ -f "$SORTIX_PORTS_DIR/$PACKAGE/tixbuildinfo" ] || - echo $PACKAGE - done -} - # Clean all the packages. -for PACKAGE in $(get_all_packages); do - [ -f "$SORTIX_REPOSITORY_DIR/$PACKAGE.tix.tar.xz" ] || - tix-build \ - --sysroot="/" \ - --host=$HOST \ - --prefix= \ - --destination="/" \ - --start=clean \ - --end=clean \ - "$SORTIX_PORTS_DIR/$PACKAGE" +for PACKAGE in $("$(dirname -- "$0")"/list-packages.sh 'all!'); do + if [ "$1" = distclean ]; then + DEVELOPMENT=$(tix-vars -d false $SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.port \ + DEVELOPMENT) + if [ "$DEVELOPMENT" = true ]; then + case "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.version" in + *.development) + echo "Port is in development: '$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE'" + continue + ;; + esac + fi + if [ -e "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE" ]; then + echo "Removing '$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE'" + fi + rm -rf "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE" + rm -rf "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.upstream" + rm -f "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.version" + rm -f "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.version.new" + fi + if [ -e "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.version" -o \ + -e "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.version.new" ]; then + SOURCE_PORT=$(tix-vars -d '' $SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.port \ + SOURCE_PORT) + if [ -z "$SOURCE_PORT" ] || + [ -e "$SORTIX_PORTS_DIR/$SOURCE_PORT/$SOURCE_PORT" ]; then + tix-build \ + --sysroot="/" \ + --prefix= \ + --destination="/" \ + --start=clean \ + --end=clean \ + ${SOURCE_PORT:+--source-port "$SORTIX_PORTS_DIR/$SOURCE_PORT/$SOURCE_PORT"} \ + "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE" + fi + fi done diff --git a/build-aux/iso-grub-cfg.sh b/build-aux/iso-grub-cfg.sh index 27ce507a..851b4ea3 100755 --- a/build-aux/iso-grub-cfg.sh +++ b/build-aux/iso-grub-cfg.sh @@ -115,7 +115,9 @@ live_initrd=$(maybe_compressed boot/live.initrd) overlay_initrd=$(maybe_compressed boot/overlay.initrd) src_initrd=$(maybe_compressed boot/src.initrd) system_initrd=$(maybe_compressed boot/system.initrd) -ports=$(ls repository | sed 's/\.tix\.tar\.xz//') +ports=$(ls repository | + grep -E '\.tix\.tar\.xz$' | + sed -E 's/\.tix\.tar\.xz$//') mkdir -p boot/grub exec > boot/grub/grub.cfg diff --git a/build-aux/iso-repository.sh b/build-aux/iso-repository.sh index 1f207a4c..691e4dd8 100755 --- a/build-aux/iso-repository.sh +++ b/build-aux/iso-repository.sh @@ -1,4 +1,5 @@ -#!/bin/sh -e +#!/bin/sh +set -e # Detect if the environment isn't set up properly. if [ -z "$HOST" ]; then @@ -17,12 +18,11 @@ if ! [ -d "$SORTIX_REPOSITORY_DIR" ]; then exit 0 fi +PACKAGES="$("$(dirname -- "$0")"/list-packages.sh PACKAGES)" + mkdir -p "$1" -if [ -z "${PACKAGES+x}" ]; then - cp -RT "$SORTIX_REPOSITORY_DIR" "$1" -else - for PACKAGE in $PACKAGES; do - cp "$SORTIX_REPOSITORY_DIR/$PACKAGE.tix.tar.xz" "$1" - done -fi +for PACKAGE in $PACKAGES; do + cp "$SORTIX_REPOSITORY_DIR/$PACKAGE.tix.tar.xz" "$1" + cp "$SORTIX_REPOSITORY_DIR/$PACKAGE.version" "$1" +done diff --git a/build-aux/list-packages.sh b/build-aux/list-packages.sh new file mode 100755 index 00000000..145a6d1f --- /dev/null +++ b/build-aux/list-packages.sh @@ -0,0 +1,108 @@ +#!/bin/sh +set -e + +if [ -z "$SORTIX_PORTS_DIR" ]; then + SORTIX_PORTS_DIR="$(dirname -- "$0")/../ports" +fi + +# Load the ports sets. +. "$(dirname -- "$0")/ports.conf" + +get_all_packages() {( + for package in $(ls "$SORTIX_PORTS_DIR"); do + if [ -f "$SORTIX_PORTS_DIR/$package/$package.port" ]; then + echo $package + fi + done +)} + +get_package_dependencies_raw() {( + if [ -f "$SORTIX_PORTS_DIR/$1/$1.port" ]; then + tix-vars -d '' "$SORTIX_PORTS_DIR/$1/$1.port" BUILD_LIBRARIES + elif [ "$1" = "all" ]; then + get_all_packages + else + for set in $sets; do + if [ $set = $1 ]; then + echo $(eval echo \$set_$set) + fi + done + fi +)} + +# TODO: This algorithm scales extremely poorly. +get_package_dependencies_recursive() {( + for dependency in $(get_package_dependencies_raw $1); do + want=false + if [ "$2" = "!!" ]; then + want=true + else + case "$dependency" in + *"?") ;; + *) want=true ;; + esac + fi + if $want; then + dependency=$(echo "$dependency" | tr -d '?') + # Optional dependencies might not exist yet. + if [ -f "$SORTIX_PORTS_DIR/$dependency/$dependency.port" ]; then + echo "$dependency" + get_package_dependencies_recursive "$dependency" "$2" + fi + fi + done +)} + +list_dependencies() {( + package="$1" + for dependency in $(get_package_dependencies_raw "$package"); do + if [ "$dependency" != "${dependency%\?}" ]; then + dependency="${dependency%\?}" + for candidate in $PACKAGES; do + if [ "$candidate" = "$dependency" ]; then + echo "$dependency" + break + fi + done + else + echo "$dependency" + fi + done +)} + +list_package() {( + package="$1" + # Fast path for listing all packages. + if [ "$package" = "all!" -o "$package" = "all!!" ]; then + get_all_packages + exit + fi + recursion=$(echo "$package" | grep -Eo '!*$') + package=$(echo "$package" | grep -Eo '^[^!]*') + # TODO: Better way of detecting if a port is a set. + if [ -f "$SORTIX_PORTS_DIR/$package/$package.port" ]; then + echo "$package" + fi + if [ -n "$recursion" ]; then + get_package_dependencies_recursive "$package" "$recursion" + fi +)} + +if [ "$1" = "--dependencies" ]; then + shift + PACKAGES=$("$0" PACKAGES) + for package; do + list_dependencies "$package" + done | sort -u + exit +fi + +for package; do + if [ "$package" = PACKAGES ]; then + for package in ${PACKAGES-all!}; do + list_package "$package" + done + else + list_package "$1" + fi +done | sort -u diff --git a/build-aux/upgrade-port.sh b/build-aux/upgrade-port.sh new file mode 100755 index 00000000..ce6866f6 --- /dev/null +++ b/build-aux/upgrade-port.sh @@ -0,0 +1,103 @@ +#!/bin/sh +set -e + +NAME=$(tix-vars -d '' "$1" NAME) +COMPRESSION=$(tix-vars -d '' "$1" COMPRESSION) +DISTNAME_REGEX=$(tix-vars -d '' "$1" DISTNAME_REGEX) +RELEASE_SEARCH_PAGE=$(tix-vars -d '' "$1" RELEASE_SEARCH_PAGE) +RELEASE_SEARCH_REGEX=$(tix-vars -d '' "$1" RELEASE_SEARCH_REGEX) +UPSTREAM_ARCHIVE=$(tix-vars -d '' "$1" UPSTREAM_ARCHIVE) +UPSTREAM_SITE=$(tix-vars -d '' "$1" UPSTREAM_SITE) +VERSION=$(tix-vars -d '' "$1" VERSION) +VERSION_REGEX=$(tix-vars -d '' "$1" VERSION_REGEX) + +if [ -z "$UPSTREAM_ARCHIVE" ]; then exit; fi + +escape_regex() { + echo "$1" | sed -E 's,[\\+*?.{}<>],\\\0,g' +} + +TAR_REGEX="(\.tar(\.(gz|bz2|xz)))" + +if [ -z "$RELEASE_SEARCH_PAGE" ]; then + case "$UPSTREAM_SITE" in + https://github.com/*/releases/*) + RELEASE_SEARCH_PAGE=$(echo "$UPSTREAM_SITE" | grep -Eo '.*/releases/');; + *) RELEASE_SEARCH_PAGE="$UPSTREAM_SITE/";; + esac +fi + +if [ -z "$VERSION_REGEX" ]; then + VERSION_REGEX="([0-9]+\.[0-9]+(\.[0-9]+)*)" +fi + +if [ -z "$DISTNAME_REGEX" ]; then + DISTNAME_REGEX=$(echo "$UPSTREAM_ARCHIVE" | + sed -E 's,\+,\\+,g' | + sed -E "s,$VERSION_REGEX(\.tar.*),$(escape_regex "$VERSION_REGEX"),") +fi + +if [ -z "$RELEASE_SEARCH_REGEX" ]; then + RELEASE_SEARCH_REGEX="\<$DISTNAME_REGEX$TAR_REGEX\>" +fi + +upgrade_version() { + sed -E -e "s,^(VERSION_MAJOR)=.*,\\1=$(echo "$2" | sed -E 's,([0-9]+)\.([0-9]+)(\.([0-9]+))?.*,\1,')," \ + -e "s,^(VERSION_MINOR)=.*,\\1=$(echo "$2" | sed -E 's,([0-9]+)\.([0-9]+)(\.([0-9]+))?.*,\2,')," \ + -e "s,^(VERSION_PATCH)=.*,\\1=$(echo "$2" | sed -E 's,([0-9]+)\.([0-9]+)(\.([0-9]+))?.*,\4,')," \ + -e "s/^(VERSION)=[^$]*$/\\1=$2/" \ + -e "s/^(COMPRESSION)=.*/\1=$COMPRESSION/" \ + "$1" +} + +instantiate() { + upgrade_version "$1" "$2" | tix-vars - "$3" +} + +LATEST=$(curl -Ls "$RELEASE_SEARCH_PAGE" | grep -Eo "$RELEASE_SEARCH_REGEX" | sort -Vu | tail -1) +case "$LATEST" in +*.tar) COMPRESSION=tar;; +*.tar.gz) COMPRESSION=tar.gz;; +*.tar.bz2) COMPRESSION=tar.bz2;; +*.tar.xz) COMPRESSION=tar.xz;; +esac +NEW_VERSION="$(echo "$LATEST" | sed -E "s,$RELEASE_SEARCH_REGEX,\1,")" + +if [ -t 1 ]; then + RED='\033[91m' + GREEN='\033[92m' + RESET='\033[m' +else + RED='' + GREEN='' + RESET='' +fi + +if [ -z "$NEW_VERSION" ]; then + printf "$RED%s$RESET\n" "$UPSTREAM_ARCHIVE failed to find available versions: $RELEASE_SEARCH_PAGE | grep -E '$RELEASE_SEARCH_REGEX'" + exit 1 +fi + +NEW_UPSTREAM_SITE=$(instantiate "$1" "$NEW_VERSION" "UPSTREAM_SITE") +NEW_UPSTREAM_ARCHIVE=$(instantiate "$1" "$NEW_VERSION" "UPSTREAM_ARCHIVE") + +if ! wget -q "$NEW_UPSTREAM_SITE/$NEW_UPSTREAM_ARCHIVE" -O /dev/null; then + printf "$RED%s$RESET\n" "$NAME failed to download: $NEW_UPSTREAM_SITE/$NEW_UPSTREAM_ARCHIVE" + exit 1 +fi + +if [ "$VERSION" = "$NEW_VERSION" ]; then + echo "$NAME $VERSION is up to date" + exit +fi + +if [ "$2" = upgrade ]; then + if [ "$(tix-vars -d false "$1" DEVELOPMENT)" = true ]; then + echo "$0: warning: Not upgrading $1 in DEVELOPMENT=true mode" >&2 + exit + fi + (upgrade_version "$1" "$NEW_VERSION" && echo DEVELOPMENT=true) > "$1.new" + mv "$1.new" "$1" +fi + +printf "$GREEN%s$RESET\n" "$NAME $VERSION -> $NEW_VERSION $NEW_UPSTREAM_SITE/$NEW_UPSTREAM_ARCHIVE" diff --git a/build-aux/verify-coding-style.sh b/build-aux/verify-coding-style.sh index fd4dd488..7254d671 100755 --- a/build-aux/verify-coding-style.sh +++ b/build-aux/verify-coding-style.sh @@ -93,7 +93,7 @@ verify_source() { # TODO: Some of these patterns should also apply to build-aux, and maybe also # partially to libm. Makefile and kblayout should also not have whitespace # problems. -for MODULE in $(git ls-files | grep / | sed 's,/.*,,' | sort -u | grep -Ev '^(build-aux|doc|etc|libm|share)$'); do +for MODULE in $(git ls-files | grep / | sed 's,/.*,,' | sort -u | grep -Ev '^(build-aux|etc|libm|ports|share)$'); do cd "$MODULE" for FILE in $(git ls-files | grep -Ev '^include/' | grep -Ev '((^|/)(Makefile|\.gitignore|tixbuildinfo)|\.([0-9]|kblayout|f16|rgb))$'); do verify_source "$FILE" diff --git a/doc/.gitignore b/doc/.gitignore deleted file mode 100644 index dcaf7169..00000000 --- a/doc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -index.html diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index 42ef20a4..00000000 --- a/doc/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -include ../build-aux/platform.mak -include ../build-aux/compiler.mak -include ../build-aux/version.mak -include ../build-aux/dirs.mak - -DOCUMENTS:=\ -cross-compilation-sins \ -obsolete-stuff \ -porting-guide \ -posix-divergence \ -welcome \ - -all: $(BINARIES) - -.PHONY: all install clean - -install: all - mkdir -p $(DESTDIR)$(DOCDIR) - cp -t $(DESTDIR)$(DOCDIR) $(DOCUMENTS) - -clean: diff --git a/doc/cross-compilation-sins b/doc/cross-compilation-sins deleted file mode 100644 index 4018a7e8..00000000 --- a/doc/cross-compilation-sins +++ /dev/null @@ -1,268 +0,0 @@ -Cross Compilation Sins -====================== - -Cross-compilation is the act of compiling a program for execution on another -machine that is different from the current machine. The other machine can have -another processor, another operating system, or just another directory structure -with different programs and libraries installed. The important part is that the -cross-compiled program is not meant to be executed on the build machine and -cannot be assumed to execute correctly on the build machine. - -Cross-compilation works in concept simply by substituting the usual compiler -with a special cross-compiler targeting the host machine rather than the build -machine. The development headers and libraries would then already be installed -in the system root used by the cross-compiler. The program will then be built -normally and the result is a binary for the host machine. - -Unfortunately, a lot of software attempt to be too clever for their own good and -rely on assumptions that are not valid in the face of cross-compilation. This is -a list of such sins that software packages occasionally make that prevent proper -cross-compilation. Almost all software ought to cross-compile cleanly. - -Not supporting cross-compilation --------------------------------- - -Programs should use a build system that allows cross-compiler, or be stupid and -just use the specified compiler without violating rules in this document. Build -systems should not hard-code a particular compiler, but use a CC or CXX -environmental variable that possibly default to reasonable values, or using the -full ./configure machinery for detecting the correct compiler. - -Root is the empty prefix ------------------------- - -The build system must treat the empty prefix as distinct from the default prefix -(which is usually /usr/local). A prefix is a string of characters that is added -before the usual installation directories such as /bin and /lib. To install a -program into the /bin directory (in the root filesystem), you need add no -characters in front of /lib. Thus, the empty prefix is the root directory. The -root directory is the prefix of /, as that would install the program into //bin. -Indeed //bin is not only ugly, but it actually has a special alternate meaning -than the root directory on some operating systems. - -Probing root filesystem ------------------------ - -The actual root filesystem of the host machine is not available at build time. -That means that probing system files are out of the question and should be -recoded into a runtime check at program startup. For instance, checking special -directories such as /dev or /proc, or system configuration in /etc, even -manually locating headers in /usr/include and libraries in /usr/lib is not -allowed (when though they would be there in the system root, potentially). - -Instead build systems should view things through the eyes of the cross-compiler -that may use exotic strategies to locate the desired resources (perhaps the -cross-compiler is an executable that wraps the real compiler and adds special --I and --sysroot options, for instance). To check whether a header is available, -the build system should preprocess a file that #includes it. To check whether a -library is available, the build system should try to link an executable against -it. - -This discussion even covers looking at the configured prefix and other -installation directories, even if prefixed with $DESTDIR, except for the purpose -of installing files there. - -Executing cross-compiled programs ---------------------------------- - -It is not possible to run a cross-compiled program when cross-compiling. The -results vary, maybe the program works, maybe the program loads but does -something unexpected, maybe the program loads and enter an infinite loop, maybe -the program loads and crashes, or maybe the program doesn't even load. The -important part is that the build system should not even attempt to execute any -programs it compiles. Some packages use special configure-time tests to compile -test programs to check the behavior of the host machine, such as whether a -standard function works. - -Such tests are fundamentally broken if they require executing the test program; -usually it is sufficient to just check if the program links. This means that -tests about the run-time behavior of programs are not possible on the build -machine. If possible, such tests could be delayed until program startup. - -However, such tests are usually to detect broken systems. If testing is not -possible, then the build system should assume that the system is not broken. It -is often just a single operating system that has such a problem and it may be -fixed in later releases. It is acceptable to inconvenience users of broken -operating systems by asking them to pass an --using-broken-os configure option -or something similar, as long as it doesn't inconvenience honest users of good -operating systems. - -$DESTDIR --------- - -Programs must support the DESTDIR environmental variable at package installation -time. It is an additional temporary prefix that is added to all the installation -directory paths when installing files and directories. It is commonly used for -package management that wishes to stage programs at a temporary location rather -than installing into the final destination immediately. It is also used for -cross-compilation where installation into the local machine's root directory -would be disastrous, where you rather want to use the cross-compilation system -root as DESTDIR. - -It is important to understand that the prefix set at configure time is the -location where the program will end up on the host machine, not the installation -directory on the build machine. The installation directory on the build machine -would be the prefix given at configure time prefixed with DESTDIR being the -system root. - -If packages do not support DESTDIR, it is possible to work-around the issue by -adding the intended DESTDIR to the prefix given at configure time. This works -only as long as the program doesn't remember the prefix or store it in system -configuration files. The better solution is just to patch in $(DESTDIR) support. - -Cross-compiled Build Tools --------------------------- - -Programs often need special-purpose build tools to compile some aspects of them -or associated files or documentation. If such a program is local to the project -and not a stand-alone tool on its own right, then it is not uncommon for the -build system to build first the tool and then use the tool during the build of -the real program. - -This presents a crucial problem for cross-compilation: Two compilers must be in -play. Otherwise, the build system may helpfully use the cross-compiler to -cross-compile the build tool and attempt to execute the cross-compiled build -tool (which is intended to run on the host machine, not the build machine). This -is a common problem that prevents otherwise cross-compilable programs from -being cross-compilable. - -The solution is to detect and use two compilers: The compiler for the build -machine and the compiler for the host machine. This introduces some new -complexity, but autoconf generated ./configure scripts can deal rather easily -with it. There is a problem, though, if the build tool itself has dependencies -on external projects besides the standard library, as that would mean the build -system would need to detect and handle dependencies for both the build and host -machine. I'm not even sure the autoconf configure style --with-foo options are -fine-grained enough to support --with-build-foo and with-host-foo options if -they differ. - -A better solution is perhaps to promote the custom build tool to a general -purpose or at least special purpose tool that is installed along with the -program, while allowing the special purpose tool to be built separately and -just that tool. This allows the user wishing to cross-compile to first build the -custom build tool locally on his configure, install it on the build machine, and -then have the tool in $PATH during the actual cross-compilation of the program. -This way the build system doesn't need to have two compilers in play, but at the -cost of essentially splitting the project into two subprojects: The real program -and the custom build tool. This option is preferable if the custom build tool -can be adapted so it is reusable by other projects. - -You can also change the implementation language of the build tool to an -interpreted language, such as a shell script, python or anything suitable. It -would be prudent to ensure such interpreted languages can also be cross-compiled -cleanly. - -Degrading functionality of program ----------------------------------- - -Programs should not be partially cross-compilable, with optional parts of the -program not available if cross-compiled. In the event that such optional parts -cannot be cross-compiled, it might be because they are violating rules in this -document or an external dependency does. - -Degrading quality of program ----------------------------- - -Programs that are cross-compiled should be as similar as possible to the case -where they are not cross-compiled. However, it is acceptable if there is a -performance loss if the program needs to do run-time checking when a test is not -possible at compile time or other cases where the build system needs to make a -decision and insufficient data is available and both solutions would work -correctly. - -Custom Configure Scripts ------------------------- - -Some perhaps ship with a custom hand-written ./configure script as opposed to a -script generated by tools such as autoconf. It doesn't matter in what language -a configure script is written (as long as it can be correctly executed) or -whether it is generated or hand-written. However, it is important that it -correctly implement the standard semantics customary with GNU autoconf generated -./configure scripts. In particular, for this discussion, it must support the ---build, --host and --target options, as well as all the standard installation -directory options (--prefix, --exec-prefix, ...). It is also important that it -correctly locate a cross-compiler through the --host option by using it as a -cross-tool prefix. For instance, --host=x86_64-sortix must correctly locate -the x86_64-sortix-gcc compiler. - -Remembering the Compiler ------------------------- - -Unusually, some libraries remember the compiler executable and used compiler -options and store them in special foo-config files or even installed system -headers. This must never be done as the cross-compiler is a temporary tool. The -library is meant to be used on the host system, it would be odd if programs -depending on the library attempted to use a cross-compiler when building such -programs on the host machine. It also violates the principle that which compiler -is used is decided by the user, rather than secretly by the package. - -Making cross-compilation needlessly hard ----------------------------------------- - -Some build systems require the user to answer particular questions about the -host machine, while is perfectly capable of automatically answering such -questions about the build machine. This occasionally takes the form of autoconf -generated ./configure scripts requiring the user to set autoconf cache values -that answer runtime tests. The obvious solution is to do runtime tests at -program startup instead or more careful tests that are possible at compile time. - -Other problems include all sorts of miscellaneous situations where the user is -required to jump through hoops to cross-compile a program, when it could have -been much simpler if the build system had followed standard patterns. This is -often a symptom of projects where cross-compilation is considered unusual and -special-purpose, rather than than a natural state of things if you don't assume -particular runtime tests are possible at compile time. - -pkg-config ----------- - -Libraries should install pkg-config files rather than libtool .la files or -foo-config scripts as neither of those approaches support cross-compilation or -system roots, while pkg-config is perfectly aware of such use cases. - -Programs should never look for libtool .la files or use foo-config scripts for -the same reasons. It is too possible that the program ends up finding a tool for -the build machine instead, if the installed foo-config script wasn't in the -user's PATH. Fortunately, the invocation of foo-config scripts and pkg-config -are usually similar enough, so it is simple to adapt a build system to use the -pkg-config variant exclusively instead. - -The user can build a special cross-pkg-config or wrap an existing pkg-config by -setting special environmental variables. There are some caveats if the program -builds custom build tools that needs dependencies detected through pkg-config. -In that case, the user may need to have a special pkg-config with a tool prefix -or pass a configure option setting the name of the build machine pkg-config -script. - -libtool .la files ------------------ - -Libraries managed with libtool often install special .la files into the -configured libdir. These files contain information on how to link against the -library and what compiler options to use. Unfortunately they don't support -cross-compilation and system roots. As such, too easily the compile process will -begin attempting to link against files relative to the root directory on the -build machine. - -The recommendation is to kill such files on sight and to never generate them in -the first place, and certainly to never install them into the system root. It is -usually safe to delete such files, especially if the library installs pkg-config -files or if you install into well-known system directories. - -foo-config ----------- - -Libraries occasionally install special foo-config scripts into the configured -bindir. These files are executable shell scripts that output the compiler -options that should be used to link against the library. Unfortunately they -don't support cross-compilation and system roots. As such, too easily the -compile process will begin attempting to link against files relative to the root -directory on the build machine. - -The recommendation is to kill such files on sight and to never generate them in -the first place, and certainly to never install them into the system root. It is -usually safe to delete such files, especially if the library installs pkg-config -files or if you install into well-known system directories. Watch out for -programs linking against the library that wrongly locate foo-config scripts in -your $PATH (which potentially come from your distribution). Such programs needs -to be patched to use pkg-config instead. diff --git a/doc/obsolete-stuff b/doc/obsolete-stuff deleted file mode 100644 index 6cbaa8a9..00000000 --- a/doc/obsolete-stuff +++ /dev/null @@ -1,342 +0,0 @@ -Obsolete Stuff -============== - -One of the primary design goals of Sortix is to be a modern Unix system with the -old cruft removed. This means that some features/functions/headers in the C API -has been removed, never implemented in the first place, or is scheduled for -future removal. This is likely inconvenient, as a lot of programs still rely on -these obsolete/broken features, which will have to be fixed. Additionally, it'll -further complicate porting programs to Sortix. However, it is our belief that -ultimately such removals will be beneficial and this is merely a transitional -period. In almost all cases, we have made available superior interfaces that can -be used instead. - -It may cause problems for portable programs that these features cannot or should -not be used, as lesser operating systems may not implement the modern -replacements. Either fix such systems or add some feature detection magic. - -This is a list of common features that may currently be implemented, but that -you shouldn't use and if you do, then you should fix your program before it -breaks when the feature is finally removed. - -You might be tempted to use a preprocessor conditional for __sortix__ to detect -the absence of these obsolete features and the availability of their modern -replacements. Keep in mind that other systems may have the modern replacements -and also may have removed features, and that they may supply other extensions to -replace the features. If you need to be portable, you should use whatever means -to automatically detect the availability of features at compile time, rather -than hardcode cases for each platform, as your software is likely to be ported -to platforms that didn't exist when you wrote your code. - -asctime, asctime_r ------------------- - -This function is fundamentally broken. It doesn't support locales, it adds some -useless newline character at the end, the date format doesn't comply with ISO -standards, asctime is not thread safe, and so on. Actually, the POSIX standard -supplies code that implements the function because the format simply cannot -change. The function was actually already deprecated back in 1989 when the -original C standard was released. The solution is today the same as back then, -simply use the much superior strftime function instead. asctime_r tries to make -the function thread safe, but it doesn't fix the other broken semantics. The -only use of this function is to participate in protocols that somehow manages to -use asctime formatted dates, but then you might as well just paste in the POSIX -example code and hard code it in your program. - -Sortix currently implement these functions for compatibility reasons. - -creat ------ - -Use open() instead of this poorly named function. Additionally, open() has a -similarly poorly named flag O_CREAT that does what you need. - -Sortix currently implement this function for compatibility reasons. - -clock ------ - -The clock() function suffers from overflow issues where it wraps around and the -caller has to handle that, meaning it's not suitable for measuring long -intervals. Converting a clock interval to seconds it also bothersome and -requires division by CLOCKS_PER_SEC. - -You should use clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) instead as it has no -overflow issues, provides nanosecond precision if available, and can be combined -with APIs such as Sortix's for convenient computing. - -Sortix currently implements this function for compatibility reasons. - -ctime, ctime_r --------------- - -These functions are defined in terms of asctime and asctime_r. Therefore they -will need to be removed as well. - -Sortix currently implement these functions for compatibility reasons. - -F_GETLK, F_SETLK, F_SETLKW --------------------------- - -These fcntl commands implement POSIX advisory file locking. Unfortunately, this -standard interface is very poorly designed. In particular, if a process closes -a file descriptor, then all locks the process has for that file is unlocked, -even though there might not be a lock associated with that file descriptor in -the first place. This means that if the main program locks /foo/bar and runs -a library routine that also happen to open /foo/bar, then the advisory lock set -up by the main program is silently gone when when the library routine closes the -file and returns to the main program. Additionally, the locks are attached to -processes, rather than file descriptors. This complicates using them for threads -and passing file locks onto child processes. - -Use the flock (not to be confused with lockf) call instead as it works at a file -descriptor level. - -ftime ------ - -Use clock_gettime instead. - -gethostbyname, gethostbyaddr ----------------------------- - -Use the protocol agnostic functions such as getaddrinfo(). For instance, if you -want a HTTP connection to www.example.com, do you really care how the data get -to and from there? Most of the time you want a reliable transport protocol to a -named host, but don't care much about the low-level details. If you use these -modern networking interfaces, then your program can use without modification -IPv4, IPv6, or whatever new protocol is used in the future. - -gethostid, sethostid --------------------- - -These functions are built on the assumption that 32-bits are enough such that -each computer has an unique identity. It isn't. These functions are usually -implemented by using the IPv4 address, which already creates conflicts because -multiple systems can have the same LAN address. The functions are silly and any -use of them probably is silly too. - -getpgrp -------- - -POSIX and BSD disagree on the function prototype for getpgrp. Use getpgid -instead, as everyone agrees on that. - -gets ----- - -Use fgets or getline instead. This function has been removed in the latest C -standard, but most implementations carry it anyways. Curiously it is hated so -much that some compatibility libraries such as gnulib actively use magic to add -deprecation warnings not to use it, but these won't compile because gets isn't -declared in any Sortix headers. - -gettimeofday ------------- - -Use clock_gettime instead. - -getwd ------ - -Use get_current_dir_name() or getcwd() instead. Don't rely on the existence of -PATH_MAX, but allocate buffers as needed. - -isascii -------- - -This function is rather pointless. If we use a character encoding that wasn't -ascii compatible, then it doesn't make sense. If we use a sane character -encoding such as UTF-8, then you can simply check if the value is at most 127. - -inet_addr ---------- - -This function only supports IPv4 and it supports a variety of weird ways to type -IPv4 addresses. Use inet_pton instead, which supports other address families as -well and only support standard address notations. - -inet_ntoa ---------- - -This function only supports IPv4 and it isn't thread safe. Use inet_ntop instead -which is thread safe and supports other address families. - -lockf ------ - -This function implements POSIX advisory locks. It suffers from the same basic -design mistakes that the fnctl advisory lock commands (F_GETLK, F_SETLK, -F_SETLKW) do and should be avoided for the same reasons (see above). - -Use the flock (not to be confused with lockf) call instead as it works at a file -descriptor level. - -mktemp ------- - -mktemp(3) (not the mktemp(1) utility) creates a unique path name, but creates no -file, and thus offers no guarantee that is unique with respect to other threads -and system processes. The function is racy and dangerous. - -Use mkstemp(3) (or for directories mkdtemp(3)) instead. - -PATH_MAX --------- - -There is no such limit in Sortix. The kernel might restrict the path lengths at -some point, but that'll just be to protect against misbehaving processes. You -can use pathconf() or fpathconf() to see if a particular path has a limit, but -otherwise you should just allocate strings as much as needed. There should be -functions in place so you can use paths of any length. If you really need a -limit as a hack to fix a broken program, you can do something like: - - #if !defined(PATH_MAX) && defined(__sortix__) - #define PATH_MAX 32768 - #endif - -If there is ever going to be a path limit, it'll probably be either this value -or higher. Ideally, your programs ought to work with paths of any reasonable -length. - -putenv ------- - -This is a poorly designed interface for manipulating the environment which -interacts quite badly with interfaces such as setenv and unsetenv. The major -problem is that putenv makes the input string itself part of the environment, -but setenv makes a copy of the input string part of the environment. This means -that unsetenv (as well as putenv and setenv when changing an existing variable) -has to somehow know whether the a given entry in environ was allocated by setenv -and whether to free it. This isn't helped by the fact that the environ symbol -is publicly accessible and callers of putenv can change the environment by -editing the string the caller inserted. This means that the implementations of -setenv and unsetenv must do a considerable amount of book-keeping behind the -scenes to figure out whether a string was allocated by setenv or face memory -leaks when environment variables are changed or unset. The solution to get rid -of all the needless complexity putenv forces upon the other functions is simply: -Don't provide putenv in the first place and fix any software that uses putenv to -just call setenv instead. - -sdl-config ----------- - -This SDL utility program is basically broken for cross-compilation and seems to -be a poor counterpart to to pkg-config. If you insist on using such config -tools, use pkg-config instead as it causes fewer problems. If you really need a -sdl-config script, implement it using pkg-config: - - pkg-config "$@" sdl - -The Sortix build system actually injects such a sdl-config into the PATH to make -sure programs don't use the wrong SDL libraries when cross-compiling. - -setpgrp -------- - -POSIX and BSD disagree on the function prototype for setpgrp. Use setpgid -instead, as everyone agrees on that. - -settimeofday ------------- - -Use clock_settime instead. - -select ------- - -The fd_set system is poorly designed and the FD_SETSIZE is considerably smaller -than INT_MIN on most systems, which violates that the value of the file -descriptor shouldn't matter as long as it is between 0 and INT_MAX. It would be -better to use poll instead. There is also the problem that select uses struct -timeval instead of the superior struct timespec, though pselect solves that -particular problem. - -Sortix currently provides this function for compatibility reasons. - -sprintf -------- - -The sprintf function is dangerous as it can be hard to predict the length of the -output string safely. A mistake can easily end in security vulnerabilities and -undefined behavior. Use the snprintf function instead as it knows the size of -the destination buffer and safely truncates in the error case. Such truncation -can be detected by the caller. Use the asprintf function or another approach -if determining the output length is hard. - -Sortix currently provides this function for compatibility reasons. - -strings.h ---------- - -There must have been some confusion back in the day since this header was -created, rather than the functions just added to string.h. In sane -implementations, you can just include string.h that also declares these -functions. The strings.h header exists in Sortix for source-code compatibility, -but don't be surprised if it just includes the regular string.h. - -struct timeval --------------- - -This microsecond precision data structure has been fully replaced by struct -timespec, which offers nanosecond precision. All kernel APIs use struct timespec -exclusively. - -Sortix currently provides this structure for compatibility reasons. - -sys/param.h ------------ - -This is a BSD header that contains a bunch of BSD-specific stuff and other -miscellaneous junk. The GNU libc implementation contains some useless macros -that doesn't justify its existence. The header inclusion can often be deleted -without any problems, but older systems may require its inclusion. - -sys/time.h ----------- - -You don't need this header and it'll be removed at some point. It is filled with -obsolete functions and macros. The only reason you might want it is to get the -declaration of struct timeval, but that data type has been replaced by struct -timespec. - -Sortix currently provides this header for compatibility reasons. - -sys/timeb.h ------------ - -This is a header that contains the ftime function that has been replaced, this -header has been removed as well. - -times ------ - -This function is badly designed and the whole clock_t and sysconf(_SC_CLK_TCK) -business is insane. It doesn't help there is problem with potential overflowing -and the accuracy of the function varies between systems. You should avoid this -function in favor of clock_gettime and the Sortix extension clocks that provide -the same information as struct timespec. If you need the atomic semantics of -times, you can use the Sortix extension timens. - -Sortix currently provides this function for compatibility reasons. - -tmpnam ------- - -There is an inherently race condition prone and has thread safely issues with a -NULL argument. Use tmpfile() instead if you can do with a file whose name you do -not know. Unfortunately, Sortix has yet no satisfying temporary file creation -function that gives you a file and its name without having to deal with silly -template strings and other problems. - -utime ------ - -Use utimens instead, or perhaps the more portable utimensat. - -Sortix currently provides this function for compatibility reasons. - -utimes ------- - -Use utimens instead, or perhaps the more portable utimensat. diff --git a/doc/portability-sins b/doc/portability-sins deleted file mode 100644 index 9a982967..00000000 --- a/doc/portability-sins +++ /dev/null @@ -1,85 +0,0 @@ -Portability Sins -================ - -Sortix makes use of third-party software. In many cases porting software and -integrating it into the Sortix ports is a fairly smooth ride. Unfortunately, -this is not always the case if the package is flawed. Such mistakes are usually -not intentional, but are simply accidents, rarely tested code cases or simply -the upstream being unaware of portability issues. We should identify such issues -and report them to the upstream projects. - -This is a list of common problems that cause problems when integrating packages -into the Sortix ports build system. Almost all the issues listed here will tend -to get patched in Sortix as we want good ports, not fragile ports that we would -need all sorts of tricks to work around. - -TODO: Potentially merge with cross-compilation-sins as a package-sins guide. - -Cross-compilation issues ------------------------- - -See doc/cross-compilation-sins as well. - -Don't be different for the sake of it -------------------------------------- - -Pay respect to the traditions unless you are strictly better. - -distclean is what goes into a release -------------------------------------- - -When finishing it's useful to be able to reset the source tree to the state that -you got it in (i.e. no temporary build files left behind) so you can easily diff -it against the upstream tarball. Packages usually have a makefile target called -distclean that cleans the source directory for distribution, ideal for such -purposes. However, in some packages the distclean target doesn't actually do -that: It occasionally deletes files present in the upstream tarball while -leaving other files behind that wasn't in the upstream tarball. This is pretty -annoying. It makes the Sortix patches for a port harder to read as they are -filled with noise (generated XML files are fun), unless manual care is taken. - -The ideal is that you can extract a tarball and run configure, make and finally -make distclean. The source directory should then be equal to what is in the -tarball. Otherwise the actual distribution wasn't actually distribution-clean. - -Fun examples: Deleting the configure script upon distclean, deleting the license -files upon distclean, calling the target dist-clean instead of distclean. - -DESTDIR comes from the environment ----------------------------------- - -It comes from the environment. - -Use setenv instead of putenv ----------------------------- - -Use the system malloc - -Print system types in a portable manner ---------------------------------------- - -Use the proper casts and large types or Sortix extensions. - -64-bit and JIT --------------- - -Don't assume that mmap() always returns below 4 GiB and that the distance -between any two memory mappings are always less than 2 GiB. There are no such -guarantees on 64-bit systems, yet many just-in-time virtual machines assumes -this is true and truncate pointers if it is not (leading to obscure crashes). - -Don't use seemingly-unused bits in types ----------------------------------------- - -For instance, on x86-64 the address space is currently actually only 48-bit -and the most significant 16-bits must always equal the 47th bit. Some see this -as 16-bit perfectly usable bits for their own purposes. Don't do this, it's -crazy and you know it. This often comes up in more subtle cases such as telldir -that returns an opaque value that might have any bits set, but usually doesn't, -which looks like bits that can be re-purposed. That is, until the system changes -a bit and the package explodes. - -Don't do crazy stuff --------------------- - -Just don't. diff --git a/doc/porting-guide b/doc/porting-guide deleted file mode 100644 index adfc4819..00000000 --- a/doc/porting-guide +++ /dev/null @@ -1,480 +0,0 @@ -Porting Guide -============= - -This guide documents how to port software to the Sortix operating system and how -to release your port to the Sortix community. Before you get started, you should -get the system source code and the current core set of existing ports and be -comfortable with building the system (with ports) entirely from scratch. - -Overview --------- - -### `$SORTIX_TOPLEVEL` ### - -This is the top-level source directory containing the system source code. This -is actually not a real environmental variable, but just something used in this -document to denote the top-level system source code directory. This is where you -have cloned the Sortix source repository. - -### Source Tix ### - -A source tix is simply a directory, whose name is the name of a package, and -which contains the source code for the package and a special `tixbuildinfo` -file, which contains instructions for building the source tix into a binary tix. - -### `$SORTIX_PORTS_DIR` (default `$SORTIX_TOPLEVEL/ports`) ### - -This directory is where the build system will search for source tixes that -will automatically be built along with the rest of the system. Any other files -and sub-directories will be ignored. You can use symbolic links to source tixes -if you wish. You integrate new packages into the build simply by simply putting -the source tix inside this directory as a sub-directory. It will automatically -be built along with the rest of the system during the next system build. - -### `.srctix.tar.xz` (Archived Source Tix) ### - -Since you cannot publish raw directories, published source tixes are put into -a compressed archive and given the extension `.srctix.tar.xz`. You can easily -install an archived source tix by extracting it using standard tools: - - cd $SORTIX_PORTS_DIR && - tar --extract --file libfoo.srctix.tar.xz - -This will install the source tix into the source repository and it will -automatically be built the next time you compile the system and ports. - -The archived source tix is simply a tarball that contains a single directory, -which is a source tix as described above. - -### `.porttix.tar.xz` (Archived Port Tix) ### - -Upstream releases of software cannot be expected to contain a `tixbuildinfo` -file and sometimes they need to be patched. When maintaining a port, it is often -useful to have a copy of the upstream release and the patches applied to it. -The `.porttix.tar.xz` archives contain a copy of the upstream release (as a -compressed archive) and all the patches applied to it. This can automatically be -converted into an archived source tix using the `srctix-create` program. Users -will normally not use this format unless they wish to inspect how a package was -ported or confirm that no malicious alternations were made to the upstream -release. - -Can the package be ported? --------------------------- - -It's a very good idea to examine the package closely before attempting to port -it, or you might end up wasting a lot of time on something that isn't even -possible in the first place. There's a number of red flags that can prevent the -successful porting of a package, at least not without enhancements to the tix -package management system or to Sortix itself. - -The first thing to verify is whether we want such a package on Sortix. Not all -packages are good, some have bad licenses, some have security problems, or bad -code quality -- and so on. Perhaps there is a similar package already ported, -which is technically superior, and it's better to have just one such package on -the system for the sake of purity. Perhaps it's just better to leave this -package behind and focus on the pure Sortix future? Does the philosophy of the -package developers contradict that of the Sortix project? - -The second thing to verify is the build system. If it uses GNU autoconf or a -compatible ./configure script things are looking good. If the package has a -custom hand-written ./configure script you will likely have trouble, as the -authors of these tend to be ignorant about many useful ./configure options and -likely don't properly support-cross-compilation. If the package uses some exotic -build system, you might need to write wrapper scripts or teach Tix how to deal -with such build systems. If the package just has a makefile, you will likely run -into trouble if it doesn't follow good makefile conventions and you might end up -heavily patching it or rolling your own makefile. In these bad cases, consider -whether we even want to port such a package to Sortix. - -The third thing to check is whether it cross-compiles. A lot of software have -considerable problems with this, and while we are able to work around some of -these problems, sometimes it's just not feasible. It's probably worth searching -around the net to see if other people have cross-compiled it. Perhaps they ran -into similar problems - as you are about to have - but have a fix? - -The fourth thing to verify is whether Sortix is ready. Perhaps it uses some API -that Sortix doesn't have yet or depend on kernel features that are missing? -Perhaps the package has dependencies that are not yet satisfies, because nobody -has ported all the dependencies yet. You can often check guides such as "Beyond -Linux from Scratch" which contains a lot of building instructions and -dependency information. Try ask around in the operating system development -community if anyone has ported it before and what their experience was. - -Authoring a Source Tix ----------------------- - -The first step in porting software to Sortix is creating a working source tix -and building it along with the rest of the system. You will need to get a copy -of the software you wish to install. You will need to save a copy of this -original compressed archive in a safe place, as you will need it later when you -create an archived port tix for publishing. - -In this example we will pretend to port a fictitious piece of software called -`libfoo`. The latest release of libfoo is released as a compressed tarball with -the filename `libfoo-0.42.tar.xz`. You will save a copy of this original tarball -in a safe location and then proceed to extract it into the `$SORTIX_PORTS_DIR` -directory. This will usually create a `libfoo-0.42` sub-directory, but you need -to rename it to simply `libfoo`. - -The next step is to author a `libfoo/tixbuildinfo` file, if libfoo does not ship -with support for Sortix. You will need to examine the package and deduce what -it's build system is and write the file accordingly. As a minimum, you will need -to put this in the file (with no leading spaces): - - tix.version=1 - tix.class=srctix - pkg.name=libfoo - pkg.build-libraries=libbar libbaz libqux - -This is a simple key-value format. You will need to set the `pkg.name` variable -to the exact name of the source tix. The `pkg.build-libraries` variable contains -the build-time dependencies of the package as a space-delimited set. This is the -common key-values that all `tixbuildinfo` files *must* contain. In addition, -they must also contain the `pkg.build-system` variable. - -GNU configure scripts ---------------------- - -The Tix package management system is designed such that it is normally easy to -port a package using autoconf generated `./configure` scripts (or compatible). -In the best case, it will simply suffice to write: - - pkg.build-system=configure - -### config.sub ### - -Most packages contain a copy of the config.sub shell script that recognizes the -platform triplets. While Sortix has been added to the upstream config.sub, some -packages still use an obsolete copy without it. In such cases we will need to -add it ourselves. You can simply search the line that contains the `-aos*` -operating system entry and append `-sortix*` to it: - - - | -aos* | -aros* \ - + | -aos* | -aros* | -sortix* \ - -If you don't do this, you will receive mysterious errors about that the package -doesn't know what Sortix is. - -### Passing options and variables to configure and make ### - -However, some packages are known to be silly and requires further tricks to be -ported. Fortunately, the `tixbuildinfo` file provides control of what arguments -and environmental variables are given to `./configure` and to make: - - pkg.configure.args=--enable-bar --without-x - pkg.configure.vars=gt_cv_locale_fr=false gt_cv_locale_ja=false - pkg.make.vars=V=1 - -It is generally recommended to set V=1 when running Make, if the package is -silly and doesn't actually report the exact executed commands to the terminal -during the compilation. This often happens with packages that use libtool. The -exact used commands are valuable for debugging purposes, if you run into a -compile warning or a compile error. - -### Building Out-Of-Directory ### - -If the package requires being built outside of the main source directory, you -can easily enable this behaviour: - - pkg.configure.use-build-directory=true - -### Changing Make Targets ### - -By default the make command will be run twice as `make all` and `make install`. -However, in some cases you would want to customize which targets are invoked: - - pkg.make.build-target=all-libfoo - pkg.make.install-target=install-libfoo - -### Post-Install Command ### - -After the make install target has been run, you have the option of running a -custom command, with the working directory being the temporary staging -directory, before the package is fully packaged up. If you need to run multiple -commands at this point, you will need to wrap them in a shell script: - - pkg.post-install.cmd=./srctix-post-install.sh - -### `.la` files ### - -Packages that use libtool have a nasty habit of installing `.la` files into the -system library directory. However, this format doesn't properly support -cross-compilation and have a number of other problems. The better choice is -simply to eradicate such files using a post build command: - - pkg.post-install.cmd=tix-eradicate-libtool-la - -You should check whether your port produces such `.la` files and use this post -build command if you see any. - -### `--with-sysroot`, `--with-build-sysroot` ### - -If the package supports the --with-sysroot configure option and it works -correctly for cross-compilation, then you can take advantage of it: - - pkg.configure.with-sysroot=true - -Otherwise the build system will simply communicate the correct system root to -the compiler through hidden environmental variables and other tricks (such as -the cross-compiler's default system root). If the package supports also the ---with-build-sysroot to support having one system-root at runtime and another -at build-time, then you should enable both options: - - pkg.configure.with-sysroot=true - pkg.configure.with-build-sysroot=true - -If you are in doubt whether this works, simply disable these options (they are -disabled by default) and the default system-root tricks will do just fine. - -### Wrapping configure and make ### - -If you are unlucky, the configure script is custom and doesn't support common -options or have other flaws. In that case you best yell a lot at the developers -and question whether we want to port such a package in the first place, if the -developers can't get the build system right. However, you can often work-around -such problems by wrapping the configure and make commands in custom shell -scripts: - - pkg.configure.cmd=./srctix-configure.sh - pkg.make.cmd=./srctix-make.sh - -You'll need to set the executable bit on these files and these scripts should -emulate the standard configure and make tools and do whatever magic to work -around the broken build system. This should be considered the last resort - you -should check if there are other key-values you can set that works around the -issue or whether patching the software solves the issue. - -### CC, CXX ### - -If the package somehow fails to detect the correct compiler from the `--build`, -`--host`, and `--target` configure options, but it honours the CC and CXX -environmental variables, then you can set these keys and they will be set: - - pkg.make.needed-vars.CC=true - pkg.make.needed-vars.CXX=true - -### DESTDIR ### - -During the install phase, the DESTDIR environmental variable points to a -temporary staging directory, which the port *must* use as an additional prefix. -If the package does not honour this, please yell a lot at the developers and -question whether we want to port such a package in the first place. You can -possibly work around this by wrapping make and configure. - -### make distclean ### - -The source tix will automatically be cleaned whenever it is built. If you are -using the configure build system, then the `make distclean` target will be used. -There currently is no way to override this, but you can wrap the make command to -work-around this or add support to `tix-build` for configuration. - -Simple Makefile ---------------- - -Tix can use a conventional Makefile with a default target and an install target. - - pkg.build-system=makefile - -The appropriate variables such as CC, CFLAGS, PREFIX, DESTDIR and such will be -set and must be honored from the environment. - -Testing the Port ----------------- - -You can now proceed to attempt to compile your port. The simplest solution is -simply to rebuild the system along with all its ports, as usual. Keep in mind -that you will likely run into compile warnings or errors. It might be useful -to pass the `-O` or '--output-sync` option to Make to ensure the output is -consistent, even in the face of parallel execution - if you are using the -j -make option. - -If everything goes well, congratulations, you just ported a piece of software to -Sortix. You should test it out and see if it works as expected and whether the -port can be improved -- be sure to follow the rest of the guide and publish it -to the Sortix community. - -If things didn't work, it's time to troubleshoot and examine whether the port is -actually possible and what modifications will have to be made, as described in -the next section. - -Porting the Software --------------------- - -Alright, so things didn't work in the first try. Tough luck. A lot of packages -do the same silly things that makes it harder to port them. You'll have to be -creative to determine the correct strategy for completing the port, sometimes -you will have to implement features in Sortix or add some compatibility. Other -times, you can work around the build system or patch the software. - -Try ask around and examine other archived port tixes and see their patches -reveal any useful advice on how to resolve the situation: - -Here is a list of common problems: - -### Configure fails ### - -Try and examine the config.log file inside the build directory. At the bottom, -there is a dump of environmental variables, but just above it is information -about what particular test program failed. - -If you examine the ./configure script closely, you will find that most checks -have an associated cache environmental variable. If a particular check fails -erroneously or isn't cross-compilation compatible, you can work around this -issue by modifying the `tixbuildinfo` file such that it declares these -environmental variables. - -### Running cross-compiled programs ### - -Some packages are silly and think they are always able to execute compiled test -programs, but this is inherently untrue for cross-compilation. Fortunately most -packages know better as cross-compilation is somewhat common. Still -- some -packages still do this, sometimes even as part of the check whether the compiler -works. The result is often that the process hangs, as Sortix executables are -Linux speak for "just hang and do nothing" in many cases. You'll have to fix the -package or somehow work around the problem. Don't forget to yell at the -developers of the package and question whether we really want it. - -### Broken Locale Check ### - -Some packages (like GNU tar) suffers from a defect where they scan for many -locales by running cross-compiled programs (see above). This can be worked -around by declaring the appropriate cache variables. - -### Gnulib ### - -Yuck! There's a lot of dirty hacks here and everybody has partial copies of it -integrated into the build system, but people rarely update such copies. As such, -it'll continue to be a pain to repeatedly work around. You should really check -existing ports and see if their patches solve this particular gnulib problem. -The problems here are often nasty, as gnulib occasionally wants to access libc -internals it has no business dealing with to work-around some obscure bug on -long-forgotten systems. You can probably safely `#if defined(__sortix__)` at the -relevant places where there seem to be no better solution. - -You may even run into gnulib adding a warning to the gets(3) prototype telling -people to never use it. This ironically fails to compile on Sortix, which has no -gets(3) function in the first place. - -### PATH_MAX ### - -Sortix has no such limit and programs shouldn't rely on such a limit existing. -Nonetheless, sometimes it's easier to work-around the problem rather than really -fixing the problem: - - #if defined(__sortix__) && !defined(PATH_MAX) - #define PATH_MAX 32768 - #endif - -### Other problems ### - -There's lots of problems that can arise when porting packages. While Sortix -itself is at fault for many of them, as it is still young and much remains to be -implemented, a lot of problems is the direct result of poor packages with -cross-compilation problems or not adhering strictly enough to standards. It can -be useful to maintain a branch of the main system, which has had a number of -hacks applied for compatibility. Ideally, this allows the Sortix developers to -know what compatibility problems needs to be addressed. Indeed, many features -originally started out as compatibility hacks. - -Be also sure to consult the `obsolete-stuff` document, as it enumerates a list -of problematic APIs that we'd like to remove or refuse to implement - and what -the modern replacement APIs are. - -Publishing the Port -------------------- - -Now that your port works, it's time to publish it and let the community enjoy -your work. - -### Cleaning the Source Directory ### - -Your source tix likely have a lot of left-over temporary files as the result of -the testing phase. We'll need to clean the source directory before proceeding: - - cd $SORTIX_PORTS_DIR/libfoo && - ./configure && - make distclean - -Or perhaps you'll need to do something else. The important thing is that no -object files and other problematic binary files are left behind. If the source -tree is already configured, you can skip the ./configure step. - -### Creating the Normalized Tree ### - -Unfortunately, some upstream releases are not actually distcleaned. This is a -problem because the diff between the upstream release and your port will contain -a lot of garbage. We'll then proceed to create a normalized tree that you can -diff cleanly against. - - cd $SORTIX_PORTS_DIR && - tar --extract --file $THAT_SAFE_LOCATION/libfoo-0.42.tar.xz && - mv libfoo-0.42 libfoo.normalized & - (cd libfoo.original && ./configure && colormake distclean) - -This should hopefully ensure that the two trees should be identical, except the -few changes you had to make to port the package. Be mindful if the upstream -developers are silly and don't put a single directory in their tarballs. You can -then proceed to analyse the difference between the two trees: - - diff -Naur libfoo.normalized libfoo - -If everything went well, you should only see your changes. If there are other -changes, you should resolve the situation by deleting files from the normalized -tree, or by copying files from the normalized tree into the patched tree. Be -mindful that diff(1) and patch(1) doesn't preserve the executable bit. Don't put -a `tixbuildinfo` into the normalized tree, or it might unexpectedly become a -source tix. - -### Creating the Archived Port Tix ### - -The next step is to create the archived port tix, which contains the upstream -tarball and the patches done to it (including the normalization step). This file -allows others to easily review your port and ensure you have not made any -malicious changes. It will also allow others to recreate the normalized tree -and continue further development of the port. To create the archived port tix, -you simply have to invoke this command: - - cd $SORTIX_PORTS_DIR && - porttix-create --tarball $THAT_SAFE_LOCATION/libfoo-0.42.tar.xz \ - --normalized libfoo.normalized \ - libfoo - -This will create a `libfoo.porttix.tar.xz` file, which is publishable. It is -not, however, ideal for simple extraction as a source tix. - -### Creating the Archived Source Tix ### - -In concept, it's easy to create an archived source tix: You simply tar up the -source tix you previously created. However, while it is easy to convert an -archived port tix into an archived source tix, it is not possible to go in the -other direction. It is recommended to create a port tix as it forces you to -carefully consider all the applied patches and is respectful to the community. -As mentioned, it is easy to convert the `.porttix.tar.xz` file into the desired -archived source tix: - - srctix-create libfoo.porttix.tar.xz - -This will create an suitable `libfoo.srctix.tar.xz` in the current directory, -which is an archive containing the normalized tree with all patches applied. -When reviewing, be sure to verify the included tarball in the archived port tix -is entirely identical to the upstream release byte-for-byte to avoid security -problems. - -### Publishing ### - -Now that you have completed your port and built the archived port tix, it is -time to share your work with the Sortix community. The simplest solution is -sending the archived port tix (not the archived source tix) to the Sortix -developers. They will then review your work and graciously publish your port -through the appropriate channels. Alternatively, you can upload the port tix and -the source tix to your own site and maintain it as a third party port. - -Conclusion ----------- - -This should be a basic walk-through the process of porting a piece of software -to the Sortix operating system. Note how the porting facilities are experimental -and much is subject to change in the near future. Porting software is an -advanced topic and this documentation merely touches the more common situations -and surely important advice is missing from this documentation. It's always a -good idea to consult the Sortix developers for advice. diff --git a/doc/posix-divergence b/doc/posix-divergence deleted file mode 100644 index 92e03c45..00000000 --- a/doc/posix-divergence +++ /dev/null @@ -1,71 +0,0 @@ -POSIX Divergence -================ - -The Sortix operating system cares about compatibility with existing software and -maintaining such software by purging obsolete stuff from the system. Sortix -recognizes the POSIX standard as valuable and embraces it rather than fighting -it. Nonetheless, we don't implement standards for the sake of standards, but for -the benefits we get from complying. Sometimes the standard mandates something -that is broken or we can do considerably better. In those cases it's best to -diverge and fix the design mistakes properly - but we must not forget there is -a considerable compatibility cost we must pay. Don't diverge unless there is a -good reason to and compatibility and an upgrade path must be considered. - -That said, Sortix has diverged from full POSIX compliance in the hope such -decisions would be for the better. This document attempts to list where Sortix -has intentionally diverged from POSIX 2008. See doc/obsolete-stuff for a more -detailed rationale of why the interfaces are absent or scheduled for removal. -Mind that Sortix doesn't fully intend to implement the XSI option and violations -of that isn't listed here. - -It is worth noting that some particular interfaces scheduled for removal will -likely take a very long time to phase out and wholly remove. - -Mandated by POSIX but not implemented in Sortix ----- -* POSIX advisory locks (fcntl, lockf) are not implemented. -* getpgrp is not implemented. -* has been merged into . -* Numerous namespace violations (will be fixed or documented here). -* Numerous missing features (will be fixed or documented here). - -Obsolescent in POSIX but not implemented in Sortix ----- -* gets is not implemented (obsolescent in POSIX). -* tmpnam is not implemented (obsolescent in POSIX). - -Mandated by POSIX and scheduled for Sortix removal ----- -* select is scheduled for removal. -* struct timeval is scheduled for removal. -* times, is scheduled for removal. - -Obsolescent in POSIX and scheduled for Sortix removal ---- -* asctime and asctime_r are scheduled for removal (obsolescent in POSIX). -* ctime, ctime_r are scheduled for removal (obsolescent in POSIX). -* utime, are scheduled for removal (obsolescent in POSIX). - -Signal Stacks -------------- - -Threads are able to set a recursive signal handling stack using sigaltstack(2) -even if SS_ONSTACK is currently set - while POSIX mandates EPERM in this case. -Such a stack will be used for recursive signals (with SA_ONSTACK set) for the -duration of the signal handler. The original signal stack state will be restored -when the signal handler returns, any edit with sigaltstack will be temporary -(unless the saved ucontext is modified). - -Timestamps ----------- - -The time_t values given by clock_gettime(CLOCK_REALTIME, ...) (and other system -interfaces built upon that) are the number of actual seconds that has passed -since 1970-01-01 00:00:00 UTC. This includes leap seconds, unlike the timestamps -mandated by POSIX. This has the advantage that time_t values are unambiguously -translate to a particular date and time and back and that the values are -continuous and adding an internal to a time_t value actually delays by that -interval. This has the unfortunate consequence that translating to and from -POSIX time requires subtracting the number of leap seconds that has occurred for -that time value. The standard library needs to get some utility functions for -doing such conversion. diff --git a/doc/welcome b/doc/welcome deleted file mode 100644 index b5884860..00000000 --- a/doc/welcome +++ /dev/null @@ -1,7 +0,0 @@ -You can view the documentation for new users by typing: - - man user-guide - -You can view the installation instructions by typing: - - man installation diff --git a/ports/ag/ag.patch b/ports/ag/ag.patch new file mode 100644 index 00000000..b98b3238 --- /dev/null +++ b/ports/ag/ag.patch @@ -0,0 +1,60 @@ +diff -Paur --no-dereference -- ag.upstream/config.sub ag/config.sub +--- ag.upstream/config.sub ++++ ag/config.sub +@@ -1373,7 +1373,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- ag.upstream/configure ag/configure +--- ag.upstream/configure ++++ ag/configure +@@ -4992,8 +4992,7 @@ + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); +- pthread_cleanup_push(routine, 0); +- pthread_cleanup_pop(0) /* ; */ ++ /* ; */ + ; + return 0; + } +@@ -5216,7 +5215,7 @@ + + + # Run CFLAGS="-pg" ./configure if you want debug symbols +-CFLAGS="$CFLAGS $PTHREAD_CFLAGS $PCRE_CFLAGS -Wall -Wextra -Wformat=2 -Wno-format-nonliteral -Wshadow -Wpointer-arith -Wcast-qual -Wmissing-prototypes -Wno-missing-braces -std=gnu89 -D_GNU_SOURCE -O2" ++CFLAGS="$CFLAGS $PTHREAD_CFLAGS $PCRE_CFLAGS -Wall -Wextra -Wformat=2 -Wno-format-nonliteral -Wshadow -Wpointer-arith -Wmissing-prototypes -Wno-missing-braces -std=gnu89 -D_GNU_SOURCE" + LDFLAGS="$LDFLAGS" + + case $host in +diff -Paur --no-dereference -- ag.upstream/src/main.c ag/src/main.c +--- ag.upstream/src/main.c ++++ ag/src/main.c +@@ -69,8 +69,10 @@ + GetSystemInfo(&si); + num_cores = si.dwNumberOfProcessors; + } +-#else ++#elif defined(_SC_NPROCESSORS_ONLN) + num_cores = (int)sysconf(_SC_NPROCESSORS_ONLN); ++#else ++ num_cores = 1; + #endif + + workers_len = num_cores < 8 ? num_cores : 8; +diff -Paur --no-dereference -- ag.upstream/src/options.c ag/src/options.c +--- ag.upstream/src/options.c ++++ ag/src/options.c +@@ -4,7 +4,6 @@ + #include + #include + #include +-#include + #include + #include + diff --git a/ports/ag/ag.port b/ports/ag/ag.port new file mode 100644 index 00000000..fb8b23a5 --- /dev/null +++ b/ports/ag/ag.port @@ -0,0 +1,15 @@ +NAME=ag +BUILD_LIBRARIES='libpcre libz xz' +VERSION=0.33.0 +DISTNAME=the_silver_searcher-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=8ca680399df5ee8846a509c8a67c10ee1d5fc1a94456806a0ff9dd913b961db3 +UPSTREAM_SITE=https://geoff.greer.fm/ag/releases +UPSTREAM_ARCHIVE=$ARCHIVE +RUNTIME_PROGRAMS=git +BUILD_SYSTEM=configure +CONFIGURE_ARGS= +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la +RELEASE_SEARCH_PAGE=https://geoff.greer.fm/ag/ diff --git a/ports/ag/ag.rmpatch b/ports/ag/ag.rmpatch new file mode 100644 index 00000000..96f57a98 --- /dev/null +++ b/ports/ag/ag.rmpatch @@ -0,0 +1 @@ +rm -rf -- 'the_silver_searcher.spec' diff --git a/ports/binutils/binutils.port b/ports/binutils/binutils.port new file mode 100644 index 00000000..f14104cf --- /dev/null +++ b/ports/binutils/binutils.port @@ -0,0 +1,18 @@ +NAME=binutils +BUILD_LIBRARIES=gettext +VERSION=1.1-rc1 +DISTNAME=sortix-binutils-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=c7ee1a05728882a2da6c2658d3cd3099e45525e3d3d0d9b29477ed0486f59f30 +UPSTREAM_SITE=https://pub.sortix.org/sortix/toolchain +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_WITH_SYSROOT=true +CONFIGURE_WITH_SYSROOT_LD_BUG=true +CONFIGURE_WITH_BUILD_SYSROOT=true +CONFIGURE_ARGS=--disable-werror +CONFIGURE_USE_BUILD_DIRECTORY=true +MAKE_ARGS='tooldir="$(EXEC_PREFIX)"' +POST_INSTALL=../binutils.post-install +VERSION_REGEX='([0-9]+\.[0-9]+(\.[0-9]+)*(-rc[0-9]+)?)' diff --git a/ports/binutils/binutils.post-install b/ports/binutils/binutils.post-install new file mode 100755 index 00000000..fb72e9b3 --- /dev/null +++ b/ports/binutils/binutils.post-install @@ -0,0 +1,9 @@ +#!/bin/sh -e +tix-eradicate-libtool-la +programs=$(ls "$TIX_INSTALL_DIR$EXEC_PREFIX/bin") +for program in $programs; do + if [ ! -e "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/$TARGET-$program" ]; then + ln "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/$program" \ + "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/$TARGET-$program" + fi +done diff --git a/ports/bison/bison.patch b/ports/bison/bison.patch new file mode 100644 index 00000000..0eea32cc --- /dev/null +++ b/ports/bison/bison.patch @@ -0,0 +1,270 @@ +diff -Paur --no-dereference -- bison.upstream/build-aux/config.sub bison/build-aux/config.sub +--- bison.upstream/build-aux/config.sub ++++ bison/build-aux/config.sub +@@ -1356,7 +1356,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- bison.upstream/configure bison/configure +--- bison.upstream/configure ++++ bison/configure +@@ -1,4 +1,122 @@ + #! /bin/sh ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for GNU Bison 3.0.2. + # +diff -Paur --no-dereference -- bison.upstream/lib/spawn_faction_addclose.c bison/lib/spawn_faction_addclose.c +--- bison.upstream/lib/spawn_faction_addclose.c ++++ bison/lib/spawn_faction_addclose.c +@@ -22,10 +22,6 @@ + #include + #include + +-#if !_LIBC +-# define __sysconf(open_max) getdtablesize () +-#endif +- + #if !HAVE_WORKING_POSIX_SPAWN + # include "spawn_int.h" + #endif +@@ -37,7 +33,7 @@ + int fd) + #undef posix_spawn_file_actions_addclose + { +- int maxfd = __sysconf (_SC_OPEN_MAX); ++ int maxfd = sysconf (_SC_OPEN_MAX); + + /* Test for the validity of the file descriptor. */ + if (fd < 0 || fd >= maxfd) +diff -Paur --no-dereference -- bison.upstream/lib/spawn_faction_adddup2.c bison/lib/spawn_faction_adddup2.c +--- bison.upstream/lib/spawn_faction_adddup2.c ++++ bison/lib/spawn_faction_adddup2.c +@@ -22,10 +22,6 @@ + #include + #include + +-#if !_LIBC +-# define __sysconf(open_max) getdtablesize () +-#endif +- + #if !HAVE_WORKING_POSIX_SPAWN + # include "spawn_int.h" + #endif +@@ -37,7 +33,7 @@ + int fd, int newfd) + #undef posix_spawn_file_actions_adddup2 + { +- int maxfd = __sysconf (_SC_OPEN_MAX); ++ int maxfd = sysconf (_SC_OPEN_MAX); + + /* Test for the validity of the file descriptor. */ + if (fd < 0 || newfd < 0 || fd >= maxfd || newfd >= maxfd) +diff -Paur --no-dereference -- bison.upstream/lib/spawn_faction_addopen.c bison/lib/spawn_faction_addopen.c +--- bison.upstream/lib/spawn_faction_addopen.c ++++ bison/lib/spawn_faction_addopen.c +@@ -22,10 +22,6 @@ + #include + #include + +-#if !_LIBC +-# define __sysconf(open_max) getdtablesize () +-#endif +- + #if !HAVE_WORKING_POSIX_SPAWN + # include "spawn_int.h" + #endif +@@ -38,7 +34,7 @@ + mode_t mode) + #undef posix_spawn_file_actions_addopen + { +- int maxfd = __sysconf (_SC_OPEN_MAX); ++ int maxfd = sysconf (_SC_OPEN_MAX); + + /* Test for the validity of the file descriptor. */ + if (fd < 0 || fd >= maxfd) +diff -Paur --no-dereference -- bison.upstream/Makefile.in bison/Makefile.in +--- bison.upstream/Makefile.in ++++ bison/Makefile.in +@@ -2297,7 +2297,7 @@ + # Obfuscate with a variable. + doc_bison = doc/bison + TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc +-CLEANDIRS = doc/bison.t2d doc/figs doc/html ++CLEANDIRS = doc/bison.t2d doc/html + CROSS_OPTIONS_PL = $(top_srcdir)/build-aux/cross-options.pl + CROSS_OPTIONS_TEXI = $(top_srcdir)/doc/cross-options.texi + MAINTAINERCLEANFILES = $(CROSS_OPTIONS_TEXI) \ +@@ -4922,6 +4922,8 @@ + distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf examples/calc++/$(DEPDIR) examples/mfcalc/$(DEPDIR) examples/rpcalc/$(DEPDIR) lib/$(DEPDIR) lib/glthread/$(DEPDIR) lib/uniwidth/$(DEPDIR) src/$(DEPDIR) ++ -rm -f $(INFO_DEPS) ++ -rm -f $(CROSS_OPTIONS_TEXI) + -rm -f Makefile + distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-local distclean-tags +@@ -5145,22 +5147,28 @@ + doc/refcard.pdf: doc/refcard.tex + $(AM_V_GEN) cd doc && pdftex $(abs_top_srcdir)/doc/refcard.tex + $(top_srcdir)/doc/bison.help: src/bison$(EXEEXT) +- $(AM_V_GEN)src/bison$(EXEEXT) --version >doc/bison.help.tmp +- $(AM_V_at) src/bison$(EXEEXT) --help >>doc/bison.help.tmp +- $(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@ ++ # PATCH: Nope! You can't run your programs after they have been potentially ++ # cross-compiled so don't even try! ++ #$(AM_V_GEN)src/bison$(EXEEXT) --version >doc/bison.help.tmp ++ #$(AM_V_at) src/bison$(EXEEXT) --help >>doc/bison.help.tmp ++ #$(AM_V_at)$(top_srcdir)/build-aux/move-if-change doc/bison.help.tmp $@ ++ touch $@ + + # Depend on configure to get version number changes. + $(top_srcdir)/doc/bison.1: doc/bison.help doc/bison.x $(top_srcdir)/configure +- $(AM_V_GEN)$(HELP2MAN) \ +- --include=$(top_srcdir)/doc/bison.x \ +- --output=$@.t src/bison$(EXEEXT) +- $(AM_V_at)if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \ +- $(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \ +- touch $@; \ +- else \ +- mv $@.t $@; \ +- fi +- $(AM_V_at)rm -f $@*.t ++ # PATCH: Nope! You can't run your programs after they have been potentially ++ # cross-compiled so don't even try! ++ #$(AM_V_GEN)$(HELP2MAN) \ ++ # --include=$(top_srcdir)/doc/bison.x \ ++ # --output=$@.t src/bison$(EXEEXT) ++ #$(AM_V_at)if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \ ++ # $(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \ ++ # touch $@; \ ++ #else \ ++ # mv $@.t $@; \ ++ #fi ++ #$(AM_V_at)rm -f $@*.t ++ touch $@ + + .gv.eps: + $(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'` diff --git a/ports/bison/bison.port b/ports/bison/bison.port new file mode 100644 index 00000000..11649bb0 --- /dev/null +++ b/ports/bison/bison.port @@ -0,0 +1,11 @@ +NAME=bison +BUILD_LIBRARIES='libstdc++? libiconv?' +VERSION=3.0.2 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=a2c3e8528bdb50567d6fa26deeb493dc5ccd7e277b865251608a9e43ac928f3c +UPSTREAM_SITE=https://ftp.gnu.org/gnu/bison +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' diff --git a/ports/bison/bison.rmpatch b/ports/bison/bison.rmpatch new file mode 100644 index 00000000..cf59c2f1 --- /dev/null +++ b/ports/bison/bison.rmpatch @@ -0,0 +1,4 @@ +rm -rf -- 'doc/bison.info' +rm -rf -- 'doc/cross-options.texi' +rm -rf -- 'doc/stamp-vti' +rm -rf -- 'doc/version.texi' diff --git a/ports/bochs/bochs.patch b/ports/bochs/bochs.patch new file mode 100644 index 00000000..a31a14ff --- /dev/null +++ b/ports/bochs/bochs.patch @@ -0,0 +1,239 @@ +diff -Paur --no-dereference -- bochs.upstream/config.sub bochs/config.sub +--- bochs.upstream/config.sub ++++ bochs/config.sub +@@ -1297,7 +1297,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- bochs.upstream/configure bochs/configure +--- bochs.upstream/configure ++++ bochs/configure +@@ -23755,7 +23755,7 @@ + if test "$with_sdl" = yes; then + SOUNDLOW_OBJS="$SOUNDLOW_OBJS soundsdl.o" + if test "$bx_plugins" = 1; then +- SOUND_LINK_OPTS="$SOUND_LINK_OPTS `sdl-config --libs`" ++ SOUND_LINK_OPTS="$SOUND_LINK_OPTS `${PKG_CONFIG:-pkg-config} sdl --libs`" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: sdl" >&5 + $as_echo "sdl" >&6; } +@@ -24199,7 +24199,7 @@ + SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_SDL)" + # GUI_*FLAGS are added to the compilation of every bochs file, not just + # the files in gui/*.cc. +- SDL_CFLAGS=`sdl-config --cflags` ++ SDL_CFLAGS=`${PKG_CONFIG:-pkg-config} sdl --cflags` + GUI_CFLAGS="$GUI_CFLAGS $SDL_CFLAGS" + GUI_CXXFLAGS="$GUI_CXXFLAGS $SDL_CFLAGS" + GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_SDL)" +diff -Paur --no-dereference -- bochs.upstream/configure.in bochs/configure.in +--- bochs.upstream/configure.in ++++ bochs/configure.in +@@ -1805,7 +1805,7 @@ + if test "$with_sdl" = yes; then + SOUNDLOW_OBJS="$SOUNDLOW_OBJS soundsdl.o" + if test "$bx_plugins" = 1; then +- SOUND_LINK_OPTS="$SOUND_LINK_OPTS `sdl-config --libs`" ++ SOUND_LINK_OPTS="$SOUND_LINK_OPTS `${PKG_CONFIG:-pkg-config} sdl --libs`" + fi + AC_MSG_RESULT(sdl) + else +@@ -2102,7 +2102,7 @@ + SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_SDL)" + # GUI_*FLAGS are added to the compilation of every bochs file, not just + # the files in gui/*.cc. +- SDL_CFLAGS=`sdl-config --cflags` ++ SDL_CFLAGS=`${PKG_CONFIG:-pkg-config} sdl --cflags` + GUI_CFLAGS="$GUI_CFLAGS $SDL_CFLAGS" + GUI_CXXFLAGS="$GUI_CXXFLAGS $SDL_CFLAGS" + GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_SDL)" +diff -Paur --no-dereference -- bochs.upstream/cpu/debugstuff.cc bochs/cpu/debugstuff.cc +--- bochs.upstream/cpu/debugstuff.cc ++++ bochs/cpu/debugstuff.cc +@@ -256,8 +256,8 @@ + (unsigned) BX_CPU_THIS_PTR cr0.get32(), + (unsigned) BX_CPU_THIS_PTR cr2, (unsigned) BX_CPU_THIS_PTR cr3)); + #else +- BX_INFO(("| CR0=0x%08x CR2=0x%08x", +- BX_CPU_THIS_PTR cr0.get32(), BX_CPU_THIS_PTR cr2)); ++ BX_INFO(("| CR0=0x%08x CR2=0x%08jx", ++ BX_CPU_THIS_PTR cr0.get32(), (uintmax_t)BX_CPU_THIS_PTR cr2)); + BX_INFO(("| CR3=0x%08x CR4=0x%08x", + (unsigned) BX_CPU_THIS_PTR cr3, + (unsigned) BX_CPU_THIS_PTR cr4.get32())); +diff -Paur --no-dereference -- bochs.upstream/cpu/fetchdecode.cc bochs/cpu/fetchdecode.cc +--- bochs.upstream/cpu/fetchdecode.cc ++++ bochs/cpu/fetchdecode.cc +@@ -2010,8 +2010,8 @@ + #endif + } + else { +- BX_DEBUG(("%s: instruction not supported - signalling #UD (features bitmask: 0x%08x)", +- get_bx_opcode_name(ia_opcode), BX_CPU_THIS_PTR isa_extensions_bitmask)); ++ BX_DEBUG(("%s: instruction not supported - signalling #UD (features bitmask: 0x%08jx)", ++ get_bx_opcode_name(ia_opcode), (uintmax_t)BX_CPU_THIS_PTR isa_extensions_bitmask)); + } + + exception(BX_UD_EXCEPTION, 0); +diff -Paur --no-dereference -- bochs.upstream/doc/docbook/Makefile.in bochs/doc/docbook/Makefile.in +--- bochs.upstream/doc/docbook/Makefile.in ++++ bochs/doc/docbook/Makefile.in +@@ -15,7 +15,7 @@ + TARGZ = bochsdoc.tar.gz + RENDERED_DOC_URL = http://bochs.sf.net/doc/docbook/$(TARGZ) + +-DESTDIR= ++DESTDIR?= + + # name of the major documentation sections + SECTIONS=user documentation development +diff -Paur --no-dereference -- bochs.upstream/fpu/fpu.cc bochs/fpu/fpu.cc +--- bochs.upstream/fpu/fpu.cc ++++ bochs/fpu/fpu.cc +@@ -582,7 +582,7 @@ + f *= fp.fraction*scale_factor; + #endif + float_class_t f_class = floatx80_class(fp); +- fprintf(stderr, "%sFP%d ST%d(%c): raw 0x%04x:%08lx%08lx (%.10f) (%s)\n", ++ fprintf(stderr, "%sFP%d ST%d(%c): raw 0x%04x:%08x%08x (%.10f) (%s)\n", + i==tos?"=>":" ", i, (i-tos)&7, + "v0se"[tag], + fp.exp & 0xffff, GET32H(fp.fraction), GET32L(fp.fraction), +diff -Paur --no-dereference -- bochs.upstream/gui/Makefile.in bochs/gui/Makefile.in +--- bochs.upstream/gui/Makefile.in ++++ bochs/gui/Makefile.in +@@ -69,7 +69,7 @@ + X_LIBS = @X_LIBS@ + X_PRE_LIBS = @X_PRE_LIBS@ + GUI_LINK_OPTS_X = $(X_LIBS) $(X_PRE_LIBS) +-GUI_LINK_OPTS_SDL = `sdl-config --cflags --libs` ++GUI_LINK_OPTS_SDL = `$${PKG_CONFIG:-pkg-config} sdl --cflags --libs` + GUI_LINK_OPTS_SVGA = -lvga -lvgagl + GUI_LINK_OPTS_RFB = @RFB_LIBS@ + GUI_LINK_OPTS_AMIGAOS = +diff -Paur --no-dereference -- bochs.upstream/iodev/serial.cc bochs/iodev/serial.cc +--- bochs.upstream/iodev/serial.cc ++++ bochs/iodev/serial.cc +@@ -39,6 +39,18 @@ + typedef int SOCKET; + #endif + ++#if defined(__sortix__) ++struct hostent ++{ ++ char *h_name; ++ char **h_aliases; ++ int h_addrtype; ++ int h_length; ++ char **h_addr_list; ++}; ++#define gethostbyname(a) ((void) a, (struct hostent*) NULL) ++#endif ++ + #include "iodev.h" + #include "serial.h" + +@@ -462,9 +474,9 @@ + + memset ((char*) &sin, 0, sizeof (sin)); + #if BX_HAVE_SOCKADDR_IN_SIN_LEN +- sin.sin_len = sizeof sin; ++ sin.sin_len = sizeof sin; + #endif +- memcpy ((char*) &(sin.sin_addr), hp->h_addr, hp->h_length); ++ memcpy ((char*) &(sin.sin_addr), hp->h_addr_list[0], hp->h_length); + sin.sin_family = hp->h_addrtype; + sin.sin_port = htons (port); + +diff -Paur --no-dereference -- bochs.upstream/iodev/vgacore.cc bochs/iodev/vgacore.cc +--- bochs.upstream/iodev/vgacore.cc ++++ bochs/iodev/vgacore.cc +@@ -387,9 +387,9 @@ + + void bx_vgacore_c::determine_screen_dimensions(unsigned *piHeight, unsigned *piWidth) + { +- int ai[0x20]; ++ int ai[20]; + int i,h,v; +- for (i = 0 ; i < 0x20 ; i++) ++ for (i = 0 ; i < 20 ; i++) + ai[i] = BX_VGA_THIS s.CRTC.reg[i]; + + h = (ai[1] + 1) * 8; +diff -Paur --no-dereference -- bochs.upstream/Makefile.in bochs/Makefile.in +--- bochs.upstream/Makefile.in ++++ bochs/Makefile.in +@@ -35,7 +35,7 @@ + top_builddir = . + top_srcdir = $(srcdir) + +-DESTDIR = ++DESTDIR ?= + + VERSION=@VERSION@ + VER_STRING=@VER_STRING@ +@@ -96,7 +96,7 @@ + X_LIBS = @X_LIBS@ + X_PRE_LIBS = @X_PRE_LIBS@ + GUI_LINK_OPTS_X = $(X_LIBS) $(X_PRE_LIBS) +-GUI_LINK_OPTS_SDL = `sdl-config --cflags --libs` ++GUI_LINK_OPTS_SDL = `$${PKG_CONFIG:-pkg-config} sdl --cflags --libs` + GUI_LINK_OPTS_SVGA = -lvga -lvgagl + GUI_LINK_OPTS_RFB = @RFB_LIBS@ + GUI_LINK_OPTS_AMIGAOS = +@@ -623,6 +623,8 @@ + @CD_UP_THREE@ + @RMCOMMAND@ Makefile + ++distclean: dist-clean ++ + ########################################### + # Build app on MacOS X + ########################################### +diff -Paur --no-dereference -- bochs.upstream/memory/misc_mem.cc bochs/memory/misc_mem.cc +--- bochs.upstream/memory/misc_mem.cc ++++ bochs/memory/misc_mem.cc +@@ -158,12 +158,12 @@ + const Bit64u block_address = ((Bit64u)block)*BX_MEM_BLOCK_LEN; + + if (fseeko64(BX_MEM_THIS overflow_file, block_address, SEEK_SET)) +- BX_PANIC(("FATAL ERROR: Could not seek to 0x%lx in memory overflow file!", block_address)); ++ BX_PANIC(("FATAL ERROR: Could not seek to 0x%llx in memory overflow file!", (unsigned long long) block_address)); + + // We could legitimately get an EOF condition if we are reading the last bit of memory.ram + if ((fread(BX_MEM_THIS blocks[block], BX_MEM_BLOCK_LEN, 1, BX_MEM_THIS overflow_file) != 1) && + (!feof(BX_MEM_THIS overflow_file))) +- BX_PANIC(("FATAL ERROR: Could not read from 0x%lx in memory overflow file!", block_address)); ++ BX_PANIC(("FATAL ERROR: Could not read from 0x%llx in memory overflow file!", (unsigned long long) block_address)); + } + #endif + +@@ -208,9 +208,9 @@ + } + // Write swapped out block + if (fseeko64(BX_MEM_THIS overflow_file, address, SEEK_SET)) +- BX_PANIC(("FATAL ERROR: Could not seek to 0x%llx in overflow file!", address)); ++ BX_PANIC(("FATAL ERROR: Could not seek to 0x%llx in overflow file!", (unsigned long long)address)); + if (1 != fwrite (BX_MEM_THIS blocks[BX_MEM_THIS next_swapout_idx], BX_MEM_BLOCK_LEN, 1, BX_MEM_THIS overflow_file)) +- BX_PANIC(("FATAL ERROR: Could not write at 0x%llx in overflow file!", address)); ++ BX_PANIC(("FATAL ERROR: Could not write at 0x%llx in overflow file!", (unsigned long long)address)); + // Mark swapped out block + BX_MEM_THIS blocks[BX_MEM_THIS next_swapout_idx] = BX_MEM_C::swapped_out; + BX_MEM_THIS blocks[block] = buffer; +@@ -245,9 +245,9 @@ + { + bx_phy_address address = ((bx_phy_address)idx)*BX_MEM_BLOCK_LEN; + if (fseeko64(fp, address, SEEK_SET)) +- BX_PANIC(("FATAL ERROR: Could not seek to 0x%llx in overflow file!", address)); ++ BX_PANIC(("FATAL ERROR: Could not seek to 0x%llx in overflow file!", (unsigned long long)address)); + if (1 != fwrite (BX_MEM(0)->blocks[idx], BX_MEM_BLOCK_LEN, 1, fp)) +- BX_PANIC(("FATAL ERROR: Could not write at 0x%llx in overflow file!", address)); ++ BX_PANIC(("FATAL ERROR: Could not write at 0x%llx in overflow file!", (unsigned long long)address)); + } + } + } diff --git a/ports/bochs/bochs.port b/ports/bochs/bochs.port new file mode 100644 index 00000000..a3de9816 --- /dev/null +++ b/ports/bochs/bochs.port @@ -0,0 +1,13 @@ +NAME=bochs +BUILD_LIBRARIES='libstdc++ libiconv libSDL' +VERSION=2.6 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=65123e44a6d2c1148d741da025d16311b9ccd600ef268b911aba73c67eaf86e1 +UPSTREAM_SITE=https://sourceforge.net/projects/bochs/files/bochs/$VERSION +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--with-sdl --enable-x86-64' +RELEASE_SEARCH_PAGE=https://sourceforge.net/projects/bochs/files/bochs/ +RELEASE_SEARCH_REGEX='([0-9]+\.[0-9]+(\.[0-9]+)*)/' diff --git a/ports/bzip2/bzip2.execpatch b/ports/bzip2/bzip2.execpatch new file mode 100644 index 00000000..7a667b34 --- /dev/null +++ b/ports/bzip2/bzip2.execpatch @@ -0,0 +1 @@ +chmod +x -- 'make.sortix' diff --git a/ports/bzip2/bzip2.patch b/ports/bzip2/bzip2.patch new file mode 100644 index 00000000..6e2eee68 --- /dev/null +++ b/ports/bzip2/bzip2.patch @@ -0,0 +1,129 @@ +diff -Paur --no-dereference -- bzip2.upstream/bzip2.c bzip2/bzip2.c +--- bzip2.upstream/bzip2.c ++++ bzip2/bzip2.c +@@ -72,7 +72,9 @@ + # include + # include + # include ++#if !defined(__sortix__) + # include ++#endif + + # define PATH_SEP '/' + # define MY_LSTAT lstat +diff -Paur --no-dereference -- bzip2.upstream/Makefile bzip2/Makefile +--- bzip2.upstream/Makefile ++++ bzip2/Makefile +@@ -25,6 +25,8 @@ + + # Where you want it installed when you do 'make install' + PREFIX=/usr/local ++EXEC_PREFIX=$(PREFIX) ++DESTDIR= + + + OBJS= blocksort.o \ +@@ -35,7 +37,7 @@ + decompress.o \ + bzlib.o + +-all: libbz2.a bzip2 bzip2recover test ++all: libbz2.a bzip2 bzip2recover + + bzip2: libbz2.a bzip2.o + $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2 +@@ -70,43 +72,43 @@ + @cat words3 + + install: bzip2 bzip2recover +- if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi +- if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi +- if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi +- if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi +- if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi +- cp -f bzip2 $(PREFIX)/bin/bzip2 +- cp -f bzip2 $(PREFIX)/bin/bunzip2 +- cp -f bzip2 $(PREFIX)/bin/bzcat +- cp -f bzip2recover $(PREFIX)/bin/bzip2recover +- chmod a+x $(PREFIX)/bin/bzip2 +- chmod a+x $(PREFIX)/bin/bunzip2 +- chmod a+x $(PREFIX)/bin/bzcat +- chmod a+x $(PREFIX)/bin/bzip2recover +- cp -f bzip2.1 $(PREFIX)/man/man1 +- chmod a+r $(PREFIX)/man/man1/bzip2.1 +- cp -f bzlib.h $(PREFIX)/include +- chmod a+r $(PREFIX)/include/bzlib.h +- cp -f libbz2.a $(PREFIX)/lib +- chmod a+r $(PREFIX)/lib/libbz2.a +- cp -f bzgrep $(PREFIX)/bin/bzgrep +- ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep +- ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep +- chmod a+x $(PREFIX)/bin/bzgrep +- cp -f bzmore $(PREFIX)/bin/bzmore +- ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless +- chmod a+x $(PREFIX)/bin/bzmore +- cp -f bzdiff $(PREFIX)/bin/bzdiff +- ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp +- chmod a+x $(PREFIX)/bin/bzdiff +- cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1 +- chmod a+r $(PREFIX)/man/man1/bzgrep.1 +- chmod a+r $(PREFIX)/man/man1/bzmore.1 +- chmod a+r $(PREFIX)/man/man1/bzdiff.1 +- echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1 +- echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1 +- echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1 +- echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1 ++ if ( test ! -d $(DESTDIR)$(EXEC_PREFIX)/bin ) ; then mkdir -p $(DESTDIR)$(EXEC_PREFIX)/bin ; fi ++ if ( test ! -d $(DESTDIR)$(EXEC_PREFIX)/lib ) ; then mkdir -p $(DESTDIR)$(EXEC_PREFIX)/lib ; fi ++ if ( test ! -d $(DESTDIR)$(PREFIX)/share/man ) ; then mkdir -p $(DESTDIR)$(PREFIX)/share/man ; fi ++ if ( test ! -d $(DESTDIR)$(PREFIX)/share/man/man1 ) ; then mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1 ; fi ++ if ( test ! -d $(DESTDIR)$(PREFIX)/include ) ; then mkdir -p $(DESTDIR)$(PREFIX)/include ; fi ++ cp -f bzip2 $(DESTDIR)$(EXEC_PREFIX)/bin/bzip2 ++ cp -f bzip2 $(DESTDIR)$(EXEC_PREFIX)/bin/bunzip2 ++ cp -f bzip2 $(DESTDIR)$(EXEC_PREFIX)/bin/bzcat ++ cp -f bzip2recover $(DESTDIR)$(EXEC_PREFIX)/bin/bzip2recover ++ chmod a+x $(DESTDIR)$(EXEC_PREFIX)/bin/bzip2 ++ chmod a+x $(DESTDIR)$(EXEC_PREFIX)/bin/bunzip2 ++ chmod a+x $(DESTDIR)$(EXEC_PREFIX)/bin/bzcat ++ chmod a+x $(DESTDIR)$(EXEC_PREFIX)/bin/bzip2recover ++ cp -f bzip2.1 $(DESTDIR)$(PREFIX)/share/man/man1 ++ chmod a+r $(DESTDIR)$(PREFIX)/share/man/man1/bzip2.1 ++ cp -f bzlib.h $(DESTDIR)$(PREFIX)/include ++ chmod a+r $(DESTDIR)$(PREFIX)/include/bzlib.h ++ cp -f libbz2.a $(DESTDIR)$(EXEC_PREFIX)/lib ++ chmod a+r $(DESTDIR)$(EXEC_PREFIX)/lib/libbz2.a ++ cp -f bzgrep $(DESTDIR)$(EXEC_PREFIX)/bin/bzgrep ++ ln -s -f bzgrep $(DESTDIR)$(EXEC_PREFIX)/bin/bzegrep ++ ln -s -f bzgrep $(DESTDIR)$(EXEC_PREFIX)/bin/bzfgrep ++ chmod a+x $(DESTDIR)$(EXEC_PREFIX)/bin/bzgrep ++ cp -f bzmore $(DESTDIR)$(EXEC_PREFIX)/bin/bzmore ++ ln -s -f bzmore $(DESTDIR)$(EXEC_PREFIX)/bin/bzless ++ chmod a+x $(DESTDIR)$(EXEC_PREFIX)/bin/bzmore ++ cp -f bzdiff $(DESTDIR)$(EXEC_PREFIX)/bin/bzdiff ++ ln -s -f bzdiff $(DESTDIR)$(EXEC_PREFIX)/bin/bzcmp ++ chmod a+x $(DESTDIR)$(EXEC_PREFIX)/bin/bzdiff ++ cp -f bzgrep.1 bzmore.1 bzdiff.1 $(DESTDIR)$(PREFIX)/share/man/man1 ++ chmod a+r $(DESTDIR)$(PREFIX)/share/man/man1/bzgrep.1 ++ chmod a+r $(DESTDIR)$(PREFIX)/share/man/man1/bzmore.1 ++ chmod a+r $(DESTDIR)$(PREFIX)/share/man/man1/bzdiff.1 ++ echo ".so man1/bzgrep.1" > $(DESTDIR)$(PREFIX)/share/man/man1/bzegrep.1 ++ echo ".so man1/bzgrep.1" > $(DESTDIR)$(PREFIX)/share/man/man1/bzfgrep.1 ++ echo ".so man1/bzmore.1" > $(DESTDIR)$(PREFIX)/share/man/man1/bzless.1 ++ echo ".so man1/bzdiff.1" > $(DESTDIR)$(PREFIX)/share/man/man1/bzcmp.1 + + clean: + rm -f *.o libbz2.a bzip2 bzip2recover \ +diff -Paur --no-dereference -- bzip2.upstream/make.sortix bzip2/make.sortix +--- bzip2.upstream/make.sortix ++++ bzip2/make.sortix +@@ -0,0 +1,10 @@ ++#!/bin/sh ++exec "$MAKE" "$@" \ ++ PREFIX="$PREFIX" \ ++ EXEC_PREFIX="$EXEC_PREFIX" \ ++ DESTDIR="$DESTDIR" \ ++ CC=${HOST}-gcc \ ++ AR=${HOST}-ar \ ++ RANLIB=${HOST}-ranlib \ ++ BIGFILES= \ ++# diff --git a/ports/bzip2/bzip2.port b/ports/bzip2/bzip2.port new file mode 100644 index 00000000..e84b4bca --- /dev/null +++ b/ports/bzip2/bzip2.port @@ -0,0 +1,11 @@ +NAME=bzip2 +BUILD_LIBRARIES= +VERSION=1.0.6 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd +UPSTREAM_SITE=https://sourceware.org/pub/bzip2 +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=sortix-usual-makefile +MAKE=./make.sortix diff --git a/ports/bzip2/bzip2.rmpatch b/ports/bzip2/bzip2.rmpatch new file mode 100644 index 00000000..d7dd5729 --- /dev/null +++ b/ports/bzip2/bzip2.rmpatch @@ -0,0 +1,3 @@ +rm -rf -- 'manual.html' +rm -rf -- 'manual.pdf' +rm -rf -- 'manual.ps' diff --git a/ports/cut/cut.patch b/ports/cut/cut.patch new file mode 100644 index 00000000..c008de33 --- /dev/null +++ b/ports/cut/cut.patch @@ -0,0 +1,100 @@ +diff -Paur --no-dereference -- cut.upstream/cut.c cut/cut.c +--- cut.upstream/cut.c ++++ cut/cut.c +@@ -34,7 +34,7 @@ + */ + + #include +-#include ++#include + #include + #include + #include +@@ -43,6 +43,13 @@ + #include + #include + ++#define err(eval, ...) error(eval, errno, __VA_ARGS__) ++#define errx(eval, ...) error(eval, 0, __VA_ARGS__) ++#define warn(...) error(0, errno, __VA_ARGS__) ++#define warnx(...) error(0, 0, __VA_ARGS__) ++ ++#define _POSIX2_LINE_MAX 2048 ++ + int cflag; + char dchar; + int dflag; +@@ -65,7 +72,7 @@ + + dchar = '\t'; /* default delimiter is \t */ + +- /* Since we don't support multi-byte characters, the -c and -b ++ /* Since we don't support multi-byte characters, the -c and -b + options are equivalent, and the -n option is meaningless. */ + while ((ch = getopt(argc, argv, "b:c:d:f:sn")) != -1) + switch(ch) { +@@ -187,6 +194,7 @@ + void + c_cut(FILE *fp, char *fname) + { ++ (void)fname; + int ch, col; + char *pos; + +@@ -215,13 +223,17 @@ + void + f_cut(FILE *fp, char *fname) + { ++ (void)fname; + int ch, field, isdelim; + char *pos, *p, sep; + int output; + size_t len; +- char *lbuf, *tbuf; ++ ssize_t slen; ++ size_t lbuf_raw_length = 0; ++ char *lbuf = NULL, *tbuf; + +- for (sep = dchar, tbuf = NULL; (lbuf = fgetln(fp, &len));) { ++ for (sep = dchar, tbuf = NULL; 0 <= (slen = getline(&lbuf, &lbuf_raw_length, fp));) { ++ len = slen; + output = 0; + if (lbuf[len - 1] != '\n') { + /* no newline at the end of the last line so add one */ +@@ -272,6 +284,7 @@ + } + if (tbuf) + free(tbuf); ++ free(lbuf); + } + + void +diff -Paur --no-dereference -- cut.upstream/Makefile cut/Makefile +--- cut.upstream/Makefile ++++ cut/Makefile +@@ -0,0 +1,25 @@ ++include ../../../build-aux/compiler.mak ++include ../../../build-aux/version.mak ++include ../../../build-aux/dirs.mak ++ ++OPTLEVEL?=-g -O2 ++CFLAGS?=$(OPTLEVEL) ++ ++CFLAGS:=$(CXXFLAGS) -Wall -Wextra ++CPPFLAGS:=$(CPPFLAGS) ++ ++BINARY:=cut ++ ++all: $(BINARY) ++ ++.PHONY: all install clean ++ ++%: %.c ++ $(CC) -std=gnu11 $(CFLAGS) $(CPPFLAGS) $< -o $@ $(LIBS) ++ ++install: all ++ mkdir -p $(DESTDIR)$(BINDIR) ++ install $(BINARY) $(DESTDIR)$(BINDIR) ++ ++clean: ++ rm -f $(BINARY) diff --git a/ports/cut/cut.port b/ports/cut/cut.port new file mode 100644 index 00000000..f83bba03 --- /dev/null +++ b/ports/cut/cut.port @@ -0,0 +1,11 @@ +NAME=cut +BUILD_LIBRARIES= +VERSION=2014-02-02 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=c1b7374109b8eecaa344be8981297b5ec8cebfcdaab7804cf5d6d4be16f27ab8 +UPSTREAM_SITE=https://pub.sortix.org/fork/cut +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=sortix-usual-makefile +VERSION_REGEX='([0-9]{4}-[0-9]{2}-[0-9]{2})' diff --git a/ports/dash/dash.patch b/ports/dash/dash.patch new file mode 100644 index 00000000..9ca9f9f1 --- /dev/null +++ b/ports/dash/dash.patch @@ -0,0 +1,218 @@ +diff -Paur --no-dereference -- dash.upstream/src/cd.c dash/src/cd.c +--- dash.upstream/src/cd.c ++++ dash/src/cd.c +@@ -252,7 +252,7 @@ + STATIC char * + getpwd() + { +-#ifdef __GLIBC__ ++#if defined(__GLIBC__) || defined(__sortix__) + char *dir = getcwd(0, 0); + + if (dir) +diff -Paur --no-dereference -- dash.upstream/src/exec.c dash/src/exec.c +--- dash.upstream/src/exec.c ++++ dash/src/exec.c +@@ -151,6 +151,9 @@ + STATIC void + tryexec(char *cmd, char **argv, char **envp) + { ++#if defined(__sortix__) ++ execvpe((const char*) cmd, argv, envp); ++#else + char *const path_bshell = _PATH_BSHELL; + + repeat: +@@ -166,6 +169,7 @@ + *argv = cmd = path_bshell; + goto repeat; + } ++#endif + } + + +diff -Paur --no-dereference -- dash.upstream/src/histedit.c dash/src/histedit.c +--- dash.upstream/src/histedit.c ++++ dash/src/histedit.c +@@ -32,7 +32,6 @@ + * SUCH DAMAGE. + */ + +-#include + #ifdef HAVE_PATHS_H + #include + #endif +diff -Paur --no-dereference -- dash.upstream/src/jobs.c dash/src/jobs.c +--- dash.upstream/src/jobs.c ++++ dash/src/jobs.c +@@ -40,7 +40,6 @@ + #include + #endif + #include +-#include + #ifdef BSD + #include + #include +@@ -207,7 +206,7 @@ + mflag = on = 0; + goto close; + } +- if (pgrp == getpgrp()) ++ if (pgrp == getpgid(0)) + break; + killpg(0, SIGTTIN); + } while (1); +@@ -457,7 +456,7 @@ + + if (mode & SHOW_PGID) { + /* just output process (group) id of pipeline */ +- outfmt(out, "%d\n", ps->pid); ++ outfmt(out, "%jd\n", (intmax_t) ps->pid); + return; + } + +@@ -470,7 +469,7 @@ + s[col - 2] = '-'; + + if (mode & SHOW_PID) +- col += fmtstr(s + col, 16, "%d ", ps->pid); ++ col += fmtstr(s + col, 16, "%jd ", (intmax_t) ps->pid); + + psend = ps + jp->nprocs; + +@@ -490,7 +489,7 @@ + + do { + /* for each process */ +- col = fmtstr(s, 48, " |\n%*c%d ", indent, ' ', ps->pid) - 3; ++ col = fmtstr(s, 48, " |\n%*c%jd ", indent, ' ', (intmax_t) ps->pid) - 3; + + start: + outfmt( +@@ -1136,7 +1135,7 @@ + + do { + gotsigchld = 0; +- err = wait3(status, flags, NULL); ++ err = waitpid(-1, status, flags); + if (err || !block) + break; + +diff -Paur --no-dereference -- dash.upstream/src/Makefile.in dash/src/Makefile.in +--- dash.upstream/src/Makefile.in ++++ dash/src/Makefile.in +@@ -170,9 +170,9 @@ + AM_CFLAGS = $(COMMON_CFLAGS) + AM_CPPFLAGS = $(COMMON_CPPFLAGS) + AM_CFLAGS_FOR_BUILD = -g -O2 $(COMMON_CFLAGS) +-AM_CPPFLAGS_FOR_BUILD = $(COMMON_CPPFLAGS) ++AM_CPPFLAGS_FOR_BUILD = -DBSD=1 -DSHELL -DIFS_BROKEN + COMPILE_FOR_BUILD = \ +- $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS_FOR_BUILD) \ ++ unset HOST_SYSTEM_ROOT && $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS_FOR_BUILD) \ + $(CPPFLAGS_FOR_BUILD) \ + $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) + +@@ -542,7 +542,11 @@ + + info-am: + +-install-data-am: install-man ++install-data-am: install-man install-proper-shells ++ ++install-proper-shells: ++ mkdir -p "$(DESTDIR)$(sysconfdir)/proper-shells" ++ echo dash > "$(DESTDIR)$(sysconfdir)/proper-shells/dash" + + install-dvi: install-dvi-am + +diff -Paur --no-dereference -- dash.upstream/src/miscbltin.c dash/src/miscbltin.c +--- dash.upstream/src/miscbltin.c ++++ dash/src/miscbltin.c +@@ -37,7 +37,6 @@ + */ + + #include /* quad_t */ +-#include /* BSD4_4 */ + #include + #include + #include +diff -Paur --no-dereference -- dash.upstream/src/output.c dash/src/output.c +--- dash.upstream/src/output.c ++++ dash/src/output.c +@@ -44,7 +44,6 @@ + */ + + #include /* quad_t */ +-#include /* BSD4_4 */ + #include + + #include /* defines BUFSIZ */ +diff -Paur --no-dereference -- dash.upstream/src/parser.c dash/src/parser.c +--- dash.upstream/src/parser.c ++++ dash/src/parser.c +@@ -32,10 +32,6 @@ + * SUCH DAMAGE. + */ + +-#if HAVE_ALLOCA_H +-#include +-#endif +- + #include + + #include "shell.h" +@@ -1090,10 +1086,12 @@ + if (len) { + char *str; + +- str = alloca(len + 1); ++ str = ckmalloc(len + 1); + *(char *)mempcpy(str, p, len) = 0; + + pushstring(str, NULL); ++ ++ ckfree(str); + } + } + } +@@ -1300,7 +1298,7 @@ + str = NULL; + savelen = out - (char *)stackblock(); + if (savelen > 0) { +- str = alloca(savelen); ++ str = ckmalloc(savelen); + memcpy(str, stackblock(), savelen); + } + if (oldstyle) { +@@ -1400,6 +1398,7 @@ + if (str) { + memcpy(out, str, savelen); + STADJUST(savelen, out); ++ ckfree(str); + } + USTPUTC(CTLBACKQ, out); + if (oldstyle) +diff -Paur --no-dereference -- dash.upstream/src/redir.c dash/src/redir.c +--- dash.upstream/src/redir.c ++++ dash/src/redir.c +@@ -34,7 +34,6 @@ + + #include + #include +-#include /* PIPE_BUF */ + #include + #include + #include +diff -Paur --no-dereference -- dash.upstream/src/shell.h dash/src/shell.h +--- dash.upstream/src/shell.h ++++ dash/src/shell.h +@@ -49,8 +49,6 @@ + * a quit signal will generate a core dump. + */ + +-#include +- + #ifndef JOBS + #define JOBS 1 + #endif diff --git a/ports/dash/dash.port b/ports/dash/dash.port new file mode 100644 index 00000000..c82f3605 --- /dev/null +++ b/ports/dash/dash.port @@ -0,0 +1,10 @@ +NAME=dash +BUILD_LIBRARIES= +VERSION=0.5.7 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=ae89fa9f1145b7748cf0740e1df04cd52fdf8a285da4911dd0f04983efba4e39 +UPSTREAM_SITE='http://gondor.apana.org.au/~herbert/dash/files' +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure diff --git a/ports/diffutils/diffutils.port b/ports/diffutils/diffutils.port new file mode 100644 index 00000000..88d735ed --- /dev/null +++ b/ports/diffutils/diffutils.port @@ -0,0 +1,11 @@ +NAME=diffutils +BUILD_LIBRARIES='libiconv? libintl?' +VERSION=3.8 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=a6bdd7d1b31266d11c4f4de6c1b748d4607ab0231af5188fc2533d0ae2438fec +UPSTREAM_SITE=https://ftp.gnu.org/gnu/diffutils +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' diff --git a/ports/e2fsprogs/e2fsprogs.patch b/ports/e2fsprogs/e2fsprogs.patch new file mode 100644 index 00000000..fa446696 --- /dev/null +++ b/ports/e2fsprogs/e2fsprogs.patch @@ -0,0 +1,1272 @@ +diff -Paur --no-dereference -- e2fsprogs.upstream/config/config.sub e2fsprogs/config/config.sub +--- e2fsprogs.upstream/config/config.sub ++++ e2fsprogs/config/config.sub +@@ -1360,7 +1360,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- e2fsprogs.upstream/config/parse-types.sh e2fsprogs/config/parse-types.sh +--- e2fsprogs.upstream/config/parse-types.sh ++++ e2fsprogs/config/parse-types.sh +@@ -1,5 +1,9 @@ + #!/bin/sh + ++# PATCH: Disable insanity in favor of . ++printf '' > asm_types.h ++exit 0 ++ + cat > sed.script << "EOF" + /^#/d + /^$/d +@@ -19,7 +23,7 @@ + /bin/echo -n "checking for __uNN types... " + # can't check [ -f /usr/include/asm/types.h ] directly, since + # the include path might be different if cross-compiling +-if echo '#include ' | $CPP - 2> parse-types.log | \ ++if echo '#include ' | ${BUILD_CC-${CC-gcc}} -E - 2> parse-types.log | \ + sed -f sed.script | grep '^#' > asm_types.h; then + echo "using " + else +diff -Paur --no-dereference -- e2fsprogs.upstream/e2fsck/journal.c e2fsprogs/e2fsck/journal.c +--- e2fsprogs.upstream/e2fsck/journal.c ++++ e2fsprogs/e2fsck/journal.c +@@ -14,7 +14,6 @@ + + #include "config.h" + #ifdef HAVE_SYS_MOUNT_H +-#include + #include + #define MNT_FL (MS_MGC_VAL | MS_RDONLY) + #endif +diff -Paur --no-dereference -- e2fsprogs.upstream/e2fsck/logfile.c e2fsprogs/e2fsck/logfile.c +--- e2fsprogs.upstream/e2fsck/logfile.c ++++ e2fsprogs/e2fsck/logfile.c +@@ -22,6 +22,36 @@ + + extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */ + ++#if defined(__sortix__) ++int daemon(int nochdir, int noclose) ++{ ++ if (!nochdir && chdir("/")) ++ return -1; ++ if (!noclose) { ++ int fd, failed = 0; ++ if ((fd = open("/dev/null", O_RDWR)) < 0) return -1; ++ if (dup2(fd, 0) < 0 || dup2(fd, 1) < 0 || dup2(fd, 2) < 0) ++ failed++; ++ if (fd > 2) close(fd); ++ if (failed) return -1; ++ } ++ ++ switch(fork()) { ++ case 0: break; ++ case -1: return -1; ++ default: _exit(0); ++ } ++ ++ switch(fork()) { ++ case 0: break; ++ case -1: return -1; ++ default: _exit(0); ++ } ++ ++ return 0; ++} ++#endif ++ + struct string { + char *s; + int len; +diff -Paur --no-dereference -- e2fsprogs.upstream/e2fsck/quota.c e2fsprogs/e2fsck/quota.c +--- e2fsprogs.upstream/e2fsck/quota.c ++++ e2fsprogs/e2fsck/quota.c +@@ -5,7 +5,6 @@ + + #include "config.h" + #ifdef HAVE_SYS_MOUNT_H +-#include + #include + #define MNT_FL (MS_MGC_VAL | MS_RDONLY) + #endif +diff -Paur --no-dereference -- e2fsprogs.upstream/e2fsck/scantest.c e2fsprogs/e2fsck/scantest.c +--- e2fsprogs.upstream/e2fsck/scantest.c ++++ e2fsprogs/e2fsck/scantest.c +@@ -54,7 +54,7 @@ + { + struct rusage r; + +- track->brk_start = sbrk(0); ++ track->brk_start = 0; + gettimeofday(&track->time_start, 0); + getrusage(RUSAGE_SELF, &r); + track->user_start = r.ru_utime; +@@ -77,7 +77,7 @@ + getrusage(RUSAGE_SELF, &r); + + printf(_("Memory used: %d, elapsed time: %6.3f/%6.3f/%6.3f\n"), +- (int) (((char *) sbrk(0)) - ((char *) track->brk_start)), ++ (int) (((char *) 0) - ((char *) track->brk_start)), + timeval_subtract(&time_end, &track->time_start), + timeval_subtract(&r.ru_utime, &track->user_start), + timeval_subtract(&r.ru_stime, &track->system_start)); +diff -Paur --no-dereference -- e2fsprogs.upstream/e2fsck/sigcatcher.c e2fsprogs/e2fsck/sigcatcher.c +--- e2fsprogs.upstream/e2fsck/sigcatcher.c ++++ e2fsprogs/e2fsck/sigcatcher.c +@@ -10,6 +10,7 @@ + */ + + #include "config.h" ++#include + #include + #include + #include +@@ -341,7 +342,7 @@ + fprintf(stderr, "Signal (%d) %s ", signum, + lookup_table_fallback(signum, sig_table)); + if (siginfo->si_code == SI_USER) +- fprintf(stderr, "(sent from pid %u) ", siginfo->si_pid); ++ fprintf(stderr, "(sent from pid %ji) ", (intmax_t) siginfo->si_pid); + cp = lookup_table(siginfo->si_code, generic_code_table); + if (cp) + fprintf(stderr, "si_code=%s ", cp); +diff -Paur --no-dereference -- e2fsprogs.upstream/e2fsck/unix.c e2fsprogs/e2fsck/unix.c +--- e2fsprogs.upstream/e2fsck/unix.c ++++ e2fsprogs/e2fsck/unix.c +@@ -590,8 +590,6 @@ + return 0; + } + +-#define PATH_SET "PATH=/sbin" +- + /* + * Make sure 0,1,2 file descriptors are open, so that we don't open + * the filesystem using the same file descriptor as stdout or stderr. +@@ -1007,21 +1005,21 @@ + if (cflag) { + char *oldpath = getenv("PATH"); + char *newpath; +- int len = sizeof(PATH_SET) + 1; ++ size_t len = strlen("/sbin"); + + if (oldpath) +- len += strlen(oldpath); ++ len += 1 + strlen(oldpath); + +- newpath = malloc(len); ++ newpath = malloc(len + 1); + if (!newpath) + fatal_error(ctx, "Couldn't malloc() newpath"); +- strcpy(newpath, PATH_SET); ++ strcpy(newpath, "/sbin"); + + if (oldpath) { + strcat(newpath, ":"); + strcat(newpath, oldpath); + } +- putenv(newpath); ++ setenv("PATH", newpath, 1); + } + #ifdef CONFIG_JBD_DEBUG + jbd_debug = getenv("E2FSCK_JBD_DEBUG"); +diff -Paur --no-dereference -- e2fsprogs.upstream/e2fsck/util.c e2fsprogs/e2fsck/util.c +--- e2fsprogs.upstream/e2fsck/util.c ++++ e2fsprogs/e2fsck/util.c +@@ -332,7 +332,7 @@ + #endif + io_stats io_start = 0; + +- track->brk_start = sbrk(0); ++ track->brk_start = 0; + gettimeofday(&track->time_start, 0); + #ifdef HAVE_GETRUSAGE + #ifdef sun +@@ -398,7 +398,7 @@ + kbytes(malloc_info.uordblks), kbytes(malloc_info.fordblks)); + #else + log_out(ctx, _("Memory used: %lu, "), +- (unsigned long) (((char *) sbrk(0)) - ++ (unsigned long) (((char *) 0) - + ((char *) track->brk_start))); + #endif + #ifdef HAVE_GETRUSAGE +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/blkid/blkid_types.h.in e2fsprogs/lib/blkid/blkid_types.h.in +--- e2fsprogs.upstream/lib/blkid/blkid_types.h.in ++++ e2fsprogs/lib/blkid/blkid_types.h.in +@@ -7,161 +7,46 @@ + !defined(_EXT2_TYPES_H)) + #define _BLKID_TYPES_H + +-@ASM_TYPES_HEADER@ ++#include + + #ifndef HAVE___U8 + #define HAVE___U8 +-#ifdef __U8_TYPEDEF +-typedef __U8_TYPEDEF __u8; +-#else +-typedef unsigned char __u8; +-#endif ++typedef uint8_t __u8; + #endif /* HAVE___U8 */ + + #ifndef HAVE___S8 + #define HAVE___S8 +-#ifdef __S8_TYPEDEF +-typedef __S8_TYPEDEF __s8; +-#else +-typedef signed char __s8; +-#endif ++typedef int8_t __s8; + #endif /* HAVE___S8 */ + + #ifndef HAVE___U16 + #define HAVE___U16 +-#ifdef __U16_TYPEDEF +-typedef __U16_TYPEDEF __u16; +-#else +-#if (@SIZEOF_INT@ == 2) +-typedef unsigned int __u16; +-#else +-#if (@SIZEOF_SHORT@ == 2) +-typedef unsigned short __u16; +-#else +-#undef HAVE___U16 +- ?==error: undefined 16 bit type +-#endif /* SIZEOF_SHORT == 2 */ +-#endif /* SIZEOF_INT == 2 */ +-#endif /* __U16_TYPEDEF */ ++typedef uint16_t __u16; + #endif /* HAVE___U16 */ + + #ifndef HAVE___S16 + #define HAVE___S16 +-#ifdef __S16_TYPEDEF +-typedef __S16_TYPEDEF __s16; +-#else +-#if (@SIZEOF_INT@ == 2) +-typedef int __s16; +-#else +-#if (@SIZEOF_SHORT@ == 2) +-typedef short __s16; +-#else +-#undef HAVE___S16 +- ?==error: undefined 16 bit type +-#endif /* SIZEOF_SHORT == 2 */ +-#endif /* SIZEOF_INT == 2 */ +-#endif /* __S16_TYPEDEF */ ++typedef int16_t __s16; + #endif /* HAVE___S16 */ + + #ifndef HAVE___U32 + #define HAVE___U32 +-#ifdef __U32_TYPEDEF +-typedef __U32_TYPEDEF __u32; +-#else +-#if (@SIZEOF_INT@ == 4) +-typedef unsigned int __u32; +-#else +-#if (@SIZEOF_LONG@ == 4) +-typedef unsigned long __u32; +-#else +-#if (@SIZEOF_SHORT@ == 4) +-typedef unsigned short __u32; +-#else +-#undef HAVE___U32 +- ?== error: undefined 32 bit type +-#endif /* SIZEOF_SHORT == 4 */ +-#endif /* SIZEOF_LONG == 4 */ +-#endif /* SIZEOF_INT == 4 */ +-#endif /* __U32_TYPEDEF */ ++typedef uint32_t __u32; + #endif /* HAVE___U32 */ + + #ifndef HAVE___S32 + #define HAVE___S32 +-#ifdef __S32_TYPEDEF +-typedef __S32_TYPEDEF __s32; +-#else +-#if (@SIZEOF_INT@ == 4) +-typedef int __s32; +-#else +-#if (@SIZEOF_LONG@ == 4) +-typedef long __s32; +-#else +-#if (@SIZEOF_SHORT@ == 4) +-typedef short __s32; +-#else +-#undef HAVE___S32 +- ?== error: undefined 32 bit type +-#endif /* SIZEOF_SHORT == 4 */ +-#endif /* SIZEOF_LONG == 4 */ +-#endif /* SIZEOF_INT == 4 */ +-#endif /* __S32_TYPEDEF */ ++typedef int32_t __s32; + #endif /* HAVE___S32 */ + + #ifndef HAVE___U64 + #define HAVE___U64 +-#ifdef __U64_TYPEDEF +-typedef __U64_TYPEDEF __u64; +-#else +-#if (@SIZEOF_INT@ == 8) +-typedef unsigned int __u64; +-#else +-#if (@SIZEOF_LONG_LONG@ == 8) +-typedef unsigned long long __u64; +-#else +-#if (@SIZEOF_LONG@ == 8) +-typedef unsigned long __u64; +-#else +-#undef HAVE___U64 +- ?== error: undefined 64 bit type +-#endif /* SIZEOF_LONG == 8 */ +-#endif /* SIZEOF_LONG_LONG == 8 */ +-#endif /* SIZEOF_INT == 8 */ +-#endif /* __U64_TYPEDEF */ ++typedef unsigned long long __u64; /* Uses %llu instead of PRIu64... */ + #endif /* HAVE___U64 */ + + #ifndef HAVE___S64 + #define HAVE___S64 +-#ifdef __S64_TYPEDEF +-typedef __S64_TYPEDEF __s64; +-#else +-#if (@SIZEOF_INT@ == 8) +-typedef int __s64; +-#else +-#if (@SIZEOF_LONG_LONG@ == 8) +-#if defined(__GNUC__) +-typedef __signed__ long long __s64; +-#else +-typedef signed long long __s64; +-#endif /* __GNUC__ */ +-#else +-#if (@SIZEOF_LONG@ == 8) +-typedef long __s64; +-#else +-#undef HAVE___S64 +- ?== error: undefined 64 bit type +-#endif /* SIZEOF_LONG == 8 */ +-#endif /* SIZEOF_LONG_LONG == 8 */ +-#endif /* SIZEOF_INT == 8 */ +-#endif /* __S64_TYPEDEF */ ++typedef long long __s64; /* Uses %lld instead of PRId64... */ + #endif /* HAVE___S64 */ + +-#undef __S8_TYPEDEF +-#undef __U8_TYPEDEF +-#undef __S16_TYPEDEF +-#undef __U16_TYPEDEF +-#undef __S32_TYPEDEF +-#undef __U32_TYPEDEF +-#undef __S64_TYPEDEF +-#undef __U64_TYPEDEF +- + #endif /* _*_TYPES_H */ +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/blkid/devname.c e2fsprogs/lib/blkid/devname.c +--- e2fsprogs.upstream/lib/blkid/devname.c ++++ e2fsprogs/lib/blkid/devname.c +@@ -40,6 +40,10 @@ + + #include "blkidP.h" + ++#if defined(__sortix__) ++#define makedev(a, b) 0 ++#endif ++ + /* + * Find a dev struct in the cache by device name, if available. + * +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/e2p/fgetversion.c e2fsprogs/lib/e2p/fgetversion.c +--- e2fsprogs.upstream/lib/e2p/fgetversion.c ++++ e2fsprogs/lib/e2p/fgetversion.c +@@ -61,7 +61,6 @@ + return(err); + #endif + #else /* ! HAVE_EXT2_IOCTLS */ +- extern int errno; + errno = EOPNOTSUPP; + return -1; + #endif /* ! HAVE_EXT2_IOCTLS */ +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/e2p/fsetversion.c e2fsprogs/lib/e2p/fsetversion.c +--- e2fsprogs.upstream/lib/e2p/fsetversion.c ++++ e2fsprogs/lib/e2p/fsetversion.c +@@ -59,7 +59,6 @@ + return syscall(SYS_fsctl, name, EXT2_IOC_SETVERSION, &ver, 0); + #endif + #else /* ! HAVE_EXT2_IOCTLS */ +- extern int errno; + errno = EOPNOTSUPP; + return -1; + #endif /* ! HAVE_EXT2_IOCTLS */ +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/e2p/getversion.c e2fsprogs/lib/e2p/getversion.c +--- e2fsprogs.upstream/lib/e2p/getversion.c ++++ e2fsprogs/lib/e2p/getversion.c +@@ -33,7 +33,6 @@ + *version = ver; + return r; + #else /* ! HAVE_EXT2_IOCTLS */ +- extern int errno; + errno = EOPNOTSUPP; + return -1; + #endif /* ! HAVE_EXT2_IOCTLS */ +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/e2p/setversion.c e2fsprogs/lib/e2p/setversion.c +--- e2fsprogs.upstream/lib/e2p/setversion.c ++++ e2fsprogs/lib/e2p/setversion.c +@@ -32,7 +32,6 @@ + ver = (int) version; + return ioctl (fd, EXT2_IOC_SETVERSION, &ver); + #else /* ! HAVE_EXT2_IOCTLS */ +- extern int errno; + errno = EOPNOTSUPP; + return -1; + #endif /* ! HAVE_EXT2_IOCTLS */ +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/et/com_err.c e2fsprogs/lib/et/com_err.c +--- e2fsprogs.upstream/lib/et/com_err.c ++++ e2fsprogs/lib/et/com_err.c +@@ -23,6 +23,10 @@ + #include "error_table.h" + #include "internal.h" + ++#if !defined(ONLCR) ++#define ONLCR 0 ++#endif ++ + static void + default_com_err_proc (const char *whoami, errcode_t code, const + char *fmt, va_list args) +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ext2fs/bitmaps.c e2fsprogs/lib/ext2fs/bitmaps.c +--- e2fsprogs.upstream/lib/ext2fs/bitmaps.c ++++ e2fsprogs/lib/ext2fs/bitmaps.c +@@ -21,6 +21,7 @@ + #if HAVE_SYS_STAT_H + #include + #endif ++#include + #if HAVE_SYS_TYPES_H + #include + #endif +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ext2fs/blkmap64_ba.c e2fsprogs/lib/ext2fs/blkmap64_ba.c +--- e2fsprogs.upstream/lib/ext2fs/blkmap64_ba.c ++++ e2fsprogs/lib/ext2fs/blkmap64_ba.c +@@ -20,6 +20,7 @@ + #if HAVE_SYS_STAT_H + #include + #endif ++#include + #if HAVE_SYS_TYPES_H + #include + #endif +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ext2fs/blkmap64_rb.c e2fsprogs/lib/ext2fs/blkmap64_rb.c +--- e2fsprogs.upstream/lib/ext2fs/blkmap64_rb.c ++++ e2fsprogs/lib/ext2fs/blkmap64_rb.c +@@ -19,6 +19,7 @@ + #if HAVE_SYS_STAT_H + #include + #endif ++#include + #if HAVE_SYS_TYPES_H + #include + #endif +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ext2fs/ext2_types.h.in e2fsprogs/lib/ext2fs/ext2_types.h.in +--- e2fsprogs.upstream/lib/ext2fs/ext2_types.h.in ++++ e2fsprogs/lib/ext2fs/ext2_types.h.in +@@ -7,163 +7,48 @@ + !defined(_EXT2_TYPES_H)) + #define _EXT2_TYPES_H + +-@ASM_TYPES_HEADER@ ++#include + + #ifndef HAVE___U8 + #define HAVE___U8 +-#ifdef __U8_TYPEDEF +-typedef __U8_TYPEDEF __u8; +-#else +-typedef unsigned char __u8; +-#endif ++typedef uint8_t __u8; + #endif /* HAVE___U8 */ + + #ifndef HAVE___S8 + #define HAVE___S8 +-#ifdef __S8_TYPEDEF +-typedef __S8_TYPEDEF __s8; +-#else +-typedef signed char __s8; +-#endif ++typedef int8_t __s8; + #endif /* HAVE___S8 */ + + #ifndef HAVE___U16 + #define HAVE___U16 +-#ifdef __U16_TYPEDEF +-typedef __U16_TYPEDEF __u16; +-#else +-#if (@SIZEOF_INT@ == 2) +-typedef unsigned int __u16; +-#else +-#if (@SIZEOF_SHORT@ == 2) +-typedef unsigned short __u16; +-#else +-#undef HAVE___U16 +- ?==error: undefined 16 bit type +-#endif /* SIZEOF_SHORT == 2 */ +-#endif /* SIZEOF_INT == 2 */ +-#endif /* __U16_TYPEDEF */ ++typedef uint16_t __u16; + #endif /* HAVE___U16 */ + + #ifndef HAVE___S16 + #define HAVE___S16 +-#ifdef __S16_TYPEDEF +-typedef __S16_TYPEDEF __s16; +-#else +-#if (@SIZEOF_INT@ == 2) +-typedef int __s16; +-#else +-#if (@SIZEOF_SHORT@ == 2) +-typedef short __s16; +-#else +-#undef HAVE___S16 +- ?==error: undefined 16 bit type +-#endif /* SIZEOF_SHORT == 2 */ +-#endif /* SIZEOF_INT == 2 */ +-#endif /* __S16_TYPEDEF */ ++typedef int16_t __s16; + #endif /* HAVE___S16 */ + + #ifndef HAVE___U32 + #define HAVE___U32 +-#ifdef __U32_TYPEDEF +-typedef __U32_TYPEDEF __u32; +-#else +-#if (@SIZEOF_INT@ == 4) +-typedef unsigned int __u32; +-#else +-#if (@SIZEOF_LONG@ == 4) +-typedef unsigned long __u32; +-#else +-#if (@SIZEOF_SHORT@ == 4) +-typedef unsigned short __u32; +-#else +-#undef HAVE___U32 +- ?== error: undefined 32 bit type +-#endif /* SIZEOF_SHORT == 4 */ +-#endif /* SIZEOF_LONG == 4 */ +-#endif /* SIZEOF_INT == 4 */ +-#endif /* __U32_TYPEDEF */ ++typedef uint32_t __u32; + #endif /* HAVE___U32 */ + + #ifndef HAVE___S32 + #define HAVE___S32 +-#ifdef __S32_TYPEDEF +-typedef __S32_TYPEDEF __s32; +-#else +-#if (@SIZEOF_INT@ == 4) +-typedef int __s32; +-#else +-#if (@SIZEOF_LONG@ == 4) +-typedef long __s32; +-#else +-#if (@SIZEOF_SHORT@ == 4) +-typedef short __s32; +-#else +-#undef HAVE___S32 +- ?== error: undefined 32 bit type +-#endif /* SIZEOF_SHORT == 4 */ +-#endif /* SIZEOF_LONG == 4 */ +-#endif /* SIZEOF_INT == 4 */ +-#endif /* __S32_TYPEDEF */ ++typedef int32_t __s32; + #endif /* HAVE___S32 */ + + #ifndef HAVE___U64 + #define HAVE___U64 +-#ifdef __U64_TYPEDEF +-typedef __U64_TYPEDEF __u64; +-#else +-#if (@SIZEOF_INT@ == 8) +-typedef unsigned int __u64; +-#else +-#if (@SIZEOF_LONG_LONG@ == 8) +-typedef unsigned long long __u64; +-#else +-#if (@SIZEOF_LONG@ == 8) +-typedef unsigned long __u64; +-#else +-#undef HAVE___U64 +- ?== error: undefined 64 bit type +-#endif /* SIZEOF_LONG_LONG == 8 */ +-#endif /* SIZEOF_LONG == 8 */ +-#endif /* SIZEOF_INT == 8 */ +-#endif /* __U64_TYPEDEF */ ++typedef unsigned long long __u64; /* Uses %llu instead of PRIu64... */ + #endif /* HAVE___U64 */ + + #ifndef HAVE___S64 + #define HAVE___S64 +-#ifdef __S64_TYPEDEF +-typedef __S64_TYPEDEF __s64; +-#else +-#if (@SIZEOF_INT@ == 8) +-typedef int __s64; +-#else +-#if (@SIZEOF_LONG_LONG@ == 8) +-#if defined(__GNUC__) +-typedef __signed__ long long __s64; +-#else +-typedef signed long long __s64; +-#endif /* __GNUC__ */ +-#else +-#if (@SIZEOF_LONG@ == 8) +-typedef long __s64; +-#else +-#undef HAVE___S64 +- ?== error: undefined 64 bit type +-#endif /* SIZEOF_LONG_LONG == 8 */ +-#endif /* SIZEOF_LONG == 8 */ +-#endif /* SIZEOF_INT == 8 */ +-#endif /* __S64_TYPEDEF */ ++typedef long long __s64; /* Uses %lld instead of PRId64... */ + #endif /* HAVE___S64 */ + +-#undef __S8_TYPEDEF +-#undef __U8_TYPEDEF +-#undef __S16_TYPEDEF +-#undef __U16_TYPEDEF +-#undef __S32_TYPEDEF +-#undef __U32_TYPEDEF +-#undef __S64_TYPEDEF +-#undef __U64_TYPEDEF +- + #endif /* _*_TYPES_H */ + + @PUBLIC_CONFIG_HEADER@ +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ext2fs/flushb.c e2fsprogs/lib/ext2fs/flushb.c +--- e2fsprogs.upstream/lib/ext2fs/flushb.c ++++ e2fsprogs/lib/ext2fs/flushb.c +@@ -22,7 +22,6 @@ + #include + #endif + #if HAVE_SYS_MOUNT_H +-#include + #include /* This may define BLKFLSBUF */ + #endif + +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ext2fs/getsize.c e2fsprogs/lib/ext2fs/getsize.c +--- e2fsprogs.upstream/lib/ext2fs/getsize.c ++++ e2fsprogs/lib/ext2fs/getsize.c +@@ -237,13 +237,22 @@ + { + ext2fs_struct_stat st; + +- if (ext2fs_fstat(fd, &st) == 0) ++ if (ext2fs_fstat(fd, &st) == 0) { ++#if !defined(__sortix__) + if (S_ISREG(st.st_mode)) { ++#endif + *retblocks = st.st_size / blocksize; + goto out; ++#if !defined(__sortix__) + } ++#endif ++ } + } + ++#if defined(__sortix__) ++ /* This fallback seems to get one block too few on Sortix. fstat reports ++ correctly on block devices on Sortix. That's why we always use fstat. */ ++#endif + /* + * OK, we couldn't figure it out by using a specialized ioctl, + * which is generally the best way. So do binary search to +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ext2fs/mmp.c e2fsprogs/lib/ext2fs/mmp.c +--- e2fsprogs.upstream/lib/ext2fs/mmp.c ++++ e2fsprogs/lib/ext2fs/mmp.c +@@ -122,29 +122,9 @@ + return retval; + } + +-#ifdef HAVE_SRANDOM +-#define srand(x) srandom(x) +-#define rand() random() +-#endif +- + unsigned ext2fs_mmp_new_seq(void) + { +- unsigned new_seq; +- struct timeval tv; +- +- gettimeofday(&tv, 0); +- srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec); +- +- gettimeofday(&tv, 0); +- /* Crank the random number generator a few times */ +- for (new_seq = (tv.tv_sec ^ tv.tv_usec) & 0x1F; new_seq > 0; new_seq--) +- rand(); +- +- do { +- new_seq = rand(); +- } while (new_seq > EXT4_MMP_SEQ_MAX); +- +- return new_seq; ++ return arc4random_uniform(EXT4_MMP_SEQ_MAX); + } + + static errcode_t ext2fs_mmp_reset(ext2_filsys fs) +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ext2fs/tdb.c e2fsprogs/lib/ext2fs/tdb.c +--- e2fsprogs.upstream/lib/ext2fs/tdb.c ++++ e2fsprogs/lib/ext2fs/tdb.c +@@ -56,13 +56,30 @@ + #include + #endif + #include +-#include + #include + + #ifdef HAVE_SYS_MMAN_H + #include + #endif + ++#if defined(__sortix__) ++#define F_UNLCK 0 ++#define F_RDLCK 1 ++#define F_WRLCK 2 ++#define F_GETLK 1000 ++#define F_SETLK 1001 ++#define F_SETLKW 1002 ++struct flock ++{ ++ short l_type; ++ short l_whence; ++ off_t l_start; ++ off_t l_len; ++ pid_t l_pid; ++}; ++#define fcntl(...) 0 ++#endif ++ + #ifndef MAP_FILE + #define MAP_FILE 0 + #endif +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/quota/quotaio.c e2fsprogs/lib/quota/quotaio.c +--- e2fsprogs.upstream/lib/quota/quotaio.c ++++ e2fsprogs/lib/quota/quotaio.c +@@ -14,7 +14,6 @@ + #include + #include + #include +-#include + + #include "common.h" + #include "quotaio.h" +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ss/help.c e2fsprogs/lib/ss/help.c +--- e2fsprogs.upstream/lib/ss/help.c ++++ e2fsprogs/lib/ss/help.c +@@ -24,9 +24,7 @@ + extern int errno; + #endif + #include +-#include + #include +-#include + #ifdef NEED_SYS_FCNTL_H + /* just for O_* */ + #include +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ss/listen.c e2fsprogs/lib/ss/listen.c +--- e2fsprogs.upstream/lib/ss/listen.c ++++ e2fsprogs/lib/ss/listen.c +@@ -21,7 +21,6 @@ + #include + #include + #include +-#include + + typedef void sigret_t; + +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/ss/pager.c e2fsprogs/lib/ss/pager.c +--- e2fsprogs.upstream/lib/ss/pager.c ++++ e2fsprogs/lib/ss/pager.c +@@ -27,7 +27,6 @@ + #include "ss_internal.h" + #include + #include +-#include + #include + #ifdef HAVE_SYS_PRCTL_H + #include +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/uuid/gen_uuid.c e2fsprogs/lib/uuid/gen_uuid.c +--- e2fsprogs.upstream/lib/uuid/gen_uuid.c ++++ e2fsprogs/lib/uuid/gen_uuid.c +@@ -95,9 +95,22 @@ + #include "uuidP.h" + #include "uuidd.h" + +-#ifdef HAVE_SRANDOM +-#define srand(x) srandom(x) +-#define rand() random() ++#if defined(__sortix__) ++#define F_UNLCK 0 ++#define F_RDLCK 1 ++#define F_WRLCK 2 ++#define F_GETLK 1000 ++#define F_SETLK 1001 ++#define F_SETLKW 1002 ++struct flock ++{ ++ short l_type; ++ short l_whence; ++ off_t l_start; ++ off_t l_len; ++ pid_t l_pid; ++}; ++#define fcntl(...) 0 + #endif + + #ifdef TLS +@@ -135,82 +148,12 @@ + } + #endif + +-static int get_random_fd(void) +-{ +- struct timeval tv; +- static int fd = -2; +- int i; +- +- if (fd == -2) { +- gettimeofday(&tv, 0); +-#ifndef _WIN32 +- fd = open("/dev/urandom", O_RDONLY); +- if (fd == -1) +- fd = open("/dev/random", O_RDONLY | O_NONBLOCK); +- if (fd >= 0) { +- i = fcntl(fd, F_GETFD); +- if (i >= 0) +- fcntl(fd, F_SETFD, i | FD_CLOEXEC); +- } +-#endif +- srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec); +-#ifdef DO_JRAND_MIX +- jrand_seed[0] = getpid() ^ (tv.tv_sec & 0xFFFF); +- jrand_seed[1] = getppid() ^ (tv.tv_usec & 0xFFFF); +- jrand_seed[2] = (tv.tv_sec ^ tv.tv_usec) >> 16; +-#endif +- } +- /* Crank the random number generator a few times */ +- gettimeofday(&tv, 0); +- for (i = (tv.tv_sec ^ tv.tv_usec) & 0x1F; i > 0; i--) +- rand(); +- return fd; +-} +- +- + /* +- * Generate a series of random bytes. Use /dev/urandom if possible, +- * and if not, use srandom/random. ++ * Generate a series of random bytes. + */ +-static void get_random_bytes(void *buf, int nbytes) ++static void get_random_bytes(void *buf, size_t nbytes) + { +- int i, n = nbytes, fd = get_random_fd(); +- int lose_counter = 0; +- unsigned char *cp = buf; +- +- if (fd >= 0) { +- while (n > 0) { +- i = read(fd, cp, n); +- if (i <= 0) { +- if (lose_counter++ > 16) +- break; +- continue; +- } +- n -= i; +- cp += i; +- lose_counter = 0; +- } +- } +- +- /* +- * We do this all the time, but this is the only source of +- * randomness if /dev/random/urandom is out to lunch. +- */ +- for (cp = buf, i = 0; i < nbytes; i++) +- *cp++ ^= (rand() >> 7) & 0xFF; +-#ifdef DO_JRAND_MIX +- { +- unsigned short tmp_seed[3]; +- +- memcpy(tmp_seed, jrand_seed, sizeof(tmp_seed)); +- jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid); +- for (cp = buf, i = 0; i < nbytes; i++) +- *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF; +- memcpy(jrand_seed, tmp_seed, +- sizeof(jrand_seed) - sizeof(unsigned short)); +- } +-#endif +- ++ arc4random_buf(buf, nbytes); + return; + } + +@@ -224,7 +167,9 @@ + */ + static int get_node_id(unsigned char *node_id) + { +-#ifdef HAVE_NET_IF_H ++#if defined(HAVE_NET_IF_H) && (defined(SIOCGIFHWADDR) || \ ++ defined(SIOCGENADDR) || \ ++ defined(HAVE_NET_IF_DL_H)) + int sd; + struct ifreq ifr, *ifrp; + struct ifconf ifc; +@@ -403,8 +348,8 @@ + if (state_fd > 0) { + rewind(state_f); + len = fprintf(state_f, +- "clock: %04x tv: %016lu %08lu adj: %08d\n", +- clock_seq, last.tv_sec, (long)last.tv_usec, ++ "clock: %04x tv: %016lld %08lu adj: %08d\n", ++ clock_seq, (long long) last.tv_sec, (long)last.tv_usec, + adjustment); + fflush(state_f); + if (ftruncate(state_fd, len) < 0) { +@@ -665,14 +610,10 @@ + + /* + * This is the generic front-end to uuid_generate_random and +- * uuid_generate_time. It uses uuid_generate_random only if +- * /dev/urandom is available, since otherwise we won't have +- * high-quality randomness. ++ * uuid_generate_time. It uses uuid_generate_random only, ++ * because good randomness is always available. + */ + void uuid_generate(uuid_t out) + { +- if (get_random_fd() >= 0) +- uuid_generate_random(out); +- else +- uuid_generate_time(out); ++ uuid_generate_random(out); + } +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/uuid/tst_uuid.c e2fsprogs/lib/uuid/tst_uuid.c +--- e2fsprogs.upstream/lib/uuid/tst_uuid.c ++++ e2fsprogs/lib/uuid/tst_uuid.c +@@ -143,8 +143,8 @@ + tv.tv_sec = 0; + tv.tv_usec = 0; + time_reg = uuid_time(buf, &tv); +- printf("UUID generated at %lu reports %lu (%ld.%ld)\n", +- time_gen, time_reg, tv.tv_sec, (long)tv.tv_usec); ++ printf("UUID generated at %llu reports %llu (%lld.%ld)\n", ++ (long long) time_gen, (long long) time_reg, (long long) tv.tv_sec, (long)tv.tv_usec); + /* allow 1s margin in case of rollover between sampling + * the current time and when the UUID is generated. */ + if (time_reg > time_gen + 1) { +diff -Paur --no-dereference -- e2fsprogs.upstream/lib/uuid/uuid_time.c e2fsprogs/lib/uuid/uuid_time.c +--- e2fsprogs.upstream/lib/uuid/uuid_time.c ++++ e2fsprogs/lib/uuid/uuid_time.c +@@ -165,7 +165,7 @@ + printf("Warning: not a time-based UUID, so UUID time " + "decoding will likely not work!\n"); + } +- printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, (long)tv.tv_usec, ++ printf("UUID time is: (%lld, %ld): %s\n", (long long) tv.tv_sec, (long)tv.tv_usec, + ctime(&time_reg)); + + return 0; +diff -Paur --no-dereference -- e2fsprogs.upstream/Makefile.in e2fsprogs/Makefile.in +--- e2fsprogs.upstream/Makefile.in ++++ e2fsprogs/Makefile.in +@@ -117,6 +117,10 @@ + distclean: distclean-doc distclean-recursive + $(RM) -rf autom4te.cache e2fsprogs.spec ext2ed/Makefile po/stamp-po + $(MAKE) distclean-local ++ $(RM) -f parse-types.log ++ $(RM) -f public_config.h ++ $(RM) -f util/install-symlink ++ $(RM) -f asm_types.h + + realclean: realclean-recursive realclean-local + +diff -Paur --no-dereference -- e2fsprogs.upstream/misc/badblocks.c e2fsprogs/misc/badblocks.c +--- e2fsprogs.upstream/misc/badblocks.c ++++ e2fsprogs/misc/badblocks.c +@@ -322,7 +322,7 @@ + + if (pattern == (unsigned int) ~0) { + for (ptr = buffer; ptr < buffer + n; ptr++) { +- (*ptr) = random() % (1 << (8 * sizeof(char))); ++ (*ptr) = arc4random_uniform(1 << (8 * sizeof(char))); + } + if (s_flag | v_flag) + fputs(_("Testing with random pattern: "), stderr); +@@ -1068,7 +1068,6 @@ + textdomain(NLS_CAT_NAME); + set_com_err_gettext(gettext); + #endif +- srandom((unsigned int)time(NULL)); /* simple randomness is enough */ + test_func = test_ro; + + /* Determine the system page size if possible */ +diff -Paur --no-dereference -- e2fsprogs.upstream/misc/chattr.c e2fsprogs/misc/chattr.c +--- e2fsprogs.upstream/misc/chattr.c ++++ e2fsprogs/misc/chattr.c +@@ -31,7 +31,6 @@ + #ifdef HAVE_ERRNO_H + #include + #endif +-#include + #include + #include "ext2fs/ext2_fs.h" + +diff -Paur --no-dereference -- e2fsprogs.upstream/misc/logsave.c e2fsprogs/misc/logsave.c +--- e2fsprogs.upstream/misc/logsave.c ++++ e2fsprogs/misc/logsave.c +@@ -319,7 +319,9 @@ + outfn); + exit(rc); + } ++#if !defined(__sortix__) + setsid(); /* To avoid getting killed by init */ ++#endif + while (outfd < 0) { + outfd = open(outfn, openflags, 0644); + sleep(1); +diff -Paur --no-dereference -- e2fsprogs.upstream/misc/lsattr.c e2fsprogs/misc/lsattr.c +--- e2fsprogs.upstream/misc/lsattr.c ++++ e2fsprogs/misc/lsattr.c +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + #include + + #include "ext2fs/ext2_fs.h" +diff -Paur --no-dereference -- e2fsprogs.upstream/misc/mke2fs.c e2fsprogs/misc/mke2fs.c +--- e2fsprogs.upstream/misc/mke2fs.c ++++ e2fsprogs/misc/mke2fs.c +@@ -19,6 +19,7 @@ + #define _XOPEN_SOURCE 600 /* for inclusion of PATH_MAX in Solaris */ + + #include "config.h" ++#include + #include + #include + #include +@@ -49,6 +50,9 @@ + #include + #include + #include ++#if defined(__sortix__) ++#define sync() 0 ++#endif + #include + + #include "ext2fs/ext2_fs.h" +@@ -660,7 +664,7 @@ + 100.0 * ext2fs_r_blocks_count(s) / ext2fs_blocks_count(s)); + printf(_("First data block=%u\n"), s->s_first_data_block); + if (root_uid != 0 || root_gid != 0) +- printf(_("Root directory owner=%u:%u\n"), root_uid, root_gid); ++ printf(_("Root directory owner=%ju:%ju\n"), (uintmax_t) root_uid, (uintmax_t) root_gid); + if (s->s_reserved_gdt_blocks) + printf(_("Maximum filesystem blocks=%lu\n"), + (s->s_reserved_gdt_blocks + fs->desc_blocks) * +@@ -727,8 +731,6 @@ + return 1; + } + +-#define PATH_SET "PATH=/sbin" +- + static void parse_extended_opts(struct ext2_super_block *param, + const char *opts) + { +@@ -1439,24 +1441,24 @@ + char *fs_features = 0; + int use_bsize; + char *newpath; +- int pathlen = sizeof(PATH_SET) + 1; ++ size_t pathlen = strlen("/sbin"); + + if (oldpath) +- pathlen += strlen(oldpath); +- newpath = malloc(pathlen); ++ pathlen += 1 + strlen(oldpath); ++ newpath = malloc(pathlen + 1); + if (!newpath) { + fprintf(stderr, "%s", + _("Couldn't allocate memory for new PATH.\n")); + exit(1); + } +- strcpy(newpath, PATH_SET); ++ strcpy(newpath, "/sbin"); + + /* Update our PATH to include /sbin */ + if (oldpath) { + strcat (newpath, ":"); + strcat (newpath, oldpath); + } +- putenv (newpath); ++ setenv("PATH", newpath, 1); + + tmp = getenv("MKE2FS_SYNC"); + if (tmp) +diff -Paur --no-dereference -- e2fsprogs.upstream/misc/mke2fs.conf.in e2fsprogs/misc/mke2fs.conf.in +--- e2fsprogs.upstream/misc/mke2fs.conf.in ++++ e2fsprogs/misc/mke2fs.conf.in +@@ -1,5 +1,6 @@ + [defaults] +- base_features = sparse_super,large_file,filetype,resize_inode,dir_index,ext_attr ++ #base_features = sparse_super,large_file,filetype,resize_inode,dir_index,ext_attr ++ base_features = large_file,filetype + default_mntopts = acl,user_xattr + enable_periodic_fsck = 0 + blocksize = 4096 +diff -Paur --no-dereference -- e2fsprogs.upstream/misc/mklost+found.c e2fsprogs/misc/mklost+found.c +--- e2fsprogs.upstream/misc/mklost+found.c ++++ e2fsprogs/misc/mklost+found.c +@@ -20,7 +20,6 @@ + #include + #include + #include +-#include + #include + + #include "ext2fs/ext2_fs.h" +diff -Paur --no-dereference -- e2fsprogs.upstream/misc/uuidd.c e2fsprogs/misc/uuidd.c +--- e2fsprogs.upstream/misc/uuidd.c ++++ e2fsprogs/misc/uuidd.c +@@ -12,6 +12,7 @@ + #define _GNU_SOURCE /* for setres[ug]id() */ + + #include "config.h" ++#include + #include + #ifdef HAVE_STDLIB_H + #include +@@ -33,6 +34,23 @@ + extern char *optarg; + extern int optind; + #endif ++#if defined(__sortix__) ++#define F_UNLCK 0 ++#define F_RDLCK 1 ++#define F_WRLCK 2 ++#define F_GETLK 1000 ++#define F_SETLK 1001 ++#define F_SETLKW 1002 ++struct flock ++{ ++ short l_type; ++ short l_whence; ++ off_t l_start; ++ off_t l_len; ++ pid_t l_pid; ++}; ++#define fcntl(...) 0 ++#endif + #include "uuid/uuid.h" + #include "uuid/uuidd.h" + #include "nls-enable.h" +@@ -81,10 +99,12 @@ + open("/dev/null", O_RDWR); + + if (chdir("/")) {} /* Silence warn_unused_result warning */ ++#if !defined(__sortix__) + (void) setsid(); + euid = geteuid(); + if (setreuid(euid, euid) < 0) + die("setreuid"); ++#endif + } + + static ssize_t read_all(int fd, char *buf, size_t count) +@@ -328,7 +348,7 @@ + signal(SIGALRM, terminate_intr); + signal(SIGPIPE, SIG_IGN); + +- sprintf(reply_buf, "%8d\n", getpid()); ++ sprintf(reply_buf, "%8jd\n", (intmax_t) getpid()); + if (ftruncate(fd_pidfile, 0)) {} /* Silence warn_unused_result */ + write_all(fd_pidfile, reply_buf, strlen(reply_buf)); + if (fd_pidfile > 1) +@@ -366,7 +386,7 @@ + + switch(op) { + case UUIDD_OP_GETPID: +- sprintf(reply_buf, "%d", getpid()); ++ sprintf(reply_buf, "%jd", (intmax_t) getpid()); + reply_len = strlen(reply_buf)+1; + break; + case UUIDD_OP_GET_MAXOP: +@@ -515,17 +535,21 @@ + if (setresgid(gid, gid, gid) < 0) + die("setresgid"); + #else ++#if !defined(__sortix__) + if (setregid(gid, gid) < 0) + die("setregid"); + #endif ++#endif + + #ifdef HAVE_SETRESUID + if (setresuid(uid, uid, uid) < 0) + die("setresuid"); + #else ++#if !defined(__sortix__) + if (setreuid(uid, uid) < 0) + die("setreuid"); + #endif ++#endif + } + if (num && do_type) { + ret = call_daemon(socket_path, do_type+2, buf, +diff -Paur --no-dereference -- e2fsprogs.upstream/resize/resource_track.c e2fsprogs/resize/resource_track.c +--- e2fsprogs.upstream/resize/resource_track.c ++++ e2fsprogs/resize/resource_track.c +@@ -27,7 +27,7 @@ + io_stats io_start = 0; + + track->desc = desc; +- track->brk_start = sbrk(0); ++ track->brk_start = 0; + gettimeofday(&track->time_start, 0); + #ifdef HAVE_GETRUSAGE + #ifdef sun +@@ -85,7 +85,7 @@ + kbytes(malloc_info.uordblks), kbytes(malloc_info.fordblks)); + #else + printf("Memory used: %lu, ", +- (unsigned long) (((char *) sbrk(0)) - ++ (unsigned long) (((char *) 0) - + ((char *) track->brk_start))); + #endif + #ifdef HAVE_GETRUSAGE +diff -Paur --no-dereference -- e2fsprogs.upstream/util/subst.c e2fsprogs/util/subst.c +--- e2fsprogs.upstream/util/subst.c ++++ e2fsprogs/util/subst.c +@@ -382,13 +382,8 @@ + if (fd > 0) { + /* save the original atime, if possible */ + if (fstat(fd, &stbuf) == 0) { +-#if HAVE_STRUCT_STAT_ST_ATIM + tv[0].tv_sec = stbuf.st_atim.tv_sec; + tv[0].tv_usec = stbuf.st_atim.tv_nsec / 1000; +-#else +- tv[0].tv_sec = stbuf.st_atime; +- tv[0].tv_usec = 0; +-#endif + got_atime = 1; + } + old = fdopen(fd, "r"); diff --git a/ports/e2fsprogs/e2fsprogs.port b/ports/e2fsprogs/e2fsprogs.port new file mode 100644 index 00000000..7fd302a0 --- /dev/null +++ b/ports/e2fsprogs/e2fsprogs.port @@ -0,0 +1,15 @@ +NAME=e2fsprogs +BUILD_LIBRARIES='libiconv gettext' +VERSION=1.42.13 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=e16474b5a3a30f9197160c4b91bd48d5a463583049c0fcc405b6f0f7075aa0c7 +UPSTREAM_SITE=https://kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v$VERSION +UPSTREAM_ARCHIVE=$ARCHIVE +# Requires gettext (otherwise bundled copy is used) +BUILD_SYSTEM=configure +CONFIGURE_ARGS=--disable-e2initrd-helper +MAKE_ARGS='RDYNAMIC= V=1' +RELEASE_SEARCH_PAGE=https://mirrors.edge.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/ +RELEASE_SEARCH_REGEX='v([0-9]+\.[0-9]+(\.[0-9]+)*)/' diff --git a/ports/e2fsprogs/e2fsprogs.rmpatch b/ports/e2fsprogs/e2fsprogs.rmpatch new file mode 100644 index 00000000..c3f37586 --- /dev/null +++ b/ports/e2fsprogs/e2fsprogs.rmpatch @@ -0,0 +1 @@ +rm -rf -- 'e2fsprogs.spec' diff --git a/ports/ed/ed.patch b/ports/ed/ed.patch new file mode 100644 index 00000000..dfd74855 --- /dev/null +++ b/ports/ed/ed.patch @@ -0,0 +1,64 @@ +diff -Paur --no-dereference -- ed.upstream/main.c ed/main.c +--- ed.upstream/main.c ++++ ed/main.c +@@ -60,6 +60,10 @@ + + #include "ed.h" + ++#if defined(__sortix__) && !defined(PATH_MAX) ++#define PATH_MAX 4096 ++#endif ++ + void signal_hup(int); + void signal_int(int); + void handle_winch(int); +@@ -129,8 +133,10 @@ + int c, n; + int status = 0; + ++#if 0 + if (pledge("stdio rpath wpath cpath proc exec tty", NULL) == -1) + err(1, "pledge"); ++#endif + + home = getenv("HOME"); + +diff -Paur --no-dereference -- ed.upstream/Makefile ed/Makefile +--- ed.upstream/Makefile ++++ ed/Makefile +@@ -0,0 +1,35 @@ ++include ../../../build-aux/platform.mak ++include ../../../build-aux/compiler.mak ++include ../../../build-aux/version.mak ++include ../../../build-aux/dirs.mak ++ ++OPTLEVEL?=$(DEFAULT_OPTLEVEL) ++CFLAGS?=$(OPTLEVEL) ++ ++CFLAGS:=$(CXXFLAGS) -Wall -Wextra -Wno-logical-not-parentheses -Wno-unused-parameter ++CPPFLAGS:=$(CPPFLAGS) -DBACKWARDS ++ ++PROGRAM=ed ++MANPAGE=ed.1 ++ ++OBJS=buf.o glbl.o io.o main.o re.o sub.o undo.o ++ ++.PHONY: all ++all: $(PROGRAM) ++ ++$(PROGRAM): $(OBJS) ++ $(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS) ++ ++%: %.c ++ $(CC) -std=gnu11 $(CFLAGS) $(CPPFLAGS) $< -o $@ $(LIBS) ++ ++.PHONY: clean ++clean: ++ rm -f $(PROGRAM) $(OBJS) ++ ++.PHONY: install ++install: all ++ mkdir -p $(DESTDIR)$(BINDIR) ++ install $(PROGRAM) $(DESTDIR)$(BINDIR) ++ mkdir -p $(DESTDIR)$(MANDIR)/man1 ++ install $(MANPAGE) $(DESTDIR)$(MANDIR)/man1 diff --git a/ports/ed/ed.port b/ports/ed/ed.port new file mode 100644 index 00000000..8c27088b --- /dev/null +++ b/ports/ed/ed.port @@ -0,0 +1,11 @@ +NAME=ed +BUILD_LIBRARIES= +VERSION=2016-10-11 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=c6a46496473b6982f1f4a92ec09b3216c7d9a690aa5675f4ced12ec5a21a1164 +UPSTREAM_SITE=https://pub.sortix.org/fork/ed +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=makefile +VERSION_REGEX='([0-9]{4}-[0-9]{2}-[0-9]{2})' diff --git a/ports/emacs/emacs.patch b/ports/emacs/emacs.patch new file mode 100644 index 00000000..eee19286 --- /dev/null +++ b/ports/emacs/emacs.patch @@ -0,0 +1,634 @@ +diff -Paur --no-dereference -- emacs.upstream/configure emacs/configure +--- emacs.upstream/configure ++++ emacs/configure +@@ -1,4 +1,124 @@ + #! /bin/sh ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes # Not needed since February 2015 ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypotl_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. ++export ac_cv_func_realloc_0_nonnull=yes # TODO: Investigate this, found in flex. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for GNU Emacs 26.2. + # +@@ -626,6 +746,7 @@ + ac_header_list= + gl_getopt_required=POSIX + ac_subst_vars='gltests_LTLIBOBJS ++cross_compiling + gltests_LIBOBJS + gl_LTLIBOBJS + gl_LIBOBJS +@@ -3979,11 +4100,11 @@ + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_MAKE" >&5 + $as_echo "$ac_cv_path_MAKE" >&6; } +-$ac_path_MAKE_found || { +-as_fn_error $? "Building Emacs requires GNU Make, at least version 3.81. +-If you have it installed under another name, configure with 'MAKE=...'. +-For example, run '$0 MAKE=gnu-make'." "$LINENO" 5 +-} ++#$ac_path_MAKE_found || { ++#as_fn_error $? "Building Emacs requires GNU Make, at least version 3.81. ++#If you have it installed under another name, configure with 'MAKE=...'. ++#For example, run '$0 MAKE=gnu-make'." "$LINENO" 5 ++#} + MAKE=$ac_cv_path_MAKE + export MAKE + +@@ -4791,6 +4912,11 @@ + opsys=openbsd + ;; + ++ ## Sortix ports ++ *-sortix) ++ opsys=sortix ++ ;; ++ + ## Apple Darwin / macOS + *-apple-darwin* ) + case "${canonical}" in +@@ -9190,6 +9316,7 @@ + test "x$CANNOT_DUMP" = "x" && CANNOT_DUMP=no + case "$opsys" in + nacl) CANNOT_DUMP=yes ;; ++ sortix) CANNOT_DUMP=yes ;; + esac + + if test "$CANNOT_DUMP" = "yes"; then +@@ -11306,8 +11433,8 @@ + fi + + # Does the opsystem file prohibit the use of the GNU malloc? +-# Assume not, until told otherwise. +-GNU_MALLOC=yes ++GNU_MALLOC_reason=" because that would undermine the system malloc's improvements" ++GNU_MALLOC=no + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether malloc is Doug Lea style" >&5 + $as_echo_n "checking whether malloc is Doug Lea style... " >&6; } +@@ -15813,8 +15940,10 @@ + test "${with_tiff}" != "no" && test "${HAVE_TIFF}" != "yes" && + MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no" + fi +-test "${with_gnutls}" != "no" && test "${HAVE_GNUTLS}" != "yes" && +- MISSING="$MISSING gnutls" && WITH_NO="$WITH_NO --with-gnutls=no" ++# PATCH: Emacs works without libgnutls and there's an option --with-gnutls=no, ++# so this hard error is just in the way, so this patch removes the error. ++#test "${with_gnutls}" != "no" && test "${HAVE_GNUTLS}" != "yes" && ++# MISSING="$MISSING gnutls" && WITH_NO="$WITH_NO --with-gnutls=no" + if test "X${MISSING}" != X; then + as_fn_error $? "The following required libraries were not found: + $MISSING +@@ -18588,7 +18717,7 @@ + + ;; + +- gnu-linux | gnu-kfreebsd | dragonfly | freebsd | netbsd | darwin | nacl ) ++ gnu-linux | gnu-kfreebsd | dragonfly | freebsd | netbsd | darwin | nacl | sortix ) + if test "x$ac_cv_func_grantpt" = xyes; then + + $as_echo "#define UNIX98_PTYS 1" >>confdefs.h +@@ -18598,7 +18727,7 @@ + $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { emacs_close (fd); return -1; } snprintf (pty_name, PTY_NAME_SIZE, \"%s\", ptyname); }" >>confdefs.h + + if test "x$ac_cv_func_posix_openpt" = xyes; then +- $as_echo "#define PTY_OPEN do { fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY); if (fd < 0 && errno == EINVAL) fd = posix_openpt (O_RDWR | O_NOCTTY); } while (false)" >>confdefs.h ++ $as_echo "#define PTY_OPEN do { fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY); } while (false)" >>confdefs.h + + $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h + +diff -Paur --no-dereference -- emacs.upstream/lib-src/emacsclient.c emacs/lib-src/emacsclient.c +--- emacs.upstream/lib-src/emacsclient.c ++++ emacs/lib-src/emacsclient.c +@@ -1008,7 +1008,8 @@ + } + + server->sin_family = AF_INET; +- server->sin_addr.s_addr = inet_addr (dotted); ++ /* PATCH: Sortix only has the modern inet_pton. */ ++ inet_pton (AF_INET, dotted, &server->sin_addr.s_addr); + server->sin_port = htons (atoi (port)); + + if (! fread (authentication, AUTH_KEY_LENGTH, 1, config)) +@@ -1029,13 +1030,18 @@ + struct sockaddr_in server; + struct linger l_arg = {1, 1}; + char auth_string[AUTH_KEY_LENGTH + 1]; ++ char addr[INET_ADDRSTRLEN]; + + if (! get_server_config (local_server_file, &server, auth_string)) + return INVALID_SOCKET; + +- if (server.sin_addr.s_addr != inet_addr ("127.0.0.1") && !quiet) +- message (false, "%s: connected to remote socket at %s\n", +- progname, inet_ntoa (server.sin_addr)); ++ /* PATCH: Sortix doesn't have inet_addr and this is a constant anyway. */ ++ if (server.sin_addr.s_addr != INADDR_LOOPBACK && !quiet) ++ { ++ inet_ntop (AF_INET, &server.sin_addr, addr, sizeof(addr)); ++ message (false, "%s: connected to remote socket at %s\n", ++ progname, addr); ++ } + + /* Open up an AF_INET socket. */ + if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) +@@ -1179,7 +1185,7 @@ + handle_sigcont (int signalnum) + { + int old_errno = errno; +- pid_t pgrp = getpgrp (); ++ pid_t pgrp = getpgid (0); + pid_t tcpgrp = tcgetpgrp (1); + + if (tcpgrp == pgrp) +@@ -1704,7 +1710,7 @@ + #ifndef WINDOWSNT + if (tty) + { +- pid_t pgrp = getpgrp (); ++ pid_t pgrp = getpgid (0); + pid_t tcpgrp = tcgetpgrp (1); + if (0 <= tcpgrp && tcpgrp != pgrp) + kill (-pgrp, SIGTTIN); +diff -Paur --no-dereference -- emacs.upstream/lib-src/Makefile.in emacs/lib-src/Makefile.in +--- emacs.upstream/lib-src/Makefile.in ++++ emacs/lib-src/Makefile.in +@@ -20,13 +20,20 @@ + + SHELL = @SHELL@ + ++cross_compiling = @cross_compiling@ ++ + # Following ../lisp/Makefile.in. ++ifeq ($(cross_compiling),yes) ++EMACS = emacs ++else + EMACS = ../src/emacs${EXEEXT} ++endif + EMACSOPT = -batch --no-site-file --no-site-lisp + + # ==================== Things 'configure' will edit ==================== + + CC=@CC@ ++CC_FOR_BUILD?=cc + CFLAGS=@CFLAGS@ + CPPFLAGS = @CPPFLAGS@ + LDFLAGS = @LDFLAGS@ +@@ -389,7 +396,7 @@ + $(NTLIB) $(LOADLIBES) $(LIB_CLOCK_GETTIME) -o $@ + + make-docfile${EXEEXT}: ${srcdir}/make-docfile.c $(NTLIB) $(config_h) +- $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $< $(NTLIB) $(LOADLIBES) -o $@ ++ $(AM_V_CCLD)$(CC_FOR_BUILD) -std=gnu11 ${ALL_CFLAGS} $< $(NTLIB) $(LOADLIBES) -o $@ + + movemail${EXEEXT}: ${srcdir}/movemail.c pop.o $(NTLIB) $(config_h) + $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} ${MOVE_FLAGS} $< pop.o \ +diff -Paur --no-dereference -- emacs.upstream/lib-src/movemail.c emacs/lib-src/movemail.c +--- emacs.upstream/lib-src/movemail.c ++++ emacs/lib-src/movemail.c +@@ -58,7 +58,9 @@ + #include + #include + #include ++#ifdef MAIL_USE_FLOCK + #include ++#endif + #include + #include + #include +@@ -76,6 +78,10 @@ + #include "pop.h" + #endif + ++#if defined(__sortix__) ++#define setregid(a, b) (0 <= (a) ? setgid(a) : setgid(b)) ++#endif ++ + #ifdef MSDOS + #undef access + #endif /* MSDOS */ +diff -Paur --no-dereference -- emacs.upstream/lib-src/pop.c emacs/lib-src/pop.c +--- emacs.upstream/lib-src/pop.c ++++ emacs/lib-src/pop.c +@@ -240,7 +240,11 @@ + { + if (! (flags & POP_NO_GETPASS)) + { ++#if defined(__sortix__) ++ password = NULL; ++#else + password = getpass ("Enter POP password:"); ++#endif + } + if (! password) + { +diff -Paur --no-dereference -- emacs.upstream/lisp/Makefile.in emacs/lisp/Makefile.in +--- emacs.upstream/lisp/Makefile.in ++++ emacs/lisp/Makefile.in +@@ -56,7 +56,12 @@ + # We never change directory before running Emacs, so a relative file + # name is fine, and makes life easier. If we need to change + # directory, we can use emacs --chdir. ++cross_compiling = @cross_compiling@ ++ifeq ($(cross_compiling),yes) ++EMACS = emacs ++else + EMACS = ../src/emacs${EXEEXT} ++endif + + # Command line flags for Emacs. + +@@ -458,6 +463,7 @@ + + distclean: + -rm -f ./Makefile $(lisp)/loaddefs.el~ ++ -rm -f leim/leim-list.el + + maintainer-clean: distclean bootstrap-clean + rm -f TAGS +diff -Paur --no-dereference -- emacs.upstream/Makefile.in emacs/Makefile.in +--- emacs.upstream/Makefile.in ++++ emacs/Makefile.in +@@ -687,9 +687,6 @@ + dest=`echo "$${page}" | sed -e 's/\.1$$//' -e '$(TRANSFORM)'`.1; \ + (cd "$${thisdir}"; \ + ${INSTALL_DATA} ${mansrcdir}/$${page} "$(DESTDIR)${man1dir}/$${dest}"); \ +- [ -n "${GZIP_PROG}" ] || continue ; \ +- rm -f "$(DESTDIR)${man1dir}/$${dest}.gz"; \ +- ${GZIP_PROG} -9n "$(DESTDIR)${man1dir}/$${dest}" || true; \ + done + + ## Install those items from etc/ that need to end up elsewhere. +@@ -712,16 +709,7 @@ + ${srcdir}/etc/emacs.appdata.xml > $${tmp}; \ + ${INSTALL_DATA} $${tmp} "$(DESTDIR)${appdatadir}/${EMACS_NAME}.appdata.xml"; \ + rm -f $${tmp} +- umask 022; $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)" +- tmp=etc/emacs.tmpservice; rm -f $${tmp}; \ +- client_name=`echo emacsclient | sed '$(TRANSFORM)'`${EXEEXT}; \ +- sed -e '/^##/d' \ +- -e "/^Documentation/ s/emacs(1)/${EMACS_NAME}(1)/" \ +- -e "/^ExecStart/ s|emacs|${bindir}/${EMACS}|" \ +- -e "/^ExecStop/ s|emacsclient|${bindir}/$${client_name}|" \ +- ${srcdir}/etc/emacs.service > $${tmp}; \ +- $(INSTALL_DATA) $${tmp} "$(DESTDIR)$(systemdunitdir)/${EMACS_NAME}.service"; \ +- rm -f $${tmp} ++ # Patch: Don't install systemd emacs.service. + thisdir=`/bin/pwd`; \ + cd ${iconsrcdir} || exit 1; umask 022 ; \ + for dir in */*/apps */*/mimetypes; do \ +diff -Paur --no-dereference -- emacs.upstream/src/buffer.c emacs/src/buffer.c +--- emacs.upstream/src/buffer.c ++++ emacs/src/buffer.c +@@ -22,7 +22,6 @@ + + #include + #include +-#include + #include + #include + #include +diff -Paur --no-dereference -- emacs.upstream/src/callproc.c emacs/src/callproc.c +--- emacs.upstream/src/callproc.c ++++ emacs/src/callproc.c +@@ -26,7 +26,6 @@ + #include + #include + +-#include + #include + + #include "lisp.h" +diff -Paur --no-dereference -- emacs.upstream/src/doc.c emacs/src/doc.c +--- emacs.upstream/src/doc.c ++++ emacs/src/doc.c +@@ -23,7 +23,6 @@ + + #include + #include +-#include /* Must be after sys/types.h for USG. */ + #include + #include + +diff -Paur --no-dereference -- emacs.upstream/src/emacs.c emacs/src/emacs.c +--- emacs.upstream/src/emacs.c ++++ emacs/src/emacs.c +@@ -25,7 +25,6 @@ + #include + #include + +-#include + #include + + #include +@@ -2081,7 +2080,7 @@ + /* If we are controlling the terminal, reset terminal modes. */ + #ifndef DOS_NT + { +- pid_t pgrp = getpgrp (); ++ pid_t pgrp = getpgid (0); + pid_t tpgrp = tcgetpgrp (0); + if ((tpgrp != -1) && tpgrp == pgrp) + { +diff -Paur --no-dereference -- emacs.upstream/src/filelock.c emacs/src/filelock.c +--- emacs.upstream/src/filelock.c ++++ emacs/src/filelock.c +@@ -33,7 +33,6 @@ + #include + #endif + +-#include + #include + #include + +diff -Paur --no-dereference -- emacs.upstream/src/fns.c emacs/src/fns.c +--- emacs.upstream/src/fns.c ++++ emacs/src/fns.c +@@ -4526,7 +4526,8 @@ + else if (FLOATP (args[i]) && 0 < (float) (XFLOAT_DATA (args[i]) - 1)) + rehash_size = (float) (XFLOAT_DATA (args[i]) - 1); + else +- signal_error ("Invalid hash table rehash size", args[i]); ++ /*signal_error ("Invalid hash table rehash size", args[i]);*/ ++ rehash_size = make_float (DEFAULT_REHASH_SIZE); + + /* Look for `:rehash-threshold THRESHOLD'. */ + i = get_key_arg (QCrehash_threshold, nargs, args, used); +@@ -4534,7 +4535,8 @@ + : !FLOATP (args[i]) ? 0 + : (float) XFLOAT_DATA (args[i])); + if (! (0 < rehash_threshold && rehash_threshold <= 1)) +- signal_error ("Invalid hash table rehash threshold", args[i]); ++ /*signal_error ("Invalid hash table rehash threshold", args[i]);*/ ++ rehash_threshold = make_float (DEFAULT_REHASH_THRESHOLD); + + /* Look for `:weakness WEAK'. */ + i = get_key_arg (QCweakness, nargs, args, used); +diff -Paur --no-dereference -- emacs.upstream/src/keyboard.c emacs/src/keyboard.c +--- emacs.upstream/src/keyboard.c ++++ emacs/src/keyboard.c +@@ -7073,7 +7073,7 @@ + return 0; + if (n_to_read > sizeof cbuf) + n_to_read = sizeof cbuf; +-#elif defined USG || defined CYGWIN ++#elif defined USG || defined CYGWIN || defined (__sortix__) + /* Read some input if available, but don't wait. */ + n_to_read = sizeof cbuf; + fcntl (fileno (tty->input), F_SETFL, O_NONBLOCK); +@@ -7107,7 +7107,7 @@ + #endif + + #ifndef USABLE_FIONREAD +-#if defined (USG) || defined (CYGWIN) ++#if defined (USG) || defined (CYGWIN) || defined (__sortix__) + fcntl (fileno (tty->input), F_SETFL, 0); + #endif /* USG or CYGWIN */ + #endif /* no FIONREAD */ +diff -Paur --no-dereference -- emacs.upstream/src/lread.c emacs/src/lread.c +--- emacs.upstream/src/lread.c ++++ emacs/src/lread.c +@@ -26,7 +26,6 @@ + #include + #include + #include +-#include + #include + #include + #include +diff -Paur --no-dereference -- emacs.upstream/src/Makefile.in emacs/src/Makefile.in +--- emacs.upstream/src/Makefile.in ++++ emacs/src/Makefile.in +@@ -25,6 +25,8 @@ + + SHELL = @SHELL@ + ++cross_compiling = @cross_compiling@ ++ + # Here are the things that we expect ../configure to edit. + # We use $(srcdir) explicitly in dependencies so as not to depend on VPATH. + srcdir = @srcdir@ +@@ -501,7 +503,11 @@ + ## in practice this rule was always run anyway. + $(srcdir)/macuvs.h $(lispsource)/international/charprop.el: \ + bootstrap-emacs$(EXEEXT) FORCE ++ifeq ($(cross_compiling),yes) ++ $(MAKE) -C ../admin/unidata all EMACS=emacs ++else + $(MAKE) -C ../admin/unidata all EMACS="../$(bootstrap_exe)" ++endif + + ## We require charprop.el to exist before ucs-normalize.el is + ## byte-compiled, because ucs-normalize.el needs to load 2 uni-*.el files. +diff -Paur --no-dereference -- emacs.upstream/src/process.c emacs/src/process.c +--- emacs.upstream/src/process.c ++++ emacs/src/process.c +@@ -25,7 +25,6 @@ + #include + #include + #include /* Some typedefs are used in sys/file.h. */ +-#include + #include + #include + #include +@@ -2821,7 +2820,7 @@ + #ifdef SO_BINDTODEVICE + case SOPT_IFNAME: + { +- char devname[IFNAMSIZ + 1]; ++ char devname[IF_NAMESIZE + 1]; + + /* This is broken, at least in the Linux 2.4 kernel. + To unbind, the arg must be a zero integer, not the empty string. +@@ -2830,13 +2829,13 @@ + if (STRINGP (val)) + { + char *arg = SSDATA (val); +- int len = min (strlen (arg), IFNAMSIZ); ++ int len = min (strlen (arg), IF_NAMESIZE); + memcpy (devname, arg, len); + } + else if (!NILP (val)) + error ("Bad option value for %s", name); + ret = setsockopt (s, sopt->optlevel, sopt->optnum, +- devname, IFNAMSIZ); ++ devname, IF_NAMESIZE); + break; + } + #endif +diff -Paur --no-dereference -- emacs.upstream/src/sysdep.c emacs/src/sysdep.c +--- emacs.upstream/src/sysdep.c ++++ emacs/src/sysdep.c +@@ -87,8 +87,6 @@ + #include "msdos.h" + #endif + +-#include +-#include + #include + + #include "systty.h" +@@ -96,7 +94,6 @@ + + #ifdef HAVE_SYS_UTSNAME_H + #include +-#include + #endif /* HAVE_SYS_UTSNAME_H */ + + #include "keyboard.h" +@@ -529,7 +526,9 @@ + #ifdef OLCUC + s.main.c_oflag &= ~OLCUC; /* Disable upcasing on output. */ + #endif ++#ifdef TAB3 + s.main.c_oflag &= ~TAB3; /* Disable tab expansion */ ++#endif + s.main.c_cflag = (s.main.c_cflag & ~CSIZE) | CS8; /* Don't strip 8th bit */ + s.main.c_cc[VERASE] = CDISABLE; /* disable erase processing */ + s.main.c_cc[VKILL] = CDISABLE; /* disable kill processing */ +@@ -877,7 +876,7 @@ + void + init_foreground_group (void) + { +- pid_t pgrp = getpgrp (); ++ pid_t pgrp = getpgid (0); + inherited_pgroup = getpid () == pgrp ? 0 : pgrp; + } + +@@ -1120,7 +1119,9 @@ + tty.main.c_iflag &= ~IXON; /* Disable start/stop output control */ + tty.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL + on output */ ++#ifdef TAB3 + tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */ ++#endif + #ifdef CS8 + if (tty_out->meta_key) + { +diff -Paur --no-dereference -- emacs.upstream/src/term.c emacs/src/term.c +--- emacs.upstream/src/term.c ++++ emacs/src/term.c +@@ -23,7 +23,6 @@ + #include + #include + #include +-#include + #include + #include + diff --git a/ports/emacs/emacs.port b/ports/emacs/emacs.port new file mode 100644 index 00000000..3d96769f --- /dev/null +++ b/ports/emacs/emacs.port @@ -0,0 +1,17 @@ +NAME=emacs +BUILD_LIBRARIES='libcurses libcairo? libdbus? libfontconfig? libfreetype? libgconf? libgif? libgnutls? libgobject-introspection? libgpm? libgtk? libjpeg? liblcms2? libMagick? libm17t? libotf? libpng? librsvg? libtiff? libxml2? libxpm? libz?' +VERSION=26.2 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=151ce69dbe5b809d4492ffae4a4b153b2778459de6deb26f35691e1281a9c58e +UPSTREAM_SITE=https://ftp.gnu.org/gnu/emacs +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +USE_BOOTSTRAP=true +CONFIGURE_ARGS=--without-x +MAKE_VARS='V=1' +POST_INSTALL=../emacs.post-install +BOOTSTRAP_BUILD_SYSTEM=configure +BOOTSTRAP_CONFIGURE_ARGS=--without-x +BOOTSTRAP_MAKE_VARS='V=1' diff --git a/ports/emacs/emacs.post-install b/ports/emacs/emacs.post-install new file mode 100755 index 00000000..72372cf0 --- /dev/null +++ b/ports/emacs/emacs.post-install @@ -0,0 +1,4 @@ +#!/bin/sh +set -e +cd "$TIX_INSTALL_DIR/$PREFIX" +find -type f -name '*.el.gz' -delete diff --git a/ports/emacs/emacs.rmpatch b/ports/emacs/emacs.rmpatch new file mode 100644 index 00000000..fcc2dc7b --- /dev/null +++ b/ports/emacs/emacs.rmpatch @@ -0,0 +1,8 @@ +rm -rf -- 'admin/charsets/charsets.stamp' +rm -rf -- 'admin/charsets/jisx2131-filter' +rm -rf -- 'admin/unidata/unidata-gen.elc' +rm -rf -- 'admin/unidata/unidata.txt' +rm -rf -- 'admin/unidata/uvs.elc' +rm -rf -- 'etc/charsets/JISX2131.map' +rm -rf -- 'lisp/leim/leim-list.el' +rm -rf -- 'src/emacs-module.h' diff --git a/ports/ffmpeg/ffmpeg.patch b/ports/ffmpeg/ffmpeg.patch new file mode 100644 index 00000000..418a43ea --- /dev/null +++ b/ports/ffmpeg/ffmpeg.patch @@ -0,0 +1,198 @@ +diff -Paur --no-dereference -- ffmpeg.upstream/configure ffmpeg/configure +--- ffmpeg.upstream/configure ++++ ffmpeg/configure +@@ -81,10 +81,12 @@ + --disable-logging do not log configure debug information + --fatal-warnings fail if any configure warning is generated + --prefix=PREFIX install in PREFIX [$prefix_default] +- --bindir=DIR install binaries in DIR [PREFIX/bin] ++ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX ++ [PREFIX] ++ --bindir=DIR install binaries in DIR [EPREFIX/bin] + --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg] + --docdir=DIR install documentation in DIR [PREFIX/share/doc/ffmpeg] +- --libdir=DIR install libs in DIR [PREFIX/lib] ++ --libdir=DIR install libs in DIR [EPREFIX/lib] + --shlibdir=DIR install shared libs in DIR [LIBDIR] + --incdir=DIR install includes in DIR [PREFIX/include] + --mandir=DIR install man page in DIR [PREFIX/share/man] +@@ -770,7 +772,9 @@ + + set_default(){ + for opt; do +- eval : \${$opt:=\$${opt}_default} ++ if [ -z "$(eval "echo \${${opt}_set}")" ]; then ++ eval : \${$opt:=\$${opt}_default} ++ fi + done + } + +@@ -2444,6 +2448,8 @@ + " + + PATHS_LIST=" ++ prefix ++ exec_prefix + bindir + datadir + docdir +@@ -2462,6 +2468,7 @@ + arch + as + assert_level ++ build + build_suffix + cc + objcc +@@ -2474,6 +2481,7 @@ + env + extra_version + gas ++ host + host_cc + host_cflags + host_extralibs +@@ -2500,6 +2508,7 @@ + sws_max_filter_size + sysinclude + sysroot ++ target + target_exec + target_os + target_path +@@ -3714,11 +3723,12 @@ + + # installation paths + prefix_default="/usr/local" +-bindir_default='${prefix}/bin' ++exec_prefix_default='${prefix}' ++bindir_default='${exec_prefix}/bin' + datadir_default='${prefix}/share/ffmpeg' + docdir_default='${prefix}/share/doc/ffmpeg' + incdir_default='${prefix}/include' +-libdir_default='${prefix}/lib' ++libdir_default='${exec_prefix}/lib' + mandir_default='${prefix}/share/man' + + # toolchain +@@ -4075,8 +4085,10 @@ + optname="${opt%%=*}" + optname="${optname#--}" + optname=$(echo "$optname" | sed 's/-/_/g') ++ optname_set="${optname}_set" + if is_in $optname $CMDLINE_SET; then + eval $optname='$optval' ++ eval $optname_set=true + elif is_in $optname $CMDLINE_APPEND; then + append $optname "$optval" + else +@@ -4279,6 +4291,16 @@ + ;; + esac + ++# TODO: This is pretty spotty and should be combined with config.sub and ++# possibly also config.guess. ++if [ -n "$build" -a -n "$host" -a "$build" != "$host" ]; then ++ cross_prefix=${host}- ++ arch=$(echo "$host" | grep -o '^[^-]*') ++ if echo "$host" | grep -- "-sortix$" > /dev/null; then ++ target_os="sortix" ++ fi ++fi ++ + if test -n "$cross_prefix"; then + test -n "$arch" && test -n "$target_os" || + die "Must specify target arch (--arch) and OS (--target-os) when cross-compiling" +@@ -5541,6 +5563,9 @@ + ;; + minix) + ;; ++ sortix) ++ add_cppflags -D_SORTIX_SOURCE -D_POSIX_SOURCE=200809L ++ ;; + none) + ;; + *) +@@ -7214,6 +7239,7 @@ + if test "$quiet" != "yes"; then + + echo "install prefix $prefix" ++echo "install exec-prefix $exec_prefix" + echo "source path $source_path" + echo "C compiler $cc" + echo "C library $libc_type" +@@ -7367,6 +7393,7 @@ + FFMPEG_CONFIG_MAK=1 + FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION + prefix=$prefix ++exec_prefix=$exec_prefix + LIBDIR=\$(DESTDIR)$libdir + SHLIBDIR=\$(DESTDIR)$shlibdir + INCDIR=\$(DESTDIR)$incdir +@@ -7628,6 +7655,7 @@ + shared=$shared + build_suffix=$build_suffix + prefix=$prefix ++exec_prefix=$exec_prefix + libdir=$libdir + incdir=$incdir + rpath=$(enabled rpath && echo "-Wl,-rpath,\${libdir}") +diff -Paur --no-dereference -- ffmpeg.upstream/ffbuild/pkgconfig_generate.sh ffmpeg/ffbuild/pkgconfig_generate.sh +--- ffmpeg.upstream/ffbuild/pkgconfig_generate.sh ++++ ffmpeg/ffbuild/pkgconfig_generate.sh +@@ -28,7 +28,7 @@ + + cat < $name/$fullname.pc + prefix=$prefix +-exec_prefix=\${prefix} ++exec_prefix=$exec_prefix + libdir=$libdir + includedir=$incdir + +diff -Paur --no-dereference -- ffmpeg.upstream/fftools/Makefile ffmpeg/fftools/Makefile +--- ffmpeg.upstream/fftools/Makefile ++++ ffmpeg/fftools/Makefile +@@ -30,6 +30,8 @@ + + all: $(AVPROGS) + ++progs: $(AVPROGS) ++ + fftools/ffprobe.o fftools/cmdutils.o: libavutil/ffversion.h | fftools + OUTDIRS += fftools + +diff -Paur --no-dereference -- ffmpeg.upstream/libavformat/codec2.c ffmpeg/libavformat/codec2.c +--- ffmpeg.upstream/libavformat/codec2.c ++++ ffmpeg/libavformat/codec2.c +@@ -19,7 +19,6 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#include + #include "libavcodec/codec2utils.h" + #include "libavutil/intreadwrite.h" + #include "avio_internal.h" +diff -Paur --no-dereference -- ffmpeg.upstream/libavformat/udp.c ffmpeg/libavformat/udp.c +--- ffmpeg.upstream/libavformat/udp.c ++++ ffmpeg/libavformat/udp.c +@@ -252,7 +252,9 @@ + struct sockaddr_storage *sources, + int nb_sources, int include) + { ++#if HAVE_STRUCT_IP_MREQ_SOURCE && defined(IP_BLOCK_SOURCE) + int i; ++#endif + if (addr->sa_family != AF_INET) { + #if HAVE_STRUCT_GROUP_SOURCE_REQ && defined(MCAST_BLOCK_SOURCE) + /* For IPv4 prefer the old approach, as that alone works reliably on +@@ -791,8 +793,10 @@ + + if (dscp >= 0) { + dscp <<= 2; ++#ifdef IP_TOS + if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) != 0) + goto fail; ++#endif + } + + /* If multicast, try binding the multicast address first, to avoid diff --git a/ports/ffmpeg/ffmpeg.port b/ports/ffmpeg/ffmpeg.port new file mode 100644 index 00000000..0d871851 --- /dev/null +++ b/ports/ffmpeg/ffmpeg.port @@ -0,0 +1,15 @@ +NAME=ffmpeg +BUILD_LIBRARIES='libavcodec libGL? libSDL? libSDL2?' +VERSION=4.3.1 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=ad009240d46e307b4e03a213a0f49c11b650e445b1f8be0dda2a9212b34d2ffb +UPSTREAM_SITE=https://ffmpeg.org/releases +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +DIRTY_FILE=ffbuild/config.mak +CONFIGURE_ARGS='--disable-x86asm --enable-version3 --optflags=" " --disable-debug' +MAKE_VARS='V=1' +MAKE_TARGET=progs +MAKE_INSTALL_TARGET='install-progs install-data' diff --git a/ports/flex/flex.patch b/ports/flex/flex.patch new file mode 100644 index 00000000..e41a299f --- /dev/null +++ b/ports/flex/flex.patch @@ -0,0 +1,65 @@ +diff -Paur --no-dereference -- flex.upstream/build-aux/config.sub flex/build-aux/config.sub +--- flex.upstream/build-aux/config.sub ++++ flex/build-aux/config.sub +@@ -1373,7 +1373,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- flex.upstream/configure flex/configure +--- flex.upstream/configure ++++ flex/configure +@@ -1,4 +1,6 @@ + #! /bin/sh ++export ac_cv_func_malloc_0_nonnull=yes ++export ac_cv_func_realloc_0_nonnull=yes + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for the fast lexical analyser generator 2.6.0. + # +diff -Paur --no-dereference -- flex.upstream/Makefile.in flex/Makefile.in +--- flex.upstream/Makefile.in ++++ flex/Makefile.in +@@ -227,7 +227,7 @@ + ETAGS = etags + CTAGS = ctags + CSCOPE = cscope +-DIST_SUBDIRS = $(SUBDIRS) ++DIST_SUBDIRS = $(SUBDIRS_REAL) + am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/build-aux/compile \ + $(top_srcdir)/build-aux/config.guess \ +@@ -444,15 +444,16 @@ + .indent.pro \ + autogen.sh + ++# PATCH: Building documentation and test causes problems when cross-compiling. + SUBDIRS = \ + lib \ + src \ +- doc \ + examples \ + po \ +- tests \ + tools + ++SUBDIRS_REAL = lib src doc examples po tests tools ++ + all: all-recursive + + .SUFFIXES: +diff -Paur --no-dereference -- flex.upstream/src/main.c flex/src/main.c +--- flex.upstream/src/main.c ++++ flex/src/main.c +@@ -364,7 +364,7 @@ + /* Setup the filter chain. */ + output_chain = filter_create_int(NULL, filter_tee_header, headerfilename); + if ( !(m4 = getenv("M4"))) +- m4 = M4; ++ m4 = "m4"; + filter_create_ext(output_chain, m4, "-P", 0); + filter_create_int(output_chain, filter_fix_linedirs, NULL); + diff --git a/ports/flex/flex.port b/ports/flex/flex.port new file mode 100644 index 00000000..62d89e15 --- /dev/null +++ b/ports/flex/flex.port @@ -0,0 +1,12 @@ +NAME=flex +BUILD_LIBRARIES='libiconv? gettext?' +VERSION=2.6.0 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=d39b15a856906997ced252d76e9bfe2425d7503c6ed811669665627b248e4c73 +UPSTREAM_SITE=https://sourceforge.net/projects/flex/files +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/gawk/gawk.patch b/ports/gawk/gawk.patch new file mode 100644 index 00000000..0956c965 --- /dev/null +++ b/ports/gawk/gawk.patch @@ -0,0 +1,131 @@ +diff -Paur --no-dereference -- gawk.upstream/builtin.c gawk/builtin.c +--- gawk.upstream/builtin.c ++++ gawk/builtin.c +@@ -1192,10 +1192,18 @@ + * Use snprintf return value to tell if there + * is enough room in the buffer or not. + */ ++/* PATCH: Until Sortix has floating point printing. */ ++#if defined(__sortix__) && !__SORTIX_HAS_FLOAT_PARSE__ ++ while ((i = snprintf(cpbufs[1].buf, ++ cpbufs[1].bufsize, "%lld", ++ (long long)tmpval)) >= ++ cpbufs[1].bufsize) { ++#else + while ((i = snprintf(cpbufs[1].buf, + cpbufs[1].bufsize, "%.0f", + tmpval)) >= + cpbufs[1].bufsize) { ++#endif + if (cpbufs[1].buf == cpbufs[1].stackbuf) + cpbufs[1].buf = NULL; + if (i > 0) { +diff -Paur --no-dereference -- gawk.upstream/extension/filefuncs.c gawk/extension/filefuncs.c +--- gawk.upstream/extension/filefuncs.c ++++ gawk/extension/filefuncs.c +@@ -414,8 +414,12 @@ + /* for block and character devices, add rdev, major and minor numbers */ + if (S_ISBLK(sbuf->st_mode) || S_ISCHR(sbuf->st_mode)) { + array_set_numeric(array, "rdev", sbuf->st_rdev); ++#ifdef major + array_set_numeric(array, "major", major(sbuf->st_rdev)); ++#endif ++#ifdef minor + array_set_numeric(array, "minor", minor(sbuf->st_rdev)); ++#endif + } + + #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE +diff -Paur --no-dereference -- gawk.upstream/io.c gawk/io.c +--- gawk.upstream/io.c ++++ gawk/io.c +@@ -39,6 +39,8 @@ + #include + #endif /* HAVE_SYS_IOCTL_H */ + ++#include ++ + #ifndef O_ACCMODE + #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) + #endif +diff -Paur --no-dereference -- gawk.upstream/main.c gawk/main.c +--- gawk.upstream/main.c ++++ gawk/main.c +@@ -984,13 +984,7 @@ + update_PROCINFO_num("api_minor", GAWK_API_MINOR_VERSION); + #endif + +-#ifdef GETPGRP_VOID +-#define getpgrp_arg() /* nothing */ +-#else +-#define getpgrp_arg() getpid() +-#endif +- +- value = getpgrp(getpgrp_arg()); ++ value = getpgid(0); + update_PROCINFO_num("pgrpid", value); + + /* +diff -Paur --no-dereference -- gawk.upstream/node.c gawk/node.c +--- gawk.upstream/node.c ++++ gawk/node.c +@@ -860,6 +860,8 @@ + n->flags &= ~WSTRCUR; + } + ++/* PATCH: Sortix doesn't have putwc(3) and this function is unused. */ ++#if 0 + static void __attribute__ ((unused)) + dump_wstr(FILE *fp, const wchar_t *str, size_t len) + { +@@ -869,6 +871,7 @@ + for (; len--; str++) + putwc(*str, fp); + } ++#endif + + /* wstrstr --- walk haystack, looking for needle, wide char version */ + +diff -Paur --no-dereference -- gawk.upstream/support/getopt.c gawk/support/getopt.c +--- gawk.upstream/support/getopt.c ++++ gawk/support/getopt.c +@@ -55,18 +55,9 @@ + #ifndef ELIDE_CODE + + +-/* This needs to come after some library #include +- to get __GNU_LIBRARY__ defined. */ +-#if defined (__GNU_LIBRARY__) || defined (__CYGWIN__) || defined(__DJGPP__) || defined(__APPLE__) || defined(__MINGW32__) || defined(__sun) /* Illumos */ +-/* Don't include stdlib.h for +- * non-GNU C libraries +- * non-Cygwin +- * non-DJGPP +- * non-MinGW +- * because some of them contain conflicting prototypes for getopt. */ ++/* PATCH: #&%!ing gnu portability: You need stdlib.h for malloc. */ + # include + # include +-#endif /* GNU C library. */ + + #include + +diff -Paur --no-dereference -- gawk.upstream/support/getopt.h gawk/support/getopt.h +--- gawk.upstream/support/getopt.h ++++ gawk/support/getopt.h +@@ -1,3 +1,16 @@ ++/* PATCH: Gawk doesn't seem to work with Sortix libc's getopt for some reason. ++ Gawk wants to use GNU getopt unconditionally. This causes conflicting ++ symbols, so rename gawk's replacements to avoid collisions. */ ++#if defined(__sortix__) ++#define getopt gawk_getopt ++#define optarg gawk_optarg ++#define optind gawk_optind ++#define opterr gawk_opterr ++#define optopt gawk_optopt ++#define getopt_long gawk_getopt_long ++#define getopt_long_only gawk_getopt_long_only ++#define option gawk_option ++#endif + /* Declarations for getopt. + Copyright (C) 1989-2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. diff --git a/ports/gawk/gawk.port b/ports/gawk/gawk.port new file mode 100644 index 00000000..ed0fa58e --- /dev/null +++ b/ports/gawk/gawk.port @@ -0,0 +1,11 @@ +NAME=gawk +BUILD_LIBRARIES='libiconv? libintl? libgmp? libmpfr? libreadline?' +VERSION=4.2.0 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=d4f3cd31c001fd0ed52832d4fbfbdfeaa38ad541c182f80ff8fdf87324a6a9f2 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/gawk +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/gcc/gcc.port b/ports/gcc/gcc.port new file mode 100644 index 00000000..f5a5b7e4 --- /dev/null +++ b/ports/gcc/gcc.port @@ -0,0 +1,19 @@ +NAME=gcc +BUILD_LIBRARIES='libstdc++ libiconv? libgmp libmpfr libmpc libz' +VERSION=1.1-rc3 +DISTNAME=sortix-gcc-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=4d90fe38a67cddab81dc34265009cde508338072ec9b0083010d46647f9c6320 +UPSTREAM_SITE=https://pub.sortix.org/sortix/toolchain +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_WITH_SYSROOT=true +CONFIGURE_WITH_SYSROOT_LD_BUG=true +CONFIGURE_WITH_BUILD_SYSROOT=true +CONFIGURE_ARGS='--enable-languages=c,c++ --with-system-zlib' +CONFIGURE_USE_BUILD_DIRECTORY=true +MAKE_BUILD_TARGET='all-gcc all-target-libgcc' +MAKE_INSTALL_TARGET='install-gcc install-target-libgcc' +POST_INSTALL=../gcc.post-install +VERSION_REGEX='([0-9]+\.[0-9]+(\.[0-9]+)*(-rc[0-9]+)?)' diff --git a/ports/gcc/gcc.post-install b/ports/gcc/gcc.post-install new file mode 100755 index 00000000..2b69153f --- /dev/null +++ b/ports/gcc/gcc.post-install @@ -0,0 +1,6 @@ +#!/bin/sh -e +tix-eradicate-libtool-la +if [ -e "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/gcc" ]; then + ln "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/gcc" "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/cc" +fi +ln "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/$TARGET-gcc" "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/$TARGET-cc" diff --git a/ports/gettext/gettext.patch b/ports/gettext/gettext.patch new file mode 100644 index 00000000..98ecec3f --- /dev/null +++ b/ports/gettext/gettext.patch @@ -0,0 +1,700 @@ +diff -Paur --no-dereference -- gettext.upstream/gettext-runtime/configure gettext/gettext-runtime/configure +--- gettext.upstream/gettext-runtime/configure ++++ gettext/gettext-runtime/configure +@@ -1,4 +1,124 @@ + #! /bin/sh ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes # Not needed since February 2015 ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypotl_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. ++export ac_cv_func_realloc_0_nonnull=yes # TODO: Investigate this, found in flex. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for gettext-runtime 0.19.8. + # +@@ -18912,6 +19032,8 @@ + static char buf[100]; + int main () + { ++ /* PATCH: Never replace Sortix printf even if it doesn't have this feature. */ ++ return 0; + sprintf (buf, format, 33, 55); + return (strcmp (buf, "55 33") != 0); + } +diff -Paur --no-dereference -- gettext.upstream/gettext-runtime/gnulib-lib/propername.c gettext/gettext-runtime/gnulib-lib/propername.c +--- gettext.upstream/gettext-runtime/gnulib-lib/propername.c ++++ gettext/gettext-runtime/gnulib-lib/propername.c +@@ -168,10 +168,10 @@ + else + { + /* Return "TRANSLATION (NAME)". */ +- char *result = +- XNMALLOC (strlen (translation) + 2 + strlen (name) + 1 + 1, char); ++ size_t size = strlen (translation) + 2 + strlen (name) + 1 + 1; ++ char *result = XNMALLOC (size, char); + +- sprintf (result, "%s (%s)", translation, name); ++ snprintf (result, size, "%s (%s)", translation, name); + return result; + } + } +@@ -270,10 +270,10 @@ + else + { + /* Return "TRANSLATION (NAME)". */ +- char *result = +- XNMALLOC (strlen (translation) + 2 + strlen (name) + 1 + 1, char); ++ size_t size = strlen (translation) + 2 + strlen (name) + 1 + 1; ++ char *result = XNMALLOC (size, char); + +- sprintf (result, "%s (%s)", translation, name); ++ snprintf (result, size, "%s (%s)", translation, name); + + if (alloc_name_converted != NULL) + free (alloc_name_converted); +diff -Paur --no-dereference -- gettext.upstream/gettext-runtime/intl/dcigettext.c gettext/gettext-runtime/intl/dcigettext.c +--- gettext.upstream/gettext-runtime/intl/dcigettext.c ++++ gettext/gettext-runtime/intl/dcigettext.c +@@ -997,6 +997,8 @@ + resultlen = domain->trans_sysdep_tab[act - nstrings].length; + } + ++#if 0 /* PATCH: Disable iconv dependency to produce smaller programs. With luck ++ anything that matters at this time is already UTF-8. */ + #if defined _LIBC || HAVE_ICONV + # ifdef IN_LIBGLOCALE + if (encoding != NULL) +@@ -1406,6 +1408,7 @@ + /* The result string is converted. */ + + #endif /* _LIBC || HAVE_ICONV */ ++#endif + + *lengthp = resultlen; + return result; +diff -Paur --no-dereference -- gettext.upstream/gettext-runtime/libasprintf/configure gettext/gettext-runtime/libasprintf/configure +--- gettext.upstream/gettext-runtime/libasprintf/configure ++++ gettext/gettext-runtime/libasprintf/configure +@@ -18352,6 +18352,8 @@ + static char buf[100]; + int main () + { ++ /* PATCH: Never replace Sortix printf even if it doesn't have this feature. */ ++ return 0; + sprintf (buf, format, 33, 55); + return (strcmp (buf, "55 33") != 0); + } +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/configure gettext/gettext-tools/configure +--- gettext.upstream/gettext-tools/configure ++++ gettext/gettext-tools/configure +@@ -1,4 +1,124 @@ + #! /bin/sh ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes # Not needed since February 2015 ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypotl_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. ++export ac_cv_func_realloc_0_nonnull=yes # TODO: Investigate this, found in flex. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for gettext-tools 0.19.8. + # +@@ -21267,6 +21387,8 @@ + static char buf[100]; + int main () + { ++ /* PATCH: Never replace Sortix printf even if it doesn't have this feature. */ ++ return 0; + sprintf (buf, format, 33, 55); + return (strcmp (buf, "55 33") != 0); + } +@@ -44404,7 +44526,9 @@ + + + +- use_additional=yes ++ # PATCH: It's just plain wrong to search for libxml2 in the prefix rather ++ # than using the pkg-config, or at least using the system root. ++ use_additional=no + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" +@@ -44424,6 +44548,7 @@ + if test "X$withval" = "Xno"; then + use_additional=no + else ++ use_additional=yes + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" +@@ -44858,6 +44983,8 @@ + + + ++ LIBXML2="$LIBXML2 $(${PKG_CONFIG-pkg-config} --libs libxml-2.0)" ++ LTLIBXML2="$LTLIBXML2 $(${PKG_CONFIG-pkg-config} --libs libxml-2.0)" + LIBS="$gl_save_LIBS $LIBXML2 $LIBICONV" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -50550,6 +50677,8 @@ + static char buf[100]; + int main () + { ++ /* PATCH: Never replace Sortix printf even if it doesn't have this feature. */ ++ return 0; + sprintf (buf, format, 33, 55); + return (strcmp (buf, "55 33") != 0); + } +@@ -54324,6 +54453,8 @@ + static char buf[100]; + int main () + { ++ /* PATCH: Never replace Sortix printf even if it doesn't have this feature. */ ++ return 0; + sprintf (buf, format, 33, 55); + return (strcmp (buf, "55 33") != 0); + } +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/gnulib-lib/backupfile.c gettext/gettext-tools/gnulib-lib/backupfile.c +--- gettext.upstream/gettext-tools/gnulib-lib/backupfile.c ++++ gettext/gettext-tools/gnulib-lib/backupfile.c +@@ -90,14 +90,15 @@ + size_t numbered_suffix_size_max = INT_STRLEN_BOUND (int) + 4; + char *s; + const char *suffix = simple_backup_suffix; ++ size_t ssize; + + /* Allow room for simple or '.~N~' backups. */ + backup_suffix_size_max = strlen (simple_backup_suffix) + 1; + if (HAVE_DIR && backup_suffix_size_max < numbered_suffix_size_max) + backup_suffix_size_max = numbered_suffix_size_max; + +- s = (char *) malloc (file_len + backup_suffix_size_max +- + numbered_suffix_size_max); ++ ssize = file_len + backup_suffix_size_max + numbered_suffix_size_max; ++ s = (char *) malloc (ssize); + if (s) + { + strcpy (s, file); +@@ -112,8 +113,10 @@ + highest_backup = max_backup_version (file + dir_len, s); + if (! (backup_type == numbered_existing && highest_backup == 0)) + { +- char *numbered_suffix = s + (file_len + backup_suffix_size_max); +- sprintf (numbered_suffix, ".~%d~", highest_backup + 1); ++ size_t off = file_len + backup_suffix_size_max; ++ size_t rem = ssize - off; ++ char *numbered_suffix = s + off; ++ snprintf (numbered_suffix, rem, ".~%d~", highest_backup + 1); + suffix = numbered_suffix; + } + strcpy (s, file); +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/gnulib-lib/html-ostream.c gettext/gettext-tools/gnulib-lib/html-ostream.c +--- gettext.upstream/gettext-tools/gnulib-lib/html-ostream.c ++++ gettext/gettext-tools/gnulib-lib/html-ostream.c +@@ -178,7 +178,7 @@ + /* Output non-ASCII characters in #&nnn; + notation. */ + char bytes[32]; +- sprintf (bytes, "&#%d;", (int) uc); ++ snprintf (bytes, sizeof(bytes), "&#%d;", (int) uc); + ostream_write_str (stream->destination, bytes); + } + break; +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/gnulib-lib/html-ostream.oo.c gettext/gettext-tools/gnulib-lib/html-ostream.oo.c +--- gettext.upstream/gettext-tools/gnulib-lib/html-ostream.oo.c ++++ gettext/gettext-tools/gnulib-lib/html-ostream.oo.c +@@ -177,7 +177,7 @@ + /* Output non-ASCII characters in #&nnn; + notation. */ + char bytes[32]; +- sprintf (bytes, "&#%d;", (int) uc); ++ snprintf (bytes, sizeof(bytes), "&#%d;", (int) uc); + ostream_write_str (stream->destination, bytes); + } + break; +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/gnulib-lib/propername.c gettext/gettext-tools/gnulib-lib/propername.c +--- gettext.upstream/gettext-tools/gnulib-lib/propername.c ++++ gettext/gettext-tools/gnulib-lib/propername.c +@@ -168,10 +168,10 @@ + else + { + /* Return "TRANSLATION (NAME)". */ +- char *result = +- XNMALLOC (strlen (translation) + 2 + strlen (name) + 1 + 1, char); ++ size_t size = strlen (translation) + 2 + strlen (name) + 1 + 1; ++ char *result = XNMALLOC (size, char); + +- sprintf (result, "%s (%s)", translation, name); ++ snprintf (result, size, "%s (%s)", translation, name); + return result; + } + } +@@ -270,10 +270,10 @@ + else + { + /* Return "TRANSLATION (NAME)". */ +- char *result = +- XNMALLOC (strlen (translation) + 2 + strlen (name) + 1 + 1, char); ++ size_t size = strlen (translation) + 2 + strlen (name) + 1 + 1; ++ char *result = XNMALLOC (size, char); + +- sprintf (result, "%s (%s)", translation, name); ++ snprintf (result, size, "%s (%s)", translation, name); + + if (alloc_name_converted != NULL) + free (alloc_name_converted); +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/gnulib-lib/tmpdir.c gettext/gettext-tools/gnulib-lib/tmpdir.c +--- gettext.upstream/gettext-tools/gnulib-lib/tmpdir.c ++++ gettext/gettext-tools/gnulib-lib/tmpdir.c +@@ -154,6 +154,7 @@ + } + + memcpy (tmpl, dir, dlen); +- sprintf (tmpl + dlen, &"/%.*sXXXXXX"[!add_slash], (int) plen, pfx); ++ snprintf (tmpl + dlen, 1 + tmpl_len - dlen, &"/%.*sXXXXXX"[!add_slash], ++ (int) plen, pfx); + return 0; + } +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/gnulib-lib/tparm.c gettext/gettext-tools/gnulib-lib/tparm.c +--- gettext.upstream/gettext-tools/gnulib-lib/tparm.c ++++ gettext/gettext-tools/gnulib-lib/tparm.c +@@ -496,7 +496,7 @@ + char *s; + if (popstring (&s)) + return OOPS; +- sprintf (sbuf, fmt, s); ++ snprintf (sbuf, sizeof(sbuf), fmt, s); + } + else + { +@@ -512,7 +512,7 @@ + if (i == 0 && conv_char == 'c') + strcpy (sbuf, "\000"); + else +- sprintf (sbuf, fmt, i); ++ snprintf (sbuf, sizeof(sbuf), fmt, i); + } + } + sp++; +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/gnulib-lib/uniname/uniname.c gettext/gettext-tools/gnulib-lib/uniname/uniname.c +--- gettext.upstream/gettext-tools/gnulib-lib/uniname/uniname.c ++++ gettext/gettext-tools/gnulib-lib/uniname/uniname.c +@@ -284,8 +284,8 @@ + small. */ + + /* buf needs to have at least 19 + 3 bytes here. */ +- sprintf (buf, "VARIATION SELECTOR-%d", +- c <= 0xFE0F ? c - 0xFE00 + 1 : c - 0xE0100 + 17); ++ snprintf (buf, UNINAME_MAX, "VARIATION SELECTOR-%d", ++ c <= 0xFE0F ? c - 0xFE00 + 1 : c - 0xE0100 + 17); + return buf; + } + else +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/src/cldr-plurals.c gettext/gettext-tools/src/cldr-plurals.c +--- gettext.upstream/gettext-tools/src/cldr-plurals.c ++++ gettext/gettext-tools/src/cldr-plurals.c +@@ -162,7 +162,7 @@ + buffer = (char *) xrealloc (buffer, bufmax); + } + +- sprintf (buffer + buflen, "%s: %s; ", count, content); ++ snprintf (buffer + buflen, bufmax - buflen, "%s: %s; ", count, content); + xmlFree (count); + xmlFree (content); + +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/src/format.c gettext/gettext-tools/src/format.c +--- gettext.upstream/gettext-tools/src/format.c ++++ gettext/gettext-tools/src/format.c +@@ -110,7 +110,7 @@ + + if (msgid_plural != NULL) + { +- sprintf (buf, "msgstr[%u]", j); ++ snprintf (buf, sizeof(buf), "msgstr[%u]", j); + pretty_msgstr = buf; + } + +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/src/read-mo.c gettext/gettext-tools/src/read-mo.c +--- gettext.upstream/gettext-tools/src/read-mo.c ++++ gettext/gettext-tools/src/read-mo.c +@@ -184,7 +184,8 @@ + if (!(ss_length > 0 && bfp->data[ss_end - 1] == '\0')) + { + char location[30]; +- sprintf (location, "sysdep_segment[%u]", (unsigned int) sysdepref); ++ snprintf (location, sizeof (location), ++ "sysdep_segment[%u]", (unsigned int) sysdepref); + error (EXIT_FAILURE, 0, + _("file \"%s\" contains a not NUL terminated string, at %s"), + bfp->filename, location); +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/src/search-path.c gettext/gettext-tools/src/search-path.c +--- gettext.upstream/gettext-tools/src/search-path.c ++++ gettext/gettext-tools/src/search-path.c +@@ -142,7 +142,7 @@ + gettextdatadirs = getenv ("XDG_DATA_DIRS"); + if (gettextdatadirs != NULL) + foreach_elements (gettextdatadirs, fill, &array); +- free (array.sub); ++ free ((char *)array.sub); + + /* Append version specific directory. */ + base = xasprintf ("%s%s", gettextdatadir, PACKAGE_SUFFIX); +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/src/write-csharp.c gettext/gettext-tools/src/write-csharp.c +--- gettext.upstream/gettext-tools/src/write-csharp.c ++++ gettext/gettext-tools/src/write-csharp.c +@@ -716,10 +716,10 @@ + { + char *class_name_part1 = construct_class_name (resource_name); + char *p; ++ size_t size = strlen (class_name_part1) + 1 + strlen (culture_name) + 1; + +- class_name = +- XNMALLOC (strlen (class_name_part1) + 1 + strlen (culture_name) + 1, char); +- sprintf (class_name, "%s_%s", class_name_part1, culture_name); ++ class_name = XNMALLOC (size, char); ++ snprintf (class_name, size, "%s_%s", class_name_part1, culture_name); + for (p = class_name + strlen (class_name_part1) + 1; *p != '\0'; p++) + if (*p == '-') + *p = '_'; +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/src/write-po.c gettext/gettext-tools/src/write-po.c +--- gettext.upstream/gettext-tools/src/write-po.c ++++ gettext/gettext-tools/src/write-po.c +@@ -78,16 +78,16 @@ + case possible: + if (debug) + { +- sprintf (result, "possible-%s-format", lang); ++ snprintf (result, sizeof(result), "possible-%s-format", lang); + break; + } + /* FALLTHROUGH */ + case yes_according_to_context: + case yes: +- sprintf (result, "%s-format", lang); ++ snprintf (result, sizeof(result), "%s-format", lang); + break; + case no: +- sprintf (result, "no-%s-format", lang); ++ snprintf (result, sizeof(result), "no-%s-format", lang); + break; + default: + /* The others have already been filtered out by significant_format_p. */ +@@ -399,7 +399,7 @@ + || pp->line_number == (size_t)(-1)) + buffer[0] = '\0'; + else +- sprintf (buffer, ":%ld", (long) pp->line_number); ++ snprintf (buffer, sizeof (buffer), ":%ld", (long) pp->line_number); + len = strlen (cp) + strlen (buffer) + 1; + if (column > 2 && column + len > page_width) + { +@@ -1375,7 +1375,7 @@ + p < mp->msgstr + mp->msgstr_len; + p += strlen (p) + 1, i++) + { +- sprintf (prefix_buf, "msgstr[%u]", i); ++ snprintf (prefix_buf, sizeof (prefix_buf), "msgstr[%u]", i); + wrap (mp, stream, NULL, extra_indent, class_msgstr, prefix_buf, p, + mp->do_wrap, page_width, charset); + } +@@ -1499,7 +1499,7 @@ + p < mp->msgstr + mp->msgstr_len; + p += strlen (p) + 1, i++) + { +- sprintf (prefix_buf, "msgstr[%u]", i); ++ snprintf (prefix_buf, sizeof (prefix_buf), "msgstr[%u]", i); + wrap (mp, stream, "#~ ", extra_indent, class_msgstr, prefix_buf, p, + mp->do_wrap, page_width, charset); + } +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/src/write-properties.c gettext/gettext-tools/src/write-properties.c +--- gettext.upstream/gettext-tools/src/write-properties.c ++++ gettext/gettext-tools/src/write-properties.c +@@ -96,7 +96,7 @@ + else if (uc < 0x10000) + { + /* Single UCS-2 'char' */ +- sprintf (newstr, "\\u%c%c%c%c", ++ snprintf (newstr, length + 1 - (newstr - result), "\\u%c%c%c%c", + hexdigit[(uc >> 12) & 0x0f], hexdigit[(uc >> 8) & 0x0f], + hexdigit[(uc >> 4) & 0x0f], hexdigit[uc & 0x0f]); + newstr += 6; +@@ -106,11 +106,11 @@ + /* UTF-16 surrogate: two 'char's. */ + ucs4_t uc1 = 0xd800 + ((uc - 0x10000) >> 10); + ucs4_t uc2 = 0xdc00 + ((uc - 0x10000) & 0x3ff); +- sprintf (newstr, "\\u%c%c%c%c", ++ snprintf (newstr, length + 1 - (newstr - result), "\\u%c%c%c%c", + hexdigit[(uc1 >> 12) & 0x0f], hexdigit[(uc1 >> 8) & 0x0f], + hexdigit[(uc1 >> 4) & 0x0f], hexdigit[uc1 & 0x0f]); + newstr += 6; +- sprintf (newstr, "\\u%c%c%c%c", ++ snprintf (newstr, length + 1 - (newstr - result), "\\u%c%c%c%c", + hexdigit[(uc2 >> 12) & 0x0f], hexdigit[(uc2 >> 8) & 0x0f], + hexdigit[(uc2 >> 4) & 0x0f], hexdigit[uc2 & 0x0f]); + newstr += 6; +diff -Paur --no-dereference -- gettext.upstream/gettext-tools/src/xgettext.c gettext/gettext-tools/src/xgettext.c +--- gettext.upstream/gettext-tools/src/xgettext.c ++++ gettext/gettext-tools/src/xgettext.c +@@ -2321,7 +2321,7 @@ + if (line_number == (size_t)(-1)) + buffer[0] = '\0'; + else +- sprintf (buffer, ":%ld", (long) line_number); ++ snprintf (buffer, sizeof (buffer), ":%ld", (long) line_number); + + switch (lcontext) + { +@@ -2441,7 +2441,7 @@ + if (pos->line_number == (size_t)(-1)) + buffer[0] = '\0'; + else +- sprintf (buffer, ":%ld", (long) pos->line_number); ++ snprintf (buffer, sizeof (buffer), ":%ld", (long) pos->line_number); + multiline_warning (xasprintf (_("%s%s: warning: "), + pos->file_name, buffer), + xasprintf (is_format[i] == yes_according_to_context +@@ -2474,7 +2474,7 @@ + if (pos->line_number == (size_t)(-1)) + buffer[0] = '\0'; + else +- sprintf (buffer, ":%ld", (long) pos->line_number); ++ snprintf (buffer, sizeof (buffer), ":%ld", (long) pos->line_number); + multiline_warning (xasprintf (_("%s%s: warning: "), + pos->file_name, buffer), + xasprintf (_("\ +@@ -2539,7 +2539,7 @@ + if (pos->line_number == (size_t)(-1)) + buffer[0] = '\0'; + else +- sprintf (buffer, ":%ld", (long) pos->line_number); ++ snprintf (buffer, sizeof (buffer), ":%ld", (long) pos->line_number); + multiline_warning (xasprintf (_("%s%s: warning: "), pos->file_name, + buffer), + xstrdup (_("\ diff --git a/ports/gettext/gettext.port b/ports/gettext/gettext.port new file mode 100644 index 00000000..0d00bd86 --- /dev/null +++ b/ports/gettext/gettext.port @@ -0,0 +1,15 @@ +NAME=gettext +BUILD_LIBRARIES='libiconv libintl libxml2 libcroco? libcurses? libexpat? libunistring?' +VERSION=0.19.8 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=9c1781328238caa1685d7bc7a2e1dcf1c6c134e86b42ed554066734b621bd12f +UPSTREAM_SITE=https://ftp.gnu.org/gnu/gettext +UPSTREAM_ARCHIVE=$ARCHIVE +# TODO: libcroco and libunistring are bundled and are only marked as optional +# here as there's no official port yet. Finish those and then remove +# them as optional. +SUBDIR=gettext-tools +BUILD_SYSTEM=configure +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/git/git.patch b/ports/git/git.patch new file mode 100644 index 00000000..7908a49e --- /dev/null +++ b/ports/git/git.patch @@ -0,0 +1,429 @@ +diff -Paur --no-dereference -- git.upstream/builtin/log.c git/builtin/log.c +--- git.upstream/builtin/log.c ++++ git/builtin/log.c +@@ -249,7 +249,12 @@ + fprintf(rev->diffopt.file, _("Final output: %d %s\n"), nr, stage); + } + ++/* PATCH: Sortix does not have obsolescent XSI itimers. */ ++#if defined(__sortix__) ++static timer_t early_output_timer; ++#else + static struct itimerval early_output_timer; ++#endif + + static void log_show_early(struct rev_info *revs, struct commit_list *list) + { +@@ -297,9 +302,18 @@ + * trigger every second even if we're blocked on a + * reader! + */ ++#if defined(__sortix__) ++ struct itimerspec its; ++ its.it_value.tv_sec = 0; ++ its.it_value.tv_nsec = 500000000; ++ its.it_interval.tv_sec = 0; ++ its.it_interval.tv_nsec = 0; ++ timer_settime(early_output_timer, 0, &its, NULL); ++#else + early_output_timer.it_value.tv_sec = 0; + early_output_timer.it_value.tv_usec = 500000; + setitimer(ITIMER_REAL, &early_output_timer, NULL); ++#endif + } + + static void early_output(int signal) +@@ -309,6 +323,13 @@ + + static void setup_early_output(struct rev_info *rev) + { ++#if defined(__sortix__) && !defined(__SORTIX_HAS_RESTARTABLE_SYSCALLS__) ++ /* TODO: Sortix doesn't have restartable system calls at the moment and this ++ feature creates spurious failures, so this feature is disabled for ++ now. */ ++ return; ++#endif ++ + struct sigaction sa; + + /* +@@ -331,13 +352,37 @@ + * + * This is a one-time-only trigger. + */ ++#if defined(__sortix__) ++ struct sigevent sev; ++ memset(&sev, 0, sizeof(sev)); ++ sev.sigev_notify = SIGEV_SIGNAL; ++ sev.sigev_signo = SIGALRM; ++ timer_create(CLOCK_MONOTONIC, &sev, &early_output_timer); ++ struct itimerspec its; ++ its.it_value.tv_sec = 0; ++ its.it_value.tv_nsec = 100000000; ++ its.it_interval.tv_sec = 0; ++ its.it_interval.tv_nsec = 0; ++ timer_settime(early_output_timer, 0, &its, NULL); ++#else + early_output_timer.it_value.tv_sec = 0; + early_output_timer.it_value.tv_usec = 100000; + setitimer(ITIMER_REAL, &early_output_timer, NULL); ++#endif + } + + static void finish_early_output(struct rev_info *rev) + { ++#if defined(__sortix__) && !defined(__SORTIX_HAS_RESTARTABLE_SYSCALLS__) ++ /* TODO: Sortix doesn't have restartable system calls at the moment and this ++ feature creates spurious failures, so this feature is disabled for ++ now. */ ++ return; ++#endif ++ ++#if defined(__sortix__) ++ timer_delete(early_output_timer); ++#endif + int n = estimate_commit_count(rev, rev->commits); + signal(SIGALRM, SIG_IGN); + show_early_header(rev, "done", n); +diff -Paur --no-dereference -- git.upstream/compat/hstrerror.c git/compat/hstrerror.c +--- git.upstream/compat/hstrerror.c ++++ git/compat/hstrerror.c +@@ -2,6 +2,10 @@ + #include + #include + ++/* PATCH: hstrerror(3) is not used by git when getaddrinfo(3) is available. ++ Sortix has the modern getaddrinfo(3), but does not have the obsolete ++ gethostbyname(3). */ ++#ifdef NO_IPV6 + const char *githstrerror(int err) + { + static char buffer[48]; +@@ -19,3 +23,4 @@ + snprintf(buffer, sizeof(buffer), "Name resolution error %d", err); + return buffer; + } ++#endif +diff -Paur --no-dereference -- git.upstream/config.mak.uname git/config.mak.uname +--- git.upstream/config.mak.uname ++++ git/config.mak.uname +@@ -17,6 +17,8 @@ + # because maintaining the nesting to match is a pain. If + # we had "elif" things would have been much nicer... + ++# PATCH: Assume unknown operating systems have /dev/tty as required by POSIX. ++HAVE_DEV_TTY = YesPlease + ifeq ($(uname_S),OSF1) + # Need this for u_short definitions et al + BASIC_CFLAGS += -D_OSF_SOURCE +diff -Paur --no-dereference -- git.upstream/configure git/configure +--- git.upstream/configure ++++ git/configure +@@ -5315,7 +5315,7 @@ + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +-LIBS="-lcurl $LIBS" ++LIBS="-lcurl -lssl -lcrypto -lz $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +@@ -5364,52 +5364,13 @@ + + if test -z "$NO_CURL"; then + +-# Extract the first word of "curl-config", so it can be a program name with args. +-set dummy curl-config; ac_word=$2 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +-$as_echo_n "checking for $ac_word... " >&6; } +-if ${ac_cv_prog_CURL_CONFIG+:} false; then : +- $as_echo_n "(cached) " >&6 +-else +- if test -n "$CURL_CONFIG"; then +- ac_cv_prog_CURL_CONFIG="$CURL_CONFIG" # Let the user override the test. +-else +-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +-for as_dir in $PATH +-do +- IFS=$as_save_IFS +- test -z "$as_dir" && as_dir=. +- for ac_exec_ext in '' $ac_executable_extensions; do +- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then +- ac_cv_prog_CURL_CONFIG="curl-config" +- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 +- break 2 +- fi +-done +- done +-IFS=$as_save_IFS +- +- test -z "$ac_cv_prog_CURL_CONFIG" && ac_cv_prog_CURL_CONFIG="no" +-fi +-fi +-CURL_CONFIG=$ac_cv_prog_CURL_CONFIG +-if test -n "$CURL_CONFIG"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CURL_CONFIG" >&5 +-$as_echo "$CURL_CONFIG" >&6; } +-else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +-fi +- +- +- +-if test $CURL_CONFIG != no; then ++# PATCH: pkg-config must be used instead of the bad curl-config. + + config_appended_defs="$config_appended_defs${newline}CURL_CONFIG=${CURL_CONFIG}" + if test -z "${NO_OPENSSL}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Curl supports SSL" >&5 + $as_echo_n "checking if Curl supports SSL... " >&6; } +- if test $(curl-config --features|grep SSL) = SSL; then ++ if test -n "$(${PKG_CONFIG:-pkg-config} libcurl --variable=supported_features|grep SSL)"; then + NEEDS_SSL_WITH_CURL=YesPlease + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + $as_echo "yes" >&6; } +@@ -5423,8 +5384,6 @@ + fi + fi + +-fi +- + + # + # Define NO_EXPAT if you do not have expat installed. git-http-push is +diff -Paur --no-dereference -- git.upstream/git-compat-util.h git/git-compat-util.h +--- git.upstream/git-compat-util.h ++++ git/git-compat-util.h +@@ -325,6 +325,10 @@ + typedef uintmax_t timestamp_t; + #define PRItime PRIuMAX + #define parse_timestamp strtoumax ++/* PATCH: Avoid conflicting Sortix macro. */ ++#ifdef TIME_MAX ++#undef TIME_MAX ++#endif + #define TIME_MAX UINTMAX_MAX + + #ifndef PATH_SEP +diff -Paur --no-dereference -- git.upstream/lockfile.c git/lockfile.c +--- git.upstream/lockfile.c ++++ git/lockfile.c +@@ -105,16 +105,10 @@ + int n = 1; + int multiplier = 1; + long remaining_ms = 0; +- static int random_initialized = 0; + + if (timeout_ms == 0) + return lock_file(lk, path, flags); + +- if (!random_initialized) { +- srand((unsigned int)getpid()); +- random_initialized = 1; +- } +- + if (timeout_ms > 0) + remaining_ms = timeout_ms; + +@@ -133,7 +127,8 @@ + + backoff_ms = multiplier * INITIAL_BACKOFF_MS; + /* back off for between 0.75*backoff_ms and 1.25*backoff_ms */ +- wait_ms = (750 + rand() % 500) * backoff_ms / 1000; ++ /* PATCH: Avoid rand(3) warning and modulo bias. */ ++ wait_ms = (750 + arc4random_uniform(500)) * backoff_ms / 1000; + sleep_millisec(wait_ms); + remaining_ms -= wait_ms; + +diff -Paur --no-dereference -- git.upstream/Makefile git/Makefile +--- git.upstream/Makefile ++++ git/Makefile +@@ -1176,9 +1176,7 @@ + endif + ifdef NEEDS_SSL_WITH_CURL + CURL_LIBCURL += -lssl +- ifdef NEEDS_CRYPTO_WITH_SSL +- CURL_LIBCURL += -lcrypto +- endif ++ CURL_LIBCURL += -lcrypto + endif + ifdef NEEDS_IDN_WITH_CURL + CURL_LIBCURL += -lidn +@@ -1252,6 +1250,12 @@ + LIB_4_CRYPTO += -framework Security -framework CoreFoundation + endif + endif ++# PATCH: Link with libintl first so it can statically link with libiconv. ++ifndef NO_GETTEXT ++ifndef LIBC_CONTAINS_LIBINTL ++ EXTLIBS += -lintl ++endif ++endif + ifdef NEEDS_LIBICONV + ifdef ICONVDIR + BASIC_CFLAGS += -I$(ICONVDIR)/include +@@ -1259,19 +1263,11 @@ + else + ICONV_LINK = + endif +- ifdef NEEDS_LIBINTL_BEFORE_LIBICONV +- ICONV_LINK += -lintl +- endif + EXTLIBS += $(ICONV_LINK) -liconv + endif + ifdef NEEDS_LIBGEN + EXTLIBS += -lgen + endif +-ifndef NO_GETTEXT +-ifndef LIBC_CONTAINS_LIBINTL +- EXTLIBS += -lintl +-endif +-endif + ifdef NEEDS_SOCKET + EXTLIBS += -lsocket + endif +@@ -2184,8 +2180,10 @@ + doc: + $(MAKE) -C Documentation all + ++# PATCH: Build manual pages if asciidoc and xmlto are installed. ++all:: man + man: +- $(MAKE) -C Documentation man ++ if which asciidoc 1>/dev/null 2>/dev/null && which xmlto 1>/dev/null 2>/dev/null; then $(MAKE) -C Documentation man; fi + + html: + $(MAKE) -C Documentation html +@@ -2502,7 +2500,7 @@ + profile-fast-install: profile-fast + $(MAKE) install + +-install: all ++install: all install-man + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)' + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' + $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' +@@ -2570,8 +2568,9 @@ + install-doc: + $(MAKE) -C Documentation install + ++# PATCH: Install manual pages if asciidoc and xmlto are installed. + install-man: +- $(MAKE) -C Documentation install-man ++ if which asciidoc 1>/dev/null 2>/dev/null && which xmlto 1>/dev/null 2>/dev/null; then $(MAKE) -C Documentation install-man; fi + + install-html: + $(MAKE) -C Documentation install-html +@@ -2638,8 +2637,8 @@ + + ### Cleaning rules + ++# PATCH: Don't delete configure when making distclean because it is in the dist. + distclean: clean +- $(RM) configure + $(RM) config.log config.status config.cache + $(RM) config.mak.autogen config.mak.append + $(RM) -r autom4te.cache +diff -Paur --no-dereference -- git.upstream/progress.c git/progress.c +--- git.upstream/progress.c ++++ git/progress.c +@@ -39,6 +39,10 @@ + uint64_t start_ns; + }; + ++/* PATCH: Sortix does not have obsolescent XSI itimers. */ ++#if defined(__sortix__) ++static timer_t progress_timer; ++#endif + static volatile sig_atomic_t progress_update; + + static void progress_interval(int signum) +@@ -48,8 +52,19 @@ + + static void set_progress_signal(void) + { ++#if defined(__sortix__) && !defined(__SORTIX_HAS_RESTARTABLE_SYSCALLS__) ++ /* TODO: Sortix doesn't have restartable system calls at the moment and this ++ feature creates spurious failures, so this feature is disabled for ++ now. */ ++ return; ++#endif ++ + struct sigaction sa; ++#if defined(__sortix__) ++ struct itimerspec v; ++#else + struct itimerval v; ++#endif + + progress_update = 0; + +@@ -59,16 +74,39 @@ + sa.sa_flags = SA_RESTART; + sigaction(SIGALRM, &sa, NULL); + ++#if defined(__sortix__) ++ struct sigevent sev; ++ memset(&sev, 0, sizeof(sev)); ++ sev.sigev_notify = SIGEV_SIGNAL; ++ sev.sigev_signo = SIGALRM; ++ timer_create(CLOCK_MONOTONIC, &sev, &progress_timer); ++ v.it_interval.tv_sec = 1; ++ v.it_interval.tv_nsec = 0; ++ v.it_value = v.it_interval; ++ timer_settime(progress_timer, 0, &v, NULL); ++#else + v.it_interval.tv_sec = 1; + v.it_interval.tv_usec = 0; + v.it_value = v.it_interval; + setitimer(ITIMER_REAL, &v, NULL); ++#endif + } + + static void clear_progress_signal(void) + { ++#if defined(__sortix__) && !defined(__SORTIX_HAS_RESTARTABLE_SYSCALLS__) ++ /* TODO: Sortix doesn't have restartable system calls at the moment and this ++ feature creates spurious failures, so this feature is disabled for ++ now. */ ++ return; ++#endif ++ ++#if defined(__sortix__) ++ timer_delete(progress_timer); ++#else + struct itimerval v = {{0,},}; + setitimer(ITIMER_REAL, &v, NULL); ++#endif + signal(SIGALRM, SIG_IGN); + progress_update = 0; + } +diff -Paur --no-dereference -- git.upstream/run-command.c git/run-command.c +--- git.upstream/run-command.c ++++ git/run-command.c +@@ -491,9 +491,12 @@ + #else + bug_die(pthread_sigmask(SIG_SETMASK, &all, &as->old), + "blocking all signals"); ++/* PATCH: Sortix doesn't have pthread cancelation. */ ++#ifdef PTHREAD_CANCEL_DISABLE + bug_die(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &as->cs), + "disabling cancellation"); + #endif ++#endif + } + + static void atfork_parent(struct atfork_state *as) +@@ -502,8 +505,11 @@ + if (sigprocmask(SIG_SETMASK, &as->old, NULL)) + die_errno("sigprocmask"); + #else ++/* PATCH: Sortix doesn't have pthread cancelation. */ ++#ifdef PTHREAD_CANCEL_DISABLE + bug_die(pthread_setcancelstate(as->cs, NULL), + "re-enabling cancellation"); ++#endif + bug_die(pthread_sigmask(SIG_SETMASK, &as->old, NULL), + "restoring signal mask"); + #endif diff --git a/ports/git/git.port b/ports/git/git.port new file mode 100644 index 00000000..f87d6539 --- /dev/null +++ b/ports/git/git.port @@ -0,0 +1,22 @@ +NAME=git +BUILD_LIBRARIES='libiconv libz libcurl? libexpat? libintl? libpcre? libssl?' +VERSION=2.14.3 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=5330960dd52467f6e5bf1931b9fd42b76d3f8ce9bc75150b54ecfb57d407151d +UPSTREAM_SITE=https://www.kernel.org/pub/software/scm/git +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_PROGRAMS='asciidoc? dblatex? docbook2x? xmlto?' +BUILD_SYSTEM=configure +DIRTY_FILE=config.mak.autogen +CONFIGURE_ARGS='--with-editor=editor --with-pager=pager --with-shell=sh --with-perl=perl --with-python=python' +CONFIGURE_VARS='ac_cv_fread_reads_directories=no ac_cv_snprintf_returns_bogus=no' +# TODO: We force MAKE to make because I occasionally use a tool called colormake +# that likes to colorize even when the output device is a pipe, which +# causes trouble here. You can safely remove this sortie has learned the +# error of his ways. +# Perl is disabled because Sortix has no perl port at the moment and I'm not +# confident it cross-compiles properly. It also installs stuff into /usr/local +# when prefix is empty and not sure how that happens. +MAKE_VARS='V=1 MAKE=make NO_PERL=NoThanks' diff --git a/ports/grep/grep.patch b/ports/grep/grep.patch new file mode 100644 index 00000000..3c26fb0d --- /dev/null +++ b/ports/grep/grep.patch @@ -0,0 +1,138 @@ +diff -Paur --no-dereference -- grep.upstream/build-aux/config.sub grep/build-aux/config.sub +--- grep.upstream/build-aux/config.sub ++++ grep/build-aux/config.sub +@@ -1360,7 +1360,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- grep.upstream/configure grep/configure +--- grep.upstream/configure ++++ grep/configure +@@ -1,4 +1,122 @@ + #! /bin/sh ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69.117-1717 for GNU grep 2.20. + # diff --git a/ports/grep/grep.port b/ports/grep/grep.port new file mode 100644 index 00000000..6330e5d0 --- /dev/null +++ b/ports/grep/grep.port @@ -0,0 +1,11 @@ +NAME=grep +BUILD_LIBRARIES='libiconv? gettext?' +VERSION=2.20 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=f0af452bc0d09464b6d089b6d56a0a3c16672e9ed9118fbe37b0b6aeaf069a65 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/grep +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' diff --git a/ports/grep/grep.rmpatch b/ports/grep/grep.rmpatch new file mode 100644 index 00000000..c06153ab --- /dev/null +++ b/ports/grep/grep.rmpatch @@ -0,0 +1 @@ +rm -rf -- 'doc/stamp-vti' diff --git a/ports/grub/grub.execpatch b/ports/grub/grub.execpatch new file mode 100644 index 00000000..063bb676 --- /dev/null +++ b/ports/grub/grub.execpatch @@ -0,0 +1,2 @@ +chmod +x -- '10_sortix' +chmod +x -- 'update-grub' diff --git a/ports/grub/grub.patch b/ports/grub/grub.patch new file mode 100644 index 00000000..bf5faf9d --- /dev/null +++ b/ports/grub/grub.patch @@ -0,0 +1,869 @@ +diff -Paur --no-dereference -- grub.upstream/10_sortix grub/10_sortix +--- grub.upstream/10_sortix ++++ grub/10_sortix +@@ -0,0 +1,70 @@ ++#!/bin/sh -e ++! [ -e /etc/sortix-release ] && exit 0 ++. /etc/sortix-release ++find_mountpoint() {( ++ FILE="$1" ++ DEVICE=$(grub-probe -t device -- "$FILE") ++ while [ "$FILE" != "/" ]; do ++ PARENT="$(dirname -- "$FILE")" ++ if [ x"$(grub-probe -t device -- "$PARENT")" != x"$DEVICE" ]; then ++ echo "$FILE" ++ exit 0 ++ fi ++ FILE="$PARENT" ++ done ++ echo "$FILE" ++ exit 0 ++)} ++mountpoint_relative() {( ++ REL="" ++ FILE="$1" ++ DEVICE=$(grub-probe -t device -- "$FILE") ++ while [ "$FILE" != "/" ]; do ++ PARENT="$(dirname -- "$FILE")" ++ if [ x"$(grub-probe -t device -- "$PARENT")" != x"$DEVICE" ]; then ++ echo "$REL" ++ exit 0 ++ fi ++ REL="/$(basename -- "$FILE")$REL" ++ FILE="$PARENT" ++ done ++ echo "$REL" ++ exit 0 ++)} ++BOOT_MNT=$(find_mountpoint /boot) ++BOOT_REL=$(mountpoint_relative /boot) ++DEVICE=$(grub-probe -t device -- "$BOOT_MNT") ++FS_UUID=$(grub-probe -t fs_uuid -- "$BOOT_MNT") ++HINTS_STRING=$(grub-probe -t hints_string -- "$BOOT_MNT") ++PARTMAP=$(grub-probe -t partmap -- "$BOOT_MNT") ++FS=$(grub-probe -t fs -- "$BOOT_MNT") ++echo "Found $PRETTY_NAME on $DEVICE" >&2 ++cat > "$0.cache" << EOF ++menuentry "$PRETTY_NAME (on $DEVICE)" --unrestricted { ++ insmod part_$PARTMAP ++ insmod $FS ++ search --no-floppy --fs-uuid --set=root $HINTS_STRING $FS_UUID ++ if [ -e $BOOT_REL/sortix.bin.xz ]; then ++ insmod xzio ++ multiboot $BOOT_REL/sortix.bin.xz ++ elif [ -e $BOOT_REL/sortix.bin.gz ]; then ++ insmod gzio ++ multiboot $BOOT_REL/sortix.bin.gz ++ else ++ multiboot $BOOT_REL/sortix.bin ++ fi ++ if [ -e $BOOT_REL/random.seed ]; then ++ module $BOOT_REL/random.seed --random-seed ++ fi ++ if [ -e $BOOT_REL/sortix.initrd.xz ]; then ++ insmod xzio ++ module $BOOT_REL/sortix.initrd.xz ++ elif [ -e $BOOT_REL/sortix.initrd.gz ]; then ++ insmod gzio ++ module $BOOT_REL/sortix.initrd.gz ++ else ++ module $BOOT_REL/sortix.initrd ++ fi ++} ++EOF ++cat "$0.cache" +diff -Paur --no-dereference -- grub.upstream/build-aux/config.sub grub/build-aux/config.sub +--- grub.upstream/build-aux/config.sub ++++ grub/build-aux/config.sub +@@ -1354,7 +1354,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- grub.upstream/configure grub/configure +--- grub.upstream/configure ++++ grub/configure +@@ -1,4 +1,126 @@ + #! /bin/sh ++# CFLAGS containing -s produces a broken GRUB on boot. ++if [ -n "$CFLAGS" ]; then ++ CFLAGS=$(printf '%s\n' "$CFLAGS" | sed 's/\(^\|[[:space:]]\+\)-s\([[:space:]]\+\|$\)/ /g') ++fi ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for GRUB 2.02~beta2. + # +@@ -26950,6 +27072,11 @@ + + fi + fi ++if ${PKG_CONFIG:-pkg-config} --exists freetype2; then ++ ac_cv_prog_FREETYPE="${PKG_CONFIG:-pkg-config} freetype2" ++else ++ ac_cv_prog_FREETYPE= ++fi + FREETYPE=$ac_cv_prog_FREETYPE + if test -n "$FREETYPE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE" >&5 +diff -Paur --no-dereference -- grub.upstream/grub-core/lib/libgcrypt-grub/cipher/rijndael.c grub/grub-core/lib/libgcrypt-grub/cipher/rijndael.c +--- grub.upstream/grub-core/lib/libgcrypt-grub/cipher/rijndael.c ++++ grub/grub-core/lib/libgcrypt-grub/cipher/rijndael.c +@@ -180,8 +180,9 @@ + static int initialized = 0; + static const char *selftest_failed=0; + int rounds; +- int i,j, r, t, rconpointer = 0; ++ int j, r, t, rconpointer = 0; + int KC; ++ unsigned i; + union + { + PROPERLY_ALIGNED_TYPE dummy; +@@ -226,7 +227,9 @@ + KC = 4; + + if (0) +- ; ++ { ++ ; /* [-Wempty-body] */ ++ } + #ifdef USE_PADLOCK + else if ((_gcry_get_hw_features () & HWF_PADLOCK_AES)) + { +@@ -349,7 +352,7 @@ + else + { + #define W (ctx->keyschenc) +- for (i = 0; i < keylen; i++) ++ for (i = 0; i < keylen; i++) /* [-Wsign-compare] */ + { + k[i >> 2][i & 3] = key[i]; + } +diff -Paur --no-dereference -- grub.upstream/grub-core/osdep/getroot.c grub/grub-core/osdep/getroot.c +--- grub.upstream/grub-core/osdep/getroot.c ++++ grub/grub-core/osdep/getroot.c +@@ -16,6 +16,8 @@ + #include "aros/getroot.c" + #elif defined (__HAIKU__) + #include "haiku/getroot.c" ++#elif defined(__sortix__) ++#include "sortix/getroot.c" + #else + # warning "No getroot OS-specific functions is available for your system. Device detection may not work properly." + #include "basic/getroot.c" +diff -Paur --no-dereference -- grub.upstream/grub-core/osdep/hostdisk.c grub/grub-core/osdep/hostdisk.c +--- grub.upstream/grub-core/osdep/hostdisk.c ++++ grub/grub-core/osdep/hostdisk.c +@@ -16,6 +16,8 @@ + #include "aros/hostdisk.c" + #elif defined (__HAIKU__) + #include "haiku/hostdisk.c" ++#elif defined(__sortix__) ++#include "sortix/hostdisk.c" + #else + # warning "No hostdisk OS-specific functions is available for your system. Device detection may not work properly." + #include "basic/hostdisk.c" +diff -Paur --no-dereference -- grub.upstream/grub-core/osdep/random.c grub/grub-core/osdep/random.c +--- grub.upstream/grub-core/osdep/random.c ++++ grub/grub-core/osdep/random.c +@@ -5,6 +5,8 @@ + || defined (__GNU__) || defined (__NetBSD__) \ + || defined (__APPLE__) || defined(__sun__) || defined (__HAIKU__) + #include "unix/random.c" ++#elif defined(__sortix__) ++#include "sortix/random.c" + #else + #include "basic/random.c" + #endif +diff -Paur --no-dereference -- grub.upstream/grub-core/osdep/sortix/getroot.c grub/grub-core/osdep/sortix/getroot.c +--- grub.upstream/grub-core/osdep/sortix/getroot.c ++++ grub/grub-core/osdep/sortix/getroot.c +@@ -0,0 +1,162 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011,2012,2013 Free Software Foundation, Inc. ++ * ++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see . ++ */ ++ ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#include ++ ++#include ++#include ++#include ++#include ++#include ++ ++int ++is_sortix_partition_path (const char *path) ++{ ++ const char *dev = "/dev/"; ++ size_t devlen = strlen (dev); ++ if (memcmp (path, dev, devlen) != 0) ++ return 0; ++ path += devlen; ++ if (!*path || isdigit ((unsigned char)*path)) ++ return 0; ++ while (*path && !isdigit ((unsigned char)*path)) ++ path++; ++ if (!*path || !isdigit ((unsigned char)*path)) ++ return 0; ++ while (*path && isdigit ((unsigned char)*path)) ++ path++; ++ if (*path++ != 'p') ++ return 0; ++ if (!*path || !isdigit ((unsigned char)*path)) ++ return 0; ++ while (*path && isdigit ((unsigned char)*path)) ++ path++; ++ if (*path) ++ return 0; ++ return 1; ++} ++ ++char * ++grub_util_part_to_disk (const char *os_dev, ++ struct stat *st, ++ int *is_part) ++{ ++ if (! S_ISBLK (st->st_mode)) ++ { ++ *is_part = 0; ++ return xstrdup (os_dev); ++ } ++ ++ char *path = realpath (os_dev, NULL); ++ ++ if (is_sortix_partition_path (path)) ++ { ++ *strrchr (path, 'p') = '\0'; ++ *is_part = 1; ++ return path; ++ } ++ ++ return path; ++} ++ ++enum grub_dev_abstraction_types ++grub_util_get_dev_abstraction_os (const char *os_dev __attribute__((unused))) ++{ ++ return GRUB_DEV_ABSTRACTION_NONE; ++} ++ ++int ++grub_util_pull_device_os (const char *os_dev __attribute__ ((unused)), ++ enum grub_dev_abstraction_types ab __attribute__ ((unused))) ++{ ++ return 0; ++} ++ ++char * ++grub_util_get_grub_dev_os (const char *os_dev __attribute__ ((unused))) ++{ ++ return NULL; ++} ++ ++ ++grub_disk_addr_t ++grub_util_find_partition_start_os (const char *dev __attribute__ ((unused))) ++{ ++ /* TODO: We need new system support for this in Sortix. */ ++ return 0; ++} ++ ++static char * ++find_sortix_root_device (const char *path) ++{ ++ int fd = open (path, O_RDONLY); ++ if (fd < 0) ++ return 0; ++ ssize_t blob_size = tcgetblob (fd, "device-path", NULL, 0); ++ if (blob_size < 0) ++ return close (fd), (char *)0; ++ char *blob = malloc (blob_size + 1); ++ if (!blob) ++ return close (fd), (char *)0; ++ if (tcgetblob(fd, "device-path", blob, blob_size) != blob_size) ++ return free (blob), close (fd), (char *)0; ++ close (fd); ++ blob[blob_size] = '\0'; ++ return blob; ++} ++ ++char ** ++grub_guess_root_devices (const char *dir) ++{ ++ char **os_dev = NULL; ++ ++ os_dev = xmalloc (2 * sizeof (os_dev[0])); ++ ++ /* Sortix specific function. */ ++ os_dev[0] = find_sortix_root_device (dir); ++ ++ if (!os_dev[0]) ++ { ++ free (os_dev); ++ return 0; ++ } ++ ++ os_dev[1] = 0; ++ ++ return os_dev; ++} +diff -Paur --no-dereference -- grub.upstream/grub-core/osdep/sortix/hostdisk.c grub/grub-core/osdep/sortix/hostdisk.c +--- grub.upstream/grub-core/osdep/sortix/hostdisk.c ++++ grub/grub-core/osdep/sortix/hostdisk.c +@@ -0,0 +1,66 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,2013 Free Software Foundation, Inc. ++ * ++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see . ++ */ ++ ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++grub_int64_t ++grub_util_get_fd_size_os (grub_util_fd_t fd, ++ const char *name, ++ unsigned *log_secsize) ++{ ++ struct stat st; ++ if (fstat (fd, &st)) ++ return -1; ++ unsigned int sector_size = st.st_blksize; ++ unsigned int log_sector_size; ++ for (log_sector_size = 0; ++ (1 << log_sector_size) < sector_size; ++ log_sector_size++); ++ if (log_secsize) ++ *log_secsize = log_sector_size; ++ return st.st_size; ++} ++ ++void ++grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused))) ++{ ++} +diff -Paur --no-dereference -- grub.upstream/grub-core/osdep/sortix/random.c grub/grub-core/osdep/sortix/random.c +--- grub.upstream/grub-core/osdep/sortix/random.c ++++ grub/grub-core/osdep/sortix/random.c +@@ -0,0 +1,35 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 1992-1999,2001,2003,2004,2005,2009,2010,2011,2012,2013 Free Software Foundation, Inc. ++ * ++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see . ++ */ ++ ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++int ++grub_get_random (void *out, grub_size_t len) ++{ ++ arc4random_buf(out, len); ++ return 0; ++} +diff -Paur --no-dereference -- grub.upstream/grub-core/osdep/unix/getroot.c grub/grub-core/osdep/unix/getroot.c +--- grub.upstream/grub-core/osdep/unix/getroot.c ++++ grub/grub-core/osdep/unix/getroot.c +@@ -111,7 +111,8 @@ + #include + #endif + +-#if !defined (__GNU__) ++/* Sortix implements these in grub-core/osdep/sortix/getroot.c instead. */ ++#if !defined (__GNU__) && !defined(__sortix__) + static void + strip_extra_slashes (char *dir) + { +@@ -441,7 +442,7 @@ + + cwd = xgetcwd (); + res = xmalloc (strlen (cwd) + strlen (ent->d_name) + 3); +- sprintf (res, ++ snprintf (res, strlen (cwd) + strlen (ent->d_name) + 3, + #if defined(__NetBSD__) || defined(__OpenBSD__) + /* Convert this block device to its character (raw) device. */ + "%s/r%s", +diff -Paur --no-dereference -- grub.upstream/grub-core/osdep/unix/hostdisk.c grub/grub-core/osdep/unix/hostdisk.c +--- grub.upstream/grub-core/osdep/unix/hostdisk.c ++++ grub/grub-core/osdep/unix/hostdisk.c +@@ -200,16 +200,7 @@ + char * + grub_canonicalize_file_name (const char *path) + { +-#if defined (PATH_MAX) +- char *ret; +- +- ret = xmalloc (PATH_MAX); +- if (!realpath (path, ret)) +- return NULL; +- return ret; +-#else +- return realpath (path, NULL); +-#endif ++ return canonicalize_file_name (path); + } + + FILE * +diff -Paur --no-dereference -- grub.upstream/grub-core/osdep/unix/password.c grub/grub-core/osdep/unix/password.c +--- grub.upstream/grub-core/osdep/unix/password.c ++++ grub/grub-core/osdep/unix/password.c +@@ -37,9 +37,9 @@ + grub_refresh (); + + /* Disable echoing. Based on glibc. */ +- in = fopen ("/dev/tty", "w+c"); ++ in = fopen ("/dev/tty", "w+"); /* 'c' on glibc means no thread cancellation */ + if (in == NULL) +- in = stdin; ++ return 0; + + if (tcgetattr (fileno (in), &t) == 0) + { +diff -Paur --no-dereference -- grub.upstream/grub-core/osdep/unix/platform.c grub/grub-core/osdep/unix/platform.c +--- grub.upstream/grub-core/osdep/unix/platform.c ++++ grub/grub-core/osdep/unix/platform.c +@@ -114,8 +114,14 @@ + || line[sizeof ("Boot") - 1] < '0' + || line[sizeof ("Boot") - 1] > '9') + continue; ++#if defined(__sortix__) ++/* PATCH: Sortix doesn't have strcasestr yet. */ ++ if (!strstr (line, efi_distributor)) ++ continue; ++#else + if (!strcasestr (line, efi_distributor)) + continue; ++#endif + bootnum = line + sizeof ("Boot") - 1; + bootnum[4] = '\0'; + if (!verbosity) +diff -Paur --no-dereference -- grub.upstream/include/grub/emu/getroot.h grub/include/grub/emu/getroot.h +--- grub.upstream/include/grub/emu/getroot.h ++++ grub/include/grub/emu/getroot.h +@@ -101,4 +101,8 @@ + grub_util_fprint_full_disk_name (FILE *f, + const char *drive, grub_device_t dev); + ++#if defined(__sortix__) ++int is_sortix_partition_path (const char *path); ++#endif ++ + #endif /* ! GRUB_UTIL_GETROOT_HEADER */ +diff -Paur --no-dereference -- grub.upstream/update-grub grub/update-grub +--- grub.upstream/update-grub ++++ grub/update-grub +@@ -0,0 +1,2 @@ ++#!/bin/sh -e ++exec grub-mkconfig -o /boot/grub/grub.cfg "$@" +diff -Paur --no-dereference -- grub.upstream/util/getroot.c grub/util/getroot.c +--- grub.upstream/util/getroot.c ++++ grub/util/getroot.c +@@ -223,7 +223,7 @@ + return convert_system_partition_to_system_disk (os_dev, &is_part); + } + +-#if !defined(__APPLE__) ++#if !defined(__APPLE__) && !defined(__sortix__) + /* Context for grub_util_biosdisk_get_grub_dev. */ + struct grub_util_biosdisk_get_grub_dev_ctx + { +@@ -314,6 +314,29 @@ + return ret; + } + ++#elif defined(__sortix__) ++ ++ /* Sortix uses "/dev/[a-z]+[0-9]+(p[0-9]+)?". */ ++ /* ++ * Note: we do not use the new partition naming scheme as dos_part does not ++ * necessarily correspond to an msdos partition. ++ */ ++ { ++ char *dri; ++ ++ dri = make_device_name (drive); ++ ++ if (is_sortix_partition_path (os_dev)) ++ { ++ long part = strtol (strrchr (os_dev, 'p') + 1, NULL, 10); ++ char *ret = xasprintf ("%s,%ld", dri, part); ++ free (dri); ++ return ret; ++ } ++ ++ return dri; ++ } ++ + #else + + /* Linux counts partitions uniformly, whether a BSD partition or a DOS +diff -Paur --no-dereference -- grub.upstream/util/grub.d/00_header.in grub/util/grub.d/00_header.in +--- grub.upstream/util/grub.d/00_header.in ++++ grub/util/grub.d/00_header.in +@@ -27,6 +27,13 @@ + + . "$pkgdatadir/grub-mkconfig_lib" + ++if [ -f "/etc/grubpw" ]; then ++ echo 'insmod password_pbkdf2' ++ echo 'set superusers="root"' ++ echo "password_pbkdf2 root $(cat /etc/grubpw)" ++ echo ++fi ++ + # Do this as early as possible, since other commands might depend on it. + # (e.g. the `loadfont' command might need lvm or raid modules) + for i in ${GRUB_PRELOAD_MODULES} ; do +diff -Paur --no-dereference -- grub.upstream/util/grub-fstest.c grub/util/grub-fstest.c +--- grub.upstream/util/grub-fstest.c ++++ grub/util/grub-fstest.c +@@ -753,7 +753,7 @@ + { + alloc_root = xmalloc (strlen (default_root) + strlen (root) + 2); + +- sprintf (alloc_root, "%s,%s", default_root, root); ++ snprintf (alloc_root, strlen (default_root) + strlen (root) + 2, "%s,%s", default_root, root); + root = alloc_root; + } + } +diff -Paur --no-dereference -- grub.upstream/util/grub-mkconfig.in grub/util/grub-mkconfig.in +--- grub.upstream/util/grub-mkconfig.in ++++ grub/util/grub-mkconfig.in +@@ -102,27 +102,6 @@ + esac + done + +-if [ "x$EUID" = "x" ] ; then +- EUID=`id -u` +-fi +- +-if [ "$EUID" != 0 ] ; then +- root=f +- case "`uname 2>/dev/null`" in +- CYGWIN*) +- # Cygwin: Assume root if member of admin group +- for g in `id -G 2>/dev/null` ; do +- case $g in +- 0|544) root=t ;; +- esac +- done ;; +- esac +- if [ $root != t ] ; then +- gettext_printf "%s: You must run this as root\n" "$self" >&2 +- exit 1 +- fi +-fi +- + set $grub_probe dummy + if test -f "$1"; then + : +diff -Paur --no-dereference -- grub.upstream/util/misc.c grub/util/misc.c +--- grub.upstream/util/misc.c ++++ grub/util/misc.c +@@ -68,9 +68,10 @@ + grub_util_get_path (const char *dir, const char *file) + { + char *path; ++ size_t path_size = strlen (dir) + 1 + strlen (file) + 1; + +- path = (char *) xmalloc (strlen (dir) + 1 + strlen (file) + 1); +- sprintf (path, "%s/%s", dir, file); ++ path = (char *) xmalloc (path_size); ++ snprintf (path, path_size, "%s/%s", dir, file); + return path; + } + +diff -Paur --no-dereference -- grub.upstream/util/probe.c grub/util/probe.c +--- grub.upstream/util/probe.c ++++ grub/util/probe.c +@@ -81,6 +81,22 @@ + ptr++; + else + ptr = canon; ++#if defined(__sortix__) ++ if (! strncmp(ptr, "ata", strlen ("ata")) && ++ isdigit((unsigned char)*(ptr + strlen ("ata")))) ++ { ++ int num = strtol(ptr + strlen("ata"), NULL, 10); ++ free (canon); ++ return xasprintf ("hd%d", num); ++ } ++ if (! strncmp(ptr, "ahci", strlen ("ahci")) && ++ isdigit((unsigned char)*(ptr + strlen ("ahci")))) ++ { ++ int num = strtol(ptr + strlen("ahci"), NULL, 10); ++ free (canon); ++ return xasprintf ("hd%d", num); ++ } ++#endif + if ((ptr[0] == 's' || ptr[0] == 'h') && ptr[1] == 'd') + { + int num = ptr[2] - 'a'; +@@ -110,6 +126,22 @@ + ptr++; + else + ptr = canon; ++#if defined(__sortix__) ++ if (! strncmp(ptr, "ata", strlen ("ata")) && ++ isdigit((unsigned char)*(ptr + strlen ("ata")))) ++ { ++ int num = strtol(ptr + strlen("ata"), NULL, 10); ++ free (canon); ++ return xasprintf ("hd%d", num); ++ } ++ if (! strncmp(ptr, "ahci", strlen ("ahci")) && ++ isdigit((unsigned char)*(ptr + strlen ("ahci")))) ++ { ++ int num = strtol(ptr + strlen("ahci"), NULL, 10); ++ free (canon); ++ return xasprintf ("hd%d", num); ++ } ++#endif + if ((ptr[0] == 's' || ptr[0] == 'h') && ptr[1] == 'd') + { + int num = ptr[2] - 'a'; +@@ -139,6 +171,22 @@ + ptr++; + else + ptr = canon; ++#if defined(__sortix__) ++ if (! strncmp(ptr, "ata", strlen ("ata")) && ++ isdigit((unsigned char)*(ptr + strlen ("ata")))) ++ { ++ int num = strtol(ptr + strlen("ata"), NULL, 10); ++ free (canon); ++ return xasprintf ("ata%d", num); ++ } ++ if (! strncmp(ptr, "ahci", strlen ("ahci")) && ++ isdigit((unsigned char)*(ptr + strlen ("ahci")))) ++ { ++ int num = strtol(ptr + strlen("ahci"), NULL, 10); ++ free (canon); ++ return xasprintf ("ahci%d", num); ++ } ++#endif + if (ptr[0] == 'h' && ptr[1] == 'd') + { + int num = ptr[2] - 'a'; +diff -Paur --no-dereference -- grub.upstream/util/resolve.c grub/util/resolve.c +--- grub.upstream/util/resolve.c ++++ grub/util/resolve.c +@@ -172,7 +172,7 @@ + else + { + base = xmalloc (strlen (str) + 4 + 1); +- sprintf (base, "%s.mod", str); ++ snprintf (base, strlen (str) + 4 + 1, "%s.mod", str); + } + + dir = strchr (str, '/'); diff --git a/ports/grub/grub.port b/ports/grub/grub.port new file mode 100644 index 00000000..32776400 --- /dev/null +++ b/ports/grub/grub.port @@ -0,0 +1,13 @@ +NAME=grub +BUILD_LIBRARIES='libiconv? gettext? libfreetype? xz?' +VERSION=1.0-rc1 +DISTNAME=sortix-grub-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=82ac8faf257fb3476969a0b79a0b5fd53d4cdefb2e2aa5941381477e38c5f9c5 +UPSTREAM_SITE=https://pub.sortix.org/sortix/toolchain +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--disable-werror --program-prefix=' +POST_INSTALL=../grub.post-install +VERSION_REGEX='([0-9]+\.[0-9]+(\.[0-9]+)*(-rc[0-9]+)?)' diff --git a/ports/grub/grub.post-install b/ports/grub/grub.post-install new file mode 100755 index 00000000..827f136f --- /dev/null +++ b/ports/grub/grub.post-install @@ -0,0 +1,10 @@ +#!/bin/sh -e +cp update-grub "$TIX_INSTALL_DIR$EXEC_PREFIX/sbin/update-grub" +cp 10_sortix "$TIX_INSTALL_DIR$PREFIX/etc/grub.d/10_sortix" +if [ ! -e "$TIX_INSTALL_DIR$PREFIX/share/grub/unicode.pf2" ]; then + # Cheat as I'm not sure how to get this when cross-building. + [ -e /share/grub/unicode.pf2 ] && + cp /share/grub/unicode.pf2 "$TIX_INSTALL_DIR$PREFIX/share/grub/unicode.pf2" + [ -e /usr/share/grub/unicode.pf2 ] && + cp /usr/share/grub/unicode.pf2 "$TIX_INSTALL_DIR$PREFIX/share/grub/unicode.pf2" +fi diff --git a/ports/grub/grub.rmpatch b/ports/grub/grub.rmpatch new file mode 100644 index 00000000..088a6ac7 --- /dev/null +++ b/ports/grub/grub.rmpatch @@ -0,0 +1,2 @@ +rm -rf -- 'docs/stamp-1' +rm -rf -- 'docs/stamp-vti' diff --git a/ports/gzip/gzip.patch b/ports/gzip/gzip.patch new file mode 100644 index 00000000..11895c0d --- /dev/null +++ b/ports/gzip/gzip.patch @@ -0,0 +1,214 @@ +diff -Paur --no-dereference -- gzip.upstream/build-aux/config.sub gzip/build-aux/config.sub +--- gzip.upstream/build-aux/config.sub ++++ gzip/build-aux/config.sub +@@ -1348,7 +1348,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- gzip.upstream/gunzip.in gzip/gunzip.in +--- gzip.upstream/gunzip.in ++++ gzip/gunzip.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + # Uncompress files. This is the inverse of gzip. + + # Copyright (C) 2007 Free Software Foundation +diff -Paur --no-dereference -- gzip.upstream/gzexe.in gzip/gzexe.in +--- gzip.upstream/gzexe.in ++++ gzip/gzexe.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + # gzexe: compressor for Unix executables. + # Use this only for binaries that you do not use frequently. + # +diff -Paur --no-dereference -- gzip.upstream/lib/fcntl.c gzip/lib/fcntl.c +--- gzip.upstream/lib/fcntl.c ++++ gzip/lib/fcntl.c +@@ -181,7 +181,7 @@ + result = dupfd (fd, target, 0); + break; + } +-#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR ++#elif (FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR) && !defined(__sortix__) + case F_DUPFD: + { + int target = va_arg (arg, int); +diff -Paur --no-dereference -- gzip.upstream/lib/freadahead.c gzip/lib/freadahead.c +--- gzip.upstream/lib/freadahead.c ++++ gzip/lib/freadahead.c +@@ -22,6 +22,10 @@ + #include + #include "stdio-impl.h" + ++#if defined __sortix__ ++#include ++#endif ++ + size_t + freadahead (FILE *fp) + { +@@ -84,6 +88,10 @@ + if (fp->state == 4 /* WR */ || fp->rp >= fp->wp) + return 0; + return fp->wp - fp->rp; ++#elif defined __sortix__ ++ if ( !(fp->flags & _FILE_LAST_READ) ) ++ return 0; ++ return fp->amount_input_buffered - fp->offset_input_buffer; + #elif defined SLOW_BUT_NO_HACKS /* users can define this */ + abort (); + return 0; +diff -Paur --no-dereference -- gzip.upstream/lib/fseeko.c gzip/lib/fseeko.c +--- gzip.upstream/lib/fseeko.c ++++ gzip/lib/fseeko.c +@@ -99,6 +99,8 @@ + #elif defined EPLAN9 /* Plan9 */ + if (fp->rp == fp->buf + && fp->wp == fp->buf) ++#elif defined __sortix__ ++ if (0) /* wtf is this shit - sortix handles fseeko just fine. */ + #else + #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib." + #endif +diff -Paur --no-dereference -- gzip.upstream/lib/fseterr.c gzip/lib/fseterr.c +--- gzip.upstream/lib/fseterr.c ++++ gzip/lib/fseterr.c +@@ -23,6 +23,10 @@ + + #include "stdio-impl.h" + ++#if defined __sortix__ ++#include ++#endif ++ + void + fseterr (FILE *fp) + { +@@ -48,6 +52,8 @@ + #elif defined EPLAN9 /* Plan9 */ + if (fp->state != 0 /* CLOSED */) + fp->state = 5 /* ERR */; ++#elif defined __sortix__ ++ fp->flags |= _FILE_STATUS_ERROR; + #elif 0 /* unknown */ + /* Portable fallback, based on an idea by Rich Felker. + Wow! 6 system calls for something that is just a bit operation! +diff -Paur --no-dereference -- gzip.upstream/Makefile.am gzip/Makefile.am +--- gzip.upstream/Makefile.am ++++ gzip/Makefile.am +@@ -82,7 +82,6 @@ + SUFFIXES = .in + .in: + $(AM_V_GEN)sed \ +- -e 's|/bin/sh|$(SHELL)|g' \ + -e 's|[@]bindir@|'\''$(bindir)'\''|g' \ + -e 's|[@]VERSION@|$(VERSION)|g' \ + $(srcdir)/$@.in >$@-t \ +diff -Paur --no-dereference -- gzip.upstream/Makefile.in gzip/Makefile.in +--- gzip.upstream/Makefile.in ++++ gzip/Makefile.in +@@ -2102,7 +2102,6 @@ + $(AM_V_GEN)./gzip < $(srcdir)/gzip.doc >$@-t && mv $@-t $@ + .in: + $(AM_V_GEN)sed \ +- -e 's|/bin/sh|$(SHELL)|g' \ + -e 's|[@]bindir@|'\''$(bindir)'\''|g' \ + -e 's|[@]VERSION@|$(VERSION)|g' \ + $(srcdir)/$@.in >$@-t \ +diff -Paur --no-dereference -- gzip.upstream/zcat.in gzip/zcat.in +--- gzip.upstream/zcat.in ++++ gzip/zcat.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + # Uncompress files to standard output. + + # Copyright (C) 2007 Free Software Foundation +diff -Paur --no-dereference -- gzip.upstream/zcmp.in gzip/zcmp.in +--- gzip.upstream/zcmp.in ++++ gzip/zcmp.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + # Compare the uncompressed contents of compressed files, byte by byte. + + # Copyright (C) 2007, 2010-2012 Free Software Foundation, Inc. +diff -Paur --no-dereference -- gzip.upstream/zdiff.in gzip/zdiff.in +--- gzip.upstream/zdiff.in ++++ gzip/zdiff.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh + + # Copyright (C) 1998, 2002, 2006, 2007, 2009 Free Software Foundation +diff -Paur --no-dereference -- gzip.upstream/zegrep.in gzip/zegrep.in +--- gzip.upstream/zegrep.in ++++ gzip/zegrep.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + bindir=@bindir@ + case $1 in + --__bindir) bindir=${2?}; shift; shift;; +diff -Paur --no-dereference -- gzip.upstream/zfgrep.in gzip/zfgrep.in +--- gzip.upstream/zfgrep.in ++++ gzip/zfgrep.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + bindir=@bindir@ + case $1 in + --__bindir) bindir=${2?}; shift; shift;; +diff -Paur --no-dereference -- gzip.upstream/zforce.in gzip/zforce.in +--- gzip.upstream/zforce.in ++++ gzip/zforce.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + # zforce: force a gz extension on all gzip files so that gzip will not + # compress them twice. + # +diff -Paur --no-dereference -- gzip.upstream/zgrep.in gzip/zgrep.in +--- gzip.upstream/zgrep.in ++++ gzip/zgrep.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + + # zgrep -- a wrapper around a grep program that decompresses files as needed + # Adapted from a version sent by Charles Levert +diff -Paur --no-dereference -- gzip.upstream/zless.in gzip/zless.in +--- gzip.upstream/zless.in ++++ gzip/zless.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + + # Copyright (C) 1998, 2002, 2006, 2007 Free Software Foundation + +diff -Paur --no-dereference -- gzip.upstream/zmore.in gzip/zmore.in +--- gzip.upstream/zmore.in ++++ gzip/zmore.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + + # Copyright (C) 2001, 2002, 2007, 2010 Free Software Foundation + # Copyright (C) 1992, 1993 Jean-loup Gailly +diff -Paur --no-dereference -- gzip.upstream/znew.in gzip/znew.in +--- gzip.upstream/znew.in ++++ gzip/znew.in +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!sh + + # Copyright (C) 1998, 2002, 2004, 2007, 2010 Free Software Foundation + # Copyright (C) 1993 Jean-loup Gailly diff --git a/ports/gzip/gzip.port b/ports/gzip/gzip.port new file mode 100644 index 00000000..dddcceaa --- /dev/null +++ b/ports/gzip/gzip.port @@ -0,0 +1,12 @@ +NAME=gzip +BUILD_LIBRARIES=libz +VERSION=1.5 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=9ac20a3841a1246a8bedd800ea1fb93ef76521535d89cb59397d267026b6a173 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/gzip +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' +CONFIGURE_VARS='gt_cv_locale_fr=false gt_cv_locale_ja=false gt_cv_locale_fr_utf8=false gt_cv_locale_ja_utf8=false gt_cv_locale_tr_utf8=false gt_cv_locale_zh_CN=false' diff --git a/ports/hello/hello.patch b/ports/hello/hello.patch new file mode 100644 index 00000000..6225102e --- /dev/null +++ b/ports/hello/hello.patch @@ -0,0 +1,12 @@ +diff -Paur --no-dereference -- hello.upstream/build-aux/config.sub hello/build-aux/config.sub +--- hello.upstream/build-aux/config.sub ++++ hello/build-aux/config.sub +@@ -1342,7 +1342,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/ports/hello/hello.port b/ports/hello/hello.port new file mode 100644 index 00000000..9741b860 --- /dev/null +++ b/ports/hello/hello.port @@ -0,0 +1,11 @@ +NAME=hello +BUILD_LIBRARIES='libiconv? gettext?' +VERSION=2.8 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=e6b77f81f7cf7daefad4a9f5b65de6cae9c3f13b8cfbaea8cb53bb5ea5460d73 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/hello +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_VARS='gt_cv_locale_fr=false gt_cv_locale_ja=false gt_cv_locale_fr_utf8=false gt_cv_locale_ja_utf8=false gt_cv_locale_tr_utf8=false gt_cv_locale_zh_CN=false' diff --git a/ports/libSDL/libSDL.execpatch b/ports/libSDL/libSDL.execpatch new file mode 100644 index 00000000..7a667b34 --- /dev/null +++ b/ports/libSDL/libSDL.execpatch @@ -0,0 +1 @@ +chmod +x -- 'make.sortix' diff --git a/ports/libSDL/libSDL.patch b/ports/libSDL/libSDL.patch new file mode 100644 index 00000000..9fe8d10d --- /dev/null +++ b/ports/libSDL/libSDL.patch @@ -0,0 +1,12 @@ +diff -Paur --no-dereference -- libSDL.upstream/make.sortix libSDL/make.sortix +--- libSDL.upstream/make.sortix ++++ libSDL/make.sortix +@@ -0,0 +1,8 @@ ++#!/bin/sh ++set -e ++ ++"$MAKE" "$@" ++ ++if [ "$1" = "install" ]; then ++rm -fv "$DESTDIR/$EXEC_PREFIX/bin/sdl-config" ++fi diff --git a/ports/libSDL/libSDL.port b/ports/libSDL/libSDL.port new file mode 100644 index 00000000..97b66083 --- /dev/null +++ b/ports/libSDL/libSDL.port @@ -0,0 +1,13 @@ +NAME=libSDL +BUILD_LIBRARIES='libstdc++ libiconv libgmp' +VERSION=1.2.15 +DISTNAME=sortix-libSDL-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=09e4215a0f8ecad45a36aee04f97bfb662cf9578e3bee55dbd3750a9dd021b12 +UPSTREAM_SITE=https://pub.sortix.org/fork/libSDL +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--without-x --disable-pulseaudio --enable-video-dispd --disable-pthreads' +MAKE=./make.sortix +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libavcodec/libavcodec.port b/ports/libavcodec/libavcodec.port new file mode 100644 index 00000000..e6f222eb --- /dev/null +++ b/ports/libavcodec/libavcodec.port @@ -0,0 +1,6 @@ +NAME=libavcodec +SOURCE_PORT=ffmpeg +BUILD_SYSTEM=configure +DIRTY_FILE=ffbuild/config.mak +CONFIGURE_ARGS='--disable-x86asm --enable-version3 --optflags=" " --disable-debug --disable-programs' +MAKE_VARS='V=1' diff --git a/ports/libcairo/libcairo.patch b/ports/libcairo/libcairo.patch new file mode 100644 index 00000000..970f63e4 --- /dev/null +++ b/ports/libcairo/libcairo.patch @@ -0,0 +1,90 @@ +diff -Paur --no-dereference -- libcairo.upstream/build/config.sub libcairo/build/config.sub +--- libcairo.upstream/build/config.sub ++++ libcairo/build/config.sub +@@ -1348,7 +1348,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libcairo.upstream/build/configure.ac.warnings libcairo/build/configure.ac.warnings +--- libcairo.upstream/build/configure.ac.warnings ++++ libcairo/build/configure.ac.warnings +@@ -36,16 +36,6 @@ + dnl We also abuse the warning-flag facility to enable other compiler + dnl options. Namely, the following: + +-dnl -flto working really needs a test link, not just a compile +- +-safe_MAYBE_WARN="$MAYBE_WARN" +-MAYBE_WARN="$MAYBE_WARN -flto" +-AC_TRY_LINK([],[ +- int main(int argc, char **argv) { return 0; } +-],[],[ +- MAYBE_WARN="$safe_MAYBE_WARN" +-]) +- + MAYBE_WARN="$MAYBE_WARN -fno-strict-aliasing -fno-common" + + dnl Also to turn various gcc/glibc-specific preprocessor checks +diff -Paur --no-dereference -- libcairo.upstream/configure libcairo/configure +--- libcairo.upstream/configure ++++ libcairo/configure +@@ -18159,33 +18159,6 @@ + MAYBE_WARN="$MAYBE_WARN -erroff=E_ENUM_TYPE_MISMATCH_ARG \ + -erroff=E_ENUM_TYPE_MISMATCH_OP" + +- +- +-safe_MAYBE_WARN="$MAYBE_WARN" +-MAYBE_WARN="$MAYBE_WARN -flto" +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +- +-int +-main () +-{ +- +- int main(int argc, char **argv) { return 0; } +- +- ; +- return 0; +-} +-_ACEOF +-if ac_fn_c_try_link "$LINENO"; then : +- +-else +- +- MAYBE_WARN="$safe_MAYBE_WARN" +- +-fi +-rm -f core conftest.err conftest.$ac_objext \ +- conftest$ac_exeext conftest.$ac_ext +- + MAYBE_WARN="$MAYBE_WARN -fno-strict-aliasing -fno-common" + + MAYBE_WARN="$MAYBE_WARN -Wp,-D_FORTIFY_SOURCE=2" +@@ -31800,7 +31773,7 @@ + + + +-if pkg-config --exists 'pixman-1 >= 0.27.1'; then ++if ${PKG_CONFIG:-pkg-config} --exists 'pixman-1 >= 0.27.1'; then + + $as_echo "#define HAS_PIXMAN_GLYPHS 1" >>confdefs.h + +diff -Paur --no-dereference -- libcairo.upstream/configure.ac libcairo/configure.ac +--- libcairo.upstream/configure.ac ++++ libcairo/configure.ac +@@ -662,7 +662,7 @@ + image_LIBS=$pixman_LIBS + ]) + +-if pkg-config --exists 'pixman-1 >= 0.27.1'; then ++if ${PKG_CONFIG:-pkg-config} --exists 'pixman-1 >= 0.27.1'; then + AC_DEFINE([HAS_PIXMAN_GLYPHS], 1, [Enable pixman glyph cache]) + fi + diff --git a/ports/libcairo/libcairo.port b/ports/libcairo/libcairo.port new file mode 100644 index 00000000..9eb8bf88 --- /dev/null +++ b/ports/libcairo/libcairo.port @@ -0,0 +1,13 @@ +NAME=libcairo +BUILD_LIBRARIES='libz bzip2 libpng libfreetype libfontconfig? librsvg? libexpat? libpixman libglib?' +VERSION=1.12.14 +DISTNAME=cairo-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=96d0d1e3f9b74d2ca3469ff187c5e5f25649b1ad35cf06f4f3a83847dff4ac13 +UPSTREAM_SITE=https://www.cairographics.org/releases +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--without-x --disable-valgrind --disable-xlib --enable-xlib=no --enable-xcb=no --enable-xlib-xcb=no --enable-xcb-shm=no --enable-glx=no' +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libcairo/libcairo.rmpatch b/ports/libcairo/libcairo.rmpatch new file mode 100644 index 00000000..7ba13fe0 --- /dev/null +++ b/ports/libcairo/libcairo.rmpatch @@ -0,0 +1,45 @@ +rm -rf -- 'boilerplate/cairo-boilerplate-constructors.c' +rm -rf -- 'doc/public/xml/' +rm -rf -- 'doc/public/xml/api-index-1.0.xml' +rm -rf -- 'doc/public/xml/api-index-1.10.xml' +rm -rf -- 'doc/public/xml/api-index-1.12.xml' +rm -rf -- 'doc/public/xml/api-index-1.2.xml' +rm -rf -- 'doc/public/xml/api-index-1.4.xml' +rm -rf -- 'doc/public/xml/api-index-1.6.xml' +rm -rf -- 'doc/public/xml/api-index-1.8.xml' +rm -rf -- 'doc/public/xml/api-index-TBD.xml' +rm -rf -- 'doc/public/xml/api-index-deprecated.xml' +rm -rf -- 'doc/public/xml/api-index-full.xml' +rm -rf -- 'doc/public/xml/cairo-device.xml' +rm -rf -- 'doc/public/xml/cairo-font-face.xml' +rm -rf -- 'doc/public/xml/cairo-font-options.xml' +rm -rf -- 'doc/public/xml/cairo-ft.xml' +rm -rf -- 'doc/public/xml/cairo-image.xml' +rm -rf -- 'doc/public/xml/cairo-matrix.xml' +rm -rf -- 'doc/public/xml/cairo-paths.xml' +rm -rf -- 'doc/public/xml/cairo-pattern.xml' +rm -rf -- 'doc/public/xml/cairo-pdf.xml' +rm -rf -- 'doc/public/xml/cairo-png.xml' +rm -rf -- 'doc/public/xml/cairo-ps.xml' +rm -rf -- 'doc/public/xml/cairo-quartz-fonts.xml' +rm -rf -- 'doc/public/xml/cairo-quartz.xml' +rm -rf -- 'doc/public/xml/cairo-raster-source.xml' +rm -rf -- 'doc/public/xml/cairo-recording.xml' +rm -rf -- 'doc/public/xml/cairo-region.xml' +rm -rf -- 'doc/public/xml/cairo-scaled-font.xml' +rm -rf -- 'doc/public/xml/cairo-script.xml' +rm -rf -- 'doc/public/xml/cairo-status.xml' +rm -rf -- 'doc/public/xml/cairo-surface.xml' +rm -rf -- 'doc/public/xml/cairo-svg.xml' +rm -rf -- 'doc/public/xml/cairo-text.xml' +rm -rf -- 'doc/public/xml/cairo-transforms.xml' +rm -rf -- 'doc/public/xml/cairo-types.xml' +rm -rf -- 'doc/public/xml/cairo-user-fonts.xml' +rm -rf -- 'doc/public/xml/cairo-version.xml' +rm -rf -- 'doc/public/xml/cairo-win32-fonts.xml' +rm -rf -- 'doc/public/xml/cairo-win32.xml' +rm -rf -- 'doc/public/xml/cairo-xcb.xml' +rm -rf -- 'doc/public/xml/cairo-xlib-xrender.xml' +rm -rf -- 'doc/public/xml/cairo-xlib.xml' +rm -rf -- 'doc/public/xml/cairo.xml' +rm -rf -- 'test/cairo-test-constructors.c' diff --git a/ports/libcurl/libcurl.patch b/ports/libcurl/libcurl.patch new file mode 100644 index 00000000..32a20365 --- /dev/null +++ b/ports/libcurl/libcurl.patch @@ -0,0 +1,233 @@ +diff -Paur --no-dereference -- libcurl.upstream/configure libcurl/configure +--- libcurl.upstream/configure ++++ libcurl/configure +@@ -20065,9 +20065,7 @@ + fi + + +-if test "$HAVE_GETHOSTBYNAME" != "1"; then +- as_fn_error $? "couldn't find libraries for gethostbyname()" "$LINENO" 5 +-fi ++# PATCH: gethostbyname is not actually needed. + + + curl_includes_winsock2="\ +@@ -33676,11 +33674,8 @@ + + int main (void) + { +-#ifdef h_errno ++ /* PATCH: h_errno has nothing to do with getaddrinfo */ + return 0; +-#else +- force compilation error +-#endif + } + + +@@ -45798,107 +45793,9 @@ + + + +-## ---------------------------------- ## +-## Start of distclean amending code ## +-## ---------------------------------- ## +- +-for xc_subdir in lib src tests/unit tests/server tests/libtest docs/examples +-do +- +-if test ! -f "$xc_subdir/Makefile"; then +- echo "$xc_msg_err $xc_subdir/Makefile file not found. $xc_msg_abrt" >&2 +- exit 1 +-fi +- +-# Fetch dependency tracking file list from Makefile include lines. +- +-xc_inc_lines=`grep '^include .*(DEPDIR)' "$xc_subdir/Makefile" 2>/dev/null` +-xc_cnt_words=`echo "$xc_inc_lines" | wc -w | tr -d "$xc_space$xc_tab"` +- +-# --disable-dependency-tracking might have been used, consequently +-# there is nothing to amend without a dependency tracking file list. +- +-if test $xc_cnt_words -gt 0; then +- +-{ $as_echo "$as_me:${as_lineno-$LINENO}: amending $xc_subdir/Makefile" >&5 +-$as_echo "$as_me: amending $xc_subdir/Makefile" >&6;} +- +-# Build Makefile specific patch hunk. +- +-xc_p="$xc_subdir/xc_patch.tmp" +- +-xc_rm_depfiles=`echo "$xc_inc_lines" \ +- | $SED 's%include% -rm -f%' 2>/dev/null` +- +-xc_dep_subdirs=`echo "$xc_inc_lines" \ +- | $SED 's%include[ ][ ]*%%' 2>/dev/null \ +- | $SED 's%(DEPDIR)/.*%(DEPDIR)%' 2>/dev/null \ +- | sort | uniq` +- +-echo "$xc_rm_depfiles" >$xc_p +- +-for xc_dep_dir in $xc_dep_subdirs; do +- echo "${xc_tab}@xm_dep_cnt=\`ls $xc_dep_dir | wc -l 2>/dev/null\`; \\" >>$xc_p +- echo "${xc_tab}if test \$\$xm_dep_cnt -eq 0 && test -d $xc_dep_dir; then \\" >>$xc_p +- echo "${xc_tab} rm -rf $xc_dep_dir; \\" >>$xc_p +- echo "${xc_tab}fi" >>$xc_p +-done +- +-# Build Makefile patching sed scripts. +- +-xc_s1="$xc_subdir/xc_script_1.tmp" +-xc_s2="$xc_subdir/xc_script_2.tmp" +-xc_s3="$xc_subdir/xc_script_3.tmp" +- +-cat >$xc_s1 <<\_EOT +-/^distclean[ ]*:/,/^[^ ][^ ]*:/{ +- s/^.*(DEPDIR)/___xc_depdir_line___/ +-} +-/^maintainer-clean[ ]*:/,/^[^ ][^ ]*:/{ +- s/^.*(DEPDIR)/___xc_depdir_line___/ +-} +-_EOT +- +-cat >$xc_s2 <<\_EOT +-/___xc_depdir_line___$/{ +- N +- /___xc_depdir_line___$/D +-} +-_EOT +- +-cat >$xc_s3 <<_EOT +-/^___xc_depdir_line___/{ +- r $xc_p +- d +-} +-_EOT +- +-# Apply patch to Makefile and cleanup. +- +-$SED -f "$xc_s1" "$xc_subdir/Makefile" >"$xc_subdir/Makefile.tmp1" +-$SED -f "$xc_s2" "$xc_subdir/Makefile.tmp1" >"$xc_subdir/Makefile.tmp2" +-$SED -f "$xc_s3" "$xc_subdir/Makefile.tmp2" >"$xc_subdir/Makefile.tmp3" +- +-if test -f "$xc_subdir/Makefile.tmp3"; then +- mv -f "$xc_subdir/Makefile.tmp3" "$xc_subdir/Makefile" +-fi +- +-test -f "$xc_subdir/Makefile.tmp1" && rm -f "$xc_subdir/Makefile.tmp1" +-test -f "$xc_subdir/Makefile.tmp2" && rm -f "$xc_subdir/Makefile.tmp2" +-test -f "$xc_subdir/Makefile.tmp3" && rm -f "$xc_subdir/Makefile.tmp3" +- +-test -f "$xc_p" && rm -f "$xc_p" +-test -f "$xc_s1" && rm -f "$xc_s1" +-test -f "$xc_s2" && rm -f "$xc_s2" +-test -f "$xc_s3" && rm -f "$xc_s3" +- +-fi +- +-done +- +-## -------------------------------- ## +-## End of distclean amending code ## +-## -------------------------------- ## ++# PATCH: Removed cursed distclean patching logic that somehow produces distclean ++# targets for me with hundreds of thousands of duplicate rm -f commands. ++# The build seems to work fine without it. + + + +diff -Paur --no-dereference -- libcurl.upstream/docs/Makefile.in libcurl/docs/Makefile.in +--- libcurl.upstream/docs/Makefile.in ++++ libcurl/docs/Makefile.in +@@ -461,10 +461,10 @@ + # but distribute it (using the relative file name) in the next variable + man_MANS = $(abs_builddir)/curl.1 + noinst_man_MANS = curl.1 mk-ca-bundle.1 +-dist_man_MANS = curl-config.1 +-GENHTMLPAGES = curl.html curl-config.html mk-ca-bundle.html +-PDFPAGES = curl.pdf curl-config.pdf mk-ca-bundle.pdf +-MANDISTPAGES = curl.1.dist curl-config.1.dist ++dist_man_MANS = ++GENHTMLPAGES = curl.html mk-ca-bundle.html ++PDFPAGES = curl.pdf mk-ca-bundle.pdf ++MANDISTPAGES = curl.1.dist + HTMLPAGES = $(GENHTMLPAGES) index.html + + # Build targets in this file (.) before cmdline-opts to ensure that +diff -Paur --no-dereference -- libcurl.upstream/include/curl/curl.h libcurl/include/curl/curl.h +--- libcurl.upstream/include/curl/curl.h ++++ libcurl/include/curl/curl.h +@@ -68,16 +68,7 @@ + #endif + #endif + +-/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish +- libc5-based Linux systems. Only include it on systems that are known to +- require it! */ +-#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \ +- defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \ +- defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \ +- defined(__CYGWIN__) || \ +- (defined(__FreeBSD_version) && (__FreeBSD_version < 800000)) + #include +-#endif + + #if !defined(CURL_WIN32) && !defined(_WIN32_WCE) + #include +diff -Paur --no-dereference -- libcurl.upstream/lib/curl_addrinfo.h libcurl/lib/curl_addrinfo.h +--- libcurl.upstream/lib/curl_addrinfo.h ++++ libcurl/lib/curl_addrinfo.h +@@ -71,6 +71,16 @@ + Curl_addrinfo **result); + #endif + ++#if defined(__sortix__) ++struct hostent ++{ ++ char* h_name; ++ char** h_aliases; ++ int h_addrtype; ++ int h_length; ++ char** h_addr_list; ++}; ++#endif + Curl_addrinfo * + Curl_he2ai(const struct hostent *he, int port); + +diff -Paur --no-dereference -- libcurl.upstream/lib/mprintf.c libcurl/lib/mprintf.c +--- libcurl.upstream/lib/mprintf.c ++++ libcurl/lib/mprintf.c +@@ -946,7 +946,7 @@ + + /* NOTE NOTE NOTE!! Not all sprintf implementations return number of + output characters */ +- (sprintf)(work, formatbuf, p->data.dnum); ++ (snprintf)(work, sizeof(work), formatbuf, p->data.dnum); + DEBUGASSERT(strlen(work) <= sizeof(work)); + for(fptr = work; *fptr; fptr++) + OUTCHAR(*fptr); +diff -Paur --no-dereference -- libcurl.upstream/Makefile.in libcurl/Makefile.in +--- libcurl.upstream/Makefile.in ++++ libcurl/Makefile.in +@@ -652,7 +652,7 @@ + $(VC11_LIBVCXPROJ) $(VC11_SRCVCXPROJ) $(VC12_LIBVCXPROJ) $(VC12_SRCVCXPROJ) \ + $(VC14_LIBVCXPROJ) $(VC14_SRCVCXPROJ) $(VC15_LIBVCXPROJ) $(VC15_SRCVCXPROJ) + +-bin_SCRIPTS = curl-config ++bin_SCRIPTS = + SUBDIRS = lib src + DIST_SUBDIRS = $(SUBDIRS) tests packages scripts include docs + pkgconfigdir = $(libdir)/pkgconfig +@@ -1285,6 +1285,12 @@ + distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile ++ -rm -f docs/cmdline-opts/Makefile ++ -rm -rf docs/examples/.deps ++ -rm -f docs/examples/Makefile ++ -rm -f docs/libcurl/Makefile ++ -rm -f docs/libcurl/opts/Makefile ++ -rm -f docs/Makefile + distclean-am: clean-am distclean-generic distclean-libtool \ + distclean-tags + diff --git a/ports/libcurl/libcurl.port b/ports/libcurl/libcurl.port new file mode 100644 index 00000000..5bb33d32 --- /dev/null +++ b/ports/libcurl/libcurl.port @@ -0,0 +1,13 @@ +NAME=libcurl +BUILD_LIBRARIES='libz? libssl? libidn? libssh2? librtmp? libmetalink? libpsl?' +VERSION=7.69.0 +DISTNAME=curl-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=9fadf2f082c127757808a28ddd5ab9d1bc2c7061ca7ddaf85814285e15e3271f +UPSTREAM_SITE=https://curl.se/download +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--with-ca-bundle=/etc/ssl/cert.pem --with-ca-path=/etc/ssl/certs' +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libcurl/libcurl.rmpatch b/ports/libcurl/libcurl.rmpatch new file mode 100644 index 00000000..fd6181d7 --- /dev/null +++ b/ports/libcurl/libcurl.rmpatch @@ -0,0 +1,3 @@ +rm -rf -- 'Makefile' +rm -rf -- 'docs/curl.1' +rm -rf -- 'src/tool_hugehelp.c' diff --git a/ports/libcurses/libcurses.patch b/ports/libcurses/libcurses.patch new file mode 100644 index 00000000..405df04a --- /dev/null +++ b/ports/libcurses/libcurses.patch @@ -0,0 +1,905 @@ +diff -Paur --no-dereference -- libcurses.upstream/GNUmakefile libcurses/GNUmakefile +--- libcurses.upstream/GNUmakefile ++++ libcurses/GNUmakefile +@@ -1,4 +1,5 @@ +-HOSTCC ?= $(CC) ++CC_FOR_BUILD ?= $(CC) ++HOSTCC ?= $(CC_FOR_BUILD) + AWK ?= awk + AR ?= ar + RANLIB ?= ranlib +@@ -11,13 +12,15 @@ + + PIC = -fPIC + +-PREFIX=/usr/local +-BINDIR=$(PREFIX)/bin +-LIBDIR=$(PREFIX)/lib +-INCDIR=$(PREFIX)/include +-MANDIR=$(PREFIX)/share/man +-MAN1DIR=$(MANDIR)/man1 +-MAN3DIR=$(MANDIR)/man3 ++PREFIX?=/usr/local ++EXEC_PREFIX?=$(PREFIX) ++BINDIR?=$(EXEC_PREFIX)/bin ++LIBDIR?=$(EXEC_PREFIX)/lib ++INCLUDEDIR?=$(PREFIX)/include ++INCDIR?=$(INCLUDEDIR) ++MANDIR?=$(PREFIX)/share/man ++MAN1DIR?=$(MANDIR)/man1 ++MAN3DIR?=$(MANDIR)/man3 + + -include config.mak + +@@ -40,6 +43,7 @@ + else + STATIC_BINS=0 + endif ++STATIC_BINS=1 + + CFLAGS+=-Werror-implicit-function-declaration + CPPFLAGS+= -I. -I./libterminfo +@@ -166,7 +170,8 @@ + TI_LINKLIB=$(TI_LIBA) + endif + +-all: $(STALIBS) $(DYNLIBS) $(PROGS) ++#all: $(STALIBS) $(DYNLIBS) $(PROGS) ++all: all-static + + all-static: $(STALIBS) $(PROGS) + +@@ -181,7 +186,7 @@ + + install-tput: tput/tput tput/clear.sh + $(INSTALL) -Dm 755 tput/tput $(DESTDIR)$(BINDIR)/tput +- $(INSTALL) -Dm 755 tput/clear.sh $(DESTDIR)$(BINDIR)/clear ++ #$(INSTALL) -Dm 755 tput/clear.sh $(DESTDIR)$(BINDIR)/clear + + install-infocmp: infocmp/infocmp + $(INSTALL) -Dm 755 infocmp/infocmp $(DESTDIR)$(BINDIR)/infocmp +@@ -257,7 +262,8 @@ + $(LN) -sf $(notdir $<) $(DESTDIR)$(LIBDIR)/$(basename $(notdir $<))w$(SO_SUFFIX) + + install-dynlibs: install-dynlib-terminfo install-dynlib-curses install-dynlib-panel install-dynlib-menu install-dynlib-form +-install-libs: install-stalibs install-dynlibs ++#install-libs: install-stalibs install-dynlibs ++install-libs: install-stalibs + + install-pc-dir: + $(MKDIR) -p $(DESTDIR)$(LIBDIR)/pkgconfig +@@ -329,7 +335,15 @@ + + install-manpages: install-prog-manpages install-lib-manpages + +-install: install-headers install-libs install-progs install-pcs install-manpages ++install-terminfo: $(TOOL_HOSTTIC) ++ cat terminfo/terminfo terminfo/sortix.terminfo > $(DESTDIR)$(PREFIX)/share/terminfo.tmp ++ $(TOOL_HOSTTIC) -x -o $(DESTDIR)$(PREFIX)/share/terminfo.cdb $(DESTDIR)$(PREFIX)/share/terminfo.tmp ++ rm -f $(DESTDIR)$(PREFIX)/share/terminfo.tmp ++ mkdir -p $(DESTDIR)$(PREFIX)/share/terminfo ++ mkdir -p $(DESTDIR)$(PREFIX)/share/terminfo/s ++ cp terminfo/sortix.terminfo $(DESTDIR)$(PREFIX)/share/terminfo/s/sortix.terminfo ++ ++install: install-headers install-libs install-progs install-pcs install-manpages install-terminfo + + install-static: install-headers install-progs install-pcs install-stalibs + install-dynamic: TI_LINKLIB=$(TI_LIBSO) +@@ -549,4 +563,4 @@ + install-man-infocmp install-man-tabs install-prog-manpages \ + install-man-terminfo install-man-curses install-man-panel \ + install-man-menu install-man-form install-lib-manpages \ +- install-manpages ++ install-manpages install-terminfo +diff -Paur --no-dereference -- libcurses.upstream/libcurses/acs.c libcurses/libcurses/acs.c +--- libcurses.upstream/libcurses/acs.c ++++ libcurses/libcurses/acs.c +@@ -38,7 +38,9 @@ + #ifdef HAVE_WCHAR + #include + #include ++#if !defined(__sortix__) || (defined(__has_include) && __has_include()) + #include ++#endif + #include + + cchar_t _wacs_char[ NUM_ACS ]; +@@ -156,7 +158,11 @@ + /* Add the SUSv2 defaults (those that are not '+') */ + if (!strcmp(setlocale(LC_CTYPE, NULL), "C")) + setlocale(LC_CTYPE, ""); ++#if !defined(__sortix__) || (defined(__has_include) && __has_include()) + lstr = nl_langinfo(CODESET); ++#else ++ lstr = "UTF-8"; ++#endif + _DIAGASSERT(lstr); + if (strcasecmp(lstr, "UTF-8")) { + #ifdef DEBUG +diff -Paur --no-dereference -- libcurses.upstream/libcurses/color.c libcurses/libcurses/color.c +--- libcurses.upstream/libcurses/color.c ++++ libcurses/libcurses/color.c +@@ -35,6 +35,8 @@ + #include "curses.h" + #include "curses_private.h" + ++typedef uint32_t u_int32_t; ++ + /* Have we initialised colours? */ + int __using_color = 0; + +diff -Paur --no-dereference -- libcurses.upstream/libcurses/cur_hash.c libcurses/libcurses/cur_hash.c +--- libcurses.upstream/libcurses/cur_hash.c ++++ libcurses/libcurses/cur_hash.c +@@ -36,6 +36,8 @@ + #include "curses.h" + #include "curses_private.h" + ++typedef unsigned int u_int; ++ + /* + * __hash_more() is "hashpjw" from the Dragon Book, Aho, Sethi & Ullman, p.436. + */ +diff -Paur --no-dereference -- libcurses.upstream/libcurses/get_wch.c libcurses/libcurses/get_wch.c +--- libcurses.upstream/libcurses/get_wch.c ++++ libcurses/libcurses/get_wch.c +@@ -44,6 +44,35 @@ + #include "curses_private.h" + #include "keymap.h" + ++#ifdef __sortix__ ++#include ++#include ++static wint_t getwchar(void) ++{ ++ mbstate_t ps = { 0 }; ++ wchar_t wc; ++ while (1) { ++ int ic = getchar(); ++ if (ic == EOF) { ++ if (!mbsinit(&ps)) { ++ errno = EILSEQ; ++ __fseterr(stdin); ++ } ++ return WEOF; ++ } ++ char c = ic; ++ size_t bytes = mbrtowc(&wc, &c, 1, &ps); ++ if (bytes == (size_t) -1) { ++ __fseterr(stdin); ++ return WEOF; ++ } ++ if (bytes == (size_t) -2) ++ continue; ++ return wc; ++ } ++} ++#endif ++ + #ifdef HAVE_WCHAR + static short wstate; /* state of the wcinkey function */ + #endif /* HAVE_WCHAR */ +diff -Paur --no-dereference -- libcurses.upstream/libcurses/putchar.c libcurses/libcurses/putchar.c +--- libcurses.upstream/libcurses/putchar.c ++++ libcurses/libcurses/putchar.c +@@ -31,6 +31,8 @@ + + #include + ++#include ++ + #include "curses.h" + #include "curses_private.h" + +@@ -68,7 +70,18 @@ + #ifdef DEBUG + __CTRACE(__CTRACE_OUTPUT, "__cputwchar: 0x%x\n", wch); + #endif ++#ifdef __sortix__ ++ mbstate_t ps = { 0 }; ++ char mb[MB_CUR_MAX]; ++ size_t bytes = wcrtomb(mb, wch, &ps); ++ if (bytes == (size_t) -1) ++ return WEOF; ++ if (fwrite(mb, bytes, 1, _cursesi_screen->outfd) != 1) ++ return WEOF; ++ return wch; ++#else + return (putwc(wch, _cursesi_screen->outfd)); ++#endif + } + + /* +@@ -85,6 +98,17 @@ + __CTRACE(__CTRACE_OUTPUT, "__cputwchar_args: 0x%x on fd %d\n", + wch, outfd->_file); + #endif ++#ifdef __sortix__ ++ mbstate_t ps = { 0 }; ++ char mb[MB_CUR_MAX]; ++ size_t bytes = wcrtomb(mb, wch, &ps); ++ if (bytes == (size_t) -1) ++ return WEOF; ++ if (fwrite(mb, bytes, 1, outfd) != 1) ++ return WEOF; ++ return wch; ++#else + return putwc(wch, outfd); ++#endif + } + #endif /* HAVE_WCHAR */ +diff -Paur --no-dereference -- libcurses.upstream/libcurses/refresh.c libcurses/libcurses/refresh.c +--- libcurses.upstream/libcurses/refresh.c ++++ libcurses/libcurses/refresh.c +@@ -37,6 +37,8 @@ + #include "curses.h" + #include "curses_private.h" + ++typedef unsigned int u_int; ++ + static void domvcur(int, int, int, int); + static int makech(int); + static void quickch(void); +diff -Paur --no-dereference -- libcurses.upstream/libcurses/tty.c libcurses/libcurses/tty.c +--- libcurses.upstream/libcurses/tty.c ++++ libcurses/libcurses/tty.c +@@ -63,6 +63,10 @@ + #endif + #endif + ++#ifndef ONLCR ++#define ONLCR 0 ++#endif ++ + /* + * baudrate -- + * Return the current baudrate +diff -Paur --no-dereference -- libcurses.upstream/libform/field.c libcurses/libform/field.c +--- libcurses.upstream/libform/field.c ++++ libcurses/libform/field.c +@@ -31,7 +31,6 @@ + #include + #include + #include +-#include + #include + #include + #include +diff -Paur --no-dereference -- libcurses.upstream/libform/type_ipv4.c libcurses/libform/type_ipv4.c +--- libcurses.upstream/libform/type_ipv4.c ++++ libcurses/libform/type_ipv4.c +@@ -79,7 +79,7 @@ + hex_val = 0; + mask = 0; + +- if ((slash = index(buf, '/')) != NULL) ++ if ((slash = strchr(buf, '/')) != NULL) + style = FORMI_CLASSLESS; + else { + start = _formi_skip_blanks(buf, 0); +diff -Paur --no-dereference -- libcurses.upstream/libterminfo/cdbr.c libcurses/libterminfo/cdbr.c +--- libcurses.upstream/libterminfo/cdbr.c ++++ libcurses/libterminfo/cdbr.c +@@ -59,6 +59,8 @@ + #define malloc(size) kmem_alloc(size, KM_SLEEP) + #define free(ptr) kmem_free(ptr, sizeof(struct cdbr)) + #else ++/* TODO: Sortix doesn't define everything it should. */ ++#include + #include + #include + #include +@@ -142,7 +144,7 @@ + + + size = (size_t)sb.st_size; +- base = mmap(NULL, size, PROT_READ, MAP_FILE|MAP_SHARED, fd, 0); ++ base = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); + close(fd); + + if (base == MAP_FAILED) +diff -Paur --no-dereference -- libcurses.upstream/libterminfo/term.c libcurses/libterminfo/term.c +--- libcurses.upstream/libterminfo/term.c ++++ libcurses/libterminfo/term.c +@@ -52,6 +52,11 @@ + #endif + #endif + ++/* TODO: Hack. */ ++#ifndef PATH_MAX ++#define PATH_MAX 4096 ++#endif ++ + static char database[PATH_MAX]; + static char pathbuf[PATH_MAX]; + const char *_ti_database; +diff -Paur --no-dereference -- libcurses.upstream/libterminfo/tparm.c libcurses/libterminfo/tparm.c +--- libcurses.upstream/libterminfo/tparm.c ++++ libcurses/libterminfo/tparm.c +@@ -28,11 +28,11 @@ + */ + + #include +-#include + + #include + #include + #include ++#include + #include + #include + #include +diff -Paur --no-dereference -- libcurses.upstream/netbsd_sys/cdefs.h libcurses/netbsd_sys/cdefs.h +--- libcurses.upstream/netbsd_sys/cdefs.h ++++ libcurses/netbsd_sys/cdefs.h +@@ -60,5 +60,10 @@ + #define __predict_false(exp) (exp) + #endif + ++#if defined(__sortix__) ++#define bcopy(src, dest, size) memcpy(dest, src, size) ++#endif ++#define MAX(a,b) (((a)>(b))?(a):(b)) ++ + #endif + +diff -Paur --no-dereference -- libcurses.upstream/terminfo/sortix.terminfo libcurses/terminfo/sortix.terminfo +--- libcurses.upstream/terminfo/sortix.terminfo ++++ libcurses/terminfo/sortix.terminfo +@@ -0,0 +1,230 @@ ++# TODO: Decode setab and setaf and see if they are what I want. ++# TODO: Implement BEL \a and add bel=^G, ++# TODO: Add blink support and add blink=\E[5m, ++# TODO: Add backtab support and add cbt=\E[Z, and kcbt=\E[Z, ++# TODO: Support csr=\E[%i%p1%d;%p2%dr, ++# TODO: Support dch=\E[%p1%dP, ++# TODO: dch1=\E[P, ++# TODO: Add faint support and add dim=\E[2m, ++# TODO: dl1=\E[M, ++# TODO: ech=\E[%p1%dX, ++# TODO: hts=\EH, ++# TODO: ich=\E[%p1%d@, ++# TODO: il=\E[%p1%dL, ++# TODO: il1=\E[L, ++# TODO: invis=\E[8m, ++# TODO: Some modifiers for the function keys are missing, like control + alt + ++# shift + f12, kfxx should probably go up to 96. On the other hand, ++# control-alt-fxx switches virtual terminals. ++# TODO: Sequences for key pad presses (with numlock off) such as kb2 ++# TODO: Sequences for backspace with modifiers (kbs)? ++# TODO: Support mouse event kmous=\E[M, ++# TODO: Add italicized support sitm=\E[3m, ritm=\E[23m, ++# TODO: rmkx=\E[?1l\E>, ++# TODO: smkx=\E[?1h\E=, ++ ++sortix-16color|Sortix with 16 colors, ++ am, ++ bce, ++ km, ++ mc5i, ++ msgr, ++ npc, ++ xenl, ++ colors#16, ++ cols#80, ++ it#8, ++ lines#25, ++ pairs#256, ++ bold=\E[1m, ++ civis=\E[?25l, ++ clear=\E[H\E[2J, ++ cnorm=\E[?25h, ++ cr=^M, ++ cub1=\E[D, ++ cub=\E[%p1%dD, ++ cud1=^J, ++ cud=\E[%p1%dB, ++ cuf1=\E[C, ++ cuf=\E[%p1%dC, ++ cup=\E[%i%p1%d;%p2%dH, ++ cuu1=\E[A, ++ cuu=\E[%p1%dA, ++ ed=\E[J, ++ el1=\E[1K, ++ el=\E[K, ++ home=\E[H, ++ hpa=\E[%i%p1%dG, ++ ht=^I, ++ ind=^J, ++ indn=\E[%p1%dS, ++ nel=^J, ++ op=\E[39;49m, ++ rc=\E[u, ++ rev=\E[7m, ++ ri=\E[T, ++ rin=\E[%p1%dT, ++ rmcup=\E[?1049l, ++ rmso=\E[27m, ++ sc=\E[s, ++ setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m, ++ setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m, ++ sgr0=\E[m, ++ sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, ++ smcup=\E[?1049h, ++ smso=\E[7m, ++ vpa=\E[%i%p1%dd, ++ kbs=\177, ++ kcub1=\E[D, ++ kLFT=\E[1;2D, ++ kLFT3=\E[1;3D, ++ kLFT4=\E[1;4D, ++ kLFT5=\E[1;5D, ++ kLFT6=\E[1;6D, ++ kLFT7=\E[1;7D, ++ kLFT8=\E[1;8D, ++ kcud1=\E[B, ++ kDN=\E[1;2B, ++ kDN3=\E[1;3B, ++ kDN4=\E[1;4B, ++ kDN5=\E[1;5B, ++ kDN6=\E[1;6B, ++ kDN7=\E[1;7B, ++ kDN8=\E[1;8B, ++ kcuf1=\E[C, ++ kRIT=\E[1;2C, ++ kRIT3=\E[1;3C, ++ kRIT4=\E[1;4C, ++ kRIT5=\E[1;5C, ++ kRIT6=\E[1;6C, ++ kRIT7=\E[1;7C, ++ kRIT8=\E[1;8C, ++ kcuu1=\E[A, ++ kUP=\E[1;2A, ++ kUP3=\E[1;3A, ++ kUP4=\E[1;4A, ++ kUP5=\E[1;5A, ++ kUP6=\E[1;6A, ++ kUP7=\E[1;7A, ++ kUP8=\E[1;8A, ++ kdch1=\E[3~, ++ kDC=\E[3;2~, ++ kDC3=\E[3;3~, ++ kDC4=\E[3;4~, ++ kDC5=\E[3;5~, ++ kDC6=\E[3;6~, ++ kDC7=\E[3;7~, ++ kDC8=\E[3;8~, ++ kend=\E[F, ++ kEND=\E[1;2F, ++ kEND3=\E[1;3F, ++ kEND4=\E[1;4F, ++ kEND5=\E[1;5F, ++ kEND6=\E[1;6F, ++ kEND7=\E[1;7F, ++ kEND8=\E[1;8F, ++ kent=\E0M, ++ kf1=\EOP, ++ kf2=\EOQ, ++ kf3=\EOR, ++ kf4=\EOS, ++ kf5=\E[15~, ++ kf6=\E[17~, ++ kf7=\E[18~, ++ kf8=\E[19~, ++ kf9=\E[20~, ++ kf10=\E[21~, ++ kf11=\E[23~, ++ kf12=\E[24~, ++ kf13=\E[1;2P, ++ kf14=\E[1;2Q, ++ kf15=\E[1;2R, ++ kf16=\E[1;2S, ++ kf17=\E[15;2~, ++ kf18=\E[17;2~, ++ kf19=\E[18;2~, ++ kf20=\E[19;2~, ++ kf21=\E[20;2~, ++ kf22=\E[21;2~, ++ kf23=\E[23;2~, ++ kf24=\E[24;2~, ++ kf25=\E[1;5P, ++ kf26=\E[1;5Q, ++ kf27=\E[1;5R, ++ kf28=\E[1;5S, ++ kf29=\E[15;5~, ++ kf30=\E[17;5~, ++ kf31=\E[18;5~, ++ kf32=\E[19;5~, ++ kf33=\E[20;5~, ++ kf34=\E[21;5~, ++ kf35=\E[23;5~, ++ kf36=\E[24;5~, ++ kf37=\E[1;6P, ++ kf38=\E[1;6Q, ++ kf39=\E[1;6R, ++ kf40=\E[1;6S, ++ kf41=\E[15;6~, ++ kf42=\E[17;6~, ++ kf43=\E[18;6~, ++ kf44=\E[19;6~, ++ kf45=\E[20;6~, ++ kf46=\E[21;6~, ++ kf47=\E[23;6~, ++ kf48=\E[24;6~, ++ kf49=\E[1;3P, ++ kf50=\E[1;3Q, ++ kf51=\E[1;3R, ++ kf52=\E[1;3S, ++ kf53=\E[15;3~, ++ kf54=\E[17;3~, ++ kf55=\E[18;3~, ++ kf56=\E[19;3~, ++ kf57=\E[20;3~, ++ kf58=\E[21;3~, ++ kf59=\E[23;3~, ++ kf60=\E[24;3~, ++ kf61=\E[1;4P, ++ kf62=\E[1;4Q, ++ kf63=\E[1;4R, ++ khome=\E[H, ++ kHOM=\E[1;2H, ++ kHOM3=\E[1;3H, ++ kHOM4=\E[1;4H, ++ kHOM5=\E[1;5H, ++ kHOM6=\E[1;6H, ++ kHOM7=\E[1;7H, ++ kHOM8=\E[1;8H, ++ kich1=\E[2~, ++ kIC=\E[2;2~, ++ kIC3=\E[2;3~, ++ kIC4=\E[2;4~, ++ kIC5=\E[2;5~, ++ kIC6=\E[2;6~, ++ kIC7=\E[2;7~, ++ kIC8=\E[2;8~, ++ kind=\E[1;2B, ++ knp=\E[6~, ++ kNXT=\E[6;2~, ++ kNXT3=\E[6;3~, ++ kNXT4=\E[6;4~, ++ kNXT5=\E[6;5~, ++ kNXT6=\E[6;6~, ++ kNXT7=\E[6;7~, ++ kNXT8=\E[6;8~, ++ kpp=\E[5~, ++ kPRV=\E[5;2~, ++ kPRV3=\E[5;3~, ++ kPRV4=\E[5;4~, ++ kPRV5=\E[5;5~, ++ kPRV6=\E[5;6~, ++ kPRV7=\E[5;7~, ++ kPRV8=\E[5;8~, ++ kri=\E[1;2A, ++ ++sortix|Sortix, ++ use=sortix-16color, ++ colors#256, ++ pairs#32767, ++ smul=\E[4m, ++ rmul=\E[24m, +diff -Paur --no-dereference -- libcurses.upstream/tic/musl-hsearch.c libcurses/tic/musl-hsearch.c +--- libcurses.upstream/tic/musl-hsearch.c ++++ libcurses/tic/musl-hsearch.c +@@ -0,0 +1,149 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++/* ++open addressing hash table with 2^n table size ++quadratic probing is used in case of hash collision ++tab indices and hash are size_t ++after resize fails with ENOMEM the state of tab is still usable ++ ++with the posix api items cannot be iterated and length cannot be queried ++*/ ++ ++#define MINSIZE 8 ++#define MAXSIZE ((size_t)-1/2 + 1) ++ ++struct __tab { ++ ENTRY *entries; ++ size_t mask; ++ size_t used; ++}; ++ ++static struct hsearch_data htab; ++ ++int __hcreate_r(size_t, struct hsearch_data *); ++void __hdestroy_r(struct hsearch_data *); ++int __hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); ++ ++static size_t keyhash(char *k) ++{ ++ unsigned char *p = (void *)k; ++ size_t h = 0; ++ ++ while (*p) ++ h = 31*h + *p++; ++ return h; ++} ++ ++static int resize(size_t nel, struct hsearch_data *htab) ++{ ++ size_t newsize; ++ size_t i, j; ++ ENTRY *e, *newe; ++ ENTRY *oldtab = htab->__tab->entries; ++ ENTRY *oldend = htab->__tab->entries + htab->__tab->mask + 1; ++ ++ if (nel > MAXSIZE) ++ nel = MAXSIZE; ++ for (newsize = MINSIZE; newsize < nel; newsize *= 2); ++ htab->__tab->entries = calloc(newsize, sizeof *htab->__tab->entries); ++ if (!htab->__tab->entries) { ++ htab->__tab->entries = oldtab; ++ return 0; ++ } ++ htab->__tab->mask = newsize - 1; ++ if (!oldtab) ++ return 1; ++ for (e = oldtab; e < oldend; e++) ++ if (e->key) { ++ for (i=keyhash(e->key),j=1; ; i+=j++) { ++ newe = htab->__tab->entries + (i & htab->__tab->mask); ++ if (!newe->key) ++ break; ++ } ++ *newe = *e; ++ } ++ free(oldtab); ++ return 1; ++} ++ ++int hcreate(size_t nel) ++{ ++ return __hcreate_r(nel, &htab); ++} ++ ++void hdestroy(void) ++{ ++ __hdestroy_r(&htab); ++} ++ ++static ENTRY *lookup(char *key, size_t hash, struct hsearch_data *htab) ++{ ++ size_t i, j; ++ ENTRY *e; ++ ++ for (i=hash,j=1; ; i+=j++) { ++ e = htab->__tab->entries + (i & htab->__tab->mask); ++ if (!e->key || strcmp(e->key, key) == 0) ++ break; ++ } ++ return e; ++} ++ ++ENTRY *hsearch(ENTRY item, ACTION action) ++{ ++ ENTRY *e; ++ ++ __hsearch_r(item, action, &e, &htab); ++ return e; ++} ++ ++int __hcreate_r(size_t nel, struct hsearch_data *htab) ++{ ++ int r; ++ ++ htab->__tab = calloc(1, sizeof *htab->__tab); ++ if (!htab->__tab) ++ return 0; ++ r = resize(nel, htab); ++ if (r == 0) { ++ free(htab->__tab); ++ htab->__tab = 0; ++ } ++ return r; ++} ++ ++void __hdestroy_r(struct hsearch_data *htab) ++{ ++ if (htab->__tab) free(htab->__tab->entries); ++ free(htab->__tab); ++ htab->__tab = 0; ++} ++ ++int __hsearch_r(ENTRY item, ACTION action, ENTRY **retval, struct hsearch_data *htab) ++{ ++ size_t hash = keyhash(item.key); ++ ENTRY *e = lookup(item.key, hash, htab); ++ ++ if (e->key) { ++ *retval = e; ++ return 1; ++ } ++ if (action == FIND) { ++ *retval = 0; ++ return 0; ++ } ++ *e = item; ++ if (++htab->__tab->used > htab->__tab->mask - htab->__tab->mask/4) { ++ if (!resize(2*htab->__tab->used, htab)) { ++ htab->__tab->used--; ++ e->key = 0; ++ *retval = 0; ++ return 0; ++ } ++ e = lookup(item.key, hash, htab); ++ } ++ *retval = e; ++ return 1; ++} +diff -Paur --no-dereference -- libcurses.upstream/tic/musl-search.h libcurses/tic/musl-search.h +--- libcurses.upstream/tic/musl-search.h ++++ libcurses/tic/musl-search.h +@@ -0,0 +1,60 @@ ++#ifndef _SEARCH_H ++#define _SEARCH_H ++ ++#include ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++typedef enum { FIND, ENTER } ACTION; ++typedef enum { preorder, postorder, endorder, leaf } VISIT; ++ ++typedef struct entry { ++ char *key; ++ void *data; ++} ENTRY; ++ ++int hcreate(size_t); ++void hdestroy(void); ++ENTRY *hsearch(ENTRY, ACTION); ++ ++#ifdef _GNU_SOURCE ++struct hsearch_data { ++ struct __tab *__tab; ++ unsigned int __unused1; ++ unsigned int __unused2; ++}; ++ ++int hcreate_r(size_t, struct hsearch_data *); ++void hdestroy_r(struct hsearch_data *); ++int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); ++#endif ++ ++void insque(void *, void *); ++void remque(void *); ++ ++void *lsearch(const void *, void *, size_t *, size_t, ++ int (*)(const void *, const void *)); ++void *lfind(const void *, const void *, size_t *, size_t, ++ int (*)(const void *, const void *)); ++ ++void *tdelete(const void *__restrict, void **__restrict, int(*)(const void *, const void *)); ++void *tfind(const void *, void *const *, int(*)(const void *, const void *)); ++void *tsearch(const void *, void **, int (*)(const void *, const void *)); ++void twalk(const void *, void (*)(const void *, VISIT, int)); ++ ++#ifdef _GNU_SOURCE ++struct qelem { ++ struct qelem *q_forw, *q_back; ++ char q_data[1]; ++}; ++ ++void tdestroy(void *, void (*)(void *)); ++#endif ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff -Paur --no-dereference -- libcurses.upstream/tic/tic.c libcurses/tic/tic.c +--- libcurses.upstream/tic/tic.c ++++ libcurses/tic/tic.c +@@ -49,7 +49,12 @@ + #include + #include + #include ++#if !defined(__sortix__) || (defined(__has_include) && __has_include()) + #include ++#else ++#include "musl-search.h" ++#include "musl-hsearch.c" ++#endif + #include + #include + #include +diff -Paur --no-dereference -- libcurses.upstream/tset/map.c libcurses/tset/map.c +--- libcurses.upstream/tset/map.c ++++ libcurses/tset/map.c +@@ -73,7 +73,7 @@ + char *copy, *p, *termp; + + copy = strdup(arg); +- mapp = malloc((u_int)sizeof(MAP)); ++ mapp = malloc(sizeof(MAP)); + if (copy == NULL || mapp == NULL) + err(1, "malloc"); + mapp->next = NULL; +diff -Paur --no-dereference -- libcurses.upstream/tset/set.c libcurses/tset/set.c +--- libcurses.upstream/tset/set.c ++++ libcurses/tset/set.c +@@ -36,7 +36,39 @@ + #include + #include + #include ++#if !defined(__sortix__) || (defined(__has_include) && __has_include()) + #include ++#else ++#define CTRL(x) (x&037) ++#define CEOF CTRL('d') ++ ++#ifdef _POSIX_VDISABLE ++#define CEOL _POSIX_VDISABLE ++#define CSTATUS _POSIX_VDISABLE ++#else ++#define CEOL '\0' ++#define CSTATUS '\0' ++#endif ++ ++#define CERASE 0177 ++#define CINTR CTRL('c') ++#define CKILL CTRL('u') ++#define CMIN 1 ++#define CQUIT 034 ++#define CSUSP CTRL('z') ++#define CTIME 0 ++#define CDSUSP CTRL('y') ++#define CSTART CTRL('q') ++#define CSTOP CTRL('s') ++#define CLNEXT CTRL('v') ++#define CDISCARD CTRL('o') ++#define CWERASE CTRL('w') ++#define CREPRINT CTRL('r') ++#define CEOT CEOF ++#define CBRK CEOL ++#define CRPRNT CREPRINT ++#define CFLUSH CDISCARD ++#endif + #include "extern.h" + #ifndef OXTABS + #define OXTABS 0 +diff -Paur --no-dereference -- libcurses.upstream/tset/tset.c libcurses/tset/tset.c +--- libcurses.upstream/tset/tset.c ++++ libcurses/tset/tset.c +@@ -35,7 +35,14 @@ + + #include + #include ++#if !defined(__sortix__) || (defined(__has_include) && __has_include()) + #include ++#else ++#define CTRL(x) (x&037) ++#define CERASE 0177 ++#define CKILL CTRL('u') ++#define CINTR CTRL('c') ++#endif + #include + #include + #include +@@ -47,6 +54,8 @@ + #include + #include "extern.h" + ++typedef unsigned int u_int; ++ + static void obsolete(char *[]); + static void report(const char *, int, u_int); + __dead static void usage(char*); +@@ -167,7 +176,10 @@ + nlines > 0 && columns > 0) { + win.ws_row = nlines; + win.ws_col = ncolumns; ++/* TODO: Remove after TIOCSWINSZ has been merged to Sortix master. */ ++#ifdef TIOCSWINSZ + (void)ioctl(STDERR_FILENO, TIOCSWINSZ, &win); ++#endif + } + #endif + set_control_chars(erasechar, intrchar, killchar); diff --git a/ports/libcurses/libcurses.port b/ports/libcurses/libcurses.port new file mode 100644 index 00000000..01cfcb98 --- /dev/null +++ b/ports/libcurses/libcurses.port @@ -0,0 +1,11 @@ +NAME=libcurses +BUILD_LIBRARIES= +VERSION=0.1.0 +DISTNAME=netbsd-curses-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=bea4a945c8d0ec6e923bb43882b1d261c544601c3510b73818a6c431dec7756a +UPSTREAM_SITE=https://github.com/sabotage-linux/netbsd-curses/releases/download/v$VERSION +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=makefile +UPSTREAM_SITE=https://ftp.barfooze.de/pub/sabotage/tarballs diff --git a/ports/libdbus/libdbus.patch b/ports/libdbus/libdbus.patch new file mode 100644 index 00000000..af7c7542 --- /dev/null +++ b/ports/libdbus/libdbus.patch @@ -0,0 +1,176 @@ +diff -Paur --no-dereference -- libdbus.upstream/bus/activation-helper.c libdbus/bus/activation-helper.c +--- libdbus.upstream/bus/activation-helper.c ++++ libdbus/bus/activation-helper.c +@@ -43,6 +43,10 @@ + #include + #include + ++#if defined(__sortix__) ++#define initgroups(a, b) 0 ++#endif ++ + static BusDesktopFile * + desktop_file_for_name (BusConfigParser *parser, + const char *name, +diff -Paur --no-dereference -- libdbus.upstream/bus/Makefile.in libdbus/bus/Makefile.in +--- libdbus.upstream/bus/Makefile.in ++++ libdbus/bus/Makefile.in +@@ -1510,7 +1510,6 @@ + /bin/rm *.bb *.bbg *.da *.gcov || true + + install-data-hook: +- $(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus + $(mkinstalldirs) $(DESTDIR)$(configdir)/system.d + $(mkinstalldirs) $(DESTDIR)$(configdir)/session.d + $(mkinstalldirs) $(DESTDIR)$(datadir)/dbus-1/services +diff -Paur --no-dereference -- libdbus.upstream/config.sub libdbus/config.sub +--- libdbus.upstream/config.sub ++++ libdbus/config.sub +@@ -1342,7 +1342,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libdbus.upstream/dbus/dbus-sysdeps.h libdbus/dbus/dbus-sysdeps.h +--- libdbus.upstream/dbus/dbus-sysdeps.h ++++ libdbus/dbus/dbus-sysdeps.h +@@ -50,7 +50,7 @@ + * DBusPollFD + */ + #ifdef HAVE_POLL +-#include ++#include + #endif + + #ifdef DBUS_WINCE +diff -Paur --no-dereference -- libdbus.upstream/dbus/dbus-sysdeps-unix.c libdbus/dbus/dbus-sysdeps-unix.c +--- libdbus.upstream/dbus/dbus-sysdeps-unix.c ++++ libdbus/dbus/dbus-sysdeps-unix.c +@@ -63,7 +63,7 @@ + #include + #endif + #ifdef HAVE_POLL +-#include ++#include + #endif + #ifdef HAVE_BACKTRACE + #include +@@ -76,6 +76,8 @@ + #include + #endif + ++#include ++ + #include "sd-daemon.h" + + #ifndef O_BINARY +@@ -276,6 +278,11 @@ + *n_fds = 0; + return r; + ++#elif defined(__sortix__) ++ ++ fprintf(stderr, "%s:%u Warning: Sortix cannot pass fds between processes yet\n", __FILE__, __LINE__); ++ return errno = ENOTSUP, -1; ++ + #else + int bytes_read; + int start; +@@ -426,6 +433,12 @@ + return _dbus_write_socket_two(fd, + buffer1, start1, len1, + buffer2, start2, len2); ++ ++#elif defined(__sortix__) ++ ++ fprintf(stderr, "%s:%u Warning: Sortix cannot pass fds between processes yet\n", __FILE__, __LINE__); ++ return errno = ENOTSUP, -1; ++ + #else + + struct msghdr m; +@@ -734,6 +747,7 @@ + #else /* HAVE_WRITEV */ + { + int ret1; ++ int ret2; + + ret1 = _dbus_write (fd, buffer1, start1, len1); + if (ret1 == len1 && buffer2 != NULL) +diff -Paur --no-dereference -- libdbus.upstream/dbus/dbus-sysdeps-util-unix.c libdbus/dbus/dbus-sysdeps-util-unix.c +--- libdbus.upstream/dbus/dbus-sysdeps-util-unix.c ++++ libdbus/dbus/dbus-sysdeps-util-unix.c +@@ -59,6 +59,11 @@ + #define O_BINARY 0 + #endif + ++#if defined(__sortix__) ++#define setsid() getpid() ++#define setgroups(a, b) 0 ++#endif ++ + /** + * @addtogroup DBusInternalsUtils + * @{ +diff -Paur --no-dereference -- libdbus.upstream/dbus/sd-daemon.c libdbus/dbus/sd-daemon.c +--- libdbus.upstream/dbus/sd-daemon.c ++++ libdbus/dbus/sd-daemon.c +@@ -32,7 +32,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +diff -Paur --no-dereference -- libdbus.upstream/tools/dbus-launch.c libdbus/tools/dbus-launch.c +--- libdbus.upstream/tools/dbus-launch.c ++++ libdbus/tools/dbus-launch.c +@@ -769,7 +769,7 @@ + + strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS="); + strcat (envvar, bus_address); +- putenv (envvar); ++ setenv ("DBUS_SESSION_BUS_ADDRESS", bus_address, 1); + + execvp (runprog, args); + fprintf (stderr, "Couldn't exec %s: %s\n", runprog, strerror (errno)); +diff -Paur --no-dereference -- libdbus.upstream/tools/dbus-monitor.c libdbus/tools/dbus-monitor.c +--- libdbus.upstream/tools/dbus-monitor.c ++++ libdbus/tools/dbus-monitor.c +@@ -104,11 +104,7 @@ + return DBUS_HANDLER_RESULT_HANDLED; + } + +-#ifdef __APPLE__ +-#define PROFILE_TIMED_FORMAT "%s\t%lu\t%d" +-#else +-#define PROFILE_TIMED_FORMAT "%s\t%lu\t%lu" +-#endif ++#define PROFILE_TIMED_FORMAT "%s\t%lld\t%lu" + #define TRAP_NULL_STRING(str) ((str) ? (str) : "") + + typedef enum +@@ -127,7 +123,7 @@ + profile_print_with_attrs (const char *type, DBusMessage *message, + struct timeval *t, ProfileAttributeFlags attrs) + { +- printf (PROFILE_TIMED_FORMAT, type, t->tv_sec, t->tv_usec); ++ printf (PROFILE_TIMED_FORMAT, type, (long long)t->tv_sec, t->tv_usec); + + if (attrs & PROFILE_ATTRIBUTE_FLAG_SERIAL) + printf ("\t%u", dbus_message_get_serial (message)); +@@ -197,7 +193,7 @@ + PROFILE_ATTRIBUTE_FLAG_MEMBER); + break; + default: +- printf (PROFILE_TIMED_FORMAT "\n", "tun", t.tv_sec, t.tv_usec); ++ printf (PROFILE_TIMED_FORMAT "\n", "tun", (long long)t.tv_sec, t.tv_usec); + break; + } + } diff --git a/ports/libdbus/libdbus.port b/ports/libdbus/libdbus.port new file mode 100644 index 00000000..beea8b24 --- /dev/null +++ b/ports/libdbus/libdbus.port @@ -0,0 +1,14 @@ +NAME=libdbus +BUILD_LIBRARIES=libexpat +VERSION=1.6.8 +DISTNAME=dbus-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=fc1370ef38abeeb13f55c905ec002e60705fb0bfde3b8d21c8d6eb8056c11bac +UPSTREAM_SITE=https://dbus.freedesktop.org/releases/dbus +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +# TODO: The tests depend on glib, which means we have to disable them, since glib depends on this package. +CONFIGURE_ARGS='--disable-abstract-sockets --without-x --disable-tests' +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libevent/libevent.patch b/ports/libevent/libevent.patch new file mode 100644 index 00000000..be4e8945 --- /dev/null +++ b/ports/libevent/libevent.patch @@ -0,0 +1,219 @@ +diff -Paur --no-dereference -- libevent.upstream/buffer.c libevent/buffer.c +--- libevent.upstream/buffer.c ++++ libevent/buffer.c +@@ -183,7 +183,7 @@ + /* this way we can manipulate the buffer to different addresses, + * which is required for mmap for example. + */ +- chain->buffer = EVBUFFER_CHAIN_EXTRA(u_char, chain); ++ chain->buffer = EVBUFFER_CHAIN_EXTRA(unsigned char, chain); + + return (chain); + } +@@ -2749,7 +2749,7 @@ + if (!chain) + return (-1); + chain->flags |= EVBUFFER_REFERENCE | EVBUFFER_IMMUTABLE; +- chain->buffer = (u_char *)data; ++ chain->buffer = (unsigned char *)data; + chain->buffer_len = datlen; + chain->off = datlen; + +diff -Paur --no-dereference -- libevent.upstream/bufferevent_sock.c libevent/bufferevent_sock.c +--- libevent.upstream/bufferevent_sock.c ++++ libevent/bufferevent_sock.c +@@ -63,6 +63,7 @@ + #include "event2/util.h" + #include "event2/bufferevent.h" + #include "event2/buffer.h" ++#include "event2/buffer_compat.h" + #include "event2/bufferevent_struct.h" + #include "event2/bufferevent_compat.h" + #include "event2/event.h" +@@ -75,6 +76,7 @@ + #endif + + /* prototypes */ ++void bufferevent_read_pressure_cb(struct evbuffer *, size_t, size_t, void *); + static int be_socket_enable(struct bufferevent *, short); + static int be_socket_disable(struct bufferevent *, short); + static void be_socket_destruct(struct bufferevent *); +@@ -119,6 +121,40 @@ + } + } + ++static int ++bufferevent_add(struct event *ev, struct timeval timeout) ++{ ++ struct timeval *ptv = NULL; ++ ++ if (timeout.tv_sec || timeout.tv_usec) { ++ ptv = &timeout; ++ } ++ ++ return (event_add(ev, ptv)); ++} ++ ++/* ++ * This callback is executed when the size of the input buffer changes. ++ * We use it to apply back pressure on the reading side. ++ */ ++ ++/* This API was needed to port OpenBSD's httpd to Sortix. */ ++void ++bufferevent_read_pressure_cb(struct evbuffer *buf, size_t old, size_t now, ++ void *arg) { ++ struct bufferevent *bufev = arg; ++ /* ++ * If we are below the watermark then reschedule reading if it's ++ * still enabled. ++ */ ++ if (bufev->wm_read.high == 0 || now < bufev->wm_read.high) { ++ evbuffer_setcb(buf, NULL, NULL); ++ ++ if (bufev->enabled & EV_READ) ++ bufferevent_add(&bufev->ev_read, bufev->timeout_read); ++ } ++} ++ + static void + bufferevent_readcb(evutil_socket_t fd, short event, void *arg) + { +diff -Paur --no-dereference -- libevent.upstream/config.sub libevent/config.sub +--- libevent.upstream/config.sub ++++ libevent/config.sub +@@ -1348,7 +1348,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libevent.upstream/configure libevent/configure +--- libevent.upstream/configure ++++ libevent/configure +@@ -14602,7 +14602,7 @@ + # which indicates that we try without any flags at all, and "pthread-config" + # which is a program returning the flags for the Pth emulation library. + +-acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" ++acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt" + + # The ordering *is* (sometimes) important. Some notes on the + # individual items follow: +@@ -14726,8 +14726,8 @@ + main () + { + pthread_t th; pthread_join(th, 0); +- pthread_attr_init(0); pthread_cleanup_push(0, 0); +- pthread_create(0,0,0,0); pthread_cleanup_pop(0); ++ pthread_attr_init(0); ++ pthread_create(0,0,0,0); + ; + return 0; + } +diff -Paur --no-dereference -- libevent.upstream/evutil.c libevent/evutil.c +--- libevent.upstream/evutil.c ++++ libevent/evutil.c +@@ -2102,11 +2102,7 @@ + long + _evutil_weakrand(void) + { +-#ifdef WIN32 +- return rand(); +-#else +- return random(); +-#endif ++ return arc4random() & 0x7FFFFFFF; + } + + /** +diff -Paur --no-dereference -- libevent.upstream/evutil_rand.c libevent/evutil_rand.c +--- libevent.upstream/evutil_rand.c ++++ libevent/evutil_rand.c +@@ -174,7 +174,7 @@ + void + evutil_secure_rng_add_bytes(const char *buf, size_t n) + { +- arc4random_addrandom((unsigned char*)buf, +- n>(size_t)INT_MAX ? INT_MAX : (int)n); ++ (void) buf; ++ (void) n; + } + +diff -Paur --no-dereference -- libevent.upstream/http-internal.h libevent/http-internal.h +--- libevent.upstream/http-internal.h ++++ libevent/http-internal.h +@@ -70,10 +70,10 @@ + struct event retry_ev; /* for retrying connects */ + + char *bind_address; /* address to use for binding the src */ +- u_short bind_port; /* local port for binding the src */ ++ unsigned short bind_port; /* local port for binding the src */ + + char *address; /* address to connect to */ +- u_short port; ++ unsigned short port; + + size_t max_headers_size; + ev_uint64_t max_body_size; +diff -Paur --no-dereference -- libevent.upstream/Makefile.in libevent/Makefile.in +--- libevent.upstream/Makefile.in ++++ libevent/Makefile.in +@@ -537,7 +537,7 @@ + @INSTALL_LIBEVENT_TRUE@lib_LTLIBRARIES = $(LIBEVENT_LIBS_LA) + @INSTALL_LIBEVENT_TRUE@pkgconfig_DATA = $(LIBEVENT_PKGCONFIG) + @INSTALL_LIBEVENT_FALSE@noinst_LTLIBRARIES = $(LIBEVENT_LIBS_LA) +-SUBDIRS = . include sample test ++SUBDIRS = . include + @BUILD_WIN32_FALSE@SYS_LIBS = + @BUILD_WIN32_TRUE@SYS_LIBS = -lws2_32 -lshell32 -ladvapi32 + @BUILD_WIN32_FALSE@SYS_SRC = $(am__append_5) $(am__append_6) \ +@@ -1219,6 +1219,9 @@ + clean-noinstLTLIBRARIES mostlyclean-am + + distclean: distclean-recursive ++ rm -f sample/Makefile ++ rm -rf test/.deps ++ rm -r test/Makefile + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(DEPDIR) ./$(DEPDIR) + -rm -f Makefile +diff -Paur --no-dereference -- libevent.upstream/poll.c libevent/poll.c +--- libevent.upstream/poll.c ++++ libevent/poll.c +@@ -180,7 +180,7 @@ + if (res == 0 || nfds == 0) + return (0); + +- i = random() % nfds; ++ i = arc4random_uniform(nfds); + for (j = 0; j < nfds; j++) { + int what; + if (++i == nfds) +diff -Paur --no-dereference -- libevent.upstream/select.c libevent/select.c +--- libevent.upstream/select.c ++++ libevent/select.c +@@ -177,7 +177,7 @@ + event_debug(("%s: select reports %d", __func__, res)); + + check_selectop(sop); +- i = random() % nfds; ++ i = arc4random_uniform(nfds); + for (j = 0; j < nfds; ++j) { + if (++i >= nfds) + i = 0; +diff -Paur --no-dereference -- libevent.upstream/util-internal.h libevent/util-internal.h +--- libevent.upstream/util-internal.h ++++ libevent/util-internal.h +@@ -75,7 +75,7 @@ + + /* True iff e is an error that means a read/write operation can be retried. */ + #define EVUTIL_ERR_RW_RETRIABLE(e) \ +- ((e) == EINTR || (e) == EAGAIN) ++ ((e) == EINTR || (e) == EAGAIN || (e) == EWOULDBLOCK) + /* True iff e is an error that means an connect can be retried. */ + #define EVUTIL_ERR_CONNECT_RETRIABLE(e) \ + ((e) == EINTR || (e) == EINPROGRESS) diff --git a/ports/libevent/libevent.port b/ports/libevent/libevent.port new file mode 100644 index 00000000..545fc37c --- /dev/null +++ b/ports/libevent/libevent.port @@ -0,0 +1,13 @@ +NAME=libevent +BUILD_LIBRARIES='libz? libssl?' +VERSION=2.0.22-stable +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=71c2c49f0adadacfdbe6332a372c38cf9c8b7895bb73dabeaa53cdcc1d4e1fa3 +UPSTREAM_SITE=https://github.com/libevent/libevent/releases/download/release-$VERSION +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS=--disable-malloc-replacement +POST_INSTALL=tix-eradicate-libtool-la +VERSION_REGEX='([0-9]+\.[0-9]+(\.[0-9]+)*-stable)' diff --git a/ports/libexpat/libexpat.patch b/ports/libexpat/libexpat.patch new file mode 100644 index 00000000..52e2948e --- /dev/null +++ b/ports/libexpat/libexpat.patch @@ -0,0 +1,45 @@ +diff -Paur --no-dereference -- libexpat.upstream/conftools/config.sub libexpat/conftools/config.sub +--- libexpat.upstream/conftools/config.sub ++++ libexpat/conftools/config.sub +@@ -1326,7 +1326,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libexpat.upstream/Makefile.in libexpat/Makefile.in +--- libexpat.upstream/Makefile.in ++++ libexpat/Makefile.in +@@ -45,7 +45,7 @@ + APIHEADER = $(srcdir)/lib/expat.h $(srcdir)/lib/expat_external.h + LIBRARY = libexpat.la + +-DESTDIR = $(INSTALL_ROOT) ++DESTDIR ?= $(INSTALL_ROOT) + + default: buildlib xmlwf/xmlwf@EXEEXT@ + +diff -Paur --no-dereference -- libexpat.upstream/xmlwf/readfilemap.c libexpat/xmlwf/readfilemap.c +--- libexpat.upstream/xmlwf/readfilemap.c ++++ libexpat/xmlwf/readfilemap.c +@@ -8,17 +8,7 @@ + #include + #include + +-#ifdef __WATCOMC__ +-#ifndef __LINUX__ +-#include +-#else + #include +-#endif +-#endif +- +-#ifdef __BEOS__ +-#include +-#endif + + #ifndef S_ISREG + #ifndef S_IFREG diff --git a/ports/libexpat/libexpat.port b/ports/libexpat/libexpat.port new file mode 100644 index 00000000..27db2cf8 --- /dev/null +++ b/ports/libexpat/libexpat.port @@ -0,0 +1,14 @@ +NAME=libexpat +BUILD_LIBRARIES= +VERSION_MAJOR=2 +VERSION_MINOR=1 +VERSION_PATCH=0 +VERSION=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH +DISTNAME=expat-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=823705472f816df21c8f6aa026dd162b280806838bb55b3432b0fb1fcca7eb86 +UPSTREAM_SITE=https://github.com/libexpat/libexpat/releases/download/R_${VERSION_MAJOR}_${VERSION_MINOR}_${VERSION_PATCH} +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libffi/libffi.patch b/ports/libffi/libffi.patch new file mode 100644 index 00000000..567162d5 --- /dev/null +++ b/ports/libffi/libffi.patch @@ -0,0 +1,68 @@ +diff -Paur --no-dereference -- libffi.upstream/config.sub libffi/config.sub +--- libffi.upstream/config.sub ++++ libffi/config.sub +@@ -1354,7 +1354,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libffi.upstream/configure libffi/configure +--- libffi.upstream/configure ++++ libffi/configure +@@ -20709,7 +20709,7 @@ + eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null" + if grep '^REMOVED,,,' "$ac_top_srcdir/Makefile" >/dev/null + then rm $ac_top_srcdir/Makefile ; fi +- cp $tmp/conftemp.mk $ac_top_srcdir/makefiles.mk~ ## DEBUGGING ++ #cp $tmp/conftemp.mk $ac_top_srcdir/makefiles.mk~ ## DEBUGGING + fi + if test ! -f "$ac_top_srcdir/Makefile" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: create top_srcdir/Makefile guessed from local Makefile" >&5 +@@ -20794,7 +20794,7 @@ + ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\ + ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile + _EOF +- cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefile.sed~" ## DEBUGGING ++ #cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefile.sed~" ## DEBUGGING + $ax_enable_builddir_sed -f $tmp/conftemp.sed Makefile >$ac_top_srcdir/Makefile + if test -f "$ac_top_srcdir/Makefile.mk" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: extend top_srcdir/Makefile with top_srcdir/Makefile.mk" >&5 +@@ -20815,8 +20815,8 @@ + # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed + echo "s!^$xxxx [^|]* | *$ax_enable_builddir *\$!$xxxx ...... $ax_enable_builddir!" >$tmp/conftemp.sed + $ax_enable_builddir_sed -f "$tmp/conftemp.sed" "$ac_top_srcdir/Makefile" >$tmp/mkfile.tmp +- cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefiles.sed~" ## DEBUGGING +- cp "$tmp/mkfile.tmp" "$ac_top_srcdir/makefiles.out~" ## DEBUGGING ++ #cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefiles.sed~" ## DEBUGGING ++ #cp "$tmp/mkfile.tmp" "$ac_top_srcdir/makefiles.out~" ## DEBUGGING + if cmp -s "$ac_top_srcdir/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: keeping top_srcdir/Makefile from earlier configure" >&5 + $as_echo "$as_me: keeping top_srcdir/Makefile from earlier configure" >&6;} +diff -Paur --no-dereference -- libffi.upstream/include/Makefile.in libffi/include/Makefile.in +--- libffi.upstream/include/Makefile.in ++++ libffi/include/Makefile.in +@@ -314,7 +314,7 @@ + AUTOMAKE_OPTIONS = foreign + DISTCLEANFILES = ffitarget.h + EXTRA_DIST = ffi.h.in ffi_common.h +-includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include ++includesdir = $(includedir) + nodist_includes_HEADERS = ffi.h ffitarget.h + all: all-am + +diff -Paur --no-dereference -- libffi.upstream/libffi.pc.in libffi/libffi.pc.in +--- libffi.upstream/libffi.pc.in ++++ libffi/libffi.pc.in +@@ -2,7 +2,7 @@ + exec_prefix=@exec_prefix@ + libdir=@libdir@ + toolexeclibdir=@toolexeclibdir@ +-includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include ++includedir=@includedir@ + + Name: @PACKAGE_NAME@ + Description: Library supporting Foreign Function Interfaces diff --git a/ports/libffi/libffi.port b/ports/libffi/libffi.port new file mode 100644 index 00000000..b42284f7 --- /dev/null +++ b/ports/libffi/libffi.port @@ -0,0 +1,11 @@ +NAME=libffi +BUILD_LIBRARIES= +VERSION=3.2.1 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37 +UPSTREAM_SITE=https://sourceware.org/pub/libffi +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libfontconfig/libfontconfig.patch b/ports/libfontconfig/libfontconfig.patch new file mode 100644 index 00000000..6bfa5768 --- /dev/null +++ b/ports/libfontconfig/libfontconfig.patch @@ -0,0 +1,261 @@ +diff -Paur --no-dereference -- libfontconfig.upstream/fc-blanks/Makefile.in libfontconfig/fc-blanks/Makefile.in +--- libfontconfig.upstream/fc-blanks/Makefile.in ++++ libfontconfig/fc-blanks/Makefile.in +@@ -350,7 +350,8 @@ + $(TMPL) \ + $(NULL) + +-DISTCLEANFILES = $(BLANKS_H) ++# PATCH: fc-blanks.py doesn't work on Sortix (python2 urllib issues). ++DISTCLEANFILES = + all: all-am + + .SUFFIXES: +diff -Paur --no-dereference -- libfontconfig.upstream/fontconfig.pc.in libfontconfig/fontconfig.pc.in +--- libfontconfig.upstream/fontconfig.pc.in ++++ libfontconfig/fontconfig.pc.in +@@ -14,5 +14,6 @@ + Requires: @PKGCONFIG_REQUIRES@ + Requires.private: @PKGCONFIG_REQUIRES_PRIVATELY@ + Libs: -L${libdir} -lfontconfig +-Libs.private: @EXPAT_LIBS@ @FREETYPE_LIBS@ @ICONV_LIBS@ @LIBXML2_LIBS@ +-Cflags: -I${includedir} @EXPAT_CFLAGS@ @FREETYPE_CFLAGS@ @ICONV_CFLAGS@ @LIBXML2_CFLAGS@ ++Libs.private: @ICONV_LIBS@ ++# PATCH: These were provided by the above Requires and were not cross safe. ++Cflags: -I${includedir} @ICONV_CFLAGS@ +diff -Paur --no-dereference -- libfontconfig.upstream/Makefile.in libfontconfig/Makefile.in +--- libfontconfig.upstream/Makefile.in ++++ libfontconfig/Makefile.in +@@ -434,7 +434,8 @@ + top_build_prefix = @top_build_prefix@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ +-SUBDIRS = fontconfig fc-blanks fc-case fc-lang fc-glyphname src \ ++# PATCH: fc-blanks is a python script that doesn't run on Sortix right now. ++SUBDIRS = fontconfig fc-case fc-lang fc-glyphname src \ + fc-cache fc-cat fc-list fc-match fc-pattern fc-query fc-scan \ + fc-validate conf.d test $(am__append_1) + ACLOCAL_AMFLAGS = -I m4 +diff -Paur --no-dereference -- libfontconfig.upstream/src/fccache.c libfontconfig/src/fccache.c +--- libfontconfig.upstream/src/fccache.c ++++ libfontconfig/src/fccache.c +@@ -38,6 +38,9 @@ + #if defined(_WIN32) + #include + #endif ++#if defined(__has_include) && __has_include() ++#include ++#endif + + #ifndef O_BINARY + #define O_BINARY 0 +@@ -1266,7 +1269,11 @@ + #if defined(_WIN32) + if (_locking (fd, _LK_LOCK, 1) == -1) + goto bail; +-#else ++/* PATCH: Sortix refuses to implement crap file locking. */ ++#elif defined(LOCK_EX) ++ if (flock(fd, LOCK_EX) == -1) ++ goto bail; ++#elif !defined(__sortix__) + struct flock fl; + + fl.l_type = F_WRLCK; +@@ -1276,17 +1283,21 @@ + fl.l_pid = getpid (); + if (fcntl (fd, F_SETLKW, &fl) == -1) + goto bail; ++#else ++#define FcDirCacheLock_NOBAIL + #endif + break; + } + } + FcStrListDone (list); + return fd; ++#ifndef FcDirCacheLock_NOBAIL + bail: + FcStrListDone (list); + if (fd != -1) + close (fd); + return -1; ++#endif + } + + void +@@ -1296,7 +1307,10 @@ + { + #if defined(_WIN32) + _locking (fd, _LK_UNLCK, 1); +-#else ++/* PATCH: Sortix refuses to implement crap file locking. */ ++#elif defined(LOCK_EX) ++ flock(fd, LOCK_UN); ++#elif !defined(__sortix__) + struct flock fl; + + fl.l_type = F_UNLCK; +diff -Paur --no-dereference -- libfontconfig.upstream/src/fccompat.c libfontconfig/src/fccompat.c +--- libfontconfig.upstream/src/fccompat.c ++++ libfontconfig/src/fccompat.c +@@ -164,69 +164,8 @@ + int32_t + FcRandom(void) + { +- int32_t result; +- +-#if HAVE_RANDOM_R +- static struct random_data fcrandbuf; +- static char statebuf[256]; +- static FcBool initialized = FcFalse; +-#ifdef _AIX +- static char *retval; +- long res; +-#endif +- +- if (initialized != FcTrue) +- { +-#ifdef _AIX +- initstate_r (time (NULL), statebuf, 256, &retval, &fcrandbuf); +-#else +- initstate_r (time (NULL), statebuf, 256, &fcrandbuf); +-#endif +- initialized = FcTrue; +- } +- +-#ifdef _AIX +- random_r (&res, &fcrandbuf); +- result = (int32_t)res; +-#else +- random_r (&fcrandbuf, &result); +-#endif +-#elif HAVE_RANDOM +- static char statebuf[256]; +- char *state; +- static FcBool initialized = FcFalse; +- +- if (initialized != FcTrue) +- { +- state = initstate (time (NULL), statebuf, 256); +- initialized = FcTrue; +- } +- else +- state = setstate (statebuf); +- +- result = random (); +- +- setstate (state); +-#elif HAVE_LRAND48 +- result = lrand48 (); +-#elif HAVE_RAND_R +- static unsigned int seed = time (NULL); +- +- result = rand_r (&seed); +-#elif HAVE_RAND +- static FcBool initialized = FcFalse; +- +- if (initialized != FcTrue) +- { +- srand (time (NULL)); +- initialized = FcTrue; +- } +- result = rand (); +-#else +-# error no random number generator function available. +-#endif +- +- return result; ++ /* PATCH: Use good random. */ ++ return arc4random_uniform (INT32_MAX); + } + + #ifdef _WIN32 +diff -Paur --no-dereference -- libfontconfig.upstream/src/fcname.c libfontconfig/src/fcname.c +--- libfontconfig.upstream/src/fcname.c ++++ libfontconfig/src/fcname.c +@@ -506,17 +506,17 @@ + case FcTypeVoid: + return FcTrue; + case FcTypeInteger: +- sprintf ((char *) temp, "%d", v.u.i); ++ snprintf ((char *) temp, sizeof (temp), "%d", v.u.i); + return FcNameUnparseString (buf, temp, 0); + case FcTypeDouble: +- sprintf ((char *) temp, "%g", v.u.d); ++ snprintf ((char *) temp, sizeof (temp), "%g", v.u.d); + return FcNameUnparseString (buf, temp, 0); + case FcTypeString: + return FcNameUnparseString (buf, v.u.s, escape); + case FcTypeBool: + return FcNameUnparseString (buf, v.u.b ? (FcChar8 *) "True" : (FcChar8 *) "False", 0); + case FcTypeMatrix: +- sprintf ((char *) temp, "%g %g %g %g", ++ snprintf ((char *) temp, sizeof (temp), "%g %g %g %g", + v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy); + return FcNameUnparseString (buf, temp, 0); + case FcTypeCharSet: +@@ -526,7 +526,7 @@ + case FcTypeFTFace: + return FcTrue; + case FcTypeRange: +- sprintf ((char *) temp, "[%g %g)", v.u.r->begin, v.u.r->end); ++ snprintf ((char *) temp, sizeof (temp), "[%g %g)", v.u.r->begin, v.u.r->end); + return FcNameUnparseString (buf, temp, 0); + } + return FcFalse; +diff -Paur --no-dereference -- libfontconfig.upstream/src/fcobjs.c libfontconfig/src/fcobjs.c +--- libfontconfig.upstream/src/fcobjs.c ++++ libfontconfig/src/fcobjs.c +@@ -24,11 +24,12 @@ + + #include "fcint.h" + ++/* TODO: Stick with existing fcobjshash.h regardless of system gperf. */ + static unsigned int +-FcObjectTypeHash (register const char *str, register FC_GPERF_SIZE_T len); ++FcObjectTypeHash (register const char *str, register size_t len); + + static const struct FcObjectTypeInfo * +-FcObjectTypeLookup (register const char *str, register FC_GPERF_SIZE_T len); ++FcObjectTypeLookup (register const char *str, register size_t len); + + #include "fcobjshash.h" + +diff -Paur --no-dereference -- libfontconfig.upstream/src/Makefile.in libfontconfig/src/Makefile.in +--- libfontconfig.upstream/src/Makefile.in ++++ libfontconfig/src/Makefile.in +@@ -496,7 +496,6 @@ + stamp-fcstdint \ + fcstdint.h \ + stamp-fcobjshash.gperf \ +- fcobjshash.h \ + fcobjshash.gperf + + all: $(BUILT_SOURCES) +@@ -912,9 +911,10 @@ + ' - > $@.tmp && \ + mv -f $@.tmp fcobjshash.gperf && touch $@ || ( $(RM) $@.tmp && false ) + +-fcobjshash.h: Makefile fcobjshash.gperf +- $(AM_V_GEN) $(GPERF) --pic -m 100 fcobjshash.gperf > $@.tmp && \ +- mv -f $@.tmp $@ || ( $(RM) $@.tmp && false ) ++# PATCH: Sortix doesn't have gperf at the moment. ++#fcobjshash.h: Makefile fcobjshash.gperf ++# $(AM_V_GEN) $(GPERF) --pic -m 100 fcobjshash.gperf > $@.tmp && \ ++# mv -f $@.tmp $@ || ( $(RM) $@.tmp && false ) + + @ENABLE_SHARED_TRUE@install-data-local: install-ms-import-lib install-libtool-import-lib + +diff -Paur --no-dereference -- libfontconfig.upstream/test/test-migration.c libfontconfig/test/test-migration.c +--- libfontconfig.upstream/test/test-migration.c ++++ libfontconfig/test/test-migration.c +@@ -22,6 +22,8 @@ + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ ++/* PATCH: Need HAVE_FOO macros.. */ ++#include "../config.h" + #include + #include + #include diff --git a/ports/libfontconfig/libfontconfig.port b/ports/libfontconfig/libfontconfig.port new file mode 100644 index 00000000..01c7dea0 --- /dev/null +++ b/ports/libfontconfig/libfontconfig.port @@ -0,0 +1,14 @@ +NAME=libfontconfig +BUILD_LIBRARIES='libiconv libexpat libfreetype' +VERSION=2.12.6 +DISTNAME=fontconfig-$VERSION +COMPRESSION=tar.bz2 +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=cf0c30807d08f6a28ab46c61b8dbd55c97d2f292cf88f3a07d3384687f31f017 +UPSTREAM_SITE=https://www.freedesktop.org/software/fontconfig/release +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +# Documentation requires SGMLSpm and texline, doesn't seem to work? +CONFIGURE_ARGS=--disable-docs +POST_INSTALL=tix-eradicate-libtool-la +MAKE_VARS='V=1' diff --git a/ports/libfontconfig/libfontconfig.rmpatch b/ports/libfontconfig/libfontconfig.rmpatch new file mode 100644 index 00000000..9b3f4b28 --- /dev/null +++ b/ports/libfontconfig/libfontconfig.rmpatch @@ -0,0 +1,208 @@ +rm -rf -- 'conf.d/README' +rm -rf -- 'doc/FcAtomicCreate.3' +rm -rf -- 'doc/FcAtomicDeleteNew.3' +rm -rf -- 'doc/FcAtomicDestroy.3' +rm -rf -- 'doc/FcAtomicLock.3' +rm -rf -- 'doc/FcAtomicNewFile.3' +rm -rf -- 'doc/FcAtomicOrigFile.3' +rm -rf -- 'doc/FcAtomicReplaceOrig.3' +rm -rf -- 'doc/FcAtomicUnlock.3' +rm -rf -- 'doc/FcBlanksAdd.3' +rm -rf -- 'doc/FcBlanksCreate.3' +rm -rf -- 'doc/FcBlanksDestroy.3' +rm -rf -- 'doc/FcBlanksIsMember.3' +rm -rf -- 'doc/FcCacheCopySet.3' +rm -rf -- 'doc/FcCacheCreateTagFile.3' +rm -rf -- 'doc/FcCacheDir.3' +rm -rf -- 'doc/FcCacheNumFont.3' +rm -rf -- 'doc/FcCacheNumSubdir.3' +rm -rf -- 'doc/FcCacheSubdir.3' +rm -rf -- 'doc/FcCharSetAddChar.3' +rm -rf -- 'doc/FcCharSetCopy.3' +rm -rf -- 'doc/FcCharSetCount.3' +rm -rf -- 'doc/FcCharSetCoverage.3' +rm -rf -- 'doc/FcCharSetCreate.3' +rm -rf -- 'doc/FcCharSetDelChar.3' +rm -rf -- 'doc/FcCharSetDestroy.3' +rm -rf -- 'doc/FcCharSetEqual.3' +rm -rf -- 'doc/FcCharSetFirstPage.3' +rm -rf -- 'doc/FcCharSetHasChar.3' +rm -rf -- 'doc/FcCharSetIntersect.3' +rm -rf -- 'doc/FcCharSetIntersectCount.3' +rm -rf -- 'doc/FcCharSetIsSubset.3' +rm -rf -- 'doc/FcCharSetMerge.3' +rm -rf -- 'doc/FcCharSetNew.3' +rm -rf -- 'doc/FcCharSetNextPage.3' +rm -rf -- 'doc/FcCharSetSubtract.3' +rm -rf -- 'doc/FcCharSetSubtractCount.3' +rm -rf -- 'doc/FcCharSetUnion.3' +rm -rf -- 'doc/FcConfigAppFontAddDir.3' +rm -rf -- 'doc/FcConfigAppFontAddFile.3' +rm -rf -- 'doc/FcConfigAppFontClear.3' +rm -rf -- 'doc/FcConfigBuildFonts.3' +rm -rf -- 'doc/FcConfigCreate.3' +rm -rf -- 'doc/FcConfigDestroy.3' +rm -rf -- 'doc/FcConfigEnableHome.3' +rm -rf -- 'doc/FcConfigFilename.3' +rm -rf -- 'doc/FcConfigGetBlanks.3' +rm -rf -- 'doc/FcConfigGetCache.3' +rm -rf -- 'doc/FcConfigGetCacheDirs.3' +rm -rf -- 'doc/FcConfigGetConfigDirs.3' +rm -rf -- 'doc/FcConfigGetConfigFiles.3' +rm -rf -- 'doc/FcConfigGetCurrent.3' +rm -rf -- 'doc/FcConfigGetFontDirs.3' +rm -rf -- 'doc/FcConfigGetFonts.3' +rm -rf -- 'doc/FcConfigGetRescanInterval.3' +rm -rf -- 'doc/FcConfigGetSysRoot.3' +rm -rf -- 'doc/FcConfigHome.3' +rm -rf -- 'doc/FcConfigParseAndLoad.3' +rm -rf -- 'doc/FcConfigParseAndLoadFromMemory.3' +rm -rf -- 'doc/FcConfigReference.3' +rm -rf -- 'doc/FcConfigSetCurrent.3' +rm -rf -- 'doc/FcConfigSetRescanInterval.3' +rm -rf -- 'doc/FcConfigSetSysRoot.3' +rm -rf -- 'doc/FcConfigSubstitute.3' +rm -rf -- 'doc/FcConfigSubstituteWithPat.3' +rm -rf -- 'doc/FcConfigUptoDate.3' +rm -rf -- 'doc/FcDefaultSubstitute.3' +rm -rf -- 'doc/FcDirCacheClean.3' +rm -rf -- 'doc/FcDirCacheLoad.3' +rm -rf -- 'doc/FcDirCacheLoadFile.3' +rm -rf -- 'doc/FcDirCacheRead.3' +rm -rf -- 'doc/FcDirCacheRescan.3' +rm -rf -- 'doc/FcDirCacheUnlink.3' +rm -rf -- 'doc/FcDirCacheUnload.3' +rm -rf -- 'doc/FcDirCacheValid.3' +rm -rf -- 'doc/FcDirSave.3' +rm -rf -- 'doc/FcDirScan.3' +rm -rf -- 'doc/FcFileIsDir.3' +rm -rf -- 'doc/FcFileScan.3' +rm -rf -- 'doc/FcFini.3' +rm -rf -- 'doc/FcFontList.3' +rm -rf -- 'doc/FcFontMatch.3' +rm -rf -- 'doc/FcFontRenderPrepare.3' +rm -rf -- 'doc/FcFontSetAdd.3' +rm -rf -- 'doc/FcFontSetCreate.3' +rm -rf -- 'doc/FcFontSetDestroy.3' +rm -rf -- 'doc/FcFontSetList.3' +rm -rf -- 'doc/FcFontSetMatch.3' +rm -rf -- 'doc/FcFontSetPrint.3' +rm -rf -- 'doc/FcFontSetSort.3' +rm -rf -- 'doc/FcFontSetSortDestroy.3' +rm -rf -- 'doc/FcFontSort.3' +rm -rf -- 'doc/FcFreeTypeCharIndex.3' +rm -rf -- 'doc/FcFreeTypeCharSet.3' +rm -rf -- 'doc/FcFreeTypeCharSetAndSpacing.3' +rm -rf -- 'doc/FcFreeTypeQuery.3' +rm -rf -- 'doc/FcFreeTypeQueryFace.3' +rm -rf -- 'doc/FcGetDefaultLangs.3' +rm -rf -- 'doc/FcGetLangs.3' +rm -rf -- 'doc/FcGetVersion.3' +rm -rf -- 'doc/FcInit.3' +rm -rf -- 'doc/FcInitBringUptoDate.3' +rm -rf -- 'doc/FcInitLoadConfig.3' +rm -rf -- 'doc/FcInitLoadConfigAndFonts.3' +rm -rf -- 'doc/FcInitReinitialize.3' +rm -rf -- 'doc/FcIsLower.3' +rm -rf -- 'doc/FcIsUpper.3' +rm -rf -- 'doc/FcLangGetCharSet.3' +rm -rf -- 'doc/FcLangNormalize.3' +rm -rf -- 'doc/FcLangSetAdd.3' +rm -rf -- 'doc/FcLangSetCompare.3' +rm -rf -- 'doc/FcLangSetContains.3' +rm -rf -- 'doc/FcLangSetCopy.3' +rm -rf -- 'doc/FcLangSetCreate.3' +rm -rf -- 'doc/FcLangSetDel.3' +rm -rf -- 'doc/FcLangSetDestroy.3' +rm -rf -- 'doc/FcLangSetEqual.3' +rm -rf -- 'doc/FcLangSetGetLangs.3' +rm -rf -- 'doc/FcLangSetHasLang.3' +rm -rf -- 'doc/FcLangSetHash.3' +rm -rf -- 'doc/FcLangSetSubtract.3' +rm -rf -- 'doc/FcLangSetUnion.3' +rm -rf -- 'doc/FcMatrixCopy.3' +rm -rf -- 'doc/FcMatrixEqual.3' +rm -rf -- 'doc/FcMatrixInit.3' +rm -rf -- 'doc/FcMatrixMultiply.3' +rm -rf -- 'doc/FcMatrixRotate.3' +rm -rf -- 'doc/FcMatrixScale.3' +rm -rf -- 'doc/FcMatrixShear.3' +rm -rf -- 'doc/FcNameConstant.3' +rm -rf -- 'doc/FcNameGetConstant.3' +rm -rf -- 'doc/FcNameGetObjectType.3' +rm -rf -- 'doc/FcNameParse.3' +rm -rf -- 'doc/FcNameRegisterConstants.3' +rm -rf -- 'doc/FcNameRegisterObjectTypes.3' +rm -rf -- 'doc/FcNameUnparse.3' +rm -rf -- 'doc/FcNameUnregisterConstants.3' +rm -rf -- 'doc/FcNameUnregisterObjectTypes.3' +rm -rf -- 'doc/FcObjectSetAdd.3' +rm -rf -- 'doc/FcObjectSetBuild.3' +rm -rf -- 'doc/FcObjectSetCreate.3' +rm -rf -- 'doc/FcObjectSetDestroy.3' +rm -rf -- 'doc/FcPatternAdd-Type.3' +rm -rf -- 'doc/FcPatternAdd.3' +rm -rf -- 'doc/FcPatternAddWeak.3' +rm -rf -- 'doc/FcPatternBuild.3' +rm -rf -- 'doc/FcPatternCreate.3' +rm -rf -- 'doc/FcPatternDel.3' +rm -rf -- 'doc/FcPatternDestroy.3' +rm -rf -- 'doc/FcPatternDuplicate.3' +rm -rf -- 'doc/FcPatternEqual.3' +rm -rf -- 'doc/FcPatternEqualSubset.3' +rm -rf -- 'doc/FcPatternFilter.3' +rm -rf -- 'doc/FcPatternFormat.3' +rm -rf -- 'doc/FcPatternGet-Type.3' +rm -rf -- 'doc/FcPatternGet.3' +rm -rf -- 'doc/FcPatternGetWithBinding.3' +rm -rf -- 'doc/FcPatternHash.3' +rm -rf -- 'doc/FcPatternPrint.3' +rm -rf -- 'doc/FcPatternReference.3' +rm -rf -- 'doc/FcPatternRemove.3' +rm -rf -- 'doc/FcRangeCopy.3' +rm -rf -- 'doc/FcRangeCreateDouble.3' +rm -rf -- 'doc/FcRangeCreateInteger.3' +rm -rf -- 'doc/FcRangeDestroy.3' +rm -rf -- 'doc/FcRangeGetDouble.3' +rm -rf -- 'doc/FcStrBasename.3' +rm -rf -- 'doc/FcStrCmp.3' +rm -rf -- 'doc/FcStrCmpIgnoreCase.3' +rm -rf -- 'doc/FcStrCopy.3' +rm -rf -- 'doc/FcStrCopyFilename.3' +rm -rf -- 'doc/FcStrDirname.3' +rm -rf -- 'doc/FcStrDowncase.3' +rm -rf -- 'doc/FcStrFree.3' +rm -rf -- 'doc/FcStrListCreate.3' +rm -rf -- 'doc/FcStrListDone.3' +rm -rf -- 'doc/FcStrListFirst.3' +rm -rf -- 'doc/FcStrListNext.3' +rm -rf -- 'doc/FcStrPlus.3' +rm -rf -- 'doc/FcStrSetAdd.3' +rm -rf -- 'doc/FcStrSetAddFilename.3' +rm -rf -- 'doc/FcStrSetCreate.3' +rm -rf -- 'doc/FcStrSetDel.3' +rm -rf -- 'doc/FcStrSetDestroy.3' +rm -rf -- 'doc/FcStrSetEqual.3' +rm -rf -- 'doc/FcStrSetMember.3' +rm -rf -- 'doc/FcStrStr.3' +rm -rf -- 'doc/FcStrStrIgnoreCase.3' +rm -rf -- 'doc/FcToLower.3' +rm -rf -- 'doc/FcUcs4ToUtf8.3' +rm -rf -- 'doc/FcUtf16Len.3' +rm -rf -- 'doc/FcUtf16ToUcs4.3' +rm -rf -- 'doc/FcUtf8Len.3' +rm -rf -- 'doc/FcUtf8ToUcs4.3' +rm -rf -- 'doc/FcValueDestroy.3' +rm -rf -- 'doc/FcValueEqual.3' +rm -rf -- 'doc/FcValuePrint.3' +rm -rf -- 'doc/FcValueSave.3' +rm -rf -- 'doc/FcWeightFromOpenType.3' +rm -rf -- 'doc/FcWeightToOpenType.3' +rm -rf -- 'doc/fontconfig-devel.pdf' +rm -rf -- 'doc/fontconfig-devel.txt' +rm -rf -- 'doc/fontconfig-user.html' +rm -rf -- 'doc/fontconfig-user.pdf' +rm -rf -- 'doc/fontconfig-user.txt' +rm -rf -- 'doc/fonts-conf.5' +rm -rf -- 'fontconfig.spec' +rm -rf -- 'src/fcstdint.h' diff --git a/ports/libfreetype/libfreetype.patch b/ports/libfreetype/libfreetype.patch new file mode 100644 index 00000000..64de5e74 --- /dev/null +++ b/ports/libfreetype/libfreetype.patch @@ -0,0 +1,312 @@ +diff -Paur --no-dereference -- libfreetype.upstream/builds/unix/configure libfreetype/builds/unix/configure +--- libfreetype.upstream/builds/unix/configure ++++ libfreetype/builds/unix/configure +@@ -13690,22 +13690,7 @@ + libpng_libspriv="$LIBPNG_LIBS" + libpng_libsstaticconf="$LIBPNG_LIBS" + have_libpng="yes (LIBPNG_CFLAGS and LIBPNG_LIBS)" +- else +- # fall back to config script. +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpng-config" >&5 +-$as_echo_n "checking for libpng-config... " >&6; } +- if which libpng-config > /dev/null 2>&1; then +- LIBPNG_CFLAGS=`libpng-config --cflags` +- LIBPNG_LIBS=`libpng-config --ldflags` +- libpng_libspriv=`libpng-config --static --ldflags` +- libpng_libsstaticconf="$libpng_libspriv" +- have_libpng="yes (libpng-config)" +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +-$as_echo "yes" >&6; } +- else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +- fi ++ # PATCH: libpng-config should never be used. + fi + fi + fi +diff -Paur --no-dereference -- libfreetype.upstream/builds/unix/freetype2.in libfreetype/builds/unix/freetype2.in +--- libfreetype.upstream/builds/unix/freetype2.in ++++ libfreetype/builds/unix/freetype2.in +@@ -4,7 +4,7 @@ + includedir=%includedir% + + Name: FreeType 2 +-URL: http://freetype.org ++URL: https://freetype.org + Description: A free, high-quality, and portable font engine. + Version: %ft_version% + Requires: +diff -Paur --no-dereference -- libfreetype.upstream/builds/unix/install.mk libfreetype/builds/unix/install.mk +--- libfreetype.upstream/builds/unix/install.mk ++++ libfreetype/builds/unix/install.mk +@@ -30,15 +30,14 @@ + # + # We also remove `$(includedir)/ft2build.h' for the same reason. + # ++# PATCH: freetype-config should never be used. + install: $(PROJECT_LIBRARY) + -$(DELDIR) $(DESTDIR)$(includedir)/freetype2 + -$(DELETE) $(DESTDIR)$(includedir)/ft2build.h + $(MKINSTALLDIRS) $(DESTDIR)$(libdir) \ + $(DESTDIR)$(libdir)/pkgconfig \ + $(DESTDIR)$(includedir)/freetype2/freetype/config \ +- $(DESTDIR)$(bindir) \ +- $(DESTDIR)$(datadir)/aclocal \ +- $(DESTDIR)$(mandir)/man1 ++ $(DESTDIR)$(datadir)/aclocal + $(LIBTOOL) --mode=install $(INSTALL) \ + $(PROJECT_LIBRARY) $(DESTDIR)$(libdir) + -for P in $(PUBLIC_H) ; do \ +@@ -55,23 +54,17 @@ + $(DESTDIR)$(includedir)/freetype2/freetype/config/ftconfig.h + $(INSTALL_DATA) $(OBJ_DIR)/ftmodule.h \ + $(DESTDIR)$(includedir)/freetype2/freetype/config/ftmodule.h +- $(INSTALL_SCRIPT) -m 755 $(OBJ_BUILD)/freetype-config \ +- $(DESTDIR)$(bindir)/freetype-config + $(INSTALL_SCRIPT) -m 644 $(BUILD_DIR)/freetype2.m4 \ + $(DESTDIR)$(datadir)/aclocal/freetype2.m4 + $(INSTALL_SCRIPT) -m 644 $(OBJ_BUILD)/freetype2.pc \ + $(DESTDIR)$(libdir)/pkgconfig/freetype2.pc +- $(INSTALL_DATA) $(TOP_DIR)/docs/freetype-config.1 \ +- $(DESTDIR)$(mandir)/man1/freetype-config.1 + + + uninstall: + -$(LIBTOOL) --mode=uninstall $(RM) $(DESTDIR)$(libdir)/$(LIBRARY).$A + -$(DELDIR) $(DESTDIR)$(includedir)/freetype2 +- -$(DELETE) $(DESTDIR)$(bindir)/freetype-config + -$(DELETE) $(DESTDIR)$(datadir)/aclocal/freetype2.m4 + -$(DELETE) $(DESTDIR)$(libdir)/pkgconfig/freetype2.pc +- -$(DELETE) $(DESTDIR)$(mandir)/man1/freetype-config.1 + + + check: +diff -Paur --no-dereference -- libfreetype.upstream/src/autofit/afhints.c libfreetype/src/autofit/afhints.c +--- libfreetype.upstream/src/autofit/afhints.c ++++ libfreetype/src/autofit/afhints.c +@@ -16,6 +16,8 @@ + /***************************************************************************/ + + ++/* PATCH: Make snprintf available. */ ++#define _ISOC99_SOURCE + #include "afhints.h" + #include "aferrors.h" + #include FT_INTERNAL_CALC_H +@@ -223,6 +225,7 @@ + + static char* + af_print_idx( char* p, ++ size_t len, + int idx ) + { + if ( idx == -1 ) +@@ -232,7 +235,7 @@ + p[2] = '\0'; + } + else +- ft_sprintf( p, "%d", idx ); ++ snprintf( p, len, "%d", idx ); + + return p; + } +@@ -338,12 +341,12 @@ + AF_DUMP(( " %5d %5s %5s %5s %5s %s" + " %5d %5d %7.2f %7.2f %7.2f %7.2f\n", + point_idx, +- af_print_idx( buf1, ++ af_print_idx( buf1, sizeof(buf1), + af_get_edge_index( hints, segment_idx_1, 1 ) ), +- af_print_idx( buf2, segment_idx_1 ), +- af_print_idx( buf3, ++ af_print_idx( buf2, sizeof(buf2), segment_idx_1 ), ++ af_print_idx( buf3, sizeof(buf3), + af_get_edge_index( hints, segment_idx_0, 0 ) ), +- af_print_idx( buf4, segment_idx_0 ), ++ af_print_idx( buf4, sizeof(buf4), segment_idx_0 ), + ( point->flags & AF_FLAG_NEAR ) + ? " near " + : ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) +diff -Paur --no-dereference -- libfreetype.upstream/src/bdf/bdflib.c libfreetype/src/bdf/bdflib.c +--- libfreetype.upstream/src/bdf/bdflib.c ++++ libfreetype/src/bdf/bdflib.c +@@ -31,6 +31,8 @@ + /*************************************************************************/ + + ++/* PATCH: Make snprintf available. */ ++#define _ISOC99_SOURCE + #include + + #include FT_FREETYPE_H +@@ -1822,7 +1824,7 @@ + if ( bdf_get_font_property( p->font, "FONT_ASCENT" ) == 0 ) + { + p->font->font_ascent = p->font->bbx.ascent; +- ft_sprintf( nbuf, "%hd", p->font->bbx.ascent ); ++ snprintf( nbuf, sizeof ( nbuf ), "%hd", p->font->bbx.ascent ); + error = _bdf_add_property( p->font, (char *)"FONT_ASCENT", + nbuf, lineno ); + if ( error ) +@@ -1835,7 +1837,7 @@ + if ( bdf_get_font_property( p->font, "FONT_DESCENT" ) == 0 ) + { + p->font->font_descent = p->font->bbx.descent; +- ft_sprintf( nbuf, "%hd", p->font->bbx.descent ); ++ snprintf( nbuf, sizeof ( nbuf ), "%hd", p->font->bbx.descent ); + error = _bdf_add_property( p->font, (char *)"FONT_DESCENT", + nbuf, lineno ); + if ( error ) +@@ -2164,7 +2166,7 @@ + /* Add the two standard X11 properties which are required */ + /* for compiling fonts. */ + p->font->font_ascent = p->font->bbx.ascent; +- ft_sprintf( nbuf, "%hd", p->font->bbx.ascent ); ++ snprintf( nbuf, sizeof ( nbuf ), "%hd", p->font->bbx.ascent ); + error = _bdf_add_property( p->font, (char *)"FONT_ASCENT", + nbuf, lineno ); + if ( error ) +@@ -2172,7 +2174,7 @@ + FT_TRACE2(( "_bdf_parse_properties: " ACMSG1, p->font->bbx.ascent )); + + p->font->font_descent = p->font->bbx.descent; +- ft_sprintf( nbuf, "%hd", p->font->bbx.descent ); ++ snprintf( nbuf, sizeof ( nbuf ), "%hd", p->font->bbx.descent ); + error = _bdf_add_property( p->font, (char *)"FONT_DESCENT", + nbuf, lineno ); + if ( error ) +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/adler32.c libfreetype/src/gzip/adler32.c +--- libfreetype.upstream/src/gzip/adler32.c ++++ libfreetype/src/gzip/adler32.c +@@ -1,3 +1,4 @@ ++#error no + /* adler32.c -- compute the Adler-32 checksum of a data stream + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/ftzconf.h libfreetype/src/gzip/ftzconf.h +--- libfreetype.upstream/src/gzip/ftzconf.h ++++ libfreetype/src/gzip/ftzconf.h +@@ -1,3 +1,4 @@ ++#error no + /* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/infblock.c libfreetype/src/gzip/infblock.c +--- libfreetype.upstream/src/gzip/infblock.c ++++ libfreetype/src/gzip/infblock.c +@@ -1,3 +1,4 @@ ++#error no + /* infblock.c -- interpret and process block types to last block + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/infblock.h libfreetype/src/gzip/infblock.h +--- libfreetype.upstream/src/gzip/infblock.h ++++ libfreetype/src/gzip/infblock.h +@@ -1,3 +1,4 @@ ++#error no + /* infblock.h -- header to use infblock.c + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/infcodes.c libfreetype/src/gzip/infcodes.c +--- libfreetype.upstream/src/gzip/infcodes.c ++++ libfreetype/src/gzip/infcodes.c +@@ -1,3 +1,4 @@ ++#error no + /* infcodes.c -- process literals and length/distance pairs + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/infcodes.h libfreetype/src/gzip/infcodes.h +--- libfreetype.upstream/src/gzip/infcodes.h ++++ libfreetype/src/gzip/infcodes.h +@@ -1,3 +1,4 @@ ++#error no + /* infcodes.h -- header to use infcodes.c + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/inffixed.h libfreetype/src/gzip/inffixed.h +--- libfreetype.upstream/src/gzip/inffixed.h ++++ libfreetype/src/gzip/inffixed.h +@@ -1,3 +1,4 @@ ++#error no + /* inffixed.h -- table for decoding fixed codes + * Generated automatically by the maketree.c program + */ +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/inflate.c libfreetype/src/gzip/inflate.c +--- libfreetype.upstream/src/gzip/inflate.c ++++ libfreetype/src/gzip/inflate.c +@@ -1,3 +1,4 @@ ++#error no + /* inflate.c -- zlib interface to inflate modules + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/inftrees.c libfreetype/src/gzip/inftrees.c +--- libfreetype.upstream/src/gzip/inftrees.c ++++ libfreetype/src/gzip/inftrees.c +@@ -1,3 +1,4 @@ ++#error no + /* inftrees.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/inftrees.h libfreetype/src/gzip/inftrees.h +--- libfreetype.upstream/src/gzip/inftrees.h ++++ libfreetype/src/gzip/inftrees.h +@@ -1,3 +1,4 @@ ++#error no + /* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/infutil.c libfreetype/src/gzip/infutil.c +--- libfreetype.upstream/src/gzip/infutil.c ++++ libfreetype/src/gzip/infutil.c +@@ -1,3 +1,4 @@ ++#error no + /* inflate_util.c -- data and routines common to blocks and codes + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/infutil.h libfreetype/src/gzip/infutil.h +--- libfreetype.upstream/src/gzip/infutil.h ++++ libfreetype/src/gzip/infutil.h +@@ -1,3 +1,4 @@ ++#error no + /* infutil.h -- types and macros common to blocks and codes + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/zlib.h libfreetype/src/gzip/zlib.h +--- libfreetype.upstream/src/gzip/zlib.h ++++ libfreetype/src/gzip/zlib.h +@@ -1,3 +1,4 @@ ++#error no + /* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.4, March 11th, 2002 + +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/zutil.c libfreetype/src/gzip/zutil.c +--- libfreetype.upstream/src/gzip/zutil.c ++++ libfreetype/src/gzip/zutil.c +@@ -1,3 +1,4 @@ ++#error no + /* zutil.c -- target dependent utility functions for the compression library + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/gzip/zutil.h libfreetype/src/gzip/zutil.h +--- libfreetype.upstream/src/gzip/zutil.h ++++ libfreetype/src/gzip/zutil.h +@@ -1,3 +1,4 @@ ++#error no + /* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h +diff -Paur --no-dereference -- libfreetype.upstream/src/sfnt/ttload.c libfreetype/src/sfnt/ttload.c +--- libfreetype.upstream/src/sfnt/ttload.c ++++ libfreetype/src/sfnt/ttload.c +@@ -338,7 +338,9 @@ + SFNT_HeaderRec sfnt; + FT_Error error; + FT_Memory memory = stream->memory; +- FT_UShort nn, valid_entries; ++ /* PATCH: warning: `valid_entries' may be used uninitialized in this ++ function [-Wmaybe-uninitialized] */ ++ FT_UShort nn, valid_entries = 0; + + static const FT_Frame_Field offset_table_fields[] = + { diff --git a/ports/libfreetype/libfreetype.port b/ports/libfreetype/libfreetype.port new file mode 100644 index 00000000..6dc5d11c --- /dev/null +++ b/ports/libfreetype/libfreetype.port @@ -0,0 +1,12 @@ +NAME=libfreetype +BUILD_LIBRARIES='libz bzip2? libpng?' +VERSION=2.8.1 +DISTNAME=freetype-$VERSION +COMPRESSION=tar.bz2 +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=e5435f02e02d2b87bb8e4efdcaa14b1f78c9cf3ab1ed80f94b6382fb6acc7d78 +UPSTREAM_SITE=https://download.savannah.gnu.org/releases/freetype +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +DIRTY_FILE=config.log +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libfreetype/libfreetype.rmpatch b/ports/libfreetype/libfreetype.rmpatch new file mode 100644 index 00000000..7d00ad63 --- /dev/null +++ b/ports/libfreetype/libfreetype.rmpatch @@ -0,0 +1,48 @@ +rm -rf -- 'docs/reference/' +rm -rf -- 'docs/reference/README' +rm -rf -- 'docs/reference/ft2-auto_hinter.html' +rm -rf -- 'docs/reference/ft2-base_interface.html' +rm -rf -- 'docs/reference/ft2-basic_types.html' +rm -rf -- 'docs/reference/ft2-bdf_fonts.html' +rm -rf -- 'docs/reference/ft2-bitmap_handling.html' +rm -rf -- 'docs/reference/ft2-bzip2.html' +rm -rf -- 'docs/reference/ft2-cache_subsystem.html' +rm -rf -- 'docs/reference/ft2-cff_driver.html' +rm -rf -- 'docs/reference/ft2-cid_fonts.html' +rm -rf -- 'docs/reference/ft2-computations.html' +rm -rf -- 'docs/reference/ft2-error_code_values.html' +rm -rf -- 'docs/reference/ft2-error_enumerations.html' +rm -rf -- 'docs/reference/ft2-font_formats.html' +rm -rf -- 'docs/reference/ft2-gasp_table.html' +rm -rf -- 'docs/reference/ft2-glyph_management.html' +rm -rf -- 'docs/reference/ft2-glyph_stroker.html' +rm -rf -- 'docs/reference/ft2-glyph_variants.html' +rm -rf -- 'docs/reference/ft2-gx_validation.html' +rm -rf -- 'docs/reference/ft2-gzip.html' +rm -rf -- 'docs/reference/ft2-header_file_macros.html' +rm -rf -- 'docs/reference/ft2-header_inclusion.html' +rm -rf -- 'docs/reference/ft2-incremental.html' +rm -rf -- 'docs/reference/ft2-index.html' +rm -rf -- 'docs/reference/ft2-lcd_filtering.html' +rm -rf -- 'docs/reference/ft2-list_processing.html' +rm -rf -- 'docs/reference/ft2-lzw.html' +rm -rf -- 'docs/reference/ft2-mac_specific.html' +rm -rf -- 'docs/reference/ft2-module_management.html' +rm -rf -- 'docs/reference/ft2-multiple_masters.html' +rm -rf -- 'docs/reference/ft2-ot_validation.html' +rm -rf -- 'docs/reference/ft2-outline_processing.html' +rm -rf -- 'docs/reference/ft2-pcf_driver.html' +rm -rf -- 'docs/reference/ft2-pfr_fonts.html' +rm -rf -- 'docs/reference/ft2-quick_advance.html' +rm -rf -- 'docs/reference/ft2-raster.html' +rm -rf -- 'docs/reference/ft2-sfnt_names.html' +rm -rf -- 'docs/reference/ft2-sizes_management.html' +rm -rf -- 'docs/reference/ft2-system_interface.html' +rm -rf -- 'docs/reference/ft2-toc.html' +rm -rf -- 'docs/reference/ft2-truetype_engine.html' +rm -rf -- 'docs/reference/ft2-truetype_tables.html' +rm -rf -- 'docs/reference/ft2-tt_driver.html' +rm -rf -- 'docs/reference/ft2-type1_tables.html' +rm -rf -- 'docs/reference/ft2-user_allocation.html' +rm -rf -- 'docs/reference/ft2-version.html' +rm -rf -- 'docs/reference/ft2-winfnt_fonts.html' diff --git a/ports/libglib/libglib.patch b/ports/libglib/libglib.patch new file mode 100644 index 00000000..35dcc7f3 --- /dev/null +++ b/ports/libglib/libglib.patch @@ -0,0 +1,407 @@ +diff -Paur --no-dereference -- libglib.upstream/config.sub libglib/config.sub +--- libglib.upstream/config.sub ++++ libglib/config.sub +@@ -1373,7 +1373,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libglib.upstream/configure libglib/configure +--- libglib.upstream/configure ++++ libglib/configure +@@ -22140,8 +22140,9 @@ + fi + + else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 +-$as_echo "none" >&6; } ++ glib_cv_long_long_format=ll ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ll" >&5 ++$as_echo "ll" >&6; } + fi + + elif test x$ac_cv_sizeof___int64 = x8; then : +@@ -22244,6 +22245,7 @@ + fi + + ++# TODO: Remove this check and remove G_HAVE_GROWING_STACK from public API. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for growing stack pointer" >&5 + $as_echo_n "checking for growing stack pointer... " >&6; } + if ${glib_cv_stack_grows+:} false; then : +@@ -22251,10 +22253,7 @@ + else + + if test "$cross_compiling" = yes; then : +- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error $? "cannot run test program while cross compiling +-See \`config.log' for more details" "$LINENO" 5; } ++ glib_cv_stack_grows=irrevant + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -24149,7 +24148,10 @@ + $as_echo "yes" >&6; } + NAMESER_COMPAT_INCLUDE="#include " + else +- as_fn_error $? "could not compile test program either way" "$LINENO" 5 ++ # PATCH: Sortix doesn't have and probably won't by design, so ++ # don't error out here but just report absence. ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } + fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi +@@ -24223,7 +24225,10 @@ + $as_echo "in -lbind" >&6; } + NETWORK_LIBS="-lbind $NETWORK_LIBS" + else +- as_fn_error $? "not found" "$LINENO" 5 ++ # PATCH: Sortix doesn't have at this time. ++ #as_fn_error $? "not found" "$LINENO" 5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } + fi + rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +@@ -24481,7 +24486,7 @@ + $as_echo_n "(cached) " >&6 + else + if test "$cross_compiling" = yes; then : +- ac_cv_func_vsnprintf_c99=no ++ ac_cv_func_vsnprintf_c99=yes + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -24546,7 +24551,7 @@ + $as_echo_n "(cached) " >&6 + else + if test "$cross_compiling" = yes; then : +- ac_cv_func_printf_unix98=no ++ ac_cv_func_printf_unix98=yes + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -24938,7 +24943,7 @@ + $as_echo_n "(cached) " >&6 + else + if test "$cross_compiling" = yes; then : +- ac_cv_func_snprintf_c99=no ++ ac_cv_func_snprintf_c99=yes + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -25249,6 +25254,7 @@ + + + # Check for strlcpy ++# TODO: The runtime check is to detect an ancient solaris bug so remove it. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenBSD strlcpy/strlcat" >&5 + $as_echo_n "checking for OpenBSD strlcpy/strlcat... " >&6; } + if ${glib_cv_have_strlcpy+:} false; then : +@@ -25256,7 +25262,7 @@ + else + + if test "$cross_compiling" = yes; then : +- glib_cv_have_strlcpy=no ++ glib_cv_have_strlcpy=yes + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -25620,10 +25626,7 @@ + else + + if test "$cross_compiling" = yes; then : +- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error $? "cannot run test program while cross compiling +-See \`config.log' for more details" "$LINENO" 5; } ++ glib_cv_uscore=no + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -26980,10 +26983,7 @@ + $as_echo_n "(cached) " >&6 + else + if test "$cross_compiling" = yes; then : +- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error $? "cannot run test program while cross compiling +-See \`config.log' for more details" "$LINENO" 5; } ++ ac_cv_func_posix_getpwuid_r=yes + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -27071,10 +27071,7 @@ + $as_echo_n "(cached) " >&6 + else + if test "$cross_compiling" = yes; then : +- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error $? "cannot run test program while cross compiling +-See \`config.log' for more details" "$LINENO" 5; } ++ ac_cv_func_posix_getgrgid_r=yes + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +diff -Paur --no-dereference -- libglib.upstream/gio/gdbusmessage.c libglib/gio/gdbusmessage.c +--- libglib.upstream/gio/gdbusmessage.c ++++ libglib/gio/gdbusmessage.c +@@ -3474,18 +3474,28 @@ + fs = g_string_new (NULL); + if (fstat (fds[n], &statbuf) == 0) + { ++#if defined(__sortix__) ++ g_string_append_printf (fs, "%s" "dev=%" PRIuDEV, fs->len > 0 ? "," : "", ++ statbuf.st_dev); ++#else + g_string_append_printf (fs, "%s" "dev=%d:%d", fs->len > 0 ? "," : "", + major (statbuf.st_dev), minor (statbuf.st_dev)); ++#endif + g_string_append_printf (fs, "%s" "mode=0%o", fs->len > 0 ? "," : "", + statbuf.st_mode); + g_string_append_printf (fs, "%s" "ino=%" G_GUINT64_FORMAT, fs->len > 0 ? "," : "", + (guint64) statbuf.st_ino); +- g_string_append_printf (fs, "%s" "uid=%u", fs->len > 0 ? "," : "", +- (guint) statbuf.st_uid); +- g_string_append_printf (fs, "%s" "gid=%u", fs->len > 0 ? "," : "", +- (guint) statbuf.st_gid); ++ g_string_append_printf (fs, "%s" "uid=%" G_GUINT64_FORMAT, fs->len > 0 ? "," : "", ++ (guint64) statbuf.st_uid); ++ g_string_append_printf (fs, "%s" "gid=%" G_GUINT64_FORMAT, fs->len > 0 ? "," : "", ++ (guint64) statbuf.st_gid); ++#if defined(__sortix__) ++ g_string_append_printf (fs, "%s" "rdev=%" PRIuDEV, fs->len > 0 ? "," : "", ++ statbuf.st_rdev); ++#else + g_string_append_printf (fs, "%s" "rdev=%d:%d", fs->len > 0 ? "," : "", + major (statbuf.st_rdev), minor (statbuf.st_rdev)); ++#endif + g_string_append_printf (fs, "%s" "size=%" G_GUINT64_FORMAT, fs->len > 0 ? "," : "", + (guint64) statbuf.st_size); + g_string_append_printf (fs, "%s" "atime=%" G_GUINT64_FORMAT, fs->len > 0 ? "," : "", +diff -Paur --no-dereference -- libglib.upstream/gio/ginetsocketaddress.c libglib/gio/ginetsocketaddress.c +--- libglib.upstream/gio/ginetsocketaddress.c ++++ libglib/gio/ginetsocketaddress.c +@@ -197,10 +197,10 @@ + return FALSE; + } + ++ memset (&sock, 0, sizeof(sock)); + sock->sin_family = AF_INET; + sock->sin_port = g_htons (addr->priv->port); + memcpy (&(sock->sin_addr.s_addr), g_inet_address_to_bytes (addr->priv->address), sizeof (sock->sin_addr)); +- memset (sock->sin_zero, 0, sizeof (sock->sin_zero)); + return TRUE; + } + else if (family == AF_INET6) +diff -Paur --no-dereference -- libglib.upstream/gio/gnetworking.h.in libglib/gio/gnetworking.h.in +--- libglib.upstream/gio/gnetworking.h.in ++++ libglib/gio/gnetworking.h.in +@@ -41,13 +41,19 @@ + #include + #include + #include ++#if __has_include() + #include ++#endif + #include + #include ++#if __has_include() + #include ++#endif + + #include ++#if __has_include() + #include ++#endif + @NAMESER_COMPAT_INCLUDE@ + + #ifndef T_SRV +diff -Paur --no-dereference -- libglib.upstream/gio/gresolver.c libglib/gio/gresolver.c +--- libglib.upstream/gio/gresolver.c ++++ libglib/gio/gresolver.c +@@ -323,8 +323,12 @@ + * address, so if inet_aton() succeeds, then it's an address we want + * to reject. + */ ++#if defined(__sortix__) ++ if ((void) addr, (void) ip4addr, 0) ++#else + if (inet_aton (hostname, &ip4addr)) + #endif ++#endif + { + g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND, + _("Error resolving '%s': %s"), +diff -Paur --no-dereference -- libglib.upstream/gio/gsocket.c libglib/gio/gsocket.c +--- libglib.upstream/gio/gsocket.c ++++ libglib/gio/gsocket.c +@@ -69,6 +69,39 @@ + #include "gwin32networking.h" + #endif + ++#if defined(__sortix__) ++#ifndef IP_TTL ++#define IP_TTL (-1) ++#endif ++#ifndef IP_MULTICAST_LOOP ++#define IP_MULTICAST_LOOP (-1) ++#endif ++#ifndef IP_MULTICAST_TTL ++#define IP_MULTICAST_TTL (-1) ++#endif ++#if !defined(IP_ADD_MEMBERSHIP) && !defined(IP_DROP_MEMBERSHIP) && !defined(HAVE_IP_MREQN) ++struct ip_mreq ++{ ++ struct in_addr imr_multiaddr; ++ struct in_addr imr_interface; ++}; ++#endif ++#ifndef IP_ADD_MEMBERSHIP ++#define IP_ADD_MEMBERSHIP (-1) ++#endif ++#ifndef IP_DROP_MEMBERSHIP ++#define IP_DROP_MEMBERSHIP (-1) ++#endif ++#ifndef SO_NREAD ++#define SO_NREAD (-1) ++#endif ++#ifndef CMSG_DATA ++#define CMSG_DATA(x) ((unsigned char*) x) ++#define CMSG_FIRSTHDR(x) ((struct cmsghdr *) NULL) ++#define CMSG_NXTHDR(x, y) ((struct cmsghdr *) NULL) ++#endif ++#endif ++ + /** + * SECTION:gsocket + * @short_description: Low-level socket object +@@ -319,7 +352,7 @@ + { + struct sockaddr_storage address; + gint fd; +- guint addrlen; ++ socklen_t addrlen; + int value, family; + int errsv; + +@@ -1713,7 +1746,7 @@ + GError **error) + { + struct sockaddr_storage buffer; +- guint len = sizeof (buffer); ++ socklen_t len = sizeof (buffer); + + g_return_val_if_fail (G_IS_SOCKET (socket), NULL); + +@@ -1746,7 +1779,7 @@ + GError **error) + { + struct sockaddr_storage buffer; +- guint len = sizeof (buffer); ++ socklen_t len = sizeof (buffer); + + g_return_val_if_fail (G_IS_SOCKET (socket), NULL); + +@@ -4866,7 +4899,7 @@ + gint *value, + GError **error) + { +- guint size; ++ socklen_t size; + + g_return_val_if_fail (G_IS_SOCKET (socket), FALSE); + +@@ -4891,7 +4924,7 @@ + /* If the returned value is smaller than an int then we need to + * slide it over into the low-order bytes of *value. + */ +- if (size != sizeof (gint)) ++ if (size < sizeof (gint)) + *value = *value >> (8 * (sizeof (gint) - size)); + #endif + +diff -Paur --no-dereference -- libglib.upstream/gio/gthreadedresolver.c libglib/gio/gthreadedresolver.c +--- libglib.upstream/gio/gthreadedresolver.c ++++ libglib/gio/gthreadedresolver.c +@@ -22,6 +22,7 @@ + #include + #include "glibintl.h" + ++#include + #include + #include + +@@ -263,7 +264,15 @@ + + #if defined(G_OS_UNIX) + +-#ifdef __BIONIC__ ++#if defined(__BIONIC__) || defined(__sortix__) ++#if defined(__sortix__) ++static int h_errno; ++typedef unsigned char u_char; ++#define HOST_NOT_FOUND 1 ++#define NO_DATA 2 ++#define TRY_AGAIN 3 ++#define res_query(a, b, c, d, e) ((void) (a), (void) (b), (void) (c), (void) (d), (void) (e), -1) ++#endif + /* Copy from bionic/libc/private/arpa_nameser_compat.h + * and bionic/libc/private/arpa_nameser.h */ + typedef struct { +diff -Paur --no-dereference -- libglib.upstream/gio/gunixmounts.c libglib/gio/gunixmounts.c +--- libglib.upstream/gio/gunixmounts.c ++++ libglib/gio/gunixmounts.c +@@ -713,6 +713,20 @@ + return return_list; + } + ++#elif defined(__sortix__) ++ ++static char * ++get_mtab_monitor_file (void) ++{ ++ return NULL; ++} ++ ++static GList * ++_g_get_unix_mounts (void) ++{ ++ return NULL; ++} ++ + /* Common code {{{2 */ + #else + #error No _g_get_unix_mounts() implementation for system +@@ -1118,6 +1132,14 @@ + return _g_get_unix_mounts (); + } + ++#elif defined(__sortix__) ++ ++static GList * ++_g_get_unix_mount_points (void) ++{ ++ return NULL; ++} ++ + /* Common code {{{2 */ + #else + #error No g_get_mount_table() implementation for system +diff -Paur --no-dereference -- libglib.upstream/Makefile.in libglib/Makefile.in +--- libglib.upstream/Makefile.in ++++ libglib/Makefile.in +@@ -1726,6 +1726,7 @@ + distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile ++ -find . -name '*.pyc' -delete + distclean-am: clean-am distclean-generic distclean-hdr \ + distclean-libtool distclean-local distclean-tags + diff --git a/ports/libglib/libglib.port b/ports/libglib/libglib.port new file mode 100644 index 00000000..810fcd3a --- /dev/null +++ b/ports/libglib/libglib.port @@ -0,0 +1,13 @@ +NAME=libglib +BUILD_LIBRARIES='libiconv gettext libz libffi xz? libdbus?' +VERSION=2.45.6 +DISTNAME=glib-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=a5710fcf8a073201ceca188c285af14d8da4bb2bbec22bdf6b5e0593d5bc6b77 +UPSTREAM_SITE=https://download.gnome.org/sources/glib/2.45 +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS=--disable-gtk-doc +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libglib/libglib.rmpatch b/ports/libglib/libglib.rmpatch new file mode 100644 index 00000000..a903dd65 --- /dev/null +++ b/ports/libglib/libglib.rmpatch @@ -0,0 +1,585 @@ +rm -rf -- 'INSTALL' +rm -rf -- 'README' +rm -rf -- 'build/win32/vs11/README.txt' +rm -rf -- 'build/win32/vs11/gdbus.vcxproj' +rm -rf -- 'build/win32/vs11/gdbus.vcxproj.filters' +rm -rf -- 'build/win32/vs11/gio-querymodules.vcxproj' +rm -rf -- 'build/win32/vs11/gio-querymodules.vcxproj.filters' +rm -rf -- 'build/win32/vs11/gio.vcxproj' +rm -rf -- 'build/win32/vs11/gio.vcxproj.filters' +rm -rf -- 'build/win32/vs11/glib-build-defines.props' +rm -rf -- 'build/win32/vs11/glib-compile-resources.vcxproj' +rm -rf -- 'build/win32/vs11/glib-compile-resources.vcxproj.filters' +rm -rf -- 'build/win32/vs11/glib-compile-schemas.vcxproj' +rm -rf -- 'build/win32/vs11/glib-compile-schemas.vcxproj.filters' +rm -rf -- 'build/win32/vs11/glib-gen-srcs.props' +rm -rf -- 'build/win32/vs11/glib-genmarshal.vcxproj' +rm -rf -- 'build/win32/vs11/glib-genmarshal.vcxproj.filters' +rm -rf -- 'build/win32/vs11/glib-install.props' +rm -rf -- 'build/win32/vs11/glib-install.vcxproj' +rm -rf -- 'build/win32/vs11/glib-version-paths.props' +rm -rf -- 'build/win32/vs11/glib.sln' +rm -rf -- 'build/win32/vs11/glib.vcxproj' +rm -rf -- 'build/win32/vs11/glib.vcxproj.filters' +rm -rf -- 'build/win32/vs11/gmodule.vcxproj' +rm -rf -- 'build/win32/vs11/gmodule.vcxproj.filters' +rm -rf -- 'build/win32/vs11/gobject.vcxproj' +rm -rf -- 'build/win32/vs11/gobject.vcxproj.filters' +rm -rf -- 'build/win32/vs11/gresource.vcxproj' +rm -rf -- 'build/win32/vs11/gresource.vcxproj.filters' +rm -rf -- 'build/win32/vs11/gsettings.vcxproj' +rm -rf -- 'build/win32/vs11/gsettings.vcxproj.filters' +rm -rf -- 'build/win32/vs11/gspawn-win32-helper-console.vcxproj' +rm -rf -- 'build/win32/vs11/gspawn-win32-helper-console.vcxproj.filters' +rm -rf -- 'build/win32/vs11/gspawn-win32-helper.vcxproj' +rm -rf -- 'build/win32/vs11/gspawn-win32-helper.vcxproj.filters' +rm -rf -- 'build/win32/vs11/gthread.vcxproj' +rm -rf -- 'build/win32/vs11/gthread.vcxproj.filters' +rm -rf -- 'build/win32/vs12/README.txt' +rm -rf -- 'build/win32/vs12/gdbus.vcxproj' +rm -rf -- 'build/win32/vs12/gdbus.vcxproj.filters' +rm -rf -- 'build/win32/vs12/gio-querymodules.vcxproj' +rm -rf -- 'build/win32/vs12/gio-querymodules.vcxproj.filters' +rm -rf -- 'build/win32/vs12/gio.vcxproj' +rm -rf -- 'build/win32/vs12/gio.vcxproj.filters' +rm -rf -- 'build/win32/vs12/glib-build-defines.props' +rm -rf -- 'build/win32/vs12/glib-compile-resources.vcxproj' +rm -rf -- 'build/win32/vs12/glib-compile-resources.vcxproj.filters' +rm -rf -- 'build/win32/vs12/glib-compile-schemas.vcxproj' +rm -rf -- 'build/win32/vs12/glib-compile-schemas.vcxproj.filters' +rm -rf -- 'build/win32/vs12/glib-gen-srcs.props' +rm -rf -- 'build/win32/vs12/glib-genmarshal.vcxproj' +rm -rf -- 'build/win32/vs12/glib-genmarshal.vcxproj.filters' +rm -rf -- 'build/win32/vs12/glib-install.props' +rm -rf -- 'build/win32/vs12/glib-install.vcxproj' +rm -rf -- 'build/win32/vs12/glib-version-paths.props' +rm -rf -- 'build/win32/vs12/glib.sln' +rm -rf -- 'build/win32/vs12/glib.vcxproj' +rm -rf -- 'build/win32/vs12/glib.vcxproj.filters' +rm -rf -- 'build/win32/vs12/gmodule.vcxproj' +rm -rf -- 'build/win32/vs12/gmodule.vcxproj.filters' +rm -rf -- 'build/win32/vs12/gobject.vcxproj' +rm -rf -- 'build/win32/vs12/gobject.vcxproj.filters' +rm -rf -- 'build/win32/vs12/gresource.vcxproj' +rm -rf -- 'build/win32/vs12/gresource.vcxproj.filters' +rm -rf -- 'build/win32/vs12/gsettings.vcxproj' +rm -rf -- 'build/win32/vs12/gsettings.vcxproj.filters' +rm -rf -- 'build/win32/vs12/gspawn-win32-helper-console.vcxproj' +rm -rf -- 'build/win32/vs12/gspawn-win32-helper-console.vcxproj.filters' +rm -rf -- 'build/win32/vs12/gspawn-win32-helper.vcxproj' +rm -rf -- 'build/win32/vs12/gspawn-win32-helper.vcxproj.filters' +rm -rf -- 'build/win32/vs12/gthread.vcxproj' +rm -rf -- 'build/win32/vs12/gthread.vcxproj.filters' +rm -rf -- 'config.h.win32' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/ExampleAnimal.html' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/ExampleCat.html' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/ExampleObject.html' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/ExampleObjectManagerClient.html' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/ch01.html' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/gdbus-object-manager-example.devhelp2' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/home.png' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/index.html' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/index.sgml' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/left-insensitive.png' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/left.png' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/pt01.html' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/right-insensitive.png' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/right.png' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/style.css' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/up-insensitive.png' +rm -rf -- 'docs/reference/gio/gdbus-object-manager-example/html/up.png' +rm -rf -- 'docs/reference/gio/html/' +rm -rf -- 'docs/reference/gio/html/ExampleAnimal.html' +rm -rf -- 'docs/reference/gio/html/ExampleCat.html' +rm -rf -- 'docs/reference/gio/html/ExampleObject.html' +rm -rf -- 'docs/reference/gio/html/ExampleObjectManagerClient.html' +rm -rf -- 'docs/reference/gio/html/GAction.html' +rm -rf -- 'docs/reference/gio/html/GActionGroup.html' +rm -rf -- 'docs/reference/gio/html/GActionMap.html' +rm -rf -- 'docs/reference/gio/html/GAppInfo.html' +rm -rf -- 'docs/reference/gio/html/GAppInfoMonitor.html' +rm -rf -- 'docs/reference/gio/html/GApplication.html' +rm -rf -- 'docs/reference/gio/html/GApplicationCommandLine.html' +rm -rf -- 'docs/reference/gio/html/GAsyncInitable.html' +rm -rf -- 'docs/reference/gio/html/GAsyncResult.html' +rm -rf -- 'docs/reference/gio/html/GBufferedInputStream.html' +rm -rf -- 'docs/reference/gio/html/GBufferedOutputStream.html' +rm -rf -- 'docs/reference/gio/html/GBytesIcon.html' +rm -rf -- 'docs/reference/gio/html/GCancellable.html' +rm -rf -- 'docs/reference/gio/html/GCharsetConverter.html' +rm -rf -- 'docs/reference/gio/html/GConverter.html' +rm -rf -- 'docs/reference/gio/html/GCredentials.html' +rm -rf -- 'docs/reference/gio/html/GDBusActionGroup.html' +rm -rf -- 'docs/reference/gio/html/GDBusAuthObserver.html' +rm -rf -- 'docs/reference/gio/html/GDBusConnection.html' +rm -rf -- 'docs/reference/gio/html/GDBusInterface.html' +rm -rf -- 'docs/reference/gio/html/GDBusInterfaceSkeleton.html' +rm -rf -- 'docs/reference/gio/html/GDBusMenuModel.html' +rm -rf -- 'docs/reference/gio/html/GDBusMessage.html' +rm -rf -- 'docs/reference/gio/html/GDBusMethodInvocation.html' +rm -rf -- 'docs/reference/gio/html/GDBusObject.html' +rm -rf -- 'docs/reference/gio/html/GDBusObjectManager.html' +rm -rf -- 'docs/reference/gio/html/GDBusObjectManagerClient.html' +rm -rf -- 'docs/reference/gio/html/GDBusObjectManagerServer.html' +rm -rf -- 'docs/reference/gio/html/GDBusObjectProxy.html' +rm -rf -- 'docs/reference/gio/html/GDBusObjectSkeleton.html' +rm -rf -- 'docs/reference/gio/html/GDBusProxy.html' +rm -rf -- 'docs/reference/gio/html/GDBusServer.html' +rm -rf -- 'docs/reference/gio/html/GDataInputStream.html' +rm -rf -- 'docs/reference/gio/html/GDataOutputStream.html' +rm -rf -- 'docs/reference/gio/html/GDrive.html' +rm -rf -- 'docs/reference/gio/html/GEmblem.html' +rm -rf -- 'docs/reference/gio/html/GEmblemedIcon.html' +rm -rf -- 'docs/reference/gio/html/GFile.html' +rm -rf -- 'docs/reference/gio/html/GFileDescriptorBased.html' +rm -rf -- 'docs/reference/gio/html/GFileEnumerator.html' +rm -rf -- 'docs/reference/gio/html/GFileIOStream.html' +rm -rf -- 'docs/reference/gio/html/GFileIcon.html' +rm -rf -- 'docs/reference/gio/html/GFileInfo.html' +rm -rf -- 'docs/reference/gio/html/GFileInputStream.html' +rm -rf -- 'docs/reference/gio/html/GFileMonitor.html' +rm -rf -- 'docs/reference/gio/html/GFileOutputStream.html' +rm -rf -- 'docs/reference/gio/html/GFilenameCompleter.html' +rm -rf -- 'docs/reference/gio/html/GFilterInputStream.html' +rm -rf -- 'docs/reference/gio/html/GFilterOutputStream.html' +rm -rf -- 'docs/reference/gio/html/GIOModule.html' +rm -rf -- 'docs/reference/gio/html/GIOStream.html' +rm -rf -- 'docs/reference/gio/html/GIcon.html' +rm -rf -- 'docs/reference/gio/html/GInetAddress.html' +rm -rf -- 'docs/reference/gio/html/GInetAddressMask.html' +rm -rf -- 'docs/reference/gio/html/GInetSocketAddress.html' +rm -rf -- 'docs/reference/gio/html/GInitable.html' +rm -rf -- 'docs/reference/gio/html/GInputStream.html' +rm -rf -- 'docs/reference/gio/html/GListModel.html' +rm -rf -- 'docs/reference/gio/html/GListStore.html' +rm -rf -- 'docs/reference/gio/html/GLoadableIcon.html' +rm -rf -- 'docs/reference/gio/html/GMemoryInputStream.html' +rm -rf -- 'docs/reference/gio/html/GMemoryOutputStream.html' +rm -rf -- 'docs/reference/gio/html/GMenu.html' +rm -rf -- 'docs/reference/gio/html/GMenuModel.html' +rm -rf -- 'docs/reference/gio/html/GMount.html' +rm -rf -- 'docs/reference/gio/html/GMountOperation.html' +rm -rf -- 'docs/reference/gio/html/GNetworkAddress.html' +rm -rf -- 'docs/reference/gio/html/GNetworkMonitor.html' +rm -rf -- 'docs/reference/gio/html/GNetworkService.html' +rm -rf -- 'docs/reference/gio/html/GNotification.html' +rm -rf -- 'docs/reference/gio/html/GOutputStream.html' +rm -rf -- 'docs/reference/gio/html/GPermission.html' +rm -rf -- 'docs/reference/gio/html/GPollableInputStream.html' +rm -rf -- 'docs/reference/gio/html/GPollableOutputStream.html' +rm -rf -- 'docs/reference/gio/html/GPropertyAction.html' +rm -rf -- 'docs/reference/gio/html/GProxy.html' +rm -rf -- 'docs/reference/gio/html/GProxyAddress.html' +rm -rf -- 'docs/reference/gio/html/GProxyResolver.html' +rm -rf -- 'docs/reference/gio/html/GRemoteActionGroup.html' +rm -rf -- 'docs/reference/gio/html/GResolver.html' +rm -rf -- 'docs/reference/gio/html/GResource.html' +rm -rf -- 'docs/reference/gio/html/GSeekable.html' +rm -rf -- 'docs/reference/gio/html/GSettings.html' +rm -rf -- 'docs/reference/gio/html/GSettingsBackend.html' +rm -rf -- 'docs/reference/gio/html/GSimpleAction.html' +rm -rf -- 'docs/reference/gio/html/GSimpleActionGroup.html' +rm -rf -- 'docs/reference/gio/html/GSimpleAsyncResult.html' +rm -rf -- 'docs/reference/gio/html/GSimpleIOStream.html' +rm -rf -- 'docs/reference/gio/html/GSimplePermission.html' +rm -rf -- 'docs/reference/gio/html/GSimpleProxyResolver.html' +rm -rf -- 'docs/reference/gio/html/GSocket.html' +rm -rf -- 'docs/reference/gio/html/GSocketAddress.html' +rm -rf -- 'docs/reference/gio/html/GSocketClient.html' +rm -rf -- 'docs/reference/gio/html/GSocketConnectable.html' +rm -rf -- 'docs/reference/gio/html/GSocketConnection.html' +rm -rf -- 'docs/reference/gio/html/GSocketControlMessage.html' +rm -rf -- 'docs/reference/gio/html/GSocketListener.html' +rm -rf -- 'docs/reference/gio/html/GSocketService.html' +rm -rf -- 'docs/reference/gio/html/GSrvTarget.html' +rm -rf -- 'docs/reference/gio/html/GSubprocess.html' +rm -rf -- 'docs/reference/gio/html/GSubprocessLauncher.html' +rm -rf -- 'docs/reference/gio/html/GTask.html' +rm -rf -- 'docs/reference/gio/html/GTcpConnection.html' +rm -rf -- 'docs/reference/gio/html/GTcpWrapperConnection.html' +rm -rf -- 'docs/reference/gio/html/GTestDBus.html' +rm -rf -- 'docs/reference/gio/html/GThemedIcon.html' +rm -rf -- 'docs/reference/gio/html/GThreadedSocketService.html' +rm -rf -- 'docs/reference/gio/html/GTlsBackend.html' +rm -rf -- 'docs/reference/gio/html/GTlsCertificate.html' +rm -rf -- 'docs/reference/gio/html/GTlsClientConnection.html' +rm -rf -- 'docs/reference/gio/html/GTlsConnection.html' +rm -rf -- 'docs/reference/gio/html/GTlsDatabase.html' +rm -rf -- 'docs/reference/gio/html/GTlsFileDatabase.html' +rm -rf -- 'docs/reference/gio/html/GTlsInteraction.html' +rm -rf -- 'docs/reference/gio/html/GTlsPassword.html' +rm -rf -- 'docs/reference/gio/html/GTlsServerConnection.html' +rm -rf -- 'docs/reference/gio/html/GUnixConnection.html' +rm -rf -- 'docs/reference/gio/html/GUnixCredentialsMessage.html' +rm -rf -- 'docs/reference/gio/html/GUnixFDList.html' +rm -rf -- 'docs/reference/gio/html/GUnixFDMessage.html' +rm -rf -- 'docs/reference/gio/html/GUnixInputStream.html' +rm -rf -- 'docs/reference/gio/html/GUnixOutputStream.html' +rm -rf -- 'docs/reference/gio/html/GUnixSocketAddress.html' +rm -rf -- 'docs/reference/gio/html/GVfs.html' +rm -rf -- 'docs/reference/gio/html/GVolume.html' +rm -rf -- 'docs/reference/gio/html/GVolumeMonitor.html' +rm -rf -- 'docs/reference/gio/html/GZlibCompressor.html' +rm -rf -- 'docs/reference/gio/html/GZlibDecompressor.html' +rm -rf -- 'docs/reference/gio/html/annotation-glossary.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-18.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-20.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-22.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-24.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-26.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-28.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-30.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-32.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-34.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-36.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-38.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-40.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-42.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-44.html' +rm -rf -- 'docs/reference/gio/html/api-index-2-46.html' +rm -rf -- 'docs/reference/gio/html/api-index-deprecated.html' +rm -rf -- 'docs/reference/gio/html/api-index-full.html' +rm -rf -- 'docs/reference/gio/html/application.html' +rm -rf -- 'docs/reference/gio/html/async.html' +rm -rf -- 'docs/reference/gio/html/ch01.html' +rm -rf -- 'docs/reference/gio/html/ch02.html' +rm -rf -- 'docs/reference/gio/html/ch03.html' +rm -rf -- 'docs/reference/gio/html/ch32.html' +rm -rf -- 'docs/reference/gio/html/ch33.html' +rm -rf -- 'docs/reference/gio/html/ch33s02.html' +rm -rf -- 'docs/reference/gio/html/ch33s03.html' +rm -rf -- 'docs/reference/gio/html/ch34.html' +rm -rf -- 'docs/reference/gio/html/ch34s02.html' +rm -rf -- 'docs/reference/gio/html/ch34s03.html' +rm -rf -- 'docs/reference/gio/html/ch34s04.html' +rm -rf -- 'docs/reference/gio/html/ch34s05.html' +rm -rf -- 'docs/reference/gio/html/ch34s06.html' +rm -rf -- 'docs/reference/gio/html/ch34s07.html' +rm -rf -- 'docs/reference/gio/html/ch35.html' +rm -rf -- 'docs/reference/gio/html/ch35s02.html' +rm -rf -- 'docs/reference/gio/html/ch35s03.html' +rm -rf -- 'docs/reference/gio/html/ch35s04.html' +rm -rf -- 'docs/reference/gio/html/ch35s05.html' +rm -rf -- 'docs/reference/gio/html/conversion.html' +rm -rf -- 'docs/reference/gio/html/data-models.html' +rm -rf -- 'docs/reference/gio/html/extending-gio.html' +rm -rf -- 'docs/reference/gio/html/extending.html' +rm -rf -- 'docs/reference/gio/html/failable_initialization.html' +rm -rf -- 'docs/reference/gio/html/file_mon.html' +rm -rf -- 'docs/reference/gio/html/file_ops.html' +rm -rf -- 'docs/reference/gio/html/gapplication-tool.html' +rm -rf -- 'docs/reference/gio/html/gdbus-codegen.html' +rm -rf -- 'docs/reference/gio/html/gdbus-convenience.html' +rm -rf -- 'docs/reference/gio/html/gdbus-lowlevel.html' +rm -rf -- 'docs/reference/gio/html/gdbus-org.gtk.GDBus.Example.ObjectManager.Animal.html' +rm -rf -- 'docs/reference/gio/html/gdbus-org.gtk.GDBus.Example.ObjectManager.Cat.html' +rm -rf -- 'docs/reference/gio/html/gdbus.html' +rm -rf -- 'docs/reference/gio/html/gio-D-Bus-Addresses.html' +rm -rf -- 'docs/reference/gio/html/gio-D-Bus-Introspection-Data.html' +rm -rf -- 'docs/reference/gio/html/gio-D-Bus-Utilities.html' +rm -rf -- 'docs/reference/gio/html/gio-Desktop-file-based-GAppInfo.html' +rm -rf -- 'docs/reference/gio/html/gio-Extension-Points.html' +rm -rf -- 'docs/reference/gio/html/gio-GActionGroup-exporter.html' +rm -rf -- 'docs/reference/gio/html/gio-GContentType.html' +rm -rf -- 'docs/reference/gio/html/gio-GConverterInputstream.html' +rm -rf -- 'docs/reference/gio/html/gio-GConverterOutputstream.html' +rm -rf -- 'docs/reference/gio/html/gio-GDBusError.html' +rm -rf -- 'docs/reference/gio/html/gio-GFileAttribute.html' +rm -rf -- 'docs/reference/gio/html/gio-GIOError.html' +rm -rf -- 'docs/reference/gio/html/gio-GIOScheduler.html' +rm -rf -- 'docs/reference/gio/html/gio-GMenuModel-exporter.html' +rm -rf -- 'docs/reference/gio/html/gio-GSettingsSchema-GSettingsSchemaSource.html' +rm -rf -- 'docs/reference/gio/html/gio-GWin32InputStream.html' +rm -rf -- 'docs/reference/gio/html/gio-GWin32OutputStream.html' +rm -rf -- 'docs/reference/gio/html/gio-GWin32RegistryKey.html' +rm -rf -- 'docs/reference/gio/html/gio-Owning-Bus-Names.html' +rm -rf -- 'docs/reference/gio/html/gio-TLS-Overview.html' +rm -rf -- 'docs/reference/gio/html/gio-Unix-Mounts.html' +rm -rf -- 'docs/reference/gio/html/gio-Watching-Bus-Names.html' +rm -rf -- 'docs/reference/gio/html/gio-gnetworking.h.html' +rm -rf -- 'docs/reference/gio/html/gio-gpollableutils.html' +rm -rf -- 'docs/reference/gio/html/gio-hierarchy.html' +rm -rf -- 'docs/reference/gio/html/gio-querymodules.html' +rm -rf -- 'docs/reference/gio/html/gio.devhelp2' +rm -rf -- 'docs/reference/gio/html/glib-compile-resources.html' +rm -rf -- 'docs/reference/gio/html/glib-compile-schemas.html' +rm -rf -- 'docs/reference/gio/html/gresource-tool.html' +rm -rf -- 'docs/reference/gio/html/gsettings-tool.html' +rm -rf -- 'docs/reference/gio/html/gvfs-overview.png' +rm -rf -- 'docs/reference/gio/html/highlevel-socket.html' +rm -rf -- 'docs/reference/gio/html/home.png' +rm -rf -- 'docs/reference/gio/html/icons.html' +rm -rf -- 'docs/reference/gio/html/index.html' +rm -rf -- 'docs/reference/gio/html/index.sgml' +rm -rf -- 'docs/reference/gio/html/left-insensitive.png' +rm -rf -- 'docs/reference/gio/html/left.png' +rm -rf -- 'docs/reference/gio/html/menu-example.png' +rm -rf -- 'docs/reference/gio/html/menu-model.png' +rm -rf -- 'docs/reference/gio/html/migrating.html' +rm -rf -- 'docs/reference/gio/html/networking.html' +rm -rf -- 'docs/reference/gio/html/permissions.html' +rm -rf -- 'docs/reference/gio/html/pt01.html' +rm -rf -- 'docs/reference/gio/html/pt02.html' +rm -rf -- 'docs/reference/gio/html/registry.html' +rm -rf -- 'docs/reference/gio/html/resolver.html' +rm -rf -- 'docs/reference/gio/html/resources.html' +rm -rf -- 'docs/reference/gio/html/right-insensitive.png' +rm -rf -- 'docs/reference/gio/html/right.png' +rm -rf -- 'docs/reference/gio/html/running-gio-apps.html' +rm -rf -- 'docs/reference/gio/html/settings.html' +rm -rf -- 'docs/reference/gio/html/streaming.html' +rm -rf -- 'docs/reference/gio/html/style.css' +rm -rf -- 'docs/reference/gio/html/subprocesses.html' +rm -rf -- 'docs/reference/gio/html/testing.html' +rm -rf -- 'docs/reference/gio/html/tls.html' +rm -rf -- 'docs/reference/gio/html/tools.html' +rm -rf -- 'docs/reference/gio/html/types.html' +rm -rf -- 'docs/reference/gio/html/up-insensitive.png' +rm -rf -- 'docs/reference/gio/html/up.png' +rm -rf -- 'docs/reference/gio/html/utils.html' +rm -rf -- 'docs/reference/gio/html/volume_mon.html' +rm -rf -- 'docs/reference/gio/version.xml' +rm -rf -- 'docs/reference/glib/html/' +rm -rf -- 'docs/reference/glib/html/Sorted_binary_tree_breadth-first_traversal.svg' +rm -rf -- 'docs/reference/glib/html/Sorted_binary_tree_inorder.svg' +rm -rf -- 'docs/reference/glib/html/Sorted_binary_tree_postorder.svg' +rm -rf -- 'docs/reference/glib/html/Sorted_binary_tree_preorder.svg' +rm -rf -- 'docs/reference/glib/html/annotation-glossary.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-10.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-12.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-14.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-16.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-18.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-2.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-20.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-22.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-24.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-26.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-28.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-30.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-32.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-34.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-36.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-38.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-4.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-40.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-42.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-44.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-6.html' +rm -rf -- 'docs/reference/glib/html/api-index-2-8.html' +rm -rf -- 'docs/reference/glib/html/api-index-deprecated.html' +rm -rf -- 'docs/reference/glib/html/api-index-full.html' +rm -rf -- 'docs/reference/glib/html/deprecated.html' +rm -rf -- 'docs/reference/glib/html/file-name-encodings.png' +rm -rf -- 'docs/reference/glib/html/glib-Arrays.html' +rm -rf -- 'docs/reference/glib/html/glib-Asynchronous-Queues.html' +rm -rf -- 'docs/reference/glib/html/glib-Atomic-Operations.html' +rm -rf -- 'docs/reference/glib/html/glib-Automatic-String-Completion.html' +rm -rf -- 'docs/reference/glib/html/glib-Balanced-Binary-Trees.html' +rm -rf -- 'docs/reference/glib/html/glib-Base64-Encoding.html' +rm -rf -- 'docs/reference/glib/html/glib-Basic-Types.html' +rm -rf -- 'docs/reference/glib/html/glib-Bookmark-file-parser.html' +rm -rf -- 'docs/reference/glib/html/glib-Byte-Arrays.html' +rm -rf -- 'docs/reference/glib/html/glib-Byte-Order-Macros.html' +rm -rf -- 'docs/reference/glib/html/glib-Caches.html' +rm -rf -- 'docs/reference/glib/html/glib-Character-Set-Conversion.html' +rm -rf -- 'docs/reference/glib/html/glib-Commandline-option-parser.html' +rm -rf -- 'docs/reference/glib/html/glib-Data-Checksums.html' +rm -rf -- 'docs/reference/glib/html/glib-Data-HMACs.html' +rm -rf -- 'docs/reference/glib/html/glib-Datasets.html' +rm -rf -- 'docs/reference/glib/html/glib-Date-and-Time-Functions.html' +rm -rf -- 'docs/reference/glib/html/glib-Deprecated-Thread-APIs.html' +rm -rf -- 'docs/reference/glib/html/glib-Double-ended-Queues.html' +rm -rf -- 'docs/reference/glib/html/glib-Doubly-Linked-Lists.html' +rm -rf -- 'docs/reference/glib/html/glib-Dynamic-Loading-of-Modules.html' +rm -rf -- 'docs/reference/glib/html/glib-Error-Reporting.html' +rm -rf -- 'docs/reference/glib/html/glib-File-Utilities.html' +rm -rf -- 'docs/reference/glib/html/glib-GDateTime.html' +rm -rf -- 'docs/reference/glib/html/glib-GTimeZone.html' +rm -rf -- 'docs/reference/glib/html/glib-GVariant.html' +rm -rf -- 'docs/reference/glib/html/glib-GVariantType.html' +rm -rf -- 'docs/reference/glib/html/glib-Glob-style-pattern-matching.html' +rm -rf -- 'docs/reference/glib/html/glib-Hash-Tables.html' +rm -rf -- 'docs/reference/glib/html/glib-Hook-Functions.html' +rm -rf -- 'docs/reference/glib/html/glib-Hostname-Utilities.html' +rm -rf -- 'docs/reference/glib/html/glib-I18N.html' +rm -rf -- 'docs/reference/glib/html/glib-IO-Channels.html' +rm -rf -- 'docs/reference/glib/html/glib-Key-value-file-parser.html' +rm -rf -- 'docs/reference/glib/html/glib-Keyed-Data-Lists.html' +rm -rf -- 'docs/reference/glib/html/glib-Lexical-Scanner.html' +rm -rf -- 'docs/reference/glib/html/glib-Memory-Allocation.html' +rm -rf -- 'docs/reference/glib/html/glib-Memory-Slices.html' +rm -rf -- 'docs/reference/glib/html/glib-Message-Logging.html' +rm -rf -- 'docs/reference/glib/html/glib-Miscellaneous-Macros.html' +rm -rf -- 'docs/reference/glib/html/glib-Miscellaneous-Utility-Functions.html' +rm -rf -- 'docs/reference/glib/html/glib-N-ary-Trees.html' +rm -rf -- 'docs/reference/glib/html/glib-Numerical-Definitions.html' +rm -rf -- 'docs/reference/glib/html/glib-Perl-compatible-regular-expressions.html' +rm -rf -- 'docs/reference/glib/html/glib-Pointer-Arrays.html' +rm -rf -- 'docs/reference/glib/html/glib-Quarks.html' +rm -rf -- 'docs/reference/glib/html/glib-Random-Numbers.html' +rm -rf -- 'docs/reference/glib/html/glib-Relations-and-Tuples.html' +rm -rf -- 'docs/reference/glib/html/glib-Sequences.html' +rm -rf -- 'docs/reference/glib/html/glib-Shell-related-Utilities.html' +rm -rf -- 'docs/reference/glib/html/glib-Simple-XML-Subset-Parser.html' +rm -rf -- 'docs/reference/glib/html/glib-Singly-Linked-Lists.html' +rm -rf -- 'docs/reference/glib/html/glib-Spawning-Processes.html' +rm -rf -- 'docs/reference/glib/html/glib-Standard-Macros.html' +rm -rf -- 'docs/reference/glib/html/glib-String-Chunks.html' +rm -rf -- 'docs/reference/glib/html/glib-String-Utility-Functions.html' +rm -rf -- 'docs/reference/glib/html/glib-Strings.html' +rm -rf -- 'docs/reference/glib/html/glib-Testing.html' +rm -rf -- 'docs/reference/glib/html/glib-The-Main-Event-Loop.html' +rm -rf -- 'docs/reference/glib/html/glib-Thread-Pools.html' +rm -rf -- 'docs/reference/glib/html/glib-Threads.html' +rm -rf -- 'docs/reference/glib/html/glib-Timers.html' +rm -rf -- 'docs/reference/glib/html/glib-Trash-Stacks.html' +rm -rf -- 'docs/reference/glib/html/glib-Type-Conversion-Macros.html' +rm -rf -- 'docs/reference/glib/html/glib-UNIX-specific-utilities-and-integration.html' +rm -rf -- 'docs/reference/glib/html/glib-URI-Functions.html' +rm -rf -- 'docs/reference/glib/html/glib-Unicode-Manipulation.html' +rm -rf -- 'docs/reference/glib/html/glib-Version-Information.html' +rm -rf -- 'docs/reference/glib/html/glib-Warnings-and-Assertions.html' +rm -rf -- 'docs/reference/glib/html/glib-Windows-Compatibility-Functions.html' +rm -rf -- 'docs/reference/glib/html/glib-building.html' +rm -rf -- 'docs/reference/glib/html/glib-changes.html' +rm -rf -- 'docs/reference/glib/html/glib-compiling.html' +rm -rf -- 'docs/reference/glib/html/glib-core.html' +rm -rf -- 'docs/reference/glib/html/glib-cross-compiling.html' +rm -rf -- 'docs/reference/glib/html/glib-data-types.html' +rm -rf -- 'docs/reference/glib/html/glib-fundamentals.html' +rm -rf -- 'docs/reference/glib/html/glib-gettextize.html' +rm -rf -- 'docs/reference/glib/html/glib-programming.html' +rm -rf -- 'docs/reference/glib/html/glib-regex-syntax.html' +rm -rf -- 'docs/reference/glib/html/glib-resources.html' +rm -rf -- 'docs/reference/glib/html/glib-running.html' +rm -rf -- 'docs/reference/glib/html/glib-utilities.html' +rm -rf -- 'docs/reference/glib/html/glib.devhelp2' +rm -rf -- 'docs/reference/glib/html/glib.html' +rm -rf -- 'docs/reference/glib/html/gtester-report.html' +rm -rf -- 'docs/reference/glib/html/gtester.html' +rm -rf -- 'docs/reference/glib/html/gvariant-format-strings.html' +rm -rf -- 'docs/reference/glib/html/gvariant-text.html' +rm -rf -- 'docs/reference/glib/html/home.png' +rm -rf -- 'docs/reference/glib/html/index.html' +rm -rf -- 'docs/reference/glib/html/index.sgml' +rm -rf -- 'docs/reference/glib/html/left-insensitive.png' +rm -rf -- 'docs/reference/glib/html/left.png' +rm -rf -- 'docs/reference/glib/html/mainloop-states.gif' +rm -rf -- 'docs/reference/glib/html/right-insensitive.png' +rm -rf -- 'docs/reference/glib/html/right.png' +rm -rf -- 'docs/reference/glib/html/style.css' +rm -rf -- 'docs/reference/glib/html/tools.html' +rm -rf -- 'docs/reference/glib/html/up-insensitive.png' +rm -rf -- 'docs/reference/glib/html/up.png' +rm -rf -- 'docs/reference/glib/version.xml' +rm -rf -- 'docs/reference/gobject/html/' +rm -rf -- 'docs/reference/gobject/html/GBinding.html' +rm -rf -- 'docs/reference/gobject/html/GTypeModule.html' +rm -rf -- 'docs/reference/gobject/html/GTypePlugin.html' +rm -rf -- 'docs/reference/gobject/html/annotation-glossary.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-10.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-12.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-14.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-18.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-2.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-22.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-24.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-26.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-28.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-30.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-32.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-34.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-36.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-38.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-4.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-40.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-42.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-44.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-6.html' +rm -rf -- 'docs/reference/gobject/html/api-index-2-8.html' +rm -rf -- 'docs/reference/gobject/html/api-index-deprecated.html' +rm -rf -- 'docs/reference/gobject/html/api-index-full.html' +rm -rf -- 'docs/reference/gobject/html/ch01s02.html' +rm -rf -- 'docs/reference/gobject/html/chapter-gobject.html' +rm -rf -- 'docs/reference/gobject/html/chapter-gtype.html' +rm -rf -- 'docs/reference/gobject/html/chapter-intro.html' +rm -rf -- 'docs/reference/gobject/html/chapter-signal.html' +rm -rf -- 'docs/reference/gobject/html/glib-genmarshal.html' +rm -rf -- 'docs/reference/gobject/html/glib-mkenums.html' +rm -rf -- 'docs/reference/gobject/html/glue.png' +rm -rf -- 'docs/reference/gobject/html/gobject-Boxed-Types.html' +rm -rf -- 'docs/reference/gobject/html/gobject-Closures.html' +rm -rf -- 'docs/reference/gobject/html/gobject-Enumeration-and-Flag-Types.html' +rm -rf -- 'docs/reference/gobject/html/gobject-GParamSpec.html' +rm -rf -- 'docs/reference/gobject/html/gobject-Generic-values.html' +rm -rf -- 'docs/reference/gobject/html/gobject-Signals.html' +rm -rf -- 'docs/reference/gobject/html/gobject-Standard-Parameter-and-Value-Types.html' +rm -rf -- 'docs/reference/gobject/html/gobject-The-Base-Object-Type.html' +rm -rf -- 'docs/reference/gobject/html/gobject-Type-Information.html' +rm -rf -- 'docs/reference/gobject/html/gobject-Value-arrays.html' +rm -rf -- 'docs/reference/gobject/html/gobject-Varargs-Value-Collection.html' +rm -rf -- 'docs/reference/gobject/html/gobject-memory.html' +rm -rf -- 'docs/reference/gobject/html/gobject-properties.html' +rm -rf -- 'docs/reference/gobject/html/gobject-query.html' +rm -rf -- 'docs/reference/gobject/html/gobject.devhelp2' +rm -rf -- 'docs/reference/gobject/html/gtype-conventions.html' +rm -rf -- 'docs/reference/gobject/html/gtype-instantiable-classed.html' +rm -rf -- 'docs/reference/gobject/html/gtype-non-instantiable-classed.html' +rm -rf -- 'docs/reference/gobject/html/gtype-non-instantiable.html' +rm -rf -- 'docs/reference/gobject/html/home.png' +rm -rf -- 'docs/reference/gobject/html/howto-gobject-chainup.html' +rm -rf -- 'docs/reference/gobject/html/howto-gobject-code.html' +rm -rf -- 'docs/reference/gobject/html/howto-gobject-construction.html' +rm -rf -- 'docs/reference/gobject/html/howto-gobject-destruction.html' +rm -rf -- 'docs/reference/gobject/html/howto-gobject-methods.html' +rm -rf -- 'docs/reference/gobject/html/howto-gobject.html' +rm -rf -- 'docs/reference/gobject/html/howto-interface-implement.html' +rm -rf -- 'docs/reference/gobject/html/howto-interface-override.html' +rm -rf -- 'docs/reference/gobject/html/howto-interface-prerequisite.html' +rm -rf -- 'docs/reference/gobject/html/howto-interface-properties.html' +rm -rf -- 'docs/reference/gobject/html/howto-interface.html' +rm -rf -- 'docs/reference/gobject/html/howto-signals.html' +rm -rf -- 'docs/reference/gobject/html/index.html' +rm -rf -- 'docs/reference/gobject/html/index.sgml' +rm -rf -- 'docs/reference/gobject/html/left-insensitive.png' +rm -rf -- 'docs/reference/gobject/html/left.png' +rm -rf -- 'docs/reference/gobject/html/pr01.html' +rm -rf -- 'docs/reference/gobject/html/pt01.html' +rm -rf -- 'docs/reference/gobject/html/pt02.html' +rm -rf -- 'docs/reference/gobject/html/pt03.html' +rm -rf -- 'docs/reference/gobject/html/right-insensitive.png' +rm -rf -- 'docs/reference/gobject/html/right.png' +rm -rf -- 'docs/reference/gobject/html/rn01.html' +rm -rf -- 'docs/reference/gobject/html/rn02.html' +rm -rf -- 'docs/reference/gobject/html/signal.html' +rm -rf -- 'docs/reference/gobject/html/style.css' +rm -rf -- 'docs/reference/gobject/html/tools-ginspector.html' +rm -rf -- 'docs/reference/gobject/html/tools-gob.html' +rm -rf -- 'docs/reference/gobject/html/tools-gtkdoc.html' +rm -rf -- 'docs/reference/gobject/html/tools-refdb.html' +rm -rf -- 'docs/reference/gobject/html/tools-vala.html' +rm -rf -- 'docs/reference/gobject/html/up-insensitive.png' +rm -rf -- 'docs/reference/gobject/html/up.png' +rm -rf -- 'docs/reference/gobject/version.xml' +rm -rf -- 'gio/gconstructor_as_data.h' +rm -rf -- 'gio/gdbus-2.0/codegen/config.py' +rm -rf -- 'gio/gdbus-daemon-generated.c' +rm -rf -- 'gio/gdbus-daemon-generated.h' +rm -rf -- 'gio/gio.rc' +rm -rf -- 'gio/gioenumtypes.c' +rm -rf -- 'gio/gioenumtypes.h' +rm -rf -- 'gio/tests/plugin_resources.c' +rm -rf -- 'glib/glib.rc' +rm -rf -- 'glib/glibconfig.h.win32' +rm -rf -- 'glib/makefile.msc' +rm -rf -- 'gmodule/gmodule.rc' +rm -rf -- 'gmodule/makefile.msc' +rm -rf -- 'gobject/gobject.rc' +rm -rf -- 'gobject/makefile.msc' +rm -rf -- 'gthread/gthread.rc' +rm -rf -- 'gthread/makefile.msc' +rm -rf -- 'tests/gobject/testmarshal.c' +rm -rf -- 'tests/gobject/testmarshal.h' +rm -rf -- 'tests/makefile.msc' diff --git a/ports/libgmp/libgmp.patch b/ports/libgmp/libgmp.patch new file mode 100644 index 00000000..8809465d --- /dev/null +++ b/ports/libgmp/libgmp.patch @@ -0,0 +1,60 @@ +diff -Paur --no-dereference -- libgmp.upstream/configfsf.sub libgmp/configfsf.sub +--- libgmp.upstream/configfsf.sub ++++ libgmp/configfsf.sub +@@ -1356,7 +1356,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libgmp.upstream/configure libgmp/configure +--- libgmp.upstream/configure ++++ libgmp/configure +@@ -6224,6 +6224,8 @@ + 1666 to segfault with e.g., -O2 -mpowerpc64. */ + + #if defined (__GNUC__) && ! defined (__cplusplus) ++h(); ++g(); + typedef unsigned long long t1;typedef t1*t2; + static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0) + {t1 c,x,r;int i;if(v0){c=1;for(i=1;i defines EOF but not FILE. */ + #if defined (FILE) \ ++ || defined (stdout) \ + || defined (H_STDIO) \ + || defined (_H_STDIO) /* AIX */ \ + || defined (_STDIO_H) /* glibc, Sun, SCO */ \ diff --git a/ports/libgmp/libgmp.port b/ports/libgmp/libgmp.port new file mode 100644 index 00000000..824e9bd1 --- /dev/null +++ b/ports/libgmp/libgmp.port @@ -0,0 +1,14 @@ +NAME=libgmp +BUILD_LIBRARIES=libstdc++ +VERSION=6.0.0a +DISTNAME=gmp-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=9156d32edac6955bc53b0218f5f3763facb890b73a835d5e1b901dcf8eb8b764 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/gmp +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS=--enable-cxx +POST_INSTALL=tix-eradicate-libtool-la +# TODO: Remove after upgrading past 6.0.0a. +VERSION_REGEX='([0-9]+\.[0-9]+(\.[0-9]+)*a?)' diff --git a/ports/libiconv/libiconv.patch b/ports/libiconv/libiconv.patch new file mode 100644 index 00000000..eb2340e3 --- /dev/null +++ b/ports/libiconv/libiconv.patch @@ -0,0 +1,18 @@ +diff -Paur --no-dereference -- libiconv.upstream/src/Makefile.in libiconv/src/Makefile.in +--- libiconv.upstream/src/Makefile.in ++++ libiconv/src/Makefile.in +@@ -109,11 +109,13 @@ + # refers to a libiconv.so in $prefix/lib since then it sees two libiconv.so's, + # one in $prefix/lib and one in ../lib/.libs. So we have to avoid using + # ../lib/libiconv.la entirely. ++# PATCH: Linking with the installed .la file isn't cross-compilation safe as it ++# doesn't know about the sysroot and DESTDIR. + install : all force + if [ ! -d $(DESTDIR)$(bindir) ] ; then $(mkinstalldirs) $(DESTDIR)$(bindir) ; fi + case "@host_os@" in \ + hpux*) $(CC) $(LDFLAGS) $(CFLAGS) $(iconv_LDFLAGS) iconv.@OBJEXT@ ../srclib/libicrt.a -L$(DESTDIR)$(libdir) -liconv @LIBINTL@ $(OBJECTS_RES_@WOE32@) `if test -n '$(DESTDIR)'; then echo " -Wl,+b -Wl,$(libdir)"; fi` -o iconv$(EXEEXT);; \ +- *) $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(CFLAGS) $(iconv_LDFLAGS) iconv.@OBJEXT@ ../srclib/libicrt.a $(DESTDIR)$(libdir)/libiconv.la @LTLIBINTL@ $(OBJECTS_RES_@WOE32@) -o iconv$(EXEEXT);; \ ++ *) $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(CFLAGS) $(iconv_LDFLAGS) iconv.@OBJEXT@ ../srclib/libicrt.a ../lib/libiconv.la @LTLIBINTL@ $(OBJECTS_RES_@WOE32@) -o iconv$(EXEEXT);; \ + esac + $(INSTALL_PROGRAM_ENV) $(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) iconv$(EXEEXT) $(DESTDIR)$(bindir)/iconv$(EXEEXT) + diff --git a/ports/libiconv/libiconv.port b/ports/libiconv/libiconv.port new file mode 100644 index 00000000..8a96a412 --- /dev/null +++ b/ports/libiconv/libiconv.port @@ -0,0 +1,11 @@ +NAME=libiconv +BUILD_LIBRARIES= +VERSION=1.16 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/libiconv +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libidn/libidn.patch b/ports/libidn/libidn.patch new file mode 100644 index 00000000..425e472c --- /dev/null +++ b/ports/libidn/libidn.patch @@ -0,0 +1,169 @@ +diff -Paur --no-dereference -- libidn.upstream/build-aux/config.sub libidn/build-aux/config.sub +--- libidn.upstream/build-aux/config.sub ++++ libidn/build-aux/config.sub +@@ -1365,7 +1365,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libidn.upstream/configure libidn/configure +--- libidn.upstream/configure ++++ libidn/configure +@@ -1,4 +1,124 @@ + #! /bin/sh ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes # Not needed since February 2015 ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypotl_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. ++export ac_cv_func_realloc_0_nonnull=yes # TODO: Investigate this, found in flex. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for GNU Libidn 1.33. + # +diff -Paur --no-dereference -- libidn.upstream/doc/Makefile.in libidn/doc/Makefile.in +--- libidn.upstream/doc/Makefile.in ++++ libidn/doc/Makefile.in +@@ -1502,8 +1502,8 @@ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu doc/Makefile +-.PRECIOUS: Makefile +-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status ++.PRECIOUS: Makefile.disabled ++Makefile.disabled: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ +diff -Paur --no-dereference -- libidn.upstream/Makefile.in libidn/Makefile.in +--- libidn.upstream/Makefile.in ++++ libidn/Makefile.in +@@ -1662,6 +1662,11 @@ + distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile ++ -rm -f config.log ++ -rm -f config.status ++ -rm -rf gl/sys ++ -rm -rf lib/gl/sys ++ -rm -f doc/Makefile + distclean-am: clean-am distclean-generic distclean-hdr \ + distclean-libtool distclean-tags + diff --git a/ports/libidn/libidn.port b/ports/libidn/libidn.port new file mode 100644 index 00000000..1d3bca9e --- /dev/null +++ b/ports/libidn/libidn.port @@ -0,0 +1,13 @@ +NAME=libidn +BUILD_LIBRARIES='libiconv? gettext?' +VERSION=1.33 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=44a7aab635bb721ceef6beecc4d49dfd19478325e1b47f3196f7d2acc4930e19 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/libidn +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS= +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libidn/libidn.rmpatch b/ports/libidn/libidn.rmpatch new file mode 100644 index 00000000..b6b2d702 --- /dev/null +++ b/ports/libidn/libidn.rmpatch @@ -0,0 +1,27 @@ +rm -rf -- 'doc/Makefile.gdoc' +rm -rf -- 'doc/libidn.html' +rm -rf -- 'doc/libidn.pdf' +rm -rf -- 'doc/libidn.ps' +rm -rf -- 'doc/reference/html/' +rm -rf -- 'doc/reference/html/api-index-full.html' +rm -rf -- 'doc/reference/html/home.png' +rm -rf -- 'doc/reference/html/index.html' +rm -rf -- 'doc/reference/html/index.sgml' +rm -rf -- 'doc/reference/html/intro.html' +rm -rf -- 'doc/reference/html/left-insensitive.png' +rm -rf -- 'doc/reference/html/left.png' +rm -rf -- 'doc/reference/html/libidn-components.png' +rm -rf -- 'doc/reference/html/libidn-idn-free.html' +rm -rf -- 'doc/reference/html/libidn-idna.html' +rm -rf -- 'doc/reference/html/libidn-pr29.html' +rm -rf -- 'doc/reference/html/libidn-punycode.html' +rm -rf -- 'doc/reference/html/libidn-stringprep.html' +rm -rf -- 'doc/reference/html/libidn-tld.html' +rm -rf -- 'doc/reference/html/libidn.devhelp2' +rm -rf -- 'doc/reference/html/right-insensitive.png' +rm -rf -- 'doc/reference/html/right.png' +rm -rf -- 'doc/reference/html/style.css' +rm -rf -- 'doc/reference/html/up-insensitive.png' +rm -rf -- 'doc/reference/html/up.png' +rm -rf -- 'doc/reference/libidn.pdf' +rm -rf -- 'doc/stamp-vti' diff --git a/ports/libintl/libintl.port b/ports/libintl/libintl.port new file mode 100644 index 00000000..650c424c --- /dev/null +++ b/ports/libintl/libintl.port @@ -0,0 +1,9 @@ +NAME=libintl +SOURCE_PORT=gettext +SUBDIR=gettext-runtime +BUILD_SYSTEM=configure +# libstdc++ is a dependency if libasprintf is enabled. Right now, I suspect it +# is more trouble than it is worth, so it's disabled. Does anything of value +# actually use it? +CONFIGURE_ARGS=--disable-libasprintf +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libjpeg/libjpeg.port b/ports/libjpeg/libjpeg.port new file mode 100644 index 00000000..3ffe12c5 --- /dev/null +++ b/ports/libjpeg/libjpeg.port @@ -0,0 +1,17 @@ +NAME=libjpeg +BUILD_LIBRARIES= +VERSION=9e +DISTNAME=jpegsrc.v$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=4077d6a6a75aeb01884f708919d25934c93305e49f7e3f36db9129320e6f4f3d +UPSTREAM_SITE=https://ijg.org/files +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +# TODO: Curiously, the programs shipped with libjpeg have the target name prefixed. +CONFIGURE_ARGS='--program-prefix=' +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la +# TODO: The last letter is optional but sort -V before the first release. +VERSION_REGEX='([0-9]+[a-z])' +DISTNAME_REGEX=jpegsrc\.v$VERSION_REGEX diff --git a/ports/liblua/liblua.port b/ports/liblua/liblua.port new file mode 100644 index 00000000..ad1cf201 --- /dev/null +++ b/ports/liblua/liblua.port @@ -0,0 +1,5 @@ +NAME=liblua +SOURCE_PORT=lua +BUILD_SYSTEM=makefile +MAKE_BUILD_TARGET=lib +MAKE_INSTALL_TARGET=install-lib diff --git a/ports/libmpc/libmpc.patch b/ports/libmpc/libmpc.patch new file mode 100644 index 00000000..c7fb2e03 --- /dev/null +++ b/ports/libmpc/libmpc.patch @@ -0,0 +1,12 @@ +diff -Paur --no-dereference -- libmpc.upstream/config.sub libmpc/config.sub +--- libmpc.upstream/config.sub ++++ libmpc/config.sub +@@ -1373,7 +1373,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/ports/libmpc/libmpc.port b/ports/libmpc/libmpc.port new file mode 100644 index 00000000..82227227 --- /dev/null +++ b/ports/libmpc/libmpc.port @@ -0,0 +1,11 @@ +NAME=libmpc +BUILD_LIBRARIES='libgmp libmpfr' +VERSION=1.0.3 +DISTNAME=mpc-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=617decc6ea09889fb08ede330917a00b16809b8db88c29c31bfbb49cbf88ecc3 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/mpc +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libmpfr/libmpfr.patch b/ports/libmpfr/libmpfr.patch new file mode 100644 index 00000000..ec88fe37 --- /dev/null +++ b/ports/libmpfr/libmpfr.patch @@ -0,0 +1,12 @@ +diff -Paur --no-dereference -- libmpfr.upstream/config.sub libmpfr/config.sub +--- libmpfr.upstream/config.sub ++++ libmpfr/config.sub +@@ -1373,7 +1373,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/ports/libmpfr/libmpfr.port b/ports/libmpfr/libmpfr.port new file mode 100644 index 00000000..4e9dacdb --- /dev/null +++ b/ports/libmpfr/libmpfr.port @@ -0,0 +1,12 @@ +NAME=libmpfr +BUILD_LIBRARIES='libstdc++ libgmp' +VERSION=3.1.3 +DISTNAME=mpfr-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=6835a08bd992c8257641791e9a6a2b35b02336c8de26d0a8577953747e514a16 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/mpfr +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_USE_BUILD_DIRECTORY=true +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libogg/libogg.patch b/ports/libogg/libogg.patch new file mode 100644 index 00000000..415b8fbb --- /dev/null +++ b/ports/libogg/libogg.patch @@ -0,0 +1,33 @@ +diff -Paur --no-dereference -- libogg.upstream/config.sub libogg/config.sub +--- libogg.upstream/config.sub ++++ libogg/config.sub +@@ -1342,7 +1342,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libogg.upstream/include/ogg/config_types.h.in libogg/include/ogg/config_types.h.in +--- libogg.upstream/include/ogg/config_types.h.in ++++ libogg/include/ogg/config_types.h.in +@@ -1,6 +1,9 @@ + #ifndef __CONFIG_TYPES_H__ + #define __CONFIG_TYPES_H__ + ++#if defined(__sortix__) ++#include ++#else + /* these are filled in by configure */ + #define INCLUDE_INTTYPES_H @INCLUDE_INTTYPES_H@ + #define INCLUDE_STDINT_H @INCLUDE_STDINT_H@ +@@ -15,6 +18,7 @@ + #if INCLUDE_SYS_TYPES_H + # include + #endif ++#endif + + typedef @SIZE16@ ogg_int16_t; + typedef @USIZE16@ ogg_uint16_t; diff --git a/ports/libogg/libogg.port b/ports/libogg/libogg.port new file mode 100644 index 00000000..f4176078 --- /dev/null +++ b/ports/libogg/libogg.port @@ -0,0 +1,12 @@ +NAME=libogg +BUILD_LIBRARIES= +VERSION=1.3.1 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=3a5bad78d81afb78908326d11761c0fb1a0662ee7150b6ad587cc586838cdcfa +UPSTREAM_SITE=https://ftp.osuosl.org/pub/xiph/releases/ogg +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libogg/libogg.rmpatch b/ports/libogg/libogg.rmpatch new file mode 100644 index 00000000..4e4e0db7 --- /dev/null +++ b/ports/libogg/libogg.rmpatch @@ -0,0 +1 @@ +rm -rf -- 'libogg.spec' diff --git a/ports/libpcre/libpcre.patch b/ports/libpcre/libpcre.patch new file mode 100644 index 00000000..24aba0ce --- /dev/null +++ b/ports/libpcre/libpcre.patch @@ -0,0 +1,130 @@ +diff -Paur --no-dereference -- libpcre.upstream/config.sub libpcre/config.sub +--- libpcre.upstream/config.sub ++++ libpcre/config.sub +@@ -1373,7 +1373,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libpcre.upstream/Makefile.in libpcre/Makefile.in +--- libpcre.upstream/Makefile.in ++++ libpcre/Makefile.in +@@ -130,7 +130,7 @@ + @WITH_JIT_TRUE@@WITH_PCRE32_TRUE@am__append_17 = libpcre32.la + @WITH_GCOV_TRUE@@WITH_JIT_TRUE@am__append_18 = $(GCOV_CFLAGS) + @WITH_GCOV_TRUE@@WITH_JIT_TRUE@am__append_19 = $(GCOV_LIBS) +-@WITH_PCRE8_TRUE@am__append_20 = libpcreposix.la ++@WITH_PCRE8_TRUE@am__append_20 = + @WITH_GCOV_TRUE@@WITH_PCRE8_TRUE@am__append_21 = $(GCOV_CFLAGS) + @WITH_PCRE_CPP_TRUE@am__append_22 = libpcrecpp.la + @WITH_PCRE_CPP_TRUE@am__append_23 = pcrecpp_unittest \ +@@ -144,7 +144,7 @@ + @WITH_GCOV_TRUE@@WITH_PCRE_CPP_TRUE@am__append_27 = $(GCOV_LIBS) + @WITH_GCOV_TRUE@@WITH_PCRE_CPP_TRUE@am__append_28 = $(GCOV_LIBS) + @WITH_PCRE8_TRUE@am__append_29 = pcre_printint.c +-@WITH_PCRE8_TRUE@am__append_30 = libpcre.la libpcreposix.la ++@WITH_PCRE8_TRUE@am__append_30 = libpcre.la + @WITH_PCRE16_TRUE@am__append_31 = pcre16_printint.c + @WITH_PCRE16_TRUE@am__append_32 = libpcre16.la + @WITH_PCRE32_TRUE@am__append_33 = pcre32_printint.c +@@ -422,7 +422,7 @@ + @WITH_GCOV_TRUE@@WITH_PCRE8_TRUE@ $(am__DEPENDENCIES_1) + @WITH_PCRE8_TRUE@pcregrep_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + @WITH_PCRE8_TRUE@ $(am__DEPENDENCIES_1) libpcre.la \ +-@WITH_PCRE8_TRUE@ libpcreposix.la $(am__DEPENDENCIES_4) ++@WITH_PCRE8_TRUE@ $(am__DEPENDENCIES_4) + pcregrep_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(pcregrep_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +@@ -524,7 +524,7 @@ + MANS = $(dist_man_MANS) $(man_MANS) + DATA = $(dist_doc_DATA) $(dist_html_DATA) $(dist_noinst_DATA) \ + $(html_DATA) $(pkgconfig_DATA) +-am__include_HEADERS_DIST = pcreposix.h pcrecpp.h pcre_scanner.h ++am__include_HEADERS_DIST = pcrecpp.h pcre_scanner.h + HEADERS = $(include_HEADERS) $(nodist_include_HEADERS) + am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ + $(LISP)config.h.in +@@ -914,7 +914,6 @@ + ACLOCAL_AMFLAGS = -I m4 + dist_doc_DATA = \ + doc/pcre.txt \ +- doc/pcre-config.txt \ + doc/pcregrep.txt \ + doc/pcretest.txt \ + AUTHORS \ +@@ -930,7 +929,6 @@ + doc/html/NON-AUTOTOOLS-BUILD.txt \ + doc/html/README.txt \ + doc/html/index.html \ +- doc/html/pcre-config.html \ + doc/html/pcre.html \ + doc/html/pcre16.html \ + doc/html/pcre32.html \ +@@ -973,7 +971,6 @@ + doc/html/pcrepartial.html \ + doc/html/pcrepattern.html \ + doc/html/pcreperform.html \ +- doc/html/pcreposix.html \ + doc/html/pcreprecompile.html \ + doc/html/pcresample.html \ + doc/html/pcrestack.html \ +@@ -1080,8 +1077,8 @@ + # These are the header files we'll install. We do not distribute pcre.h because + # it is generated from pcre.h.in. + nodist_include_HEADERS = pcre.h $(am__append_1) +-include_HEADERS = pcreposix.h $(am__append_2) +-bin_SCRIPTS = pcre-config ++include_HEADERS = $(am__append_2) ++bin_SCRIPTS = + @WITH_REBUILD_CHARTABLES_TRUE@dftables_SOURCES = dftables.c + BUILT_SOURCES = pcre_chartables.c + @WITH_PCRE8_TRUE@libpcre_la_SOURCES = \ +@@ -1220,7 +1217,7 @@ + @WITH_PCRE8_TRUE@pcregrep_SOURCES = pcregrep.c + @WITH_PCRE8_TRUE@pcregrep_CFLAGS = $(AM_CFLAGS) $(am__append_41) + @WITH_PCRE8_TRUE@pcregrep_LDADD = $(LIBZ) $(LIBBZ2) libpcre.la \ +-@WITH_PCRE8_TRUE@ libpcreposix.la $(am__append_42) ++@WITH_PCRE8_TRUE@ $(am__append_42) + + # A PCRE user submitted the following addition, saying that it "will allow + # anyone using the 'mingw32' compiler to simply type 'make pcre.dll' and get a +@@ -1236,12 +1233,11 @@ + + # We have .pc files for pkg-config users. + pkgconfigdir = $(libdir)/pkgconfig +-pkgconfig_DATA = libpcre.pc libpcreposix.pc $(am__append_43) \ ++pkgconfig_DATA = libpcre.pc $(am__append_43) \ + $(am__append_44) $(am__append_45) + + # Note that pcrecpp.3 is not in this list, but is included separately below. + dist_man_MANS = \ +- doc/pcre-config.1 \ + doc/pcre.3 \ + doc/pcre16.3 \ + doc/pcre32.3 \ +@@ -1284,7 +1280,6 @@ + doc/pcrepartial.3 \ + doc/pcrepattern.3 \ + doc/pcreperform.3 \ +- doc/pcreposix.3 \ + doc/pcreprecompile.3 \ + doc/pcresample.3 \ + doc/pcrestack.3 \ +diff -Paur --no-dereference -- libpcre.upstream/pcretest.c libpcre/pcretest.c +--- libpcre.upstream/pcretest.c ++++ libpcre/pcretest.c +@@ -180,9 +180,7 @@ + #define PRINTOK(c) (locale_set? isprint(c) : PRINTABLE(c)) + + /* Posix support is disabled in 16 or 32 bit only mode. */ +-#if !defined SUPPORT_PCRE8 && !defined NOPOSIX + #define NOPOSIX +-#endif + + /* It is possible to compile this test program without including support for + testing the POSIX interface, though this is not available via the standard diff --git a/ports/libpcre/libpcre.port b/ports/libpcre/libpcre.port new file mode 100644 index 00000000..937b2eab --- /dev/null +++ b/ports/libpcre/libpcre.port @@ -0,0 +1,15 @@ +NAME=libpcre +BUILD_LIBRARIES='libstdc++ libz bzip2 libedit? libreadline?' +VERSION=8.39 +DISTNAME=pcre-$VERSION +COMPRESSION=tar.bz2 +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=b858099f82483031ee02092711689e7245586ada49e534a06e678b8ea9549e8b +UPSTREAM_SITE=https://sourceforge.net/projects/pcre/files/pcre/$VERSION +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS=--enable-utf +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la +RELEASE_SEARCH_PAGE=https://sourceforge.net/projects/pcre/files/pcre/ +RELEASE_SEARCH_REGEX='([0-9]+\.[0-9]+(\.[0-9]+)*)/' diff --git a/ports/libpixman/libpixman.patch b/ports/libpixman/libpixman.patch new file mode 100644 index 00000000..6cb36717 --- /dev/null +++ b/ports/libpixman/libpixman.patch @@ -0,0 +1,12 @@ +diff -Paur --no-dereference -- libpixman.upstream/config.sub libpixman/config.sub +--- libpixman.upstream/config.sub ++++ libpixman/config.sub +@@ -1264,7 +1264,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/ports/libpixman/libpixman.port b/ports/libpixman/libpixman.port new file mode 100644 index 00000000..a7c3460d --- /dev/null +++ b/ports/libpixman/libpixman.port @@ -0,0 +1,12 @@ +NAME=libpixman +BUILD_LIBRARIES='libpng?' +VERSION=0.28.2 +DISTNAME=pixman-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=2afac9006adbc3fba28830007d7a9521b118d516342478dfe7818ffe4aeb9b55 +UPSTREAM_SITE=https://www.cairographics.org/releases +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libpixman/libpixman.rmpatch b/ports/libpixman/libpixman.rmpatch new file mode 100644 index 00000000..772ae032 --- /dev/null +++ b/ports/libpixman/libpixman.rmpatch @@ -0,0 +1 @@ +rm -rf -- 'pixman/pixman-version.h' diff --git a/ports/libpng/libpng.patch b/ports/libpng/libpng.patch new file mode 100644 index 00000000..07e6ed1b --- /dev/null +++ b/ports/libpng/libpng.patch @@ -0,0 +1,35 @@ +diff -Paur --no-dereference -- libpng.upstream/config.sub libpng/config.sub +--- libpng.upstream/config.sub ++++ libpng/config.sub +@@ -1337,7 +1337,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libpng.upstream/libpng.pc.in libpng/libpng.pc.in +--- libpng.upstream/libpng.pc.in ++++ libpng/libpng.pc.in +@@ -6,6 +6,6 @@ + Name: libpng + Description: Loads and saves PNG files + Version: @PNGLIB_VERSION@ +-Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ ++Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ -lz -lm + Libs.private: @LIBS@ + Cflags: -I${includedir} +diff -Paur --no-dereference -- libpng.upstream/Makefile.in libpng/Makefile.in +--- libpng.upstream/Makefile.in ++++ libpng/Makefile.in +@@ -1428,8 +1428,6 @@ + + # do evil things to libpng to cause libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ to be used + install-exec-hook: +- cd $(DESTDIR)$(bindir); rm -f libpng-config +- cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config + @set -x;\ + cd $(DESTDIR)$(libdir);\ + for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ sl dylib dll.a; do\ diff --git a/ports/libpng/libpng.port b/ports/libpng/libpng.port new file mode 100644 index 00000000..f9ce8744 --- /dev/null +++ b/ports/libpng/libpng.port @@ -0,0 +1,13 @@ +NAME=libpng +BUILD_LIBRARIES=libz +VERSION=1.5.13 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=b843f9cb01d10ae22acd9aaf58aceaa4a6aeb9cf78943b41588004b271257aee +UPSTREAM_SITE=https://download.sourceforge.net/libpng +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--with-binconfigs=no' +POST_INSTALL=tix-eradicate-libtool-la +RELEASE_SEARCH_PAGE=http://libpng.org/pub/png/libpng.html diff --git a/ports/libreadline/libreadline.patch b/ports/libreadline/libreadline.patch new file mode 100644 index 00000000..6623d41f --- /dev/null +++ b/ports/libreadline/libreadline.patch @@ -0,0 +1,225 @@ +diff -Paur --no-dereference -- libreadline.upstream/configure libreadline/configure +--- libreadline.upstream/configure ++++ libreadline/configure +@@ -2415,7 +2415,7 @@ + i[3456]86-*-beos*) + cross_cache=${srcdir}/cross-build/x86-beos.cache + ;; +- *) echo "configure: cross-compiling for $host is not supported" >&2 ++ *) #echo "configure: cross-compiling for $host is not supported" >&2 + ;; + esac + if test -n "${cross_cache}" && test -r "${cross_cache}"; then +@@ -5194,7 +5194,7 @@ + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" >&5 + $as_echo "$as_me: WARNING: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" >&2;} +- bash_cv_func_sigsetjmp=missing ++ bash_cv_func_sigsetjmp=yes + + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +diff -Paur --no-dereference -- libreadline.upstream/history.c libreadline/history.c +--- libreadline.upstream/history.c ++++ libreadline/history.c +@@ -57,6 +57,8 @@ + /* How big to make the_history when we first allocate it. */ + #define DEFAULT_HISTORY_INITIAL_SIZE 502 + ++#define MAX_HISTORY_INITIAL_SIZE 8192 ++ + /* The number of slots to increase the_history by. */ + #define DEFAULT_HISTORY_GROW_SIZE 50 + +@@ -307,7 +309,9 @@ + if (history_size == 0) + { + if (history_stifled && history_max_entries > 0) +- history_size = history_max_entries + 2; ++ history_size = (history_max_entries > MAX_HISTORY_INITIAL_SIZE) ++ ? MAX_HISTORY_INITIAL_SIZE ++ : history_max_entries + 2; + else + history_size = DEFAULT_HISTORY_INITIAL_SIZE; + the_history = (HIST_ENTRY **)xmalloc (history_size * sizeof (HIST_ENTRY *)); +diff -Paur --no-dereference -- libreadline.upstream/inputrc libreadline/inputrc +--- libreadline.upstream/inputrc ++++ libreadline/inputrc +@@ -0,0 +1,66 @@ ++# /etc/inputrc - global inputrc for libreadline ++# See readline(3readline) and `info rluserman' for more information. ++ ++# Be 8 bit clean. ++set input-meta on ++set output-meta on ++ ++# To allow the use of 8bit-characters like the german umlauts, uncomment ++# the line below. However this makes the meta key not work as a meta key, ++# which is annoying to those which don't need to type in 8-bit characters. ++ ++# set convert-meta off ++ ++# try to enable the application keypad when it is called. Some systems ++# need this to enable the arrow keys. ++# set enable-keypad on ++ ++# see /usr/share/doc/bash/inputrc.arrows for other codes of arrow keys ++ ++# do not bell on tab-completion ++# set bell-style none ++# set bell-style visible ++ ++# some defaults / modifications for the emacs mode ++$if mode=emacs ++ ++# allow the use of the Home/End keys ++"\e[1~": beginning-of-line ++"\e[4~": end-of-line ++ ++# allow the use of the Delete/Insert keys ++"\e[3~": delete-char ++"\e[2~": quoted-insert ++ ++# mappings for "page up" and "page down" to step to the beginning/end ++# of the history ++# "\e[5~": beginning-of-history ++# "\e[6~": end-of-history ++ ++# alternate mappings for "page up" and "page down" to search the history ++# "\e[5~": history-search-backward ++# "\e[6~": history-search-forward ++ ++# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving ++"\e[1;5C": forward-word ++"\e[1;5D": backward-word ++"\e[5C": forward-word ++"\e[5D": backward-word ++"\e\e[C": forward-word ++"\e\e[D": backward-word ++ ++$if term=rxvt ++"\e[8~": end-of-line ++"\eOc": forward-word ++"\eOd": backward-word ++$endif ++ ++# for non RH/Debian xterm, can't hurt for RH/Debian xterm ++# "\eOH": beginning-of-line ++# "\eOF": end-of-line ++ ++# for freebsd console ++# "\e[H": beginning-of-line ++# "\e[F": end-of-line ++ ++$endif +diff -Paur --no-dereference -- libreadline.upstream/Makefile.in libreadline/Makefile.in +--- libreadline.upstream/Makefile.in ++++ libreadline/Makefile.in +@@ -59,6 +59,7 @@ + includedir = @includedir@ + datadir = @datadir@ + localedir = @localedir@ ++sysconfdir = @sysconfdir@ + + infodir = @infodir@ + +@@ -66,9 +67,6 @@ + + man3dir = $(mandir)/man3 + +-# Support an alternate destination root directory for package building +-DESTDIR = +- + # Programs to make tags files. + ETAGS = etags + CTAGS = ctags -tw +@@ -220,6 +218,8 @@ + force: + + install: $(INSTALL_TARGETS) ++ mkdir -p $(DESTDIR)$(sysconfdir) ++ $(INSTALL_DATA) inputrc $(DESTDIR)$(sysconfdir)/inputrc + + install-headers: installdirs ${INSTALLED_HEADERS} + for f in ${INSTALLED_HEADERS}; do \ +diff -Paur --no-dereference -- libreadline.upstream/patchlevel libreadline/patchlevel +--- libreadline.upstream/patchlevel ++++ libreadline/patchlevel +@@ -1,3 +1,3 @@ + # Do not edit -- exists only for use by patch + +-0 ++1 +diff -Paur --no-dereference -- libreadline.upstream/readline70-001 libreadline/readline70-001 +--- libreadline.upstream/readline70-001 ++++ libreadline/readline70-001 +@@ -0,0 +1,57 @@ ++ READLINE PATCH REPORT ++ ===================== ++ ++Readline-Release: 7.0 ++Patch-ID: readline70-001 ++ ++Bug-Reported-by: Sean Zha ++Bug-Reference-ID: ++Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2016-09/msg00107.html ++ ++Bug-Description: ++ ++Readline-7.0 changed the way the history list is initially allocated to reduce ++the number of reallocations and copies. Users who set the readline ++history-size variable to a very large number to essentially unlimit the size ++of the history list will get memory allocation errors ++ ++Patch (apply with `patch -p0'): ++ ++*** ../readline-7.0/history.c 2015-12-28 13:50:31.000000000 -0500 ++--- history.c 2016-09-30 14:28:40.000000000 -0400 ++*************** ++*** 58,61 **** ++--- 58,63 ---- ++ #define DEFAULT_HISTORY_INITIAL_SIZE 502 ++ +++ #define MAX_HISTORY_INITIAL_SIZE 8192 +++ ++ /* The number of slots to increase the_history by. */ ++ #define DEFAULT_HISTORY_GROW_SIZE 50 ++*************** ++*** 308,312 **** ++ { ++ if (history_stifled && history_max_entries > 0) ++! history_size = history_max_entries + 2; ++ else ++ history_size = DEFAULT_HISTORY_INITIAL_SIZE; ++--- 310,316 ---- ++ { ++ if (history_stifled && history_max_entries > 0) ++! history_size = (history_max_entries > MAX_HISTORY_INITIAL_SIZE) ++! ? MAX_HISTORY_INITIAL_SIZE ++! : history_max_entries + 2; ++ else ++ history_size = DEFAULT_HISTORY_INITIAL_SIZE; ++ ++*** ../readline-7.0/patchlevel 2013-11-15 08:11:11.000000000 -0500 ++--- patchlevel 2014-03-21 08:28:40.000000000 -0400 ++*************** ++*** 1,3 **** ++ # Do not edit -- exists only for use by patch ++ ++! 0 ++--- 1,3 ---- ++ # Do not edit -- exists only for use by patch ++ ++! 1 +diff -Paur --no-dereference -- libreadline.upstream/support/config.sub libreadline/support/config.sub +--- libreadline.upstream/support/config.sub ++++ libreadline/support/config.sub +@@ -1356,7 +1356,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/ports/libreadline/libreadline.port b/ports/libreadline/libreadline.port new file mode 100644 index 00000000..94d485fd --- /dev/null +++ b/ports/libreadline/libreadline.port @@ -0,0 +1,11 @@ +NAME=libreadline +BUILD_LIBRARIES=libcurses +VERSION=7.0 +DISTNAME=readline-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=750d437185286f40a369e1e4f4764eda932b9459b5ec9a731628393dd3d32334 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/readline +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS=--disable-shared diff --git a/ports/libssl/libssl.patch b/ports/libssl/libssl.patch new file mode 100644 index 00000000..96680259 --- /dev/null +++ b/ports/libssl/libssl.patch @@ -0,0 +1,547 @@ +diff -Paur --no-dereference -- libssl.upstream/apps/nc/compat/base64.c libssl/apps/nc/compat/base64.c +--- libssl.upstream/apps/nc/compat/base64.c ++++ libssl/apps/nc/compat/base64.c +@@ -124,14 +124,14 @@ + + int + b64_ntop(src, srclength, target, targsize) +- u_char const *src; ++ unsigned char const *src; + size_t srclength; + char *target; + size_t targsize; + { + size_t datalength = 0; +- u_char input[3]; +- u_char output[4]; ++ unsigned char input[3]; ++ unsigned char output[4]; + int i; + + while (2 < srclength) { +@@ -189,11 +189,11 @@ + int + b64_pton(src, target, targsize) + char const *src; +- u_char *target; ++ unsigned char *target; + size_t targsize; + { + int tarindex, state, ch; +- u_char nextbyte; ++ unsigned char nextbyte; + char *pos; + + state = 0; +diff -Paur --no-dereference -- libssl.upstream/apps/nc/netcat.c libssl/apps/nc/netcat.c +--- libssl.upstream/apps/nc/netcat.c ++++ libssl/apps/nc/netcat.c +@@ -40,7 +40,10 @@ + #include + #include + #include ++/* PATCH: Sortix doesn't have yet. */ ++#if __has_include() + #include ++#endif + + #include + #include +@@ -468,8 +471,12 @@ + } else { + strlcpy(unix_dg_tmp_socket_buf, "/tmp/nc.XXXXXXXXXX", + UNIX_DG_TMP_SOCKET_SIZE); +- if (mktemp(unix_dg_tmp_socket_buf) == NULL) ++ /* PATCH: Sortix doesn't have the obsolete mktemp(3) function. */ ++ int fd = mkstemp(unix_dg_tmp_socket_buf); ++ if (fd < 0) + err(1, "mktemp"); ++ unlink(unix_dg_tmp_socket_buf); ++ close(fd); + unix_dg_tmp_socket = unix_dg_tmp_socket_buf; + } + } +@@ -1386,6 +1393,8 @@ + void + fdpass(int nfd) + { ++/* PATCH: File descriptor passing is WIP on Sortix. */ ++#ifdef CMSG_SPACE + struct msghdr mh; + union { + struct cmsghdr hdr; +@@ -1405,7 +1414,8 @@ + memset(&cmsgbuf, 0, sizeof(cmsgbuf)); + memset(&iov, 0, sizeof(iov)); + +- mh.msg_control = (caddr_t)&cmsgbuf.buf; ++ /* PATCH: Sortix doesn't have the non-standard caddr_t type. */ ++ mh.msg_control = (char*)&cmsgbuf.buf; + mh.msg_controllen = sizeof(cmsgbuf.buf); + cmsg = CMSG_FIRSTHDR(&mh); + cmsg->cmsg_len = CMSG_LEN(sizeof(int)); +@@ -1436,12 +1446,16 @@ + break; + } + exit(0); ++#else ++ errx(1, "File descriptor passing is not supported"); ++#endif + } + + /* Deal with RFC 854 WILL/WONT DO/DONT negotiation. */ + void + atelnet(int nfd, unsigned char *buf, unsigned int size) + { ++#ifdef IAC + unsigned char *p, *end; + unsigned char obuf[4]; + +@@ -1467,6 +1481,9 @@ + if (atomicio(vwrite, nfd, obuf, 3) != 3) + warn("Write Error!"); + } ++#else ++ errx(1, "Telnet negotation is not supported"); ++#endif + } + + +@@ -1581,16 +1598,20 @@ + err(1, NULL); + } + if (Tflag != -1) { ++/* PATCH: The Sortix network stack is WIP and doesn't have IP_TOS yet and ++ likewise with other features. */ ++#ifdef IP_TOS + if (af == AF_INET && setsockopt(s, IPPROTO_IP, + IP_TOS, &Tflag, sizeof(Tflag)) == -1) + err(1, "set IP ToS"); ++#endif + + #ifdef IPV6_TCLASS +- else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, ++ if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, + IPV6_TCLASS, &Tflag, sizeof(Tflag)) == -1) + err(1, "set IPv6 traffic class"); + #else +- else if (af == AF_INET6) { ++ if (af == AF_INET6) { + errno = ENOPROTOOPT; + err(1, "set IPv6 traffic class not supported"); + } +@@ -1608,13 +1629,16 @@ + } + + if (ttl != -1) { ++#ifdef IP_TTL + if (af == AF_INET && setsockopt(s, IPPROTO_IP, + IP_TTL, &ttl, sizeof(ttl))) + err(1, "set IP TTL"); +- +- else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, ++#endif ++#ifdef IPV6_UNICAST_HOPS ++ if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, + IPV6_UNICAST_HOPS, &ttl, sizeof(ttl))) + err(1, "set IPv6 unicast hops"); ++#endif + } + + if (minttl != -1) { +@@ -1652,7 +1676,9 @@ + { "af41", IPTOS_DSCP_AF41 }, + { "af42", IPTOS_DSCP_AF42 }, + { "af43", IPTOS_DSCP_AF43 }, ++#ifdef IPTOS_PREC_CRITIC_ECP + { "critical", IPTOS_PREC_CRITIC_ECP }, ++#endif + { "cs0", IPTOS_DSCP_CS0 }, + { "cs1", IPTOS_DSCP_CS1 }, + { "cs2", IPTOS_DSCP_CS2 }, +@@ -1662,11 +1688,21 @@ + { "cs6", IPTOS_DSCP_CS6 }, + { "cs7", IPTOS_DSCP_CS7 }, + { "ef", IPTOS_DSCP_EF }, ++#ifdef IPTOS_PREC_INTERNETCONTROL + { "inetcontrol", IPTOS_PREC_INTERNETCONTROL }, ++#endif ++#ifdef IPTOS_LOWDELAY + { "lowdelay", IPTOS_LOWDELAY }, ++#endif ++#ifdef IPTOS_PREC_NETCONTROL + { "netcontrol", IPTOS_PREC_NETCONTROL }, ++#endif ++#ifdef IPTOS_RELIABILITY + { "reliability", IPTOS_RELIABILITY }, ++#endif ++#ifdef IPTOS_THROUGHPUT + { "throughput", IPTOS_THROUGHPUT }, ++#endif + { NULL, -1 }, + }; + +diff -Paur --no-dereference -- libssl.upstream/apps/openssl/apps.c libssl/apps/openssl/apps.c +--- libssl.upstream/apps/openssl/apps.c ++++ libssl/apps/openssl/apps.c +@@ -147,6 +147,11 @@ + #include + #include + ++/* PATCH: For snprintf path creation that handles too long paths. */ ++#if defined(__sortix__) && !defined(PATH_MAX) ++#define PATH_MAX 4096 ++#endif ++ + typedef struct { + const char *name; + unsigned long flag; +diff -Paur --no-dereference -- libssl.upstream/apps/openssl/ca.c libssl/apps/openssl/ca.c +--- libssl.upstream/apps/openssl/ca.c ++++ libssl/apps/openssl/ca.c +@@ -81,6 +81,13 @@ + #include + #include + ++/* PATCH: Sortix doesn't have a PATH_MAX limit. Provide a simple value for the ++ below snprintf calls that construct paths and handle overflow if paths ++ are longer than PATH_MAX. */ ++#if defined(__sortix__) && !defined(PATH_MAX) ++#define PATH_MAX 4096 ++#endif ++ + #define BASE_SECTION "ca" + + #define ENV_DEFAULT_CA "default_ca" +diff -Paur --no-dereference -- libssl.upstream/apps/openssl/certhash.c libssl/apps/openssl/certhash.c +--- libssl.upstream/apps/openssl/certhash.c ++++ libssl/apps/openssl/certhash.c +@@ -33,6 +33,11 @@ + + #include "apps.h" + ++/* PATCH: For readlink that handles too long paths. */ ++#if defined(__sortix__) && !defined(PATH_MAX) ++#define PATH_MAX 4096 ++#endif ++ + static struct { + int dryrun; + int verbose; +@@ -490,6 +495,11 @@ + fprintf(stderr, "failed to readlink %s\n", dep->d_name); + return (-1); + } ++ /* PATCH: Handle symbolic links that are too long. */ ++ if (n == sizeof(target) - 1) { ++ fprintf(stderr, "symbolic link is too long %s\n", dep->d_name); ++ return (-1); ++ } + target[n] = '\0'; + + hi = hashinfo_from_linkname(dep->d_name, target); +diff -Paur --no-dereference -- libssl.upstream/apps/openssl/s_socket.c libssl/apps/openssl/s_socket.c +--- libssl.upstream/apps/openssl/s_socket.c ++++ libssl/apps/openssl/s_socket.c +@@ -73,6 +73,23 @@ + + #include "s_apps.h" + ++/* PATCH: The server below only supports IPv4 and only uses the obsolete ++ gethostbyname and gethostbyaddr instead of the getaddrinfo ++ replacement. Sortix intentionally does not have gethostbyname, so ++ simply disable the feature for now. */ ++#if defined(__sortix__) ++struct hostent ++{ ++ char *h_name; ++ char **h_aliases; ++ int h_addrtype; ++ int h_length; ++ char **h_addr_list; ++}; ++#define gethostbyname(a) ((void) a, (struct hostent*) NULL) ++#define gethostbyaddr(a, b, c) (((void) a), ((void) b), ((void) c), (struct hostent*) NULL) ++#endif ++ + static int init_server(int *sock, int port, int type); + static int init_server_long(int *sock, int port, char *ip, int type); + static int do_accept(int acc_sock, int *sock, char **host); +diff -Paur --no-dereference -- libssl.upstream/configure libssl/configure +--- libssl.upstream/configure ++++ libssl/configure +@@ -13056,10 +13056,11 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + ++// PATCH: Sortix builds ports with -Werror=implicit-function-declaration so ++// make sure getpageinfo has been forward declared, or it will be ++// misdetected as missing when it does exist. + // Since Android NDK v16 getpagesize is defined as inline inside unistd.h +-#ifdef __ANDROID__ +-# include +-#endif ++#include + + int + main () +diff -Paur --no-dereference -- libssl.upstream/crypto/bio/b_sock.c libssl/crypto/bio/b_sock.c +--- libssl.upstream/crypto/bio/b_sock.c ++++ libssl/crypto/bio/b_sock.c +@@ -34,6 +34,21 @@ + #include + #include + ++/* PATCH: Sortix intentionally doesn't have the obsolete gethostbyname family ++ but only the modern getaddrinfo(3) family. Actually none of my ports ++ use BIO_gethostbyname, maybe it can just be removed. */ ++#if defined(__sortix__) ++struct hostent ++{ ++ char *h_name; ++ char **h_aliases; ++ int h_addrtype; ++ int h_length; ++ char **h_addr_list; ++}; ++#define gethostbyname(a) ((void) a, (struct hostent*) NULL) ++#endif ++ + int + BIO_get_host_ip(const char *str, unsigned char *ip) + { +diff -Paur --no-dereference -- libssl.upstream/crypto/bio/bss_bio.c libssl/crypto/bio/bss_bio.c +--- libssl.upstream/crypto/bio/bss_bio.c ++++ libssl/crypto/bio/bss_bio.c +@@ -74,6 +74,11 @@ + # endif + #endif + ++/* PATCH: Sortix is buggy and doesn't define SSIZE_MAX right now. */ ++#if defined(__sortix__) ++#include ++#endif ++ + #include + #include + #include +diff -Paur --no-dereference -- libssl.upstream/crypto/chacha/chacha-merged.c libssl/crypto/chacha/chacha-merged.c +--- libssl.upstream/crypto/chacha/chacha-merged.c ++++ libssl/crypto/chacha/chacha-merged.c +@@ -16,20 +16,20 @@ + #define CHACHA_BLOCKLEN 64 + + struct chacha_ctx { +- u_int input[16]; ++ unsigned int input[16]; + uint8_t ks[CHACHA_BLOCKLEN]; + uint8_t unused; + }; + +-static inline void chacha_keysetup(struct chacha_ctx *x, const u_char *k, +- u_int kbits) ++static inline void chacha_keysetup(struct chacha_ctx *x, const unsigned char *k, ++ unsigned int kbits) + __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN))); +-static inline void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv, +- const u_char *ctr) ++static inline void chacha_ivsetup(struct chacha_ctx *x, const unsigned char *iv, ++ const unsigned char *ctr) + __attribute__((__bounded__(__minbytes__, 2, CHACHA_NONCELEN))) + __attribute__((__bounded__(__minbytes__, 3, CHACHA_CTRLEN))); +-static inline void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m, +- u_char *c, u_int bytes) ++static inline void chacha_encrypt_bytes(struct chacha_ctx *x, const unsigned char *m, ++ unsigned char *c, unsigned int bytes) + __attribute__((__bounded__(__buffer__, 2, 4))) + __attribute__((__bounded__(__buffer__, 3, 4))); + +@@ -127,7 +127,7 @@ + u32 j8, j9, j10, j11, j12, j13, j14, j15; + u8 *ctarget = NULL; + u8 tmp[64]; +- u_int i; ++ unsigned int i; + + if (!bytes) + return; +diff -Paur --no-dereference -- libssl.upstream/crypto/x509/x509_vpm.c libssl/crypto/x509/x509_vpm.c +--- libssl.upstream/crypto/x509/x509_vpm.c ++++ libssl/crypto/x509/x509_vpm.c +@@ -598,6 +598,10 @@ + static const X509_VERIFY_PARAM default_table[] = { + { + .name = "default", ++ /* PATCH: OpenBSD 6.9 errata 018, September 30, 2021: ++ Compensate for the expiry of the DST Root X3 certificate. ++ https://ftp.openbsd.org/pub/OpenBSD/patches/6.9/common/018_cert.patch.sig */ ++ .flags = X509_V_FLAG_TRUSTED_FIRST, + .depth = 100, + .trust = 0, /* XXX This is not the default trust value */ + .id = vpm_empty_id +diff -Paur --no-dereference -- libssl.upstream/include/compat/arpa/nameser.h libssl/include/compat/arpa/nameser.h +--- libssl.upstream/include/compat/arpa/nameser.h ++++ libssl/include/compat/arpa/nameser.h +@@ -4,7 +4,9 @@ + */ + + #ifndef _WIN32 ++#if __has_include_next() + #include_next ++#endif + #else + #include + +diff -Paur --no-dereference -- libssl.upstream/include/compat/machine/endian.h libssl/include/compat/machine/endian.h +--- libssl.upstream/include/compat/machine/endian.h ++++ libssl/include/compat/machine/endian.h +@@ -21,7 +21,10 @@ + #define BYTE_ORDER BIG_ENDIAN + #endif + +-#elif defined(__linux__) || defined(__midipix__) ++/* PATCH: endian.h is the header being standardized, use it instead if it ++ exists, that is what Sortix has. This machine/endian.h abstraction ++ should be renamed to endian.h. */ ++#elif defined(__linux__) || defined(__midipix__) || defined(__sortix__) || __has_include() + #include + + #elif defined(__sun) || defined(_AIX) || defined(__hpux) +diff -Paur --no-dereference -- libssl.upstream/include/compat/netinet/ip.h libssl/include/compat/netinet/ip.h +--- libssl.upstream/include/compat/netinet/ip.h ++++ libssl/include/compat/netinet/ip.h +@@ -8,7 +8,9 @@ + #endif + + #ifndef _WIN32 ++#if __has_include_next() + #include_next ++#endif + #else + #include + #endif +diff -Paur --no-dereference -- libssl.upstream/include/compat/resolv.h libssl/include/compat/resolv.h +--- libssl.upstream/include/compat/resolv.h ++++ libssl/include/compat/resolv.h +@@ -13,8 +13,10 @@ + #include <../include/resolv.h> + #endif + #else ++#if __has_include_next() + #include_next + #endif ++#endif + + #ifndef HAVE_B64_NTOP + int b64_ntop(unsigned char const *, size_t, char *, size_t); +diff -Paur --no-dereference -- libssl.upstream/include/compat/stdlib.h libssl/include/compat/stdlib.h +--- libssl.upstream/include/compat/stdlib.h ++++ libssl/include/compat/stdlib.h +@@ -16,7 +16,7 @@ + #ifndef LIBCRYPTOCOMPAT_STDLIB_H + #define LIBCRYPTOCOMPAT_STDLIB_H + +-#include ++/* PATCH: doesn't need to be included. */ + #include + + #ifndef HAVE_ARC4RANDOM_BUF +diff -Paur --no-dereference -- libssl.upstream/include/compat/string.h libssl/include/compat/string.h +--- libssl.upstream/include/compat/string.h ++++ libssl/include/compat/string.h +@@ -16,7 +16,7 @@ + #include_next + #endif + +-#include ++/* PATCH: doesn't need to be included. */ + + #if defined(__sun) || defined(_AIX) || defined(__hpux) + /* Some functions historically defined in string.h were placed in strings.h by +diff -Paur --no-dereference -- libssl.upstream/include/compat/sys/types.h libssl/include/compat/sys/types.h +--- libssl.upstream/include/compat/sys/types.h ++++ libssl/include/compat/sys/types.h +@@ -16,7 +16,7 @@ + #ifndef LIBCRYPTOCOMPAT_SYS_TYPES_H + #define LIBCRYPTOCOMPAT_SYS_TYPES_H + +-#include ++/* PATCH: doesn't need to be included. */ + + #ifdef __MINGW32__ + #include <_bsd_types.h> +diff -Paur --no-dereference -- libssl.upstream/include/compat/unistd.h libssl/include/compat/unistd.h +--- libssl.upstream/include/compat/unistd.h ++++ libssl/include/compat/unistd.h +@@ -64,9 +64,10 @@ + #endif + #endif + +-#ifndef HAVE_GETPAGESIZE +-int getpagesize(void); +-#endif ++/* PATCH: Somehow HAVE_GETPAGESIZE doesn't get defined even though configure ++ does detect Sortix has it (with the fix). Sortix getpagesize returns ++ size_t rather than int, so remove this conflicting forward ++ declaration. */ + + #define pledge(request, paths) 0 + #define unveil(path, permissions) 0 +diff -Paur --no-dereference -- libssl.upstream/tests/handshake_table.c libssl/tests/handshake_table.c +--- libssl.upstream/tests/handshake_table.c ++++ libssl/tests/handshake_table.c +@@ -19,6 +19,8 @@ + #include + #include + #include ++/* PATCH: Sortix only has the C11 and does not have __dead. */ ++#include + #include + + #include "tls13_handshake.h" +@@ -152,7 +154,7 @@ + uint8_t flags); + void fprint_flags(FILE *stream, uint8_t flags); + const char *mt2str(enum tls13_message_type mt); +-__dead void usage(void); ++noreturn void usage(void); + int verify_table(enum tls13_message_type + table[MAX_FLAGS][TLS13_NUM_MESSAGE_TYPES], int print); + +@@ -449,7 +451,7 @@ + return success; + } + +-__dead void ++noreturn void + usage(void) + { + fprintf(stderr, "usage: handshake_table [-C | -g]\n"); +diff -Paur --no-dereference -- libssl.upstream/tests/ssltest.c libssl/tests/ssltest.c +--- libssl.upstream/tests/ssltest.c ++++ libssl/tests/ssltest.c +@@ -143,7 +143,7 @@ + #define _BSD_SOURCE 1 /* Or gethostname won't be declared properly + on Linux and GNU platforms. */ + #include +-#include ++/* PATCH: Sortix does not have and it's not needed. */ + #include + + #include +diff -Paur --no-dereference -- libssl.upstream/tls/tls_config.c libssl/tls/tls_config.c +--- libssl.upstream/tls/tls_config.c ++++ libssl/tls/tls_config.c +@@ -721,8 +721,11 @@ + } + + if (sb.st_uid != getuid()) { ++ /* PATCH: Sortix has 64-bit uid_t. */ + tls_config_set_errorx(config, "session file has incorrect " +- "owner (uid %i != %i)", sb.st_uid, getuid()); ++ "owner (uid %llu != %llu)", ++ (unsigned long long) sb.st_uid, ++ (unsigned long long) getuid()); + return (-1); + } + mugo = sb.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO); diff --git a/ports/libssl/libssl.port b/ports/libssl/libssl.port new file mode 100644 index 00000000..97223c37 --- /dev/null +++ b/ports/libssl/libssl.port @@ -0,0 +1,12 @@ +NAME=libssl +BUILD_LIBRARIES= +VERSION=3.4.0 +DISTNAME=libressl-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=e52eae758d40206a71d763a1a87b71037223bf1986ac239a6be1a6d2ac3916d2 +UPSTREAM_SITE=https://ftp.openbsd.org/pub/OpenBSD/LibreSSL +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libstdc++/libstdc++.patch b/ports/libstdc++/libstdc++.patch new file mode 100644 index 00000000..4a5ef1de --- /dev/null +++ b/ports/libstdc++/libstdc++.patch @@ -0,0 +1,15 @@ +diff -Paur --no-dereference -- libstdc++.upstream/configure libstdc++/configure +--- libstdc++.upstream/configure ++++ libstdc++/configure +@@ -27278,8 +27278,9 @@ + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 + $as_echo "$acl_cv_rpath" >&6; } + wl="$acl_cv_wl" +- libext="$acl_cv_libext" +- shlibext="$acl_cv_shlibext" ++ # PATCH: acl_cv_libext is never set. There's something really wrong with how ++ # this configure script was generated for Sortix libstdc++. It only works for ++ # cross-compilation and not native builds without this fix. + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" diff --git a/ports/libstdc++/libstdc++.port b/ports/libstdc++/libstdc++.port new file mode 100644 index 00000000..a1f91989 --- /dev/null +++ b/ports/libstdc++/libstdc++.port @@ -0,0 +1,13 @@ +NAME=libstdc++ +BUILD_LIBRARIES='libiconv?' +VERSION=1.1-rc1 +DISTNAME=sortix-libstdc++-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=0669b1344d969453a01d041ec9671e32fae25f89373d205bb172a8f7a267a10e +UPSTREAM_SITE=https://pub.sortix.org/sortix/toolchain +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_USE_BUILD_DIRECTORY=true +POST_INSTALL=tix-eradicate-libtool-la +VERSION_REGEX='([0-9]+\.[0-9]+(\.[0-9]+)*(-rc[0-9]+)?)' diff --git a/ports/libtheora/libtheora.patch b/ports/libtheora/libtheora.patch new file mode 100644 index 00000000..b899d014 --- /dev/null +++ b/ports/libtheora/libtheora.patch @@ -0,0 +1,91 @@ +diff -Paur --no-dereference -- libtheora.upstream/config.sub libtheora/config.sub +--- libtheora.upstream/config.sub ++++ libtheora/config.sub +@@ -1093,7 +1093,7 @@ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* \ ++ | -aos* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ +diff -Paur --no-dereference -- libtheora.upstream/examples/dump_psnr.c libtheora/examples/dump_psnr.c +--- libtheora.upstream/examples/dump_psnr.c ++++ libtheora/examples/dump_psnr.c +@@ -37,7 +37,6 @@ + #endif + #include + #include +-#include + #include + #include + /*Yes, yes, we're going to hell.*/ +diff -Paur --no-dereference -- libtheora.upstream/examples/dump_video.c libtheora/examples/dump_video.c +--- libtheora.upstream/examples/dump_video.c ++++ libtheora/examples/dump_video.c +@@ -37,9 +37,9 @@ + #include + #include + #include +-#include + #include + #include ++#include + /*Yes, yes, we're going to hell.*/ + #if defined(_WIN32) + #include +@@ -205,9 +205,9 @@ + int long_option_index; + int c; + +- struct timeb start; +- struct timeb after; +- struct timeb last; ++ struct timespec start; ++ struct timespec after; ++ struct timespec last; + int fps_only=0; + int frames = 0; + +@@ -418,8 +418,8 @@ + } + + if(fps_only){ +- ftime(&start); +- ftime(&last); ++ clock_gettime(CLOCK_MONOTONIC, &start); ++ clock_gettime(CLOCK_MONOTONIC, &last); + } + + while(!got_sigint){ +@@ -433,7 +433,7 @@ + videobuf_ready=1; + frames++; + if(fps_only) +- ftime(&after); ++ clock_gettime(CLOCK_MONOTONIC, &after); + } + + }else +@@ -442,16 +442,16 @@ + + if(fps_only && (videobuf_ready || fps_only==2)){ + long ms = +- after.time*1000.+after.millitm- +- (last.time*1000.+last.millitm); ++ after.tv_sec*1000.+after.tv_nsec/1000000- ++ (last.tv_sec*1000.+last.tv_nsec/1000000); + + if(ms>500 || fps_only==1 || + (feof(infile) && !videobuf_ready)){ + float file_fps = (float)ti.fps_numerator/ti.fps_denominator; + fps_only=2; + +- ms = after.time*1000.+after.millitm- +- (start.time*1000.+start.millitm); ++ ms = after.tv_sec*1000.+after.tv_nsec/1000000- ++ (start.tv_sec*1000.+start.tv_nsec/1000000); + + fprintf(stderr,"\rframe:%d rate:%.2fx ", + frames, diff --git a/ports/libtheora/libtheora.port b/ports/libtheora/libtheora.port new file mode 100644 index 00000000..ed9cda47 --- /dev/null +++ b/ports/libtheora/libtheora.port @@ -0,0 +1,14 @@ +NAME=libtheora +BUILD_LIBRARIES='libogg libvorbis libSDL? libcairo? libpng?' +VERSION=1.1.1 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.bz2 +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=b6ae1ee2fa3d42ac489287d3ec34c5885730b1296f0801ae577a35193d3affbc +UPSTREAM_SITE=https://ftp.osuosl.org/pub/xiph/releases/theora +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +# TODO: This package runs cross-compiled programs when generating documentation: +CONFIGURE_ARGS=--disable-spec +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libtheora/libtheora.rmpatch b/ports/libtheora/libtheora.rmpatch new file mode 100644 index 00000000..924c6658 --- /dev/null +++ b/ports/libtheora/libtheora.rmpatch @@ -0,0 +1,73 @@ +rm -rf -- 'doc/libtheora/' +rm -rf -- 'doc/libtheora/html/' +rm -rf -- 'doc/libtheora/html/annotated.html' +rm -rf -- 'doc/libtheora/html/classes.html' +rm -rf -- 'doc/libtheora/html/codec_8h.html' +rm -rf -- 'doc/libtheora/html/codec_8h_source.html' +rm -rf -- 'doc/libtheora/html/doxygen.css' +rm -rf -- 'doc/libtheora/html/doxygen.png' +rm -rf -- 'doc/libtheora/html/files.html' +rm -rf -- 'doc/libtheora/html/functions.html' +rm -rf -- 'doc/libtheora/html/functions_vars.html' +rm -rf -- 'doc/libtheora/html/globals.html' +rm -rf -- 'doc/libtheora/html/globals_defs.html' +rm -rf -- 'doc/libtheora/html/globals_enum.html' +rm -rf -- 'doc/libtheora/html/globals_eval.html' +rm -rf -- 'doc/libtheora/html/globals_func.html' +rm -rf -- 'doc/libtheora/html/globals_type.html' +rm -rf -- 'doc/libtheora/html/globals_vars.html' +rm -rf -- 'doc/libtheora/html/group__basefuncs.html' +rm -rf -- 'doc/libtheora/html/group__decfuncs.html' +rm -rf -- 'doc/libtheora/html/group__encfuncs.html' +rm -rf -- 'doc/libtheora/html/group__oldfuncs.html' +rm -rf -- 'doc/libtheora/html/index.html' +rm -rf -- 'doc/libtheora/html/modules.html' +rm -rf -- 'doc/libtheora/html/structth__comment.html' +rm -rf -- 'doc/libtheora/html/structth__huff__code.html' +rm -rf -- 'doc/libtheora/html/structth__img__plane.html' +rm -rf -- 'doc/libtheora/html/structth__info.html' +rm -rf -- 'doc/libtheora/html/structth__quant__info.html' +rm -rf -- 'doc/libtheora/html/structth__quant__ranges.html' +rm -rf -- 'doc/libtheora/html/structth__stripe__callback.html' +rm -rf -- 'doc/libtheora/html/structtheora__comment.html' +rm -rf -- 'doc/libtheora/html/structtheora__info.html' +rm -rf -- 'doc/libtheora/html/structtheora__state.html' +rm -rf -- 'doc/libtheora/html/structyuv__buffer.html' +rm -rf -- 'doc/libtheora/html/tab_b.gif' +rm -rf -- 'doc/libtheora/html/tab_l.gif' +rm -rf -- 'doc/libtheora/html/tab_r.gif' +rm -rf -- 'doc/libtheora/html/tabs.css' +rm -rf -- 'doc/libtheora/html/theora_8h.html' +rm -rf -- 'doc/libtheora/html/theora_8h_source.html' +rm -rf -- 'doc/libtheora/html/theoradec_8h.html' +rm -rf -- 'doc/libtheora/html/theoradec_8h_source.html' +rm -rf -- 'doc/libtheora/html/theoraenc_8h.html' +rm -rf -- 'doc/libtheora/html/theoraenc_8h_source.html' +rm -rf -- 'doc/libtheora/latex/' +rm -rf -- 'doc/libtheora/latex/Makefile' +rm -rf -- 'doc/libtheora/latex/annotated.tex' +rm -rf -- 'doc/libtheora/latex/codec_8h.tex' +rm -rf -- 'doc/libtheora/latex/doxygen.sty' +rm -rf -- 'doc/libtheora/latex/files.tex' +rm -rf -- 'doc/libtheora/latex/group__basefuncs.tex' +rm -rf -- 'doc/libtheora/latex/group__decfuncs.tex' +rm -rf -- 'doc/libtheora/latex/group__encfuncs.tex' +rm -rf -- 'doc/libtheora/latex/group__oldfuncs.tex' +rm -rf -- 'doc/libtheora/latex/index.tex' +rm -rf -- 'doc/libtheora/latex/modules.tex' +rm -rf -- 'doc/libtheora/latex/refman.tex' +rm -rf -- 'doc/libtheora/latex/structth__comment.tex' +rm -rf -- 'doc/libtheora/latex/structth__huff__code.tex' +rm -rf -- 'doc/libtheora/latex/structth__img__plane.tex' +rm -rf -- 'doc/libtheora/latex/structth__info.tex' +rm -rf -- 'doc/libtheora/latex/structth__quant__info.tex' +rm -rf -- 'doc/libtheora/latex/structth__quant__ranges.tex' +rm -rf -- 'doc/libtheora/latex/structth__stripe__callback.tex' +rm -rf -- 'doc/libtheora/latex/structtheora__comment.tex' +rm -rf -- 'doc/libtheora/latex/structtheora__info.tex' +rm -rf -- 'doc/libtheora/latex/structtheora__state.tex' +rm -rf -- 'doc/libtheora/latex/structyuv__buffer.tex' +rm -rf -- 'doc/libtheora/latex/theora_8h.tex' +rm -rf -- 'doc/libtheora/latex/theoradec_8h.tex' +rm -rf -- 'doc/libtheora/latex/theoraenc_8h.tex' +rm -rf -- 'libtheora.spec' diff --git a/ports/libvorbis/libvorbis.patch b/ports/libvorbis/libvorbis.patch new file mode 100644 index 00000000..a4198f61 --- /dev/null +++ b/ports/libvorbis/libvorbis.patch @@ -0,0 +1,12 @@ +diff -Paur --no-dereference -- libvorbis.upstream/config.sub libvorbis/config.sub +--- libvorbis.upstream/config.sub ++++ libvorbis/config.sub +@@ -1195,7 +1195,7 @@ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* \ ++ | -aos* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/ports/libvorbis/libvorbis.port b/ports/libvorbis/libvorbis.port new file mode 100644 index 00000000..80425aac --- /dev/null +++ b/ports/libvorbis/libvorbis.port @@ -0,0 +1,12 @@ +NAME=libvorbis +BUILD_LIBRARIES=libogg +VERSION=1.3.3 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=834c7d35a5ebf4e7b8ab60b0979f2b7f204ca66ff6829728e9d2a67f15347ebd +UPSTREAM_SITE=https://ftp.osuosl.org/pub/xiph/releases/vorbis +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libvorbis/libvorbis.rmpatch b/ports/libvorbis/libvorbis.rmpatch new file mode 100644 index 00000000..4a8e1ec9 --- /dev/null +++ b/ports/libvorbis/libvorbis.rmpatch @@ -0,0 +1,4 @@ +rm -rf -- 'doc/Vorbis_I_spec.css' +rm -rf -- 'doc/Vorbis_I_spec.html' +rm -rf -- 'doc/Vorbis_I_spec.pdf' +rm -rf -- 'libvorbis.spec' diff --git a/ports/libxkbcommon/libxkbcommon.patch b/ports/libxkbcommon/libxkbcommon.patch new file mode 100644 index 00000000..fe50f5ca --- /dev/null +++ b/ports/libxkbcommon/libxkbcommon.patch @@ -0,0 +1,40 @@ +diff -Paur --no-dereference -- libxkbcommon.upstream/config.sub libxkbcommon/config.sub +--- libxkbcommon.upstream/config.sub ++++ libxkbcommon/config.sub +@@ -1356,7 +1356,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libxkbcommon.upstream/src/xkbcomp/include.c libxkbcommon/src/xkbcomp/include.c +--- libxkbcommon.upstream/src/xkbcomp/include.c ++++ libxkbcommon/src/xkbcomp/include.c +@@ -54,6 +54,10 @@ + #include "xkbcomp-priv.h" + #include "include.h" + ++#if defined(__sortix__) && !defined(PATH_MAX) ++#define PATH_MAX 32678 ++#endif ++ + /** + * Parse an include statement. Each call returns a file name, along with + * (possibly) a specific map in the file, an explicit group designator, and +diff -Paur --no-dereference -- libxkbcommon.upstream/test/common.c libxkbcommon/test/common.c +--- libxkbcommon.upstream/test/common.c ++++ libxkbcommon/test/common.c +@@ -38,6 +38,10 @@ + + #include "test.h" + ++#if defined(__sortix__) && !defined(PATH_MAX) ++#define PATH_MAX 32678 ++#endif ++ + /* + * Test a sequence of keysyms, resulting from a sequence of key presses, + * against the keysyms they're supposed to generate. diff --git a/ports/libxkbcommon/libxkbcommon.port b/ports/libxkbcommon/libxkbcommon.port new file mode 100644 index 00000000..76ea8886 --- /dev/null +++ b/ports/libxkbcommon/libxkbcommon.port @@ -0,0 +1,12 @@ +NAME=libxkbcommon +BUILD_LIBRARIES= +VERSION=0.3.1 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=9c973581bba0c883a301fa6474d9c3e4f3a06c34e4ae4f1f4e113692cb18b38e +UPSTREAM_SITE=https://xkbcommon.org/download +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libxkbcommon/libxkbcommon.rmpatch b/ports/libxkbcommon/libxkbcommon.rmpatch new file mode 100644 index 00000000..7a6c070d --- /dev/null +++ b/ports/libxkbcommon/libxkbcommon.rmpatch @@ -0,0 +1,2 @@ +rm -rf -- 'src/xkbcomp/parser.c' +rm -rf -- 'src/xkbcomp/parser.h' diff --git a/ports/libxml2/libxml2.patch b/ports/libxml2/libxml2.patch new file mode 100644 index 00000000..c1ad5c12 --- /dev/null +++ b/ports/libxml2/libxml2.patch @@ -0,0 +1,356 @@ +diff -Paur --no-dereference -- libxml2.upstream/config.sub libxml2/config.sub +--- libxml2.upstream/config.sub ++++ libxml2/config.sub +@@ -1342,7 +1342,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- libxml2.upstream/dict.c libxml2/dict.c +--- libxml2.upstream/dict.c ++++ libxml2/dict.c +@@ -138,15 +138,6 @@ + */ + static int xmlDictInitialized = 0; + +-#ifdef DICT_RANDOMIZATION +-#ifdef HAVE_RAND_R +-/* +- * Internal data for random function, protected by xmlDictMutex +- */ +-static unsigned int rand_seed = 0; +-#endif +-#endif +- + /** + * xmlInitializeDict: + * +@@ -180,14 +171,6 @@ + return(0); + xmlRMutexLock(xmlDictMutex); + +-#ifdef DICT_RANDOMIZATION +-#ifdef HAVE_RAND_R +- rand_seed = time(NULL); +- rand_r(& rand_seed); +-#else +- srand(time(NULL)); +-#endif +-#endif + xmlDictInitialized = 1; + xmlRMutexUnlock(xmlDictMutex); + return(1); +@@ -195,19 +178,7 @@ + + #ifdef DICT_RANDOMIZATION + int __xmlRandom(void) { +- int ret; +- +- if (xmlDictInitialized == 0) +- __xmlInitializeDict(); +- +- xmlRMutexLock(xmlDictMutex); +-#ifdef HAVE_RAND_R +- ret = rand_r(& rand_seed); +-#else +- ret = rand(); +-#endif +- xmlRMutexUnlock(xmlDictMutex); +- return(ret); ++ return(arc4random_uniform(INT_MAX)); + } + #endif + +diff -Paur --no-dereference -- libxml2.upstream/Makefile.am libxml2/Makefile.am +--- libxml2.upstream/Makefile.am ++++ libxml2/Makefile.am +@@ -17,7 +17,7 @@ + + bin_PROGRAMS = xmllint xmlcatalog + +-bin_SCRIPTS=xml2-config ++bin_SCRIPTS= + + lib_LTLIBRARIES = libxml2.la + libxml2_la_LIBADD = $(ICU_LIBS) $(THREAD_LIBS) $(Z_LIBS) $(LZMA_LIBS) $(ICONV_LIBS) $(M_LIBS) $(WIN32_EXTRA_LIBADD) +@@ -61,7 +61,7 @@ + LDADDS = $(STATIC_BINARIES) $(top_builddir)/libxml2.la $(THREAD_LIBS) $(Z_LIBS) $(LZMA_LIBS) $(ICONV_LIBS) $(M_LIBS) $(WIN32_EXTRA_LIBADD) + + +-man_MANS = xml2-config.1 libxml.3 ++man_MANS = libxml.3 + + m4datadir = $(datadir)/aclocal + m4data_DATA = libxml.m4 +@@ -1176,32 +1176,18 @@ + @(rm -rf $(distdir)/xstc/Test) + + cleantar: +- @(rm -f libxml*.tar.gz COPYING.LIB) ++ @(rm -f libxml*.tar.gz) + + rpm: cleanup cleantar + @(unset CDPATH ; $(MAKE) dist-source dist && rpmbuild -ta $(distdir).tar.gz) + +-## We create xml2Conf.sh here and not from configure because we want +-## to get the paths expanded correctly. Macros like srcdir are given +-## the value NONE in configure if the user doesn't specify them (this +-## is an autoconf feature, not a bug). +- +-xml2Conf.sh: xml2Conf.sh.in Makefile +-## Use sed and then mv to avoid problems if the user interrupts. +- sed -e 's?\@XML_LIBDIR\@?$(XML_LIBDIR)?g' \ +- -e 's?\@XML_INCLUDEDIR\@?$(XML_INCLUDEDIR)?g' \ +- -e 's?\@VERSION\@?$(VERSION)?g' \ +- -e 's?\@XML_LIBS\@?$(XML_LIBS)?g' \ +- < $(srcdir)/xml2Conf.sh.in > xml2Conf.tmp \ +- && mv xml2Conf.tmp xml2Conf.sh +- + CLEANFILES = runxmlconf.log test.out xml2Conf.sh *.gcda *.gcno *.res +-DISTCLEANFILES = COPYING missing.lst ++DISTCLEANFILES = missing.lst + + confexecdir=$(libdir) +-confexec_DATA = xml2Conf.sh ++confexec_DATA = + CVS_EXTRA_DIST= +-EXTRA_DIST = xml2-config.in xml2Conf.sh.in libxml.spec.in libxml2.spec \ ++EXTRA_DIST = libxml.spec.in libxml2.spec \ + libxml.m4 Copyright check-xml-test-suite.py gentest.py \ + check-relaxng-test-suite.py check-relaxng-test-suite2.py \ + check-xsddata-test-suite.py check-xinclude-test-suite.py \ +diff -Paur --no-dereference -- libxml2.upstream/Makefile.in libxml2/Makefile.in +--- libxml2.upstream/Makefile.in ++++ libxml2/Makefile.in +@@ -67,7 +67,7 @@ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(srcdir)/libxml-2.0-uninstalled.pc.in \ + $(srcdir)/libxml-2.0.pc.in $(srcdir)/libxml.spec.in \ +- $(srcdir)/xml2-config.in $(top_srcdir)/configure AUTHORS \ ++ $(top_srcdir)/configure AUTHORS \ + COPYING ChangeLog INSTALL NEWS TODO config.guess config.sub \ + depcomp install-sh ltmain.sh missing + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +@@ -615,7 +615,7 @@ + DIST_SUBDIRS = include . doc example python xstc + AM_CPPFLAGS = -I$(top_builddir)/include -I$(srcdir)/include + AM_CFLAGS = $(THREAD_CFLAGS) $(Z_CFLAGS) $(LZMA_CFLAGS) +-bin_SCRIPTS = xml2-config ++bin_SCRIPTS = + lib_LTLIBRARIES = libxml2.la + libxml2_la_LIBADD = $(ICU_LIBS) $(THREAD_LIBS) $(Z_LIBS) $(LZMA_LIBS) $(ICONV_LIBS) $(M_LIBS) $(WIN32_EXTRA_LIBADD) + @USE_VERSION_SCRIPT_FALSE@LIBXML2_VERSION_SCRIPT = +@@ -643,7 +643,7 @@ + + DEPS = $(top_builddir)/libxml2.la + LDADDS = $(STATIC_BINARIES) $(top_builddir)/libxml2.la $(THREAD_LIBS) $(Z_LIBS) $(LZMA_LIBS) $(ICONV_LIBS) $(M_LIBS) $(WIN32_EXTRA_LIBADD) +-man_MANS = xml2-config.1 libxml.3 ++man_MANS = libxml.3 + m4datadir = $(datadir)/aclocal + m4data_DATA = libxml.m4 + runtest_SOURCES = runtest.c +@@ -740,11 +740,11 @@ + runxmlconf_DEPENDENCIES = $(DEPS) + runxmlconf_LDADD = $(LDADDS) + CLEANFILES = runxmlconf.log test.out xml2Conf.sh *.gcda *.gcno *.res +-DISTCLEANFILES = COPYING missing.lst ++DISTCLEANFILES = missing.lst + confexecdir = $(libdir) +-confexec_DATA = xml2Conf.sh ++confexec_DATA = + CVS_EXTRA_DIST = +-EXTRA_DIST = xml2-config.in xml2Conf.sh.in libxml.spec.in libxml2.spec \ ++EXTRA_DIST = libxml.spec.in libxml2.spec \ + libxml.m4 Copyright check-xml-test-suite.py gentest.py \ + check-relaxng-test-suite.py check-relaxng-test-suite2.py \ + check-xsddata-test-suite.py check-xinclude-test-suite.py \ +@@ -829,8 +829,6 @@ + -rm -f config.h stamp-h1 + libxml2.spec: $(top_builddir)/config.status $(srcdir)/libxml.spec.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +-xml2-config: $(top_builddir)/config.status $(srcdir)/xml2-config.in +- cd $(top_builddir) && $(SHELL) ./config.status $@ + libxml-2.0.pc: $(top_builddir)/config.status $(srcdir)/libxml-2.0.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $@ + libxml-2.0-uninstalled.pc: $(top_builddir)/config.status $(srcdir)/libxml-2.0-uninstalled.pc.in +@@ -2781,19 +2779,11 @@ + @(rm -rf $(distdir)/xstc/Test) + + cleantar: +- @(rm -f libxml*.tar.gz COPYING.LIB) ++ @(rm -f libxml*.tar.gz) + + rpm: cleanup cleantar + @(unset CDPATH ; $(MAKE) dist-source dist && rpmbuild -ta $(distdir).tar.gz) + +-xml2Conf.sh: xml2Conf.sh.in Makefile +- sed -e 's?\@XML_LIBDIR\@?$(XML_LIBDIR)?g' \ +- -e 's?\@XML_INCLUDEDIR\@?$(XML_INCLUDEDIR)?g' \ +- -e 's?\@VERSION\@?$(VERSION)?g' \ +- -e 's?\@XML_LIBS\@?$(XML_LIBS)?g' \ +- < $(srcdir)/xml2Conf.sh.in > xml2Conf.tmp \ +- && mv xml2Conf.tmp xml2Conf.sh +- + install-data-local: + $(MKDIR_P) $(DESTDIR)$(BASE_DIR)/$(DOC_MODULE) + -$(INSTALL) -m 0644 $(srcdir)/Copyright $(DESTDIR)$(BASE_DIR)/$(DOC_MODULE) +diff -Paur --no-dereference -- libxml2.upstream/nanoftp.c libxml2/nanoftp.c +--- libxml2.upstream/nanoftp.c ++++ libxml2/nanoftp.c +@@ -62,6 +62,18 @@ + #include + #endif + ++#if defined(__sortix__) ++struct hostent ++{ ++char* h_name; ++char** h_aliases; ++int h_addrtype; ++int h_length; ++char** h_addr_list; ++}; ++#define gethostbyname(x) ((struct hostent*) NULL) ++#endif ++ + #include + #include + #include +diff -Paur --no-dereference -- libxml2.upstream/nanohttp.c libxml2/nanohttp.c +--- libxml2.upstream/nanohttp.c ++++ libxml2/nanohttp.c +@@ -1119,7 +1119,7 @@ + #if defined(HAVE_GETADDRINFO) && defined(SUPPORT_IP6) && !defined(_WIN32) + else + #endif +-#if !defined(HAVE_GETADDRINFO) || !defined(_WIN32) ++#if !defined(HAVE_GETADDRINFO) || (!defined(_WIN32) && !defined(__sortix__)) + { + h = gethostbyname (host); + if (h == NULL) { +diff -Paur --no-dereference -- libxml2.upstream/runtest.c libxml2/runtest.c +--- libxml2.upstream/runtest.c ++++ libxml2/runtest.c +@@ -192,6 +192,33 @@ + } + } + ++#elif defined(__sortix__) ++ ++typedef struct ++{ ++ size_t gl_pathc; /* Count of paths matched so far */ ++ char **gl_pathv; /* List of matched pathnames. */ ++ size_t gl_offs; /* Slots to reserve in 'gl_pathv'. */ ++} glob_t; ++ ++#define GLOB_DOOFFS 0 ++static int glob(const char *pattern, int flags, ++ int errfunc(const char *epath, int eerrno), ++ glob_t *pglob) { ++ (void) pattern; ++ (void) flags; ++ (void) errfunc; ++ (void) pglob; ++ pglob->gl_pathc = 0; ++ pglob->gl_pathv = NULL; ++ pglob->gl_offs = 0; ++ return -1; ++} ++ ++static void globfree(glob_t *pglob) { ++ (void) pglob; ++} ++ + #else + #include + #endif +diff -Paur --no-dereference -- libxml2.upstream/testlimits.c libxml2/testlimits.c +--- libxml2.upstream/testlimits.c ++++ libxml2/testlimits.c +@@ -1287,12 +1287,12 @@ + if (fail) + res = 0; + else { +- fprintf(stderr, "Failed to parse '%s' %lu\n", filename, limit); ++ fprintf(stderr, "Failed to parse '%s' %zu\n", filename, limit); + res = 1; + } + } else { + if (fail) { +- fprintf(stderr, "Failed to get failure for '%s' %lu\n", ++ fprintf(stderr, "Failed to get failure for '%s' %zu\n", + filename, limit); + res = 1; + } else +@@ -1341,7 +1341,7 @@ + fprintf(stderr, "Failed to parse '%s' %u\n", + filename, crazy_indx); + else +- fprintf(stderr, "Failed to parse '%s' %lu\n", ++ fprintf(stderr, "Failed to parse '%s' %zu\n", + filename, limit); + res = 1; + } +@@ -1351,7 +1351,7 @@ + fprintf(stderr, "Failed to get failure for '%s' %u\n", + filename, crazy_indx); + else +- fprintf(stderr, "Failed to get failure for '%s' %lu\n", ++ fprintf(stderr, "Failed to get failure for '%s' %zu\n", + filename, limit); + res = 1; + } else +diff -Paur --no-dereference -- libxml2.upstream/testrecurse.c libxml2/testrecurse.c +--- libxml2.upstream/testrecurse.c ++++ libxml2/testrecurse.c +@@ -146,6 +146,33 @@ + } + } + ++#elif defined(__sortix__) ++ ++typedef struct ++{ ++ size_t gl_pathc; /* Count of paths matched so far */ ++ char **gl_pathv; /* List of matched pathnames. */ ++ size_t gl_offs; /* Slots to reserve in 'gl_pathv'. */ ++} glob_t; ++ ++#define GLOB_DOOFFS 0 ++static int glob(const char *pattern, int flags, ++ int errfunc(const char *epath, int eerrno), ++ glob_t *pglob) { ++ (void) pattern; ++ (void) flags; ++ (void) errfunc; ++ (void) pglob; ++ pglob->gl_pathc = 0; ++ pglob->gl_pathv = NULL; ++ pglob->gl_offs = 0; ++ return -1; ++} ++ ++static void globfree(glob_t *pglob) { ++ (void) pglob; ++} ++ + #else + #include + #endif +diff -Paur --no-dereference -- libxml2.upstream/timsort.h libxml2/timsort.h +--- libxml2.upstream/timsort.h ++++ libxml2/timsort.h +@@ -323,7 +323,7 @@ + SORT_TYPE *tempstore = (SORT_TYPE *)realloc(store->storage, new_size * sizeof(SORT_TYPE)); + if (tempstore == NULL) + { +- fprintf(stderr, "Error allocating temporary storage for tim sort: need %lu bytes", sizeof(SORT_TYPE) * new_size); ++ fprintf(stderr, "Error allocating temporary storage for tim sort: need %zu bytes", sizeof(SORT_TYPE) * new_size); + exit(1); + } + store->storage = tempstore; diff --git a/ports/libxml2/libxml2.port b/ports/libxml2/libxml2.port new file mode 100644 index 00000000..fe606a25 --- /dev/null +++ b/ports/libxml2/libxml2.port @@ -0,0 +1,14 @@ +NAME=libxml2 +BUILD_LIBRARIES='libiconv?' +VERSION=2.9.1 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=fd3c64cb66f2c4ea27e934d275904d92cec494a8e8405613780cbc8a71680fdb +UPSTREAM_SITE=ftp://xmlsoft.org/libxml2 +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +# libxml2 looks for python in a non-cross-compile compatible manner and tries a python2.7-config script. +CONFIGURE_ARGS=--without-python +MAKE_VARS='V=1' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/ports/libxml2/libxml2.rmpatch b/ports/libxml2/libxml2.rmpatch new file mode 100644 index 00000000..869c8895 --- /dev/null +++ b/ports/libxml2/libxml2.rmpatch @@ -0,0 +1,3 @@ +rm -rf -- 'include/libxml/xmlversion.h' +rm -rf -- 'libxml2.spec' +rm -rf -- 'python/setup.py' diff --git a/ports/libz/libz.port b/ports/libz/libz.port new file mode 100644 index 00000000..47d28eda --- /dev/null +++ b/ports/libz/libz.port @@ -0,0 +1,11 @@ +NAME=libz +BUILD_LIBRARIES= +VERSION=1.2.8.2015.12.26 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=abcc2831b7a0e891d0875fa852e9b9510b420d843d3d20aad010f65493fe4f7b +UPSTREAM_SITE=https://pub.sortix.org/libz/release +UPSTREAM_ARCHIVE=$ARCHIVE +LICENSE=zlib +BUILD_SYSTEM=configure diff --git a/ports/lua/lua.patch b/ports/lua/lua.patch new file mode 100644 index 00000000..ab119565 --- /dev/null +++ b/ports/lua/lua.patch @@ -0,0 +1,219 @@ +diff -Paur --no-dereference -- lua.upstream/Makefile lua/Makefile +--- lua.upstream/Makefile ++++ lua/Makefile +@@ -10,13 +10,16 @@ + # so take care if INSTALL_TOP is not an absolute path. See the local target. + # You may want to make INSTALL_LMOD and INSTALL_CMOD consistent with + # LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h. +-INSTALL_TOP= /usr/local +-INSTALL_BIN= $(INSTALL_TOP)/bin +-INSTALL_INC= $(INSTALL_TOP)/include +-INSTALL_LIB= $(INSTALL_TOP)/lib +-INSTALL_MAN= $(INSTALL_TOP)/man/man1 +-INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V +-INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V ++PREFIX?=/usr/local ++EXEC_PREFIX?=$(EXEC_PREFIX) ++BINDIR?=$(EXEC_PREFIX)/bin ++INCLUDEDIR?=$(PREFIX)/include ++LIBDIR?=$(EXEC_PREFIX)/lib ++DATAROOTDIR?=$(PREFIX)/share ++DATADIR?=$(DATAROOTDIR) ++MANDIR?=$(DATAROOTDIR)/man ++LMODDIR=$(DATADIR)/lua/$V ++CMODDIR?=$(LIBDIR)/lua/$V + + # How to install. If your install program does not support "-p", then + # you may have to run ranlib on the installed liblua.a. +@@ -49,29 +52,31 @@ + R= $V.4 + + # Targets start here. +-all: $(PLAT) ++all: ++ cd src && $(MAKE) posix LMODDIR=$(LMODDIR) CMODDIR=$(CMODDIR) ++ ++lib: ++ cd src && $(MAKE) posix-lib LMODDIR=$(LMODDIR) CMODDIR=$(CMODDIR) + + $(PLATS) clean: +- cd src && $(MAKE) $@ ++ cd src && $(MAKE) $@ LMODDIR=$(LMODDIR) CMODDIR=$(CMODDIR) + + test: dummy + src/lua -v + +-install: dummy +- cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) +- cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) +- cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) +- cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) +- cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN) +- +-uninstall: +- cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN) +- cd src && cd $(INSTALL_INC) && $(RM) $(TO_INC) +- cd src && cd $(INSTALL_LIB) && $(RM) $(TO_LIB) +- cd doc && cd $(INSTALL_MAN) && $(RM) $(TO_MAN) +- +-local: +- $(MAKE) install INSTALL_TOP=../install ++install: all ++ $(MKDIR) $(DESTDIR)$(BINDIR) ++ cd src && $(INSTALL_EXEC) $(TO_BIN) $(DESTDIR)$(BINDIR) ++ $(MKDIR) $(DESTDIR)$(MANDIR)/man1 ++ cd doc && $(INSTALL_DATA) $(TO_MAN) $(DESTDIR)$(MANDIR)/man1 ++ $(MKDIR) $(DESTDIR)$(LMODDIR) ++ $(MKDIR) $(DESTDIR)$(CMODDIR) ++ ++install-lib: ++ $(MKDIR) $(DESTDIR)$(INCLUDEDIR) ++ cd src && $(INSTALL_DATA) $(TO_INC) $(DESTDIR)$(INCLUDEDIR) ++ $(MKDIR) $(DESTDIR)$(LIBDIR) ++ cd src && $(INSTALL_DATA) $(TO_LIB) $(DESTDIR)$(LIBDIR) + + none: + @echo "Please do 'make PLATFORM' where PLATFORM is one of these:" +diff -Paur --no-dereference -- lua.upstream/src/ldo.c lua/src/ldo.c +--- lua.upstream/src/ldo.c ++++ lua/src/ldo.c +@@ -62,9 +62,9 @@ + + #elif defined(LUA_USE_POSIX) /* }{ */ + +-/* in POSIX, try _longjmp/_setjmp (more efficient) */ +-#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +-#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } ++/* in POSIX, try siglongjmp/sigsetjmp (more efficient) */ ++#define LUAI_THROW(L,c) siglongjmp((c)->b, 1) ++#define LUAI_TRY(L,c,a) if (sigsetjmp((c)->b, 0) == 0) { a } + #define luai_jmpbuf jmp_buf + + #else /* }{ */ +@@ -72,7 +72,7 @@ + /* ISO C handling with long jumps */ + #define LUAI_THROW(L,c) longjmp((c)->b, 1) + #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +-#define luai_jmpbuf jmp_buf ++#define luai_jmpbuf sigjmp_buf + + #endif /* } */ + +diff -Paur --no-dereference -- lua.upstream/src/lmathlib.c lua/src/lmathlib.c +--- lua.upstream/src/lmathlib.c ++++ lua/src/lmathlib.c +@@ -24,7 +24,7 @@ + + + #if !defined(l_rand) /* { */ +-#if defined(LUA_USE_POSIX) ++#if defined(LUA_USE_XSI) + #define l_rand() random() + #define l_srand(x) srandom(x) + #define L_RANDMAX 2147483647 /* (2^31 - 1), following POSIX */ +diff -Paur --no-dereference -- lua.upstream/src/luac.c lua/src/luac.c +--- lua.upstream/src/luac.c ++++ lua/src/luac.c +@@ -265,7 +265,7 @@ + case LUA_TNUMFLT: + { + char buff[100]; +- sprintf(buff,LUA_NUMBER_FMT,fltvalue(o)); ++ snprintf(buff,sizeof(buff),LUA_NUMBER_FMT,fltvalue(o)); + printf("%s",buff); + if (buff[strspn(buff,"-0123456789")]=='\0') printf(".0"); + break; +diff -Paur --no-dereference -- lua.upstream/src/luaconf.h lua/src/luaconf.h +--- lua.upstream/src/luaconf.h ++++ lua/src/luaconf.h +@@ -200,9 +200,6 @@ + + #else /* }{ */ + +-#define LUA_ROOT "/usr/local/" +-#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" +-#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" + #define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ +diff -Paur --no-dereference -- lua.upstream/src/Makefile lua/src/Makefile +--- lua.upstream/src/Makefile ++++ lua/src/Makefile +@@ -6,22 +6,19 @@ + # Your platform. See PLATS for possible values. + PLAT= none + +-CC= gcc -std=gnu99 +-CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) +-LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) +-LIBS= -lm $(SYSLIBS) $(MYLIBS) ++CC?= gcc ++CFLAGS?= -O2 ++LDFLAGS?= ++LIBS?= ++ ++CFLAGS+= -std=c99 -Wall -Wextra -DLUA_COMPAT_5_2 \ ++ -DLUA_LDIR=\"$(LMODDIR)\" -DLUA_CDIR=\"$(CMODDIR)\" $(SYSCFLAGS) ++LIBS+= -llua -lm $(SYSLIBS) + +-AR= ar rcu +-RANLIB= ranlib ++AR?= ar ++RANLIB?= ranlib + RM= rm -f + +-SYSCFLAGS= +-SYSLDFLAGS= +-SYSLIBS= +- +-MYCFLAGS= +-MYLDFLAGS= +-MYLIBS= + MYOBJS= + + # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= +@@ -43,7 +40,7 @@ + LUAC_O= luac.o + + ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) +-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) ++ALL_T= $(LUA_T) $(LUAC_T) + ALL_A= $(LUA_A) + + # Targets start here. +@@ -56,17 +53,17 @@ + a: $(ALL_A) + + $(LUA_A): $(BASE_O) +- $(AR) $@ $(BASE_O) ++ $(AR) rcu $@ $(BASE_O) + $(RANLIB) $@ + +-$(LUA_T): $(LUA_O) $(LUA_A) +- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) ++$(LUA_T): $(LUA_O) ++ $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LIBS) + +-$(LUAC_T): $(LUAC_O) $(LUA_A) +- $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) ++$(LUAC_T): $(LUAC_O) ++ $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LIBS) + + clean: +- $(RM) $(ALL_T) $(ALL_O) ++ $(RM) $(ALL_T) $(ALL_A) $(ALL_O) + + depend: + @$(CC) $(CFLAGS) -MM l*.c +@@ -119,7 +116,10 @@ + $(MAKE) "LUAC_T=luac.exe" luac.exe + + posix: +- $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX" ++ $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_READLINE" SYSLIBS="-lreadline -lterminfo" ++ ++posix-lib: ++ $(MAKE) $(ALL_A) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_READLINE" SYSLIBS="-lreadline -lterminfo" + + solaris: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_REENTRANT" SYSLIBS="-ldl" diff --git a/ports/lua/lua.port b/ports/lua/lua.port new file mode 100644 index 00000000..3a88b344 --- /dev/null +++ b/ports/lua/lua.port @@ -0,0 +1,10 @@ +NAME=lua +BUILD_LIBRARIES='libreadline liblua' +VERSION=5.3.4 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=f681aa518233bc407e23acf0f5887c884f17436f000d453b2491a9f11a52400c +UPSTREAM_SITE=https://www.lua.org/ftp +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=makefile diff --git a/ports/m4/m4.patch b/ports/m4/m4.patch new file mode 100644 index 00000000..e708dd2a --- /dev/null +++ b/ports/m4/m4.patch @@ -0,0 +1,270 @@ +diff -Paur --no-dereference -- m4.upstream/build-aux/config.sub m4/build-aux/config.sub +--- m4.upstream/build-aux/config.sub ++++ m4/build-aux/config.sub +@@ -1305,7 +1305,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- m4.upstream/lib/fcntl.c m4/lib/fcntl.c +--- m4.upstream/lib/fcntl.c ++++ m4/lib/fcntl.c +@@ -178,7 +178,7 @@ + result = dupfd (fd, target, 0); + break; + } +-#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR ++#elif (FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR) && !defined(__sortix__) + case F_DUPFD: + { + int target = va_arg (arg, int); +diff -Paur --no-dereference -- m4.upstream/lib/freadahead.c m4/lib/freadahead.c +--- m4.upstream/lib/freadahead.c ++++ m4/lib/freadahead.c +@@ -1,5 +1,5 @@ + /* Retrieve information about a FILE stream. +- Copyright (C) 2007-2011 Free Software Foundation, Inc. ++ Copyright (C) 2007-2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by +@@ -22,6 +22,10 @@ + #include + #include "stdio-impl.h" + ++#if defined(__sortix__) ++#include ++#endif ++ + size_t + freadahead (FILE *fp) + { +@@ -48,6 +52,10 @@ + /* equivalent to + (fp->_ungetc_count == 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount) */ + return (fp->_rcount > 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount); ++#elif defined __minix /* Minix */ ++ if ((fp_->_flags & _IOWRITING) != 0) ++ return 0; ++ return fp_->_count; + #elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ + if ((fp_->_flag & _IOWRT) != 0) + return 0; +@@ -76,6 +84,14 @@ + return (fp->__pushed_back + ? fp->__get_limit - fp->__pushback_bufp + 1 + : fp->__get_limit - fp->__bufp); ++#elif defined EPLAN9 /* Plan9 */ ++ if (fp->state == 4 /* WR */ || fp->rp >= fp->wp) ++ return 0; ++ return fp->wp - fp->rp; ++#elif defined __sortix__ ++ if ( !(fp->flags & _FILE_LAST_READ) ) ++ return 0; ++ return fp->amount_input_buffered - fp->offset_input_buffer; + #elif defined SLOW_BUT_NO_HACKS /* users can define this */ + abort (); + return 0; +diff -Paur --no-dereference -- m4.upstream/lib/fseeko.c m4/lib/fseeko.c +--- m4.upstream/lib/fseeko.c ++++ m4/lib/fseeko.c +@@ -1,5 +1,5 @@ + /* An fseeko() function that, together with fflush(), is POSIX compliant. +- Copyright (C) 2007-2011 Free Software Foundation, Inc. ++ Copyright (C) 2007-2012 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by +@@ -12,8 +12,7 @@ + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along +- with this program; if not, write to the Free Software Foundation, +- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ ++ with this program; if not, see . */ + + #include + +@@ -32,6 +31,14 @@ + # undef fseek + # define fseeko fseek + #endif ++#if _GL_WINDOWS_64_BIT_OFF_T ++# undef fseeko ++# if HAVE__FSEEKI64 /* msvc, mingw64 */ ++# define fseeko _fseeki64 ++# else /* mingw */ ++# define fseeko fseeko64 ++# endif ++#endif + { + #if LSEEK_PIPE_BROKEN + /* mingw gives bogus answers rather than failure on non-seekable files. */ +@@ -69,6 +76,9 @@ + && fp->_rcount == 0 + && fp->_wcount == 0 + && fp->_ungetc_count == 0) ++#elif defined __minix /* Minix */ ++ if (fp_->_ptr == fp_->_buf ++ && (fp_->_ptr == NULL || fp_->_count == 0)) + #elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ + if (fp_->_ptr == fp_->_base + && (fp_->_ptr == NULL || fp_->_cnt == 0)) +@@ -86,18 +96,19 @@ + && fp->__get_limit == fp->__bufp + && fp->__put_limit == fp->__bufp + && !fp->__pushed_back) ++#elif defined EPLAN9 /* Plan9 */ ++ if (fp->rp == fp->buf ++ && fp->wp == fp->buf) ++#elif defined __sortix__ ++ if (0) /* wtf is this shit - sortix handles fseeko just fine. */ + #else + #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib." + #endif + { +- /* We get here when an fflush() call immediately preceded this one. We +- know there are no buffers. +- POSIX requires us to modify the file descriptor's position. +- But we cannot position beyond end of file here. */ +- off_t pos = +- lseek (fileno (fp), +- whence == SEEK_END && offset > 0 ? 0 : offset, +- whence); ++ /* We get here when an fflush() call immediately preceded this one (or ++ if ftell() has created buffers but no I/O has occurred on a ++ newly-opened stream). We know there are no buffers. */ ++ off_t pos = lseek (fileno (fp), offset, whence); + if (pos == -1) + { + #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ +@@ -108,6 +119,7 @@ + + #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + fp->_flags &= ~_IO_EOF_SEEN; ++ fp->_offset = pos; + #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ + # if defined __CYGWIN__ + /* fp_->_offset is typed as an integer. */ +@@ -137,10 +149,7 @@ + fp->__offset = pos; + fp->__eof = 0; + #endif +- /* If we were not requested to position beyond end of file, we're +- done. */ +- if (!(whence == SEEK_END && offset > 0)) +- return 0; ++ return 0; + } + return fseeko (fp, offset, whence); + } +diff -Paur --no-dereference -- m4.upstream/lib/sigaction.c m4/lib/sigaction.c +--- m4.upstream/lib/sigaction.c ++++ m4/lib/sigaction.c +@@ -19,6 +19,7 @@ + + /* Specification. */ + #include ++#define NSIG SIG_MAX_NUM + + #include + #include +@@ -51,9 +52,11 @@ + with this module should stick with only sigaction(). */ + + /* Check some of our assumptions. */ ++#if !defined(__sortix__) + #if defined SIGCHLD || defined HAVE_SIGALTSTACK || defined HAVE_SIGINTERRUPT + # error "Revisit the assumptions made in the sigaction module" + #endif ++#endif + + /* Out-of-range substitutes make a good fallback for uncatchable + signals. */ +diff -Paur --no-dereference -- m4.upstream/lib/spawn_faction_addclose.c m4/lib/spawn_faction_addclose.c +--- m4.upstream/lib/spawn_faction_addclose.c ++++ m4/lib/spawn_faction_addclose.c +@@ -22,7 +22,9 @@ + #include + #include + +-#if !_LIBC ++#if defined(__sortix__) ++# define __sysconf(open_max) sysconf (open_max) ++#elif !_LIBC + # define __sysconf(open_max) getdtablesize () + #endif + +diff -Paur --no-dereference -- m4.upstream/lib/spawn_faction_adddup2.c m4/lib/spawn_faction_adddup2.c +--- m4.upstream/lib/spawn_faction_adddup2.c ++++ m4/lib/spawn_faction_adddup2.c +@@ -22,7 +22,9 @@ + #include + #include + +-#if !_LIBC ++#if defined(__sortix__) ++# define __sysconf(open_max) sysconf (open_max) ++#elif !_LIBC + # define __sysconf(open_max) getdtablesize () + #endif + +diff -Paur --no-dereference -- m4.upstream/lib/spawn_faction_addopen.c m4/lib/spawn_faction_addopen.c +--- m4.upstream/lib/spawn_faction_addopen.c ++++ m4/lib/spawn_faction_addopen.c +@@ -22,7 +22,9 @@ + #include + #include + +-#if !_LIBC ++#if defined(__sortix__) ++# define __sysconf(open_max) sysconf (open_max) ++#elif !_LIBC + # define __sysconf(open_max) getdtablesize () + #endif + +diff -Paur --no-dereference -- m4.upstream/lib/spawni.c m4/lib/spawni.c +--- m4.upstream/lib/spawni.c ++++ m4/lib/spawni.c +@@ -223,16 +223,20 @@ + } + #endif + ++#if !defined(__sortix__) + /* Set the process group ID. */ + if ((flags & POSIX_SPAWN_SETPGROUP) != 0 + && setpgid (0, attrp->_pgrp) != 0) + _exit (SPAWN_ERROR); ++#endif + ++#if !defined(__sortix__) + /* Set the effective user and group IDs. */ + if ((flags & POSIX_SPAWN_RESETIDS) != 0 + && (local_seteuid (getuid ()) != 0 + || local_setegid (getgid ()) != 0)) + _exit (SPAWN_ERROR); ++#endif + + /* Execute the file actions. */ + if (file_actions != NULL) +diff -Paur --no-dereference -- m4.upstream/lib/stdio.in.h m4/lib/stdio.in.h +--- m4.upstream/lib/stdio.in.h ++++ m4/lib/stdio.in.h +@@ -158,11 +158,13 @@ + "use gnulib module fflush for portable POSIX compliance"); + #endif + ++#if !defined(__sortix__) + /* It is very rare that the developer ever has full control of stdin, + so any use of gets warrants an unconditional warning. Assume it is + always declared, since it is required by C89. */ + #undef gets + _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); ++#endif + + #if @GNULIB_FOPEN@ + # if @REPLACE_FOPEN@ diff --git a/ports/m4/m4.port b/ports/m4/m4.port new file mode 100644 index 00000000..b5ff5382 --- /dev/null +++ b/ports/m4/m4.port @@ -0,0 +1,11 @@ +NAME=m4 +BUILD_LIBRARIES='libiconv? gettext?' +VERSION=1.4.16 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=d5b5d51cf8f5b18f3bac39bc2f6b1e61f34d400136ae1a87d075e26a38028d5d +UPSTREAM_SITE=https://ftp.gnu.org/gnu/m4 +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_VARS='gt_cv_locale_fr=false gt_cv_locale_ja=false gt_cv_locale_fr_utf8=false gt_cv_locale_ja_utf8=false gt_cv_locale_tr_utf8=false gt_cv_locale_zh_CN=false' diff --git a/ports/make/make.patch b/ports/make/make.patch new file mode 100644 index 00000000..b7f8a1f2 --- /dev/null +++ b/ports/make/make.patch @@ -0,0 +1,169 @@ +diff -Paur --no-dereference -- make.upstream/config/config.sub make/config/config.sub +--- make.upstream/config/config.sub ++++ make/config/config.sub +@@ -1356,7 +1356,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- make.upstream/dir.c make/dir.c +--- make.upstream/dir.c ++++ make/dir.c +@@ -19,6 +19,8 @@ + #include "filedef.h" + #include "dep.h" + ++#include ++ + #ifdef HAVE_DIRENT_H + # include + # define NAMLEN(dirent) strlen((dirent)->d_name) +@@ -1142,7 +1144,7 @@ + /* The glob interface wants a 'struct dirent', so mock one up. */ + struct dirent *d; + unsigned int len = df->length + 1; +- unsigned int sz = sizeof (*d) - sizeof (d->d_name) + len; ++ unsigned int sz = offsetof(struct dirent, d_name) + len; + if (sz > bufsz) + { + bufsz *= 2; +diff -Paur --no-dereference -- make.upstream/function.c make/function.c +--- make.upstream/function.c ++++ make/function.c +@@ -2095,27 +2095,23 @@ + char *rp; + struct stat st; + PATH_VAR (in); +- PATH_VAR (out); + + strncpy (in, path, len); + in[len] = '\0'; + +-#ifdef HAVE_REALPATH +- ENULLLOOP (rp, realpath (in, out)); +-#else +- rp = abspath (in, out); +-#endif ++ ENULLLOOP (rp, realpath (in, NULL)); + + if (rp) + { + int r; +- EINTRLOOP (r, stat (out, &st)); ++ EINTRLOOP (r, stat (rp, &st)); + if (r == 0) + { +- o = variable_buffer_output (o, out, strlen (out)); ++ o = variable_buffer_output (o, rp, strlen (rp)); + o = variable_buffer_output (o, " ", 1); + doneany = 1; + } ++ free (rp); + } + } + } +diff -Paur --no-dereference -- make.upstream/getloadavg.c make/getloadavg.c +--- make.upstream/getloadavg.c ++++ make/getloadavg.c +@@ -78,9 +78,11 @@ + /* Both the Emacs and non-Emacs sections want this. Some + configuration files' definitions for the LOAD_AVE_CVT macro (like + sparc.h's) use macros like FSCALE, defined here. */ ++#ifdef HAVE_SYS_PARAM_H + #if defined (unix) || defined (__unix) + # include + #endif ++#endif + + + /* Exclude all the code except the test program at the end +diff -Paur --no-dereference -- make.upstream/job.c make/job.c +--- make.upstream/job.c ++++ make/job.c +@@ -67,6 +67,11 @@ + char default_shell[] = ""; + int batch_mode_shell = 0; + ++#elif defined (__sortix__) ++ ++char default_shell[] = "sh"; ++int batch_mode_shell = 0; ++ + #else + + char default_shell[] = "/bin/sh"; +diff -Paur --no-dereference -- make.upstream/main.c make/main.c +--- make.upstream/main.c ++++ make/main.c +@@ -2393,9 +2393,9 @@ + if (restarts) + { + char *b = alloca (40); +- sprintf (b, "MAKE_RESTARTS=%s%u", ++ sprintf (b, "%s%u", + OUTPUT_IS_TRACED () ? "-" : "", restarts); +- putenv (b); ++ setenv ("MAKE_RESTARTS", b, 1); + } + + fflush (stdout); +diff -Paur --no-dereference -- make.upstream/misc.c make/misc.c +--- make.upstream/misc.c ++++ make/misc.c +@@ -710,6 +710,9 @@ + unsigned int + get_path_max (void) + { ++#if defined(__sortix__) ++ return 32768; ++#else + static unsigned int value; + + if (value == 0) +@@ -722,5 +725,6 @@ + } + + return value; ++#endif + } + #endif +diff -Paur --no-dereference -- make.upstream/output.c make/output.c +--- make.upstream/output.c ++++ make/output.c +@@ -278,6 +278,10 @@ + static void * + acquire_semaphore (void) + { ++#if defined(__sortix__) ++ static int foo; ++ return &foo; ++#else + static struct flock fl; + + fl.l_type = F_WRLCK; +@@ -288,16 +292,21 @@ + return &fl; + perror ("fcntl()"); + return NULL; ++#endif + } + + /* Release the lock for writing output. */ + static void + release_semaphore (void *sem) + { ++#if defined(__sortix__) ++ (void) sem; ++#else + struct flock *flp = (struct flock *)sem; + flp->l_type = F_UNLCK; + if (fcntl (sync_handle, F_SETLKW, flp) == -1) + perror ("fcntl()"); ++#endif + } + + /* Returns a file descriptor to a temporary file. The file is automatically diff --git a/ports/make/make.port b/ports/make/make.port new file mode 100644 index 00000000..7b14b183 --- /dev/null +++ b/ports/make/make.port @@ -0,0 +1,11 @@ +NAME=make +BUILD_LIBRARIES='libiconv? libintl?' +VERSION=4.0 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.bz2 +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=e60686c7afede62cc8c86ad3012cf081ea4887daf9d223ce7115703b2bb2dbdb +UPSTREAM_SITE=https://ftp.gnu.org/gnu/make +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +POST_INSTALL=../make.post-install diff --git a/ports/make/make.post-install b/ports/make/make.post-install new file mode 100755 index 00000000..73c69a17 --- /dev/null +++ b/ports/make/make.post-install @@ -0,0 +1,3 @@ +#!/bin/sh -e +ln "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/make" "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/gmake" +ln "$TIX_INSTALL_DIR$PREFIX/share/man/man1/make.1" "$TIX_INSTALL_DIR$PREFIX/share/man/man1/gmake.1" diff --git a/ports/mdocml/mdocml.patch b/ports/mdocml/mdocml.patch new file mode 100644 index 00000000..9cc8d3a4 --- /dev/null +++ b/ports/mdocml/mdocml.patch @@ -0,0 +1,739 @@ +diff -Paur --no-dereference -- mdocml.upstream/apropos.1 mdocml/apropos.1 +--- mdocml.upstream/apropos.1 ++++ mdocml/apropos.1 +@@ -74,7 +74,7 @@ + If the standard output is a terminal device and + .Fl c + is not specified, use +-.Xr more 1 ++.Xr pager 1 + to paginate them. + In + .Fl a +@@ -93,7 +93,7 @@ + In + .Fl a + mode, copy the formatted manual pages to the standard output without using +-.Xr more 1 ++.Xr pager 1 + to paginate them. + .It Fl f + Search for all words in +@@ -342,7 +342,7 @@ + Any non-empty value of the environment variable + .Ev MANPAGER + will be used instead of the standard pagination program, +-.Xr more 1 . ++.Xr pager 1 . + .It Ev MANPATH + The standard search path used by + .Xr man 1 +@@ -365,7 +365,7 @@ + .Ev MANPAGER + is not defined. + If neither PAGER nor MANPAGER is defined, +-.Pa /usr/bin/more Fl s ++.Pa pager Fl R + will be used. + .El + .Sh FILES +diff -Paur --no-dereference -- mdocml.upstream/compat_fts.c mdocml/compat_fts.c +--- mdocml.upstream/compat_fts.c ++++ mdocml/compat_fts.c +@@ -100,7 +100,12 @@ + * Start out with 1K of path space, and enough, in any case, + * to hold the user's paths. + */ ++ /* PATCH: Sortix doesn't have PATH_MAX. */ ++#ifdef PATH_MAX + if (fts_palloc(sp, MAXIMUM(fts_maxarglen(argv), PATH_MAX))) ++#else ++ if (fts_palloc(sp, MAXIMUM(fts_maxarglen(argv), 32768))) ++#endif + goto mem1; + + /* Allocate/initialize root's parent. */ +@@ -416,7 +421,8 @@ + size_t dlen, len, maxlen; + int nitems, cderrno, descend, level, doadjust; + int saved_errno; +- char *cp; ++ /* PATCH: -Wmaybe-uninitialized */ ++ char *cp = NULL; + + /* Set current node pointer. */ + cur = sp->fts_cur; +diff -Paur --no-dereference -- mdocml.upstream/configure mdocml/configure +--- mdocml.upstream/configure ++++ mdocml/configure +@@ -16,8 +16,7 @@ + + set -e + +-[ -e config.log ] && mv config.log config.log.old +-[ -e config.h ] && mv config.h config.h.old ++# PATCH: Don't clutter the tree with useless old config files. + + # Output file descriptor usage: + # 1 (stdout): config.h, Makefile.local +@@ -33,10 +32,12 @@ + + OSNAME= + +-CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make -f -` +-CFLAGS="-g -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings" ++# PATCH: Respect CC and CFLAGS from the environment. ++[ -z "${CC+x}" ] && CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | ${MAKE:-make} -f -` ++[ -z "${CFLAGS+x}" ] && CFLAGS="-g" ++CFLAGS="$CFLAGS -std=gnu11 -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings" + DBLIB= +-STATIC="-static" ++STATIC= + + BUILD_DB=1 + BUILD_CGI=0 +@@ -60,13 +61,17 @@ + HAVE_OHASH= + HAVE_MANPATH= + +-PREFIX="/usr/local" +-BINDIR= +-SBINDIR= +-INCLUDEDIR= +-LIBDIR= +-MANDIR= +-EXAMPLEDIR= ++# PATCH: Properly determine these locations with the below options. ++unset PREFIX ++unset EXEC_PREFIX ++unset BINDIR ++unset SBINDIR ++unset DATAROOTDIR ++unset INCLUDEDIR ++unset LIBDIR ++unset MANDIR ++unset SYSCONFDIR ++unset EXAMPLEDIR + HOMEBREWDIR= + + WWWPREFIX="/var/www" +@@ -89,18 +94,63 @@ + INSTALL_MAN= + INSTALL_DATA= + +-# --- manual settings from configure.local ----------------------------- ++# PATCH: Implement standard configure script options. ++# --- parse command line options --------------------------------------- + +-if [ -e ./configure.local ]; then +- echo "configure.local: reading..." 1>&2 +- echo "configure.local: reading..." 1>&3 +- cat ./configure.local 1>&3 +- . ./configure.local +-else +- echo "configure.local: no (fully automatic configuration)" 1>&2 +- echo "configure.local: no (fully automatic configuration)" 1>&3 +-fi +-echo 1>&3 ++dashdash= ++previous_option= ++option_checking=true ++for argument do ++ if test -n "$previous_option"; then ++ eval $previous_option=\$argument ++ previous_option= ++ continue ++ fi ++ ++ case $argument in ++ *=?*) parameter=$(expr "X$argument" : '[^=]*=\(.*\)') ;; ++ *=) parameter= ;; ++ *) parameter=yes ;; ++ esac ++ ++ case $dashdash$argument in ++ --) dashdash=yes ;; ++ --bindir=*) BINDIR=$parameter ;; ++ --bindir) previous_option=BINDIR ;; ++ --datarootdir=*) DATAROOTDIR=$parameter ;; ++ --datarootdir) previous_option=DATAROOTDIR ;; ++ --exampledir=*) EXAMPLEDIR=$parameter ;; ++ --exampledir) previous_option=EXAMPLEDIR ;; ++ --exec-prefix=*) EXEC_PREFIX=$parameter ;; ++ --exec-prefix) previous_option=EXEC_PREFIX ;; ++ --includedir=*) INCLUDEDIR=$parameter ;; ++ --includedir) previous_option=INCLUDEDIR ;; ++ --libdir=*) LIBDIR=$parameter ;; ++ --libdir) previous_option=LIBDIR ;; ++ --mandir=*) MANDIR=$parameter ;; ++ --mandir) previous_option=MANDIR ;; ++ --prefix=*) PREFIX=$parameter ;; ++ --prefix) previous_option=PREFIX ;; ++ --sbindir) previous_option=SBINDIR ;; ++ --sbindir=*) SBINDIR=$parameter ;; ++ --sysconfdir) previous_option=SYSCONFDIR ;; ++ --sysconfdir=*) SYSCONFDIR=$parameter ;; ++ -h | --help | --help=*) exit 0 ;; ++ -V | --version) exit 0 ;; ++ *) echo "$0: ignoring unexpected operand $argument" >&2 ++ esac ++done ++ ++[ -z ${PREFIX+x} ] && PREFIX="/usr/local" ++[ -z ${EXEC_PREFIX+x} ] && EXEC_PREFIX="$PREFIX" ++[ -z ${BINDIR+x} ] && BINDIR="$EXEC_PREFIX/bin" ++[ -z ${SBINDIR+x} ] && SBINDIR="$EXEC_PREFIX/sbin" ++[ -z ${SYSCONFDIR+x} ] && SYSCONFDIR="$PREFIX/etc" ++[ -z ${DATAROOTDIR+x} ] && DATAROOTDIR="$PREFIX/share" ++[ -z ${INCLUDEDIR+x} ] && INCLUDEDIR="$PREFIX/include" ++[ -z ${LIBDIR+x} ] && LIBDIR="$EXEC_PREFIX/lib" ++[ -z ${MANDIR+x} ] && MANDIR="$DATAROOTDIR/man" ++[ -z ${EXAMPLEDIR+x} ] && EXAMPLEDIR="${DATAROOTDIR}/examples/mandoc" + + # --- tests for config.h ---------------------------------------------- + +@@ -135,19 +185,20 @@ + return 1 + fi + +- if ./test-${1} 1>&3 2>&3; then ++ # PATCH: Tests can't be run when cross-compiling. ++ #if ./test-${1} 1>&3 2>&3; then + echo "${1}: yes" 1>&2 + echo "${1}: yes" 1>&3 + echo 1>&3 + eval HAVE_${2}=1 + rm "test-${1}" + return 0 +- else +- echo "${1}: execution failed with $?" 1>&3 +- echo 1>&3 +- rm "test-${1}" +- return 1 +- fi ++ #else ++ # echo "${1}: execution failed with $?" 1>&3 ++ # echo 1>&3 ++ # rm "test-${1}" ++ # return 1 ++ #fi + } + + # Run a complete autoconfiguration test, including the check for +@@ -239,11 +290,12 @@ + # --- manpath --- + if ismanual manpath "${HAVE_MANPATH}"; then + : +-elif manpath 1>&3 2>&3; then +- echo "manpath: yes" 1>&2 +- echo "manpath: yes" 1>&3 +- echo 1>&3 +- HAVE_MANPATH=1 ++# PATCH: The manpath(1) in PATH doesn't make sense when cross-compiling. ++#elif manpath 1>&3 2>&3; then ++# echo "manpath: yes" 1>&2 ++# echo "manpath: yes" 1>&3 ++# echo 1>&3 ++# HAVE_MANPATH=1 + else + echo "manpath: no" 1>&2 + echo "manpath: no" 1>&3 +@@ -298,6 +350,8 @@ + #define BINM_WHATIS "${BINM_WHATIS}" + #define BINM_MAKEWHATIS "${BINM_MAKEWHATIS}" + ++#define SYSCONFDIR "${SYSCONFDIR}" ++ + #if !defined(__BEGIN_DECLS) + # ifdef __cplusplus + # define __BEGIN_DECLS extern "C" { +@@ -352,20 +406,14 @@ + + exec > Makefile.local + +-[ -z "${BINDIR}" ] && BINDIR="${PREFIX}/bin" +-[ -z "${SBINDIR}" ] && SBINDIR="${PREFIX}/sbin" +-[ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include/mandoc" +-[ -z "${LIBDIR}" ] && LIBDIR="${PREFIX}/lib/mandoc" +-[ -z "${MANDIR}" ] && MANDIR="${PREFIX}/man" +-[ -z "${EXAMPLEDIR}" ] && EXAMPLEDIR="${PREFIX}/share/examples/mandoc" +- + [ -z "${HTDOCDIR}" ] && HTDOCDIR="${WWWPREFIX}/htdocs" + [ -z "${CGIBINDIR}" ] && CGIBINDIR="${WWWPREFIX}/cgi-bin" + +-[ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555" +-[ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0444" +-[ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0444" +-[ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0444" ++# PATCH: System files should be writable by root. ++[ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0755" ++[ -z "${INSTALL_LIB}" ] && INSTALL_LIB="${INSTALL} -m 0644" ++[ -z "${INSTALL_MAN}" ] && INSTALL_MAN="${INSTALL} -m 0644" ++[ -z "${INSTALL_DATA}" ] && INSTALL_DATA="${INSTALL} -m 0644" + + if [ ${BUILD_DB} -eq 0 -a ${BUILD_CGI} -gt 0 ]; then + echo "BUILD_CGI=0 (no BUILD_DB)" 1>&2 +@@ -391,6 +439,7 @@ + INCLUDEDIR = ${INCLUDEDIR} + LIBDIR = ${LIBDIR} + MANDIR = ${MANDIR} ++SYSCONFDIR = ${SYSCONFDIR} + EXAMPLEDIR = ${EXAMPLEDIR} + WWWPREFIX = ${WWWPREFIX} + HTDOCDIR = ${HTDOCDIR} +@@ -417,4 +466,15 @@ + echo "Makefile.local: written" 1>&2 + echo "Makefile.local: written" 1>&3 + ++# PATCH: Make default configuration file so man works by default. ++exec > man.conf.default ++cat << __HEREDOC__ ++_version BSD.2 ++_default ${MANDIR}/ ++_whatdb ${MANDIR}/ ++__HEREDOC__ ++ ++echo "man.conf.default: written" 1>&2 ++echo "man.conf.default: written" 1>&3 ++ + exit 0 +diff -Paur --no-dereference -- mdocml.upstream/eqn.c mdocml/eqn.c +--- mdocml.upstream/eqn.c ++++ mdocml/eqn.c +@@ -697,7 +697,8 @@ + { + char sym[64]; + struct eqn_box *cur; +- const char *start; ++ /* PATCH: -Wmaybe-uninitialized */ ++ const char *start = NULL; + char *p; + size_t i, sz; + enum eqn_tok tok, subtok; +diff -Paur --no-dereference -- mdocml.upstream/main.c mdocml/main.c +--- mdocml.upstream/main.c ++++ mdocml/main.c +@@ -19,14 +19,16 @@ + #include "config.h" + + #include +-#include /* MACHINE */ + #include + + #include + #include + #include + #include ++/* PATCH: Sortix doesn't have glob.h at this time. */ ++#if defined(__has_include) && __has_include() + #include ++#endif + #include + #include + #include +@@ -531,10 +533,16 @@ + const char *sec, const char *arch, const char *name, + struct manpage **res, size_t *ressz) + { ++#if defined(__has_include) && __has_include() + glob_t globinfo; ++#endif + struct manpage *page; + char *file; ++#if defined(__has_include) && __has_include() + int form, globres; ++#else ++ int form; ++#endif + + form = FORM_SRC; + mandoc_asprintf(&file, "%s/man%s/%s.%s", +@@ -559,6 +567,7 @@ + free(file); + } + ++#if defined(__has_include) && __has_include() + mandoc_asprintf(&file, "%s/man%s/%s.*", + paths->paths[ipath], sec, name); + globres = glob(file, 0, NULL, &globinfo); +@@ -570,6 +579,7 @@ + file = mandoc_strdup(*globinfo.gl_pathv); + globfree(&globinfo); + if (globres != 0) ++#endif + return(0); + + found: +@@ -606,7 +616,38 @@ + *res = NULL; + *ressz = lastsz = 0; + while (argc) { +- for (ipath = 0; ipath < paths->sz; ipath++) { ++ /* PATCH: Support showing a manual page from the filesystem ++ instead of the database by doing so if the path ++ contains a directory separator. This behavior ++ matches that of the Linux man program. */ ++ if (strchr(*argv, '/')) { ++ if (access(*argv, R_OK) < 0) { ++ fprintf(stderr, ++ "%s: %s: %s\n", ++ progname, *argv, strerror(errno)); ++ } else { ++ struct manpage *page; ++ char *sec; ++ char *file; ++ file = mandoc_strdup(*argv); ++ sec = strrchr(file, '.'); ++ if (sec && sec[1]) ++ sec++; ++ else ++ sec = file + strlen(file) - 1; ++ *res = mandoc_reallocarray(*res, ++*ressz, ++ sizeof(struct manpage)); ++ page = *res + (*ressz - 1); ++ page->file = file; ++ page->names = NULL; ++ page->output = NULL; ++ page->ipath = 0; ++ page->bits = NAME_FILE & NAME_MASK; ++ page->sec = (*sec >= '1' && *sec <= '9') ? ++ *sec - '1' + 1 : 10; ++ page->form = FORM_SRC; ++ } ++ } else for (ipath = 0; ipath < paths->sz; ipath++) { + if (cfg->sec != NULL) { + if (fs_lookup(paths, ipath, cfg->sec, + cfg->arch, *argv, res, ressz) && +@@ -989,7 +1030,7 @@ + if (pager == NULL || *pager == '\0') + pager = getenv("PAGER"); + if (pager == NULL || *pager == '\0') +- pager = "/usr/bin/more -s"; ++ pager = "pager -R"; + cp = mandoc_strdup(pager); + + /* +@@ -1014,7 +1055,7 @@ + /* Hand over to the pager. */ + + execvp(argv[0], argv); +- fprintf(stderr, "%s: exec: %s\n", +- progname, strerror(errno)); ++ fprintf(stderr, "%s: exec: %s: %s\n", ++ progname, argv[0], strerror(errno)); + exit((int)MANDOCLEVEL_SYSERR); + } +diff -Paur --no-dereference -- mdocml.upstream/Makefile mdocml/Makefile +--- mdocml.upstream/Makefile ++++ mdocml/Makefile +@@ -294,6 +294,7 @@ + + distclean: clean + rm -f Makefile.local config.h config.h.old config.log config.log.old ++ rm -f man.conf.default + + clean: + rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS) +@@ -312,6 +313,8 @@ + mkdir -p $(DESTDIR)$(MANDIR)/man1 + mkdir -p $(DESTDIR)$(MANDIR)/man3 + mkdir -p $(DESTDIR)$(MANDIR)/man7 ++ mkdir -p $(DESTDIR)$(SYSCONFDIR) ++ mkdir -p $(DESTDIR)$(SYSCONFDIR)/default + $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR) + ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN) + $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR) +@@ -328,6 +331,7 @@ + $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7 + $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7 + $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR) ++ $(INSTALL_DATA) man.conf.default $(DESTDIR)$(SYSCONFDIR)/default/man.conf + + db-install: base-build + mkdir -p $(DESTDIR)$(BINDIR) +diff -Paur --no-dereference -- mdocml.upstream/man.1 mdocml/man.1 +--- mdocml.upstream/man.1 ++++ mdocml/man.1 +@@ -85,7 +85,7 @@ + for a description of the contents of this file. + .It Fl c + Copy the manual page to the standard output instead of using +-.Xr more 1 ++.Xr pager 1 + to paginate it. + This is done by default if the standard output is not a terminal device. + .It Fl f +@@ -359,7 +359,7 @@ + Any non-empty value of the environment variable + .Ev MANPAGER + will be used instead of the standard pagination program, +-.Xr more 1 . ++.Xr pager 1 . + .It Ev MANPATH + The standard search path used by + .Nm +@@ -381,7 +381,7 @@ + .Ev MANPAGER + is not defined. + If neither PAGER nor MANPAGER is defined, +-.Pa /usr/bin/more Fl s ++.Pa pager Fl R + will be used. + .El + .Sh FILES +diff -Paur --no-dereference -- mdocml.upstream/mandoc.1 mdocml/mandoc.1 +--- mdocml.upstream/mandoc.1 ++++ mdocml/mandoc.1 +@@ -58,13 +58,13 @@ + If the standard output is a terminal device and + .Fl c + is not specified, use +-.Xr more 1 ++.Xr pager 1 + to paginate the output, just like + .Xr man 1 + would. + .It Fl c + Copy the formatted manual pages to the standard output without using +-.Xr more 1 ++.Xr pager 1 + to paginate them. + This is the default. + It can be specified to override +@@ -500,13 +500,13 @@ + Any non-empty value of the environment variable + .Ev MANPAGER + will be used instead of the standard pagination program, +-.Xr more 1 . ++.Xr pager 1 . + .It Ev PAGER + Specifies the pagination program to use when + .Ev MANPAGER + is not defined. + If neither PAGER nor MANPAGER is defined, +-.Pa /usr/bin/more Fl s ++.Pa pager Fl R + will be used. + .El + .Sh EXIT STATUS +diff -Paur --no-dereference -- mdocml.upstream/mandocdb.c mdocml/mandocdb.c +--- mdocml.upstream/mandocdb.c ++++ mdocml/mandocdb.c +@@ -576,7 +576,9 @@ + static int + treescan(void) + { +- char buf[PATH_MAX]; ++ /* PATCH: Use realpath without a destination buffer so it's well-defined ++ when PATH_MAX doesn't exist, like on Sortix. */ ++ char *buf; + FTS *f; + FTSENT *ff; + struct mlink *mlink; +@@ -608,7 +610,7 @@ + * then get handled just like regular files. + */ + case FTS_SL: +- if (NULL == realpath(path, buf)) { ++ if (NULL == (buf = realpath(path, NULL))) { + if (warnings) + say(path, "&realpath"); + continue; +@@ -620,8 +622,10 @@ + ) { + if (warnings) say("", + "%s: outside base directory", buf); ++ free(buf); + continue; + } ++ free(buf); + /* Use logical inode to avoid mpages dupe. */ + if (-1 == stat(path, ff->fts_statp)) { + if (warnings) +@@ -782,7 +786,7 @@ + static void + filescan(const char *file) + { +- char buf[PATH_MAX]; ++ char *buf; + struct stat st; + struct mlink *mlink; + char *p, *start; +@@ -813,7 +817,7 @@ + * We have to resolve the file name to the real path + * in any case for the base directory check. + */ +- if (NULL == realpath(file, buf)) { ++ if (NULL == (buf = realpath(file, NULL))) { + exitcode = (int)MANDOCLEVEL_BADARG; + say(file, "&realpath"); + return; +@@ -830,6 +834,7 @@ + else { + exitcode = (int)MANDOCLEVEL_BADARG; + say("", "%s: outside base directory", buf); ++ free(buf); + return; + } + +@@ -846,10 +851,12 @@ + if (-1 == stat(buf, &st)) { + exitcode = (int)MANDOCLEVEL_BADARG; + say(file, "&stat"); ++ free(buf); + return; + } + if (strlcpy(buf, file, sizeof(buf)) >= sizeof(buf)) { + say(file, "Filename too long"); ++ free(buf); + return; + } + start = buf; +@@ -863,6 +870,7 @@ + sizeof(mlink->file)) { + say(start, "Filename too long"); + free(mlink); ++ free(buf); + return; + } + +@@ -913,6 +921,8 @@ + *p = '\0'; + } + mlink_add(mlink, &st); ++ ++ free(buf); + } + + static void +@@ -2429,6 +2439,7 @@ + static int getcwd_status; /* 1 = ok, 2 = failure */ + static int chdir_status; /* 1 = changed directory */ + char *cp; ++ char *buf; + + /* + * Remember the original working directory, if possible. +@@ -2475,13 +2486,20 @@ + * pathname and append a trailing slash, such that + * we can reliably check whether files are inside. + */ +- if (NULL == realpath(targetdir, basedir)) { ++ if (NULL == (buf = realpath(targetdir, NULL))) { + if (report_baddir || errno != ENOENT) { + exitcode = (int)MANDOCLEVEL_BADARG; + say("", "&%s: realpath", targetdir); + } + return(0); +- } else if (-1 == chdir(basedir)) { ++ } ++ if (sizeof(basedir) <= strlcpy(basedir, buf, sizeof(basedir))) { ++ exitcode = (int)MANDOCLEVEL_SYSERR; ++ say("", "Filename too long"); ++ return 0; ++ } ++ free(buf); ++ if (-1 == chdir(basedir)) { + if (report_baddir || errno != ENOENT) { + exitcode = (int)MANDOCLEVEL_BADARG; + say("", "&chdir"); +diff -Paur --no-dereference -- mdocml.upstream/manpage.c mdocml/manpage.c +--- mdocml.upstream/manpage.c ++++ mdocml/manpage.c +@@ -177,7 +177,7 @@ + cmd = NULL != getenv("MANPAGER") ? + getenv("MANPAGER") : + (NULL != getenv("PAGER") ? +- getenv("PAGER") : "more"); ++ getenv("PAGER") : "pager"); + execlp(cmd, cmd, (char *)NULL); + perror(cmd); + exit(EXIT_FAILURE); +diff -Paur --no-dereference -- mdocml.upstream/manpath.c mdocml/manpath.c +--- mdocml.upstream/manpath.c ++++ mdocml/manpath.c +@@ -26,11 +26,13 @@ + #include + #include + #include ++#include + + #include "mandoc_aux.h" + #include "manpath.h" + +-#define MAN_CONF_FILE "/etc/man.conf" ++#define MAN_CONF_FILE SYSCONFDIR "/man.conf" ++#define MAN_CONF_DEF SYSCONFDIR "/default/man.conf" + #define MAN_CONF_KEY "_whatdb" + + static void manpath_add(struct manpaths *, const char *, int); +@@ -99,6 +101,13 @@ + + /* MANPATH and man.conf(5) cooperate. */ + defp = getenv("MANPATH"); ++ /* PATCH: Use /etc/default/man.conf if no /etc/man.conf. It lets us ++ ship default configuration while the main file belongs to the ++ system administrator. */ ++ if (NULL == file && access(MAN_CONF_FILE, F_OK) != -1) ++ file = MAN_CONF_FILE; ++ if (NULL == file && access(MAN_CONF_DEF, F_OK) != -1) ++ file = MAN_CONF_DEF; + if (NULL == file) + file = MAN_CONF_FILE; + +@@ -159,12 +168,13 @@ + static void + manpath_add(struct manpaths *dirs, const char *dir, int complain) + { +- char buf[PATH_MAX]; + struct stat sb; + char *cp; + size_t i; + +- if (NULL == (cp = realpath(dir, buf))) { ++ /* PATCH: Use realpath without a destination buffer so it's well-defined ++ when PATH_MAX doesn't exist, like on Sortix. */ ++ if (NULL == (cp = realpath(dir, NULL))) { + if (complain) { + fputs("manpath: ", stderr); + perror(dir); +@@ -173,21 +183,24 @@ + } + + for (i = 0; i < dirs->sz; i++) +- if (0 == strcmp(dirs->paths[i], dir)) ++ if (0 == strcmp(dirs->paths[i], dir)) { ++ free(cp); + return; ++ } + + if (stat(cp, &sb) == -1) { + if (complain) { + fputs("manpath: ", stderr); + perror(dir); + } ++ free(cp); + return; + } + + dirs->paths = mandoc_reallocarray(dirs->paths, + dirs->sz + 1, sizeof(char *)); + +- dirs->paths[dirs->sz++] = mandoc_strdup(cp); ++ dirs->paths[dirs->sz++] = cp; + } + + void +diff -Paur --no-dereference -- mdocml.upstream/read.c mdocml/read.c +--- mdocml.upstream/read.c ++++ mdocml/read.c +@@ -847,7 +847,8 @@ + exit((int)MANDOCLEVEL_SYSERR); + } + execlp("gunzip", "gunzip", "-c", file, NULL); +- perror("exec"); ++ /* PATCH: Mention which program failed to run. */ ++ perror("exec: gunzip"); + exit((int)MANDOCLEVEL_SYSERR); + default: + close(pfd[1]); diff --git a/ports/mdocml/mdocml.port b/ports/mdocml/mdocml.port new file mode 100644 index 00000000..e6a0a088 --- /dev/null +++ b/ports/mdocml/mdocml.port @@ -0,0 +1,11 @@ +NAME=mdocml +BUILD_LIBRARIES= +VERSION=1.13.3 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=23ccab4800d50bf4c327979af5d4aa1a6a2dc490789cb67c4c3ac1bd40b8cad8 +UPSTREAM_SITE=https://mandoc.bsd.lv/snapshots +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +DIRTY_FILE=Makefile.local diff --git a/ports/nano/nano.patch b/ports/nano/nano.patch new file mode 100644 index 00000000..ef0acc1b --- /dev/null +++ b/ports/nano/nano.patch @@ -0,0 +1,157 @@ +diff -Paur --no-dereference -- nano.upstream/config.sub nano/config.sub +--- nano.upstream/config.sub ++++ nano/config.sub +@@ -1373,7 +1373,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- nano.upstream/configure nano/configure +--- nano.upstream/configure ++++ nano/configure +@@ -8675,6 +8675,7 @@ + # Extract the first word of "${ac_tool_prefix}ncursesw5-config", so it can be a program name with args. + set dummy ${ac_tool_prefix}ncursesw5-config; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++ac_cv_prog_NCURSESW_CONFIG=false + $as_echo_n "checking for $ac_word... " >&6; } + if ${ac_cv_prog_NCURSESW_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +diff -Paur --no-dereference -- nano.upstream/src/files.c nano/src/files.c +--- nano.upstream/src/files.c ++++ nano/src/files.c +@@ -1501,10 +1501,12 @@ + if (tmpdir_env != NULL) + full_tempdir = check_writable_directory(tmpdir_env); + ++#ifdef P_tmpdir + /* If $TMPDIR is unset, empty, or not a writable directory, and + * full_tempdir is NULL, try P_tmpdir instead. */ + if (full_tempdir == NULL) + full_tempdir = check_writable_directory(P_tmpdir); ++#endif + + /* if P_tmpdir is NULL, use /tmp. */ + if (full_tempdir == NULL) +diff -Paur --no-dereference -- nano.upstream/src/Makefile.in nano/src/Makefile.in +--- nano.upstream/src/Makefile.in ++++ nano/src/Makefile.in +@@ -559,6 +559,7 @@ + distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile ++ -rm -f revision.h + distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +diff -Paur --no-dereference -- nano.upstream/src/rcfile.c nano/src/rcfile.c +--- nano.upstream/src/rcfile.c ++++ nano/src/rcfile.c +@@ -23,7 +23,9 @@ + + #include "proto.h" + ++#if defined(__has_include) && __has_include() + #include ++#endif + #include + #include + #include +@@ -223,13 +225,35 @@ + * null-terminate it, and return a pointer to the /next/ word. */ + char *parse_next_regex(char *ptr) + { ++ char* outptr = ptr; ++ int escaped = 0; ++ char c; ++ size_t bracket = 0; ++ + assert(ptr != NULL); + +- /* Continue until the end of line, or until a " followed by a +- * blank character or the end of line. */ +- while (*ptr != '\0' && (*ptr != '"' || +- (*(ptr + 1) != '\0' && !isblank(*(ptr + 1))))) +- ptr++; ++ /* PATCH: This fixes issues in the nanorc parser because the Sortix regcomp ++ does not support \" and \' (just use " and ' instead). */ ++ while ((c = *ptr)) { ++ if (!escaped && !bracket && c == '"' && ++ (!ptr[1] || isspace((unsigned char) ptr[1])) ) ++ break; ++ if (escaped && c != '"' && c != '\'') ++ *outptr++ = '\\'; ++ if (c == '\\' && !escaped && !bracket) ++ escaped = 1; ++ else if (c == '[' && !escaped) { ++ bracket++; ++ *outptr++ = c; ++ } else if (bracket && c == ']' && !escaped) { ++ bracket--; ++ *outptr++ = c; ++ } else { ++ *outptr++ = c; ++ escaped = 0; ++ } ++ ptr++; ++ } + + assert(*ptr == '"' || *ptr == '\0'); + +@@ -240,7 +264,8 @@ + } + + /* Null-terminate and advance ptr. */ +- *ptr++ = '\0'; ++ *outptr = '\0'; ++ ptr++; + + while (isblank(*ptr)) + ptr++; +@@ -570,8 +595,11 @@ + void parse_includes(char *ptr) + { + char *option, *nanorc_save = nanorc, *expanded; +- size_t lineno_save = lineno, i; ++ size_t lineno_save = lineno; ++#if defined(__has_include) && __has_include() ++ size_t i; + glob_t files; ++#endif + + option = ptr; + if (*option == '"') +@@ -581,6 +609,7 @@ + /* Expand tildes first, then the globs. */ + expanded = real_dir_from_tilde(option); + ++#if defined(__has_include) && __has_include() + if (glob(expanded, GLOB_ERR|GLOB_NOSORT, NULL, &files) == 0) { + for (i = 0; i < files.gl_pathc; ++i) + parse_one_include(files.gl_pathv[i]); +@@ -589,6 +618,9 @@ + strerror(errno)); + + globfree(&files); ++#else ++ parse_one_include(expanded); ++#endif + free(expanded); + + /* We're done with the included file(s). Restore the original +diff -Paur --no-dereference -- nano.upstream/src/winio.c nano/src/winio.c +--- nano.upstream/src/winio.c ++++ nano/src/winio.c +@@ -2274,7 +2274,7 @@ + if (margin > 0) { + wattron(edit, interface_color_pair[LINE_NUMBER]); + if (last_drawn_line != fileptr->lineno || last_line_y >= line) +- mvwprintw(edit, line, 0, "%*i", margin - 1, fileptr->lineno); ++ mvwprintw(edit, line, 0, "%*zi", margin - 1, fileptr->lineno); + else + mvwprintw(edit, line, 0, "%*s", margin - 1, " "); + wattroff(edit, interface_color_pair[LINE_NUMBER]); diff --git a/ports/nano/nano.port b/ports/nano/nano.port new file mode 100644 index 00000000..ae714172 --- /dev/null +++ b/ports/nano/nano.port @@ -0,0 +1,10 @@ +NAME=nano +BUILD_LIBRARIES='libiconv? gettext? libcurses libmagic? libz?' +VERSION=2.7.1 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=df5cbe69831d7394c0a32fb27373ab313335ea4dc586d6f4be4081eb1de857cd +UPSTREAM_SITE=https://ftp.gnu.org/gnu/nano +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure diff --git a/ports/nano/nano.rmpatch b/ports/nano/nano.rmpatch new file mode 100644 index 00000000..36294821 --- /dev/null +++ b/ports/nano/nano.rmpatch @@ -0,0 +1,2 @@ +rm -rf -- 'doc/texinfo/nano.html' +rm -rf -- 'nano.spec' diff --git a/ports/nasm/nasm.patch b/ports/nasm/nasm.patch new file mode 100644 index 00000000..4eb15dd4 --- /dev/null +++ b/ports/nasm/nasm.patch @@ -0,0 +1,31 @@ +diff -Paur --no-dereference -- nasm.upstream/Makefile.in nasm/Makefile.in +--- nasm.upstream/Makefile.in ++++ nasm/Makefile.in +@@ -201,12 +201,12 @@ + manpages: nasm.1 ndisasm.1 + + install: nasm$(X) ndisasm$(X) +- $(MKDIR) -p $(INSTALLROOT)$(bindir) +- $(INSTALL_PROGRAM) nasm$(X) $(INSTALLROOT)$(bindir)/nasm$(X) +- $(INSTALL_PROGRAM) ndisasm$(X) $(INSTALLROOT)$(bindir)/ndisasm$(X) +- $(MKDIR) -p $(INSTALLROOT)$(mandir)/man1 +- $(INSTALL_DATA) $(srcdir)/nasm.1 $(INSTALLROOT)$(mandir)/man1/nasm.1 +- $(INSTALL_DATA) $(srcdir)/ndisasm.1 $(INSTALLROOT)$(mandir)/man1/ndisasm.1 ++ $(MKDIR) -p $(DESTDIR)$(bindir) ++ $(INSTALL_PROGRAM) nasm$(X) $(DESTDIR)$(bindir)/nasm$(X) ++ $(INSTALL_PROGRAM) ndisasm$(X) $(DESTDIR)$(bindir)/ndisasm$(X) ++ $(MKDIR) -p $(DESTDIR)$(mandir)/man1 ++ $(INSTALL_DATA) $(srcdir)/nasm.1 $(DESTDIR)$(mandir)/man1/nasm.1 ++ $(INSTALL_DATA) $(srcdir)/ndisasm.1 $(DESTDIR)$(mandir)/man1/ndisasm.1 + + clean: + $(RM) -f *.$(O) *.s *.i +@@ -218,7 +218,7 @@ + + distclean: clean + $(RM) -f config.h config.log config.status +- $(RM) -f Makefile *~ *.bak *.lst *.bin ++ $(RM) -f Makefile doc/Makefile *~ *.bak *.lst *.bin + $(RM) -f output/*~ output/*.bak + $(RM) -f test/*.lst test/*.bin test/*.$(O) test/*.bin + $(RM) -rf autom4te*.cache diff --git a/ports/nasm/nasm.port b/ports/nasm/nasm.port new file mode 100644 index 00000000..124a0ede --- /dev/null +++ b/ports/nasm/nasm.port @@ -0,0 +1,12 @@ +NAME=nasm +BUILD_LIBRARIES= +VERSION=2.11.02 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=233c574f2c068c0256f9b3653220ceb247c72b671085595259529156c6cfa55d +UPSTREAM_SITE=https://www.nasm.us/pub/nasm/releasebuilds/$VERSION +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +RELEASE_SEARCH_PAGE=https://www.nasm.us/pub/nasm/releasebuilds/ +RELEASE_SEARCH_REGEX='([0-9]+\.[0-9]+(\.[0-9]+)*)/' diff --git a/ports/nasm/nasm.rmpatch b/ports/nasm/nasm.rmpatch new file mode 100644 index 00000000..8bdc5612 --- /dev/null +++ b/ports/nasm/nasm.rmpatch @@ -0,0 +1 @@ +rm -rf -- 'doc/Makefile' diff --git a/ports/nyancat/nyancat.patch b/ports/nyancat/nyancat.patch new file mode 100644 index 00000000..ed1a44c0 --- /dev/null +++ b/ports/nyancat/nyancat.patch @@ -0,0 +1,119 @@ +diff -Paur --no-dereference -- nyancat.upstream/Makefile nyancat/Makefile +--- nyancat.upstream/Makefile ++++ nyancat/Makefile +@@ -1,39 +1,26 @@ +-package = nyancat +-version = 1.5.2 +-tarname = $(package) +-distdir = $(tarname)-$(version) +- +-all clean check nyancat: +- cd src && $(MAKE) $@ +- +-dist: $(distdir).tar.gz +- +-$(distdir).tar.gz: $(distdir) +- tar chof - $(distdir) | gzip -9 -c > $@ +- rm -rf $(distdir) +- +-$(distdir): FORCE +- mkdir -p $(distdir)/src +- cp Makefile $(distdir) +- cp src/Makefile $(distdir)/src +- cp src/nyancat.c $(distdir)/src +- cp src/animation.h $(distdir)/src +- cp src/telnet.h $(distdir)/src +- +-FORCE: +- -rm $(distdir).tar.gz >/dev/null 2>&1 +- -rm -rf $(distdir) >/dev/null 2>&1 +- +-distcheck: $(distdir).tar.gz +- gzip -cd $(distdir).tar.gz | tar xvf - +- cd $(distdir) && $(MAKE) all +- cd $(distdir) && $(MAKE) check +- cd $(distdir) && $(MAKE) clean +- rm -rf $(distdir) +- @echo "*** Package $(distdir).tar.gz is ready for distribution." ++include ../../../build-aux/compiler.mak ++include ../../../build-aux/version.mak ++include ../../../build-aux/dirs.mak ++ ++OPTLEVEL?=-g -O2 ++CFLAGS?=$(OPTLEVEL) ++ ++CFLAGS:=$(CXXFLAGS) -Wall -Wextra -std=c99 -pedantic -Wwrite-strings ++CPPFLAGS:=$(CPPFLAGS) ++ ++all: src/nyancat ++ ++.PHONY: all install clean ++ ++src/nyancat: src/nyancat.o ++ ++src/nyancat.o: src/animation.c src/telnet.h + + install: all +- install src/nyancat /usr/bin/${package} +- gzip -9 -c < nyancat.1 > /usr/share/man/man1/nyancat.1.gz ++ mkdir -p $(DESTDIR)$(BINDIR) ++ install src/nyancat $(DESTDIR)$(BINDIR) ++ mkdir -p $(DESTDIR)$(MANDIR)/man1 ++ install nyancat.1 $(DESTDIR)$(MANDIR)/man1 + +-.PHONY: FORCE all clean check dist distcheck install ++clean: ++ rm -f src/nyancat src/nyancat.o +diff -Paur --no-dereference -- nyancat.upstream/src/Makefile nyancat/src/Makefile +--- nyancat.upstream/src/Makefile ++++ nyancat/src/Makefile +@@ -1,20 +0,0 @@ +-OBJECTS = nyancat.o +- +-CC ?= +-CFLAGS ?= -g -Wall -Wextra -std=c99 -pedantic -Wwrite-strings +-CPPFLAGS ?= +-LDFLAGS ?= +- +-all: nyancat +- +-nyancat: $(OBJECTS) +- $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(OBJECTS) -o $@ +- +-clean: +- -rm -f $(OBJECTS) nyancat +- +-check: all +- # Unit tests go here. None currently. +- @echo "*** ALL TESTS PASSED ***" +- +-.PHONY: all clean check +diff -Paur --no-dereference -- nyancat.upstream/src/nyancat.c nyancat/src/nyancat.c +--- nyancat.upstream/src/nyancat.c ++++ nyancat/src/nyancat.c +@@ -54,6 +54,7 @@ + #define _BSD_SOURCE + #define _DEFAULT_SOURCE + #define __BSD_VISIBLE 1 ++#define _SORTIX_SOURCE 1 + #include + #include + #include +@@ -585,6 +586,8 @@ + ttype = 1; /* 256-color, spaces */ + } else if (strstr(term, "toaru")) { + ttype = 1; /* emulates xterm */ ++ } else if (strstr(term, "sortix")) { ++ ttype = 1; /* emulates xterm */ + } else if (strstr(term, "linux")) { + ttype = 3; /* Spaces and blink attribute */ + } else if (strstr(term, "vtnt")) { +@@ -892,7 +895,7 @@ + * The \033[0m prevents the Apple ][ from flipping everything, but + * makes the whole nyancat less bright on the vt220 + */ +- printf("\033[1;37mYou have nyaned for %0.0f seconds!\033[J\033[0m", diff); ++ printf("\033[1;37mYou have nyaned for %lli seconds!\033[J\033[0m", (long long)diff); + } + /* Reset the last color so that the escape sequences rewrite */ + last = 0; diff --git a/ports/nyancat/nyancat.port b/ports/nyancat/nyancat.port new file mode 100644 index 00000000..e427bb1d --- /dev/null +++ b/ports/nyancat/nyancat.port @@ -0,0 +1,11 @@ +NAME=nyancat +BUILD_LIBRARIES= +VERSION=1.5.2 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=88cdcaa9c7134503dd0364a97fa860da3381a09cb555c3aae9918360827c2032 +UPSTREAM_SITE=https://github.com/klange/nyancat/archive/refs/tags +UPSTREAM_ARCHIVE=$VERSION.tar.gz +BUILD_SYSTEM=sortix-usual-makefile +RELEASE_SEARCH_PAGE=https://github.com/klange/nyancat/tags diff --git a/ports/patch/patch.patch b/ports/patch/patch.patch new file mode 100644 index 00000000..1abb83fb --- /dev/null +++ b/ports/patch/patch.patch @@ -0,0 +1,187 @@ +diff -Paur --no-dereference -- patch.upstream/build-aux/config.sub patch/build-aux/config.sub +--- patch.upstream/build-aux/config.sub ++++ patch/build-aux/config.sub +@@ -1373,7 +1373,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* | -cloudabi* \ ++ | -aos* | -aros* | -cloudabi* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- patch.upstream/configure patch/configure +--- patch.upstream/configure ++++ patch/configure +@@ -1,4 +1,123 @@ + #! /bin/sh ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes # Not needed since February 2015 ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypotl_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for GNU patch 2.7.5. + # +diff -Paur --no-dereference -- patch.upstream/lib/getgroups.c patch/lib/getgroups.c +--- patch.upstream/lib/getgroups.c ++++ patch/lib/getgroups.c +@@ -30,7 +30,7 @@ + /* Provide a stub that fails with ENOSYS, since there is no group + information available on mingw. */ + int +-getgroups (int n _GL_UNUSED, GETGROUPS_T *groups _GL_UNUSED) ++getgroups (int n _GL_UNUSED, gid_t *groups _GL_UNUSED) + { + errno = ENOSYS; + return -1; +diff -Paur --no-dereference -- patch.upstream/src/safe.c patch/src/safe.c +--- patch.upstream/src/safe.c ++++ patch/src/safe.c +@@ -97,6 +97,8 @@ + max_cached_fds = 8; + if (getrlimit (RLIMIT_NOFILE, &nofile) == 0) + max_cached_fds = MAX (nofile.rlim_cur / 4, max_cached_fds); ++ /* PATCH: Avoid OOM if the file descriptors are unlimited. */ ++ max_cached_fds = MIN (1024, max_cached_fds); + + cached_dirfds = hash_initialize (max_cached_fds, + NULL, +@@ -225,7 +227,8 @@ + + /* Actually get the new directory file descriptor. Don't follow + symbolic links. */ +- fd = openat (dir->fd, name, O_DIRECTORY | O_NOFOLLOW); ++ /* PATCH: Request read permission instead of assuming O_RDONLY is 0. */ ++ fd = openat (dir->fd, name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + + /* Don't cache errors. */ + if (fd < 0) +diff -Paur --no-dereference -- patch.upstream/src/util.c patch/src/util.c +--- patch.upstream/src/util.c ++++ patch/src/util.c +@@ -54,6 +54,10 @@ + + #include + ++#ifndef PATH_MAX ++#define PATH_MAX 32768 ++#endif ++ + static void makedirs (char const *); + + typedef struct diff --git a/ports/patch/patch.port b/ports/patch/patch.port new file mode 100644 index 00000000..e63d2aec --- /dev/null +++ b/ports/patch/patch.port @@ -0,0 +1,11 @@ +NAME=patch +BUILD_LIBRARIES= +VERSION=2.7.5 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=fd95153655d6b95567e623843a0e77b81612d502ecf78a489a4aed7867caa299 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/patch +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' diff --git a/ports/perl/perl.patch b/ports/perl/perl.patch new file mode 100644 index 00000000..46c1811b --- /dev/null +++ b/ports/perl/perl.patch @@ -0,0 +1,1033 @@ +diff -Paur --no-dereference -- perl.upstream/cnf/configure_args.sh perl/cnf/configure_args.sh +--- perl.upstream/cnf/configure_args.sh ++++ perl/cnf/configure_args.sh +@@ -91,18 +91,23 @@ + esac + # split --set-foo and similar constructs into --set foo + # and things like --prefix=/foo into --prefix and /foo ++ # PATCH: Fix --foo= bar being parsed as --foo bar. ++ split= + case "$a" in + set-*|use-*|include-*) + k=`echo "$a" | sed -e 's/^[^-]*-//'` + a=`echo "$a" | sed -e 's/-.*//'` ++ split=1 + ;; + dont-use-*|dont-include-*) + k=`echo "$a" | sed -e 's/^dont-[^-]*-//'` + a=`echo "$a" | sed -e 's/^\(dont-[^-]*\)-.*/\1/'` ++ split=1 + ;; + *=*) + k=`echo "$a" | sed -e 's/^[^=]*=//'` + a=`echo "$a" | sed -e 's/=.*//'` ++ split=1 + ;; + esac + # check whether kv is required +@@ -114,7 +119,7 @@ + esac + # fetch argument if necessary (--set foo=bar) + # note that non-empty n means there must be no argument +- if [ -n "$x" -a -z "$k" -a -z "$n" ]; then ++ if [ -z "$split" -a -n "$x" -a -z "$k" -a -z "$n" ]; then + eval k="\${$i}"; i=$((i+1)) + fi + # split kv pair into k and v (k=foo v=bar) +@@ -155,7 +160,8 @@ + help) mode="help" ;; + regen|regenerate) mode="regen" ;; + keeplog) defuser "$a" 1 ;; +- prefix|html[13]dir|libsdir) defuser $a "$v" ;; ++ # PATCH: At least recognize --exec-prefix even though it's ignored. ++ prefix|exec-prefix|html[13]dir|libsdir) defuser $a "$v" ;; + man[13]dir|otherlibsdir) defuser $a "$v" ;; + siteprefix|sitehtml[13]dir) defuser $a "$v" ;; + siteman[13]dir|vendorman[13]dir)defuser $a "$v" ;; +diff -Paur --no-dereference -- perl.upstream/cnf/configure_func_ext.sh perl/cnf/configure_func_ext.sh +--- perl.upstream/cnf/configure_func_ext.sh ++++ perl/cnf/configure_func_ext.sh +@@ -68,7 +68,8 @@ + mstart "Checking FD_SET macros" + if not hinted d_fd_macros 'found' 'missing'; then + try_start +- try_includes sys/time.h sys/types.h unistd.h ++ # PATCH: FD_SET is defined in . ++ try_includes sys/select.h sys/time.h sys/types.h unistd.h + try_cat <. ++checktype d_fd_set 'fd_set' 'sys/select.h' + checktype d_fpos64_t 'fpos64_t' 'stdio.h' + checktype d_off64_t 'off64_t' 'sys/types.h' + checktype d_ptrdiff_t 'ptrdiff_t' 'stddef.h' +diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/constant.applied perl/cnf/diffs/perl5-5.32.0/constant.applied +--- perl.upstream/cnf/diffs/perl5-5.32.0/constant.applied ++++ perl/cnf/diffs/perl5-5.32.0/constant.applied +@@ -0,0 +1 @@ ++ +diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/dynaloader.applied perl/cnf/diffs/perl5-5.32.0/dynaloader.applied +--- perl.upstream/cnf/diffs/perl5-5.32.0/dynaloader.applied ++++ perl/cnf/diffs/perl5-5.32.0/dynaloader.applied +@@ -0,0 +1 @@ ++ +diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/findext.applied perl/cnf/diffs/perl5-5.32.0/findext.applied +--- perl.upstream/cnf/diffs/perl5-5.32.0/findext.applied ++++ perl/cnf/diffs/perl5-5.32.0/findext.applied +@@ -0,0 +1 @@ ++ +diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/installscripts.applied perl/cnf/diffs/perl5-5.32.0/installscripts.applied +--- perl.upstream/cnf/diffs/perl5-5.32.0/installscripts.applied ++++ perl/cnf/diffs/perl5-5.32.0/installscripts.applied +@@ -0,0 +1 @@ ++ +diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/liblist.applied perl/cnf/diffs/perl5-5.32.0/liblist.applied +--- perl.upstream/cnf/diffs/perl5-5.32.0/liblist.applied ++++ perl/cnf/diffs/perl5-5.32.0/liblist.applied +@@ -0,0 +1 @@ ++ +diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/makemaker.applied perl/cnf/diffs/perl5-5.32.0/makemaker.applied +--- perl.upstream/cnf/diffs/perl5-5.32.0/makemaker.applied ++++ perl/cnf/diffs/perl5-5.32.0/makemaker.applied +@@ -0,0 +1 @@ ++ +diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/posix-makefile.applied perl/cnf/diffs/perl5-5.32.0/posix-makefile.applied +--- perl.upstream/cnf/diffs/perl5-5.32.0/posix-makefile.applied ++++ perl/cnf/diffs/perl5-5.32.0/posix-makefile.applied +@@ -0,0 +1 @@ ++ +diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/test-checkcase.applied perl/cnf/diffs/perl5-5.32.0/test-checkcase.applied +--- perl.upstream/cnf/diffs/perl5-5.32.0/test-checkcase.applied ++++ perl/cnf/diffs/perl5-5.32.0/test-checkcase.applied +@@ -0,0 +1 @@ ++ +diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/test-commonsense.applied perl/cnf/diffs/perl5-5.32.0/test-commonsense.applied +--- perl.upstream/cnf/diffs/perl5-5.32.0/test-commonsense.applied ++++ perl/cnf/diffs/perl5-5.32.0/test-commonsense.applied +@@ -0,0 +1 @@ ++ +diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/xconfig.applied perl/cnf/diffs/perl5-5.32.0/xconfig.applied +--- perl.upstream/cnf/diffs/perl5-5.32.0/xconfig.applied ++++ perl/cnf/diffs/perl5-5.32.0/xconfig.applied +@@ -0,0 +1 @@ ++ +diff -Paur --no-dereference -- perl.upstream/config_h.SH perl/config_h.SH +--- perl.upstream/config_h.SH ++++ perl/config_h.SH +@@ -1230,6 +1230,9 @@ + * function used to generate normalized random numbers. + * Values include 15, 16, 31, and 48. + */ ++#if defined(__sortix__) && !defined(__SORTIX_HAS_DRAND48__) ++double drand48(void); ++#endif + #define Drand01() $drand01 /**/ + #define Rand_seed_t $randseedtype /**/ + #define seedDrand01(x) $seedfunc((Rand_seed_t)x) /**/ +diff -Paur --no-dereference -- perl.upstream/cpan/ExtUtils-Constant/t/Constant.t perl/cpan/ExtUtils-Constant/t/Constant.t +--- perl.upstream/cpan/ExtUtils-Constant/t/Constant.t ++++ perl/cpan/ExtUtils-Constant/t/Constant.t +@@ -1,8 +1,18 @@ + #!/usr/bin/perl -w + + use Config; ++use IPC::Cmd qw(can_run); ++ + unless ($Config{usedl}) { +- print "1..0 # no usedl, skipping\n"; ++ print "1..0 # SKIP no usedl\n"; ++ exit 0; ++} ++ ++my $make = $Config{make}; ++$make = $ENV{MAKE} if exists $ENV{MAKE}; ++ ++unless ( can_run($make) ) { ++ print "1..0 # SKIP make not available\n"; + exit 0; + } + +@@ -34,8 +44,6 @@ + # module from blib + @INC = map {File::Spec->rel2abs($_)} @INC if $] < 5.007 && $] >= 5.006; + +-my $make = $Config{make}; +-$make = $ENV{MAKE} if exists $ENV{MAKE}; + if ($^O eq 'MSWin32' && $make eq 'nmake') { $make .= " -nologo"; } + + # VMS may be using something other than MMS/MMK +diff -Paur --no-dereference -- perl.upstream/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm perl/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm +--- perl.upstream/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm ++++ perl/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm +@@ -20,9 +20,10 @@ + use File::Spec; + + sub ext { +- if ( $^O eq 'VMS' ) { return &_vms_ext; } +- elsif ( $^O eq 'MSWin32' ) { return &_win32_ext; } +- else { return &_unix_os2_ext; } ++ if ($Config{usemmldlt}){ return &_ld_ext; } ++ elsif($^O eq 'VMS') { return &_vms_ext; } ++ elsif($^O eq 'MSWin32') { return &_win32_ext; } ++ else { return &_unix_os2_ext; } + } + + sub _unix_os2_ext { +@@ -652,4 +653,51 @@ + wantarray ? ( $lib, '', $ldlib, '', ( $give_libs ? \@flibs : () ) ) : $lib; + } + ++# A direct test for -l validity. ++# Because guessing real file names for -llib options when dealing ++# with a cross compiler is generally a BAD IDEA^tm. ++sub _ld_ext { ++ my($self,$potential_libs, $verbose, $give_libs) = @_; ++ $verbose ||= 0; ++ ++ if ($^O =~ 'os2' and $Config{perllibs}) { ++ # Dynamic libraries are not transitive, so we may need including ++ # the libraries linked against perl.dll again. ++ ++ $potential_libs .= " " if $potential_libs; ++ $potential_libs .= $Config{perllibs}; ++ } ++ return ("", "", "", "", ($give_libs ? [] : ())) unless $potential_libs; ++ warn "Potential libraries are '$potential_libs':\n" if $verbose; ++ ++ my($ld) = $Config{ld}; ++ my($lddlflags) = $Config{lddlflags}; ++ my($libs) = defined $Config{perllibs} ? $Config{perllibs} : $Config{libs}; ++ ++ my $try = 'try_mm.c'; ++ my $tryx = 'try_mm.x'; ++ open(TRY, '>', $try) || die "Can't create MakeMaker test file $try: $!\n"; ++ print TRY "int main(void) { return 0; }\n"; ++ close(TRY); ++ ++ my $testlibs = ''; ++ my @testlibs = (); ++ foreach my $thislib (split ' ', $potential_libs) { ++ $testlibs = join(' ', @testlibs); ++ if($thislib =~ /^-L/) { ++ push(@testlibs, $thislib); ++ next ++ }; ++ my $cmd = "$ld $lddlflags -o $tryx $try $testlibs $thislib >/dev/null 2>&1"; ++ my $ret = system($cmd); ++ warn "Warning (mostly harmless): " . "No library found for $thislib\n" if $ret; ++ next if $ret; ++ push @testlibs, $thislib; ++ } ++ unlink($try); ++ unlink($tryx); ++ ++ return (join(' ', @testlibs), '', join(' ', @testlibs), ''); ++} ++ + 1; +diff -Paur --no-dereference -- perl.upstream/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm perl/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm +--- perl.upstream/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm ++++ perl/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm +@@ -36,7 +36,7 @@ + $Is{BSD} = ($^O =~ /^(?:free|net|open)bsd$/ or + grep( $^O eq $_, qw(bsdos interix dragonfly) ) + ); +- $Is{Android} = $^O =~ /android/; ++ $Is{Android} = $^O =~ /android/ || $Config{osname} eq 'android'; + if ( $^O eq 'darwin' && $^X eq '/usr/bin/perl' ) { + my @osvers = split /\./, $Config{osvers}; + $Is{ApplCor} = ( $osvers[0] >= 18 ); +diff -Paur --no-dereference -- perl.upstream/dist/Safe/Safe.pm perl/dist/Safe/Safe.pm +--- perl.upstream/dist/Safe/Safe.pm ++++ perl/dist/Safe/Safe.pm +@@ -43,7 +43,10 @@ + } + } + +-use Opcode 1.01, qw( ++# PATCH: 'use Safe;' fails with '"%.*g" is not exported by the Opcode module' ++# on Sortix without floating point support when a floating point version ++# number is used here. ++use Opcode 1, qw( + opset opset_to_ops opmask_add + empty_opset full_opset invert_opset verify_opset + opdesc opcodes opmask define_optag opset_to_hex +diff -Paur --no-dereference -- perl.upstream/ext/DynaLoader/hints/linux.pl perl/ext/DynaLoader/hints/linux.pl +--- perl.upstream/ext/DynaLoader/hints/linux.pl ++++ perl/ext/DynaLoader/hints/linux.pl +@@ -1,5 +1 @@ +-# XXX Configure test needed. +-# Some Linux releases like to hide their +-$self->{CCFLAGS} = $Config{ccflags} . ' -I/usr/include/libelf' +- if -f "/usr/include/libelf/nlist.h"; + 1; +diff -Paur --no-dereference -- perl.upstream/ext/Errno/Errno_pm.PL perl/ext/Errno/Errno_pm.PL +--- perl.upstream/ext/Errno/Errno_pm.PL ++++ perl/ext/Errno/Errno_pm.PL +@@ -2,6 +2,9 @@ + use Config; + use strict; + ++# PATCH: Recognize the right operating system when cross-compiling. ++$^O = $Config{osname}; ++ + our $VERSION = "1.30"; + + my %err = (); +@@ -167,6 +170,11 @@ + + close(CPPI); + ++ # PATCH: Simply process errno.c rather then the special logic below to ++ # locate the system headers. ++ $file{"errno.c"} = 1; ++ return keys %file; ++ + # invoke CPP and read the output + if ($IsMSWin32 || $^O eq 'NetWare') { + open(CPPO,"$Config{cpprun} $Config{cppflags} errno.c |") or +diff -Paur --no-dereference -- perl.upstream/ext/ExtUtils-Miniperl/lib/ExtUtils/Miniperl.pm perl/ext/ExtUtils-Miniperl/lib/ExtUtils/Miniperl.pm +--- perl.upstream/ext/ExtUtils-Miniperl/lib/ExtUtils/Miniperl.pm ++++ perl/ext/ExtUtils-Miniperl/lib/ExtUtils/Miniperl.pm +@@ -2,7 +2,8 @@ + package ExtUtils::Miniperl; + use strict; + require Exporter; +-use ExtUtils::Embed 1.31, qw(xsi_header xsi_protos xsi_body); ++# PATCH: "%.*g" is not exported by the ExtUtils::Embed module ++use ExtUtils::Embed 1, qw(xsi_header xsi_protos xsi_body); + + our @ISA = qw(Exporter); + our @EXPORT = qw(writemain); +diff -Paur --no-dereference -- perl.upstream/ext/POSIX/Makefile.PL perl/ext/POSIX/Makefile.PL +--- perl.upstream/ext/POSIX/Makefile.PL ++++ perl/ext/POSIX/Makefile.PL +@@ -1,4 +1,9 @@ + # Expect this line to be read by t/posix.t, don't change it ++ ++# Explicitly avoid including '.' in @INC; autoloader gets confused since it ++# can find POSIX.pm, but can't find autosplit.ix. ++BEGIN { pop @INC;} ++# + use ExtUtils::MakeMaker; + use ExtUtils::Constant 0.23 'WriteConstants'; + use Config; +diff -Paur --no-dereference -- perl.upstream/ext/POSIX/POSIX.xs perl/ext/POSIX/POSIX.xs +--- perl.upstream/ext/POSIX/POSIX.xs ++++ perl/ext/POSIX/POSIX.xs +@@ -1,3 +1,12 @@ ++#if defined(__sortix__) && !defined(__SORTIX_HAS_PAUSE__) ++#include ++#include ++int pause(void) ++{ ++ return sigsuspend(NULL); ++} ++#endif ++ + #define PERL_EXT_POSIX + #define PERL_EXT + +@@ -1418,7 +1427,11 @@ + # define mkfifo(a,b) not_here("mkfifo") + # else /* !( defined OS2 ) */ + # ifndef mkfifo ++#if defined(__sortix__) ++# define mkfifo(path, mode) not_here("mkfifo") ++#else + # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0)) ++#endif + # endif + # endif + # endif /* !HAS_MKFIFO */ +@@ -3820,12 +3833,19 @@ + ctermid(s = 0) + char * s = 0; + CODE: ++/* PATCH: Sortix doesn't have ctermid at this time. */ ++#ifdef L_ctermid + #ifdef I_TERMIOS + /* On some systems L_ctermid is a #define; but not all; this code works + * for all cases (so far...) */ + s = (char *) safemalloc((size_t) L_ctermid); + #endif + RETVAL = ctermid(s); ++#else ++ s = (char *) safemalloc(strlen("/dev/tty")); ++ strcpy(s, "/dev/tty"); ++ RETVAL = s; ++#endif + OUTPUT: + RETVAL + CLEANUP: +diff -Paur --no-dereference -- perl.upstream/installman perl/installman +--- perl.upstream/installman ++++ perl/installman +@@ -1,8 +1,6 @@ + #!./perl -w + + BEGIN { +- @INC = qw(lib); +- + # This needs to be at BEGIN time, before any use of Config + # install_lib itself loads and imports Config into main:: + require './install_lib.pl'; +diff -Paur --no-dereference -- perl.upstream/installperl perl/installperl +--- perl.upstream/installperl ++++ perl/installperl +@@ -2,8 +2,6 @@ + + BEGIN { + chdir '..' if !-d 'lib' and -d '../lib'; +- @INC = 'lib'; +- $ENV{PERL5LIB} = 'lib'; + + # This needs to be at BEGIN time, before any use of Config + # install_lib itself loads and imports Config into main:: +@@ -194,6 +192,7 @@ + + # Fetch some frequently-used items from %Config + my $installbin = "$opts{destdir}$Config{installbin}"; ++my $installlib = "$opts{destdir}$Config{installlib}"; + my $installscript = "$opts{destdir}$Config{installscript}"; + my $installprivlib = "$opts{destdir}$Config{installprivlib}"; + my $installarchlib = "$opts{destdir}$Config{installarchlib}"; +@@ -378,7 +377,8 @@ + @corefiles = <*.h>; + } else { + # [als] hard-coded 'libperl' name... not good! +- @corefiles = <*.h libperl*.* perl*$Config{lib_ext}>; ++ @corefiles = <*.h perl*$Config{lib_ext}>; ++ push(@corefiles, $Config{libperl}) if $Config{useshrplib} && !$Config{soname}; + + # AIX needs perl.exp installed as well. + push(@corefiles,'perl.exp') if $^O eq 'aix'; +@@ -404,6 +404,29 @@ + chmod($NON_SO_MODE, $dest) foreach @corefiles; + } + ++if($Config{useshrplib} && $Config{soname}) { ++ my $libperl = $Config{libperl}; ++ my $soname = $Config{soname}; ++ mkpath($installlib); ++ if (copy_if_diff($libperl, "$installlib/$libperl")) { ++ strip("-S", "$installlib/$libperl"); ++ chmod(0555, "$installlib/$libperl"); ++ ++ # Normally this should be done by ldconfig. ++ safe_unlink("$installlib/$soname") unless $soname eq $libperl; ++ safe_unlink("$installlib/libperl.so") unless $soname eq 'libperl.so'; ++ symlink($libperl, "$installlib/$soname") unless $soname eq $libperl; ++ symlink($libperl, "$installlib/libperl.so") unless $soname eq 'libperl.so'; ++ # using $so here instead of .so hardly makes any sense, ++ # all systems supporting SONAME have $so=.so ++ ++ # Backward compatibility: provide a symlink where people expect it ++ safe_unlink("$installarchlib/CORE/libperl.so"); ++ symlink("$Config{installlib}/$libperl", "$installarchlib/CORE/libperl.so"); ++ # ^ without destdir here! ++ } ++} ++ + # Install main perl executables + # Make links to ordinary names if installbin directory isn't current directory. + +diff -Paur --no-dereference -- perl.upstream/lib/unicore/mktables perl/lib/unicore/mktables +--- perl.upstream/lib/unicore/mktables ++++ perl/lib/unicore/mktables +@@ -12629,10 +12629,12 @@ + if ( defined $nv_floating_to_rational{$float} + && $nv_floating_to_rational{$float} ne $rational) + { +- die Carp::my_carp_bug("Both '$rational' and" +- . " '$nv_floating_to_rational{$float}' evaluate to" +- . " the same floating point number." +- . " \$E_FLOAT_PRECISION must be increased"); ++ # PATCH: This test fails on native Sortix due to lack of floating ++ # point formatting support, but nothing is wrong. ++ #die Carp::my_carp_bug("Both '$rational' and" ++ # . " '$nv_floating_to_rational{$float}' evaluate to" ++ # . " the same floating point number." ++ # . " \$E_FLOAT_PRECISION must be increased"); + } + $nv_floating_to_rational{$float} = $rational; + } +diff -Paur --no-dereference -- perl.upstream/Makefile perl/Makefile +--- perl.upstream/Makefile ++++ perl/Makefile +@@ -61,7 +61,8 @@ + # Original versions are not saved anymore; patch generally takes care of this, + # and if that fails, reaching for the source tarball is the safest option. + $(CROSSPATCHED): %.applied: %.patch +- patch -p1 -i $< && touch $@ ++ # PATCH: The .applied files needs to be non-empty to be in the diff. ++ patch -p1 -i $< && echo > $@ + + # ---[ common ]----------------------------------------------------------------- + +@@ -243,14 +244,19 @@ + + preplibrary: $(CONFIGPM) | miniperl$X lib/re.pm lib/lib.pm + ++# PATCH: Set LINKTYPE to static or otherwise the all target depends on linkext ++# that depends on dynamic, and thus both static and dynamic libraries ++# gets built. + dist/lib/Makefile: dist/lib/Makefile.PL cflags config.h $(CONFIGPM) | miniperl$X + $(eval top=$(shell echo $(dir $@) | sed -re 's![^/]+!..!g')) + cd $(dir $@) && $(top)miniperl_top -I$(top)lib Makefile.PL \ ++ LINKTYPE=static \ + PERL_CORE=1 LIBPERL_A=$(LIBPERL) PERL="$(top)miniperl_top" + + %/Makefile: %/Makefile.PL preplibrary cflags config.h | $(XSUBPP) miniperl$X + $(eval top=$(shell echo $(dir $@) | sed -re 's![^/]+!..!g')) + cd $(dir $@) && $(top)miniperl_top -I$(top)lib Makefile.PL \ ++ LINKTYPE=static \ + INSTALLDIRS=perl INSTALLMAN1DIR=none INSTALLMAN3DIR=none \ + PERL_CORE=1 LIBPERL_A=$(LIBPERL) PERL="$(top)miniperl_top" + +@@ -319,7 +325,7 @@ + cpan/ExtUtils-ParseXS/Makefile cpan/ExtUtils-Constant/Makefile: \ + %/Makefile: %/Makefile.PL preplibrary cflags | miniperl$X miniperl_top + $(eval top=$(shell echo $(dir $@) | sed -re 's![^/]+!..!g')) +- cd $(dir $@) && $(top)miniperl_top Makefile.PL PERL_CORE=1 PERL=$(top)miniperl_top ++ cd $(dir $@) && $(top)miniperl_top Makefile.PL LINKTYPE=static PERL_CORE=1 PERL=$(top)miniperl_top + + cpan/List-Util/pm_to_blib: | dynaloader + +@@ -432,7 +438,10 @@ + + install.sym: # deprecated + +-install.man: installman pod/perltoc.pod | miniperl$X ++# PATCH: Sever makefile dependency that tends to livelock make with 100% CPU ++# usage after doing the static modules when building -j2 or more. ++# pod/perltoc.pod and miniperl are already built by the main all target. ++install.man: installman # pod/perltoc.pod | miniperl$X + ./miniperl_top installman --destdir=$(DESTDIR) $(INSTALLFLAGS) + + # ---[ testpack ]--------------------------------------------------------------- +@@ -445,9 +454,10 @@ + tar -zcvf $@ -T $< + + # ---[ clean ]------------------------------------------------------------------ ++# PATCH: make doesn't work this way when make -j. + # clean-modules must go BEFORE clean-generated-files because it depends on config.h! + .PHONY: clean clean-obj clean-generated-files clean-subdirs clean-modules clean-testpack +-clean: clean-obj clean-modules clean-generated-files clean-subdirs clean-testpack ++clean: clean-obj clean-modules clean-subdirs clean-testpack + + clean-obj: + -test -n "$o" && rm -f *$o +@@ -458,7 +468,7 @@ + + # assuming modules w/o Makefiles were never built and need no cleaning + clean-modules: config.h +- @for i in $(modules disabled); do \ ++ @for i in $(modules) $(disabled) ext/DynaLoader; do \ + test -f $$i/Makefile && \ + touch $$i/Makefile && \ + $(MAKE) -C $$i clean \ +@@ -478,3 +488,307 @@ + clean-testpack: + -rm -fr TESTPACK + -rm -f TESTPACK.list ++ ++# PATCH: perl is terrible at cleaning up properly. ++distclean: clean ++ $(MAKE) clean-generated-files # clean-modules needs config.h... ++ rm -f *.host.o ++ rm -f cflags ++ rm -f config.log ++ find cpan dist ext -name Makefile -delete ++ find cpan dist ext -name Makefile.old -delete ++ find cpan dist ext -name '*.fnm' -delete ++ rm -rf `grep -lr 'It will be deleted automatically by make realclean' cpan dist ext` ++ rm -rf `grep -lr 'This file is auto-generated by mkheader.' cpan dist | grep -E '\.h'` ++ rm -rf cpan/Compress-Raw-Bzip2/*.[ch] ++ rm -rf cpan/Compress-Raw-Zlib/*.[ch] ++ rm -f cpan/Compress-Raw-Bzip2/constants.xs ++ rm -f cpan/Compress-Raw-Zlib/constants.xs ++ rm -f cpan/Encode/Byte/Byte.xs ++ rm -f cpan/Encode/CN/CN.xs ++ rm -f cpan/Encode/EBCDIC/EBCDIC.xs ++ rm -f cpan/Encode/JP/JP.xs ++ rm -f cpan/Encode/KR/KR.xs ++ rm -f cpan/Encode/Symbol/Symbol.xs ++ rm -f cpan/Encode/TW/TW.xs ++ rm -f cpan/Pod-Checker/podchecker ++ rm -f cpan/Pod-Checker/podchecker.PL ++ rm -f cpan/podlators/scripts/pod2man ++ rm -f cpan/podlators/scripts/pod2text ++ rm -f cpan/Pod-Usage/pod2usage ++ rm -f cpan/Pod-Usage/pod2usage.PL ++ rm -f cpan/Socket/const-c.inc ++ rm -f cpan/Socket/const-xs.inc ++ rm -f cpan/Sys-Syslog/const-c.inc ++ rm -f cpan/Sys-Syslog/const-xs.inc ++ rm -rf cpan/Sys-Syslog/lib ++ rm -f cpan/Sys-Syslog/macros.all ++ rm -f dist/lib/lib.pm ++ rm -f dist/Time-HiRes/const-c.inc ++ rm -f dist/Time-HiRes/const-xs.inc ++ rm -f dist/Time-HiRes/xdefine ++ rm -f dist/Devel-PPPort/RealPPPort.xs ++ rm -f ext/B/const-c.inc ++ rm -f ext/B/const-xs.inc ++ rm -f ext/Errno/arch.txt ++ rm -f ext/Errno/Errno.pm ++ rm -f ext/Fcntl/const-c.inc ++ rm -f ext/Fcntl/const-xs.inc ++ rm -f ext/File-Glob/const-c.inc ++ rm -f ext/File-Glob/const-xs.inc ++ rm -f ext/I18N-Langinfo/const-c.inc ++ rm -f ext/I18N-Langinfo/const-xs.inc ++ rm -f ext/Pod-Functions/Functions.pm ++ rm -f ext/POSIX/const-c.inc ++ rm -f ext/POSIX/const-xs.inc ++ rm -f ext/re/dquote.c ++ rm -f ext/re/invlist_inline.h ++ rm -f ext/re/re_comp.c ++ rm -f ext/re/re_exec.c ++ rm -f ext/XS-APItest/const-c.inc ++ rm -f ext/XS-APItest/const-xs.inc ++ rm -f extra.pods ++ rm -f lib/.exists ++ rm -rf lib/App ++ rm -rf lib/Archive ++ rm -rf lib/Attribute ++ rm -f lib/AutoLoader.pm ++ rm -f lib/AutoSplit.pm ++ rm -f lib/B.pm ++ rm -f lib/B/Concise.pm ++ rm -f lib/B/Showlex.pm ++ rm -f lib/B/Terse.pm ++ rm -f lib/B/Xref.pm ++ rm -rf lib/CPAN ++ rm -f lib/CPAN.pm ++ rm -rf lib/Carp ++ rm -f lib/Carp.pm ++ rm -rf lib/Compress ++ rm -f lib/Config.pm ++ rm -f lib/Config.pod ++ rm -rf lib/Config/Perl ++ rm -f lib/Config_git.pl ++ rm -f lib/Config_heavy.pl ++ rm -f lib/Cwd.pm ++ rm -rf lib/Data ++ rm -rf lib/Devel ++ rm -rf lib/Digest ++ rm -f lib/Digest.pm ++ rm -f lib/Dumpvalue.pm ++ rm -f lib/DynaLoader.pm ++ rm -rf lib/Encode ++ rm -f lib/Encode.pm ++ rm -f lib/Env.pm ++ rm -f lib/Errno.pm ++ rm -rf lib/Exporter ++ rm -f lib/Exporter.pm ++ rm -f lib/ExtUtils/.exists ++ rm -rf lib/ExtUtils/CBuilder ++ rm -f lib/ExtUtils/CBuilder.pm ++ rm -rf lib/ExtUtils/Command ++ rm -f lib/ExtUtils/Command.pm ++ rm -rf lib/ExtUtils/Constant ++ rm -f lib/ExtUtils/Constant.pm ++ rm -f lib/ExtUtils/Install.pm ++ rm -f lib/ExtUtils/Installed.pm ++ rm -rf lib/ExtUtils/Liblist ++ rm -f lib/ExtUtils/Liblist.pm ++ rm -f lib/ExtUtils/MANIFEST.SKIP ++ rm -f lib/ExtUtils/MM.pm ++ rm -f lib/ExtUtils/MM_AIX.pm ++ rm -f lib/ExtUtils/MM_Any.pm ++ rm -f lib/ExtUtils/MM_BeOS.pm ++ rm -f lib/ExtUtils/MM_Cygwin.pm ++ rm -f lib/ExtUtils/MM_DOS.pm ++ rm -f lib/ExtUtils/MM_Darwin.pm ++ rm -f lib/ExtUtils/MM_MacOS.pm ++ rm -f lib/ExtUtils/MM_NW5.pm ++ rm -f lib/ExtUtils/MM_OS2.pm ++ rm -f lib/ExtUtils/MM_QNX.pm ++ rm -f lib/ExtUtils/MM_UWIN.pm ++ rm -f lib/ExtUtils/MM_Unix.pm ++ rm -f lib/ExtUtils/MM_VMS.pm ++ rm -f lib/ExtUtils/MM_VOS.pm ++ rm -f lib/ExtUtils/MM_Win32.pm ++ rm -f lib/ExtUtils/MM_Win95.pm ++ rm -f lib/ExtUtils/MY.pm ++ rm -rf lib/ExtUtils/MakeMaker ++ rm -f lib/ExtUtils/MakeMaker.pm ++ rm -f lib/ExtUtils/Manifest.pm ++ rm -f lib/ExtUtils/Miniperl.pm ++ rm -f lib/ExtUtils/Mkbootstrap.pm ++ rm -f lib/ExtUtils/Mksymlists.pm ++ rm -f lib/ExtUtils/Packlist.pm ++ rm -rf lib/ExtUtils/ParseXS ++ rm -f lib/ExtUtils/ParseXS.pm ++ rm -f lib/ExtUtils/ParseXS.pod ++ rm -rf lib/ExtUtils/Typemaps ++ rm -f lib/ExtUtils/Typemaps.pm ++ rm -f lib/ExtUtils/testlib.pm ++ rm -f lib/ExtUtils/xsubpp ++ rm -f lib/Fatal.pm ++ rm -f lib/Fcntl.pm ++ rm -f lib/File/.exists ++ rm -f lib/File/DosGlob.pm ++ rm -f lib/File/Fetch.pm ++ rm -f lib/File/Find.pm ++ rm -f lib/File/Glob.pm ++ rm -f lib/File/GlobMapper.pm ++ rm -f lib/File/Path.pm ++ rm -rf lib/File/Spec ++ rm -f lib/File/Spec.pm ++ rm -f lib/File/Temp.pm ++ rm -f lib/FileCache.pm ++ rm -rf lib/Filter ++ rm -f lib/FindBin.pm ++ rm -f lib/Getopt/.exists ++ rm -f lib/Getopt/Long.pm ++ rm -rf lib/HTTP ++ rm -rf lib/Hash ++ rm -rf lib/I18N ++ rm -rf lib/IO ++ rm -f lib/IO.pm ++ rm -rf lib/IPC ++ rm -rf lib/JSON ++ rm -rf lib/List ++ rm -rf lib/Locale ++ rm -rf lib/MIME ++ rm -rf lib/Math ++ rm -rf lib/Memoize ++ rm -f lib/Memoize.pm ++ rm -rf lib/Module ++ rm -f lib/NEXT.pm ++ rm -f lib/Net/.exists ++ rm -f lib/Net/Cmd.pm ++ rm -f lib/Net/Config.pm ++ rm -f lib/Net/Domain.pm ++ rm -rf lib/Net/FTP ++ rm -f lib/Net/FTP.pm ++ rm -f lib/Net/NNTP.pm ++ rm -f lib/Net/Netrc.pm ++ rm -f lib/Net/POP3.pm ++ rm -f lib/Net/Ping.pm ++ rm -f lib/Net/SMTP.pm ++ rm -f lib/Net/Time.pm ++ rm -f lib/Net/libnetFAQ.pod ++ rm -f lib/O.pm ++ rm -f lib/Opcode.pm ++ rm -f lib/POSIX.pm ++ rm -f lib/POSIX.pod ++ rm -rf lib/Params ++ rm -rf lib/Parse ++ rm -rf lib/Perl ++ rm -rf lib/PerlIO ++ rm -f lib/Pod/.exists ++ rm -f lib/Pod/Checker.pm ++ rm -f lib/Pod/Escapes.pm ++ rm -f lib/Pod/Functions.pm ++ rm -f lib/Pod/Html.pm ++ rm -f lib/Pod/Man.pm ++ rm -f lib/Pod/ParseLink.pm ++ rm -rf lib/Pod/Perldoc ++ rm -f lib/Pod/Perldoc.pm ++ rm -rf lib/Pod/Simple ++ rm -f lib/Pod/Simple.pm ++ rm -f lib/Pod/Simple.pod ++ rm -rf lib/Pod/Text ++ rm -f lib/Pod/Text.pm ++ rm -f lib/Pod/Usage.pm ++ rm -f lib/SDBM_File.pm ++ rm -f lib/Safe.pm ++ rm -rf lib/Scalar ++ rm -rf lib/Search ++ rm -f lib/SelfLoader.pm ++ rm -f lib/Socket.pm ++ rm -f lib/Storable.pm ++ rm -rf lib/Sub ++ rm -rf lib/Sys ++ rm -rf lib/TAP ++ rm -rf lib/Term ++ rm -rf lib/Test ++ rm -f lib/Test.pm ++ rm -rf lib/Test2 ++ rm -f lib/Test2.pm ++ rm -rf lib/Text ++ rm -rf lib/Thread ++ rm -f lib/Tie/.exists ++ rm -f lib/Tie/File.pm ++ rm -rf lib/Tie/Hash ++ rm -f lib/Tie/Memoize.pm ++ rm -f lib/Tie/RefHash.pm ++ rm -f lib/Time/.exists ++ rm -f lib/Time/HiRes.pm ++ rm -f lib/Time/Local.pm ++ rm -f lib/Time/Piece.pm ++ rm -f lib/Time/Seconds.pm ++ rm -f lib/Unicode/.exists ++ rm -rf lib/Unicode/Collate ++ rm -f lib/Unicode/Collate.pm ++ rm -f lib/Unicode/Normalize.pm ++ rm -rf lib/XS ++ rm -f lib/XSLoader.pm ++ rm -f lib/attributes.pm ++ rm -rf lib/auto ++ rm -rf lib/autodie ++ rm -f lib/autodie.pm ++ rm -f lib/autouse.pm ++ rm -f lib/base.pm ++ rm -f lib/bigint.pm ++ rm -f lib/bignum.pm ++ rm -f lib/bigrat.pm ++ rm -f lib/constant.pm ++ rm -rf lib/encoding ++ rm -f lib/encoding.pm ++ rm -f lib/experimental.pm ++ rm -f lib/fields.pm ++ rm -f lib/if.pm ++ rm -f lib/lib.pm ++ rm -f lib/mro.pm ++ rm -f lib/ok.pm ++ rm -f lib/ops.pm ++ rm -f lib/parent.pm ++ rm -f lib/perldoc.pod ++ rm -f lib/perlfaq.pm ++ rm -f lib/perlfaq.pod ++ rm -f lib/perlfaq1.pod ++ rm -f lib/perlfaq2.pod ++ rm -f lib/perlfaq3.pod ++ rm -f lib/perlfaq4.pod ++ rm -f lib/perlfaq5.pod ++ rm -f lib/perlfaq6.pod ++ rm -f lib/perlfaq7.pod ++ rm -f lib/perlfaq8.pod ++ rm -f lib/perlfaq9.pod ++ rm -f lib/perlglossary.pod ++ rm -f lib/perlxs.pod ++ rm -f lib/perlxstut.pod ++ rm -f lib/perlxstypemap.pod ++ rm -rf lib/threads ++ rm -f lib/threads.pm ++ rm -f lib/unicore/CombiningClass.pl ++ rm -f lib/unicore/Decomposition.pl ++ rm -f lib/unicore/Name.pl ++ rm -f lib/unicore/Name.pm ++ rm -f lib/unicore/TestProp.pl ++ rm -rf lib/unicore/To ++ rm -f lib/unicore/UCD.pl ++ rm -rf lib/unicore/lib ++ rm -f lib/unicore/mktables.lst ++ rm -rf lib/version ++ rm -f lib/version.pm ++ rm -f lib/version.pod ++ rm -f libperl.a ++ rm -f mg_data.h ++ rm -f miniperl ++ rm -f perl ++ find pod -type l -delete ++ rm -f `grep -rl 'This file is built by' pod` ++ rm -f pod/perltoc.pod ++ rm -f pod/perluniprops.pod ++ rm -f pod/roffitall ++ rm -f try ++ rm -f try.c ++ rm -f try.h ++ rm -f try.out ++ rm -f xconfig.sh ++ rm -f Makefile.config config.sh +diff -Paur --no-dereference -- perl.upstream/perl.h perl/perl.h +--- perl.upstream/perl.h ++++ perl/perl.h +@@ -25,7 +25,11 @@ + #ifdef PERL_MICRO + # include "uconfig.h" + #else ++# ifndef USE_CROSS_COMPILE + # include "config.h" ++# else ++# include "xconfig.h" ++# endif + #endif + + /* this is used for functions which take a depth trailing +diff -Paur --no-dereference -- perl.upstream/perl_langinfo.h perl/perl_langinfo.h +--- perl.upstream/perl_langinfo.h ++++ perl/perl_langinfo.h +@@ -4,7 +4,11 @@ + #ifndef PERL_LANGINFO_H + #define PERL_LANGINFO_H 1 + ++#ifdef USE_CROSS_COMPILE ++#include "xconfig.h" ++#else + #include "config.h" ++#endif + + #if defined(HAS_NL_LANGINFO) && defined(I_LANGINFO) + # include +diff -Paur --no-dereference -- perl.upstream/pp.c perl/pp.c +--- perl.upstream/pp.c ++++ perl/pp.c +@@ -2866,6 +2866,13 @@ + --Jarkko Hietaniemi 27 September 1998 + */ + ++#if defined(__sortix__) && !defined(__SORTIX_HAS_DRAND48__) ++double drand48(void) ++{ ++ return arc4random() / 4294967295.0; ++} ++#endif ++ + PP(pp_rand) + { + if (!PL_srand_called) { +diff -Paur --no-dereference -- perl.upstream/t/lib/commonsense.t perl/t/lib/commonsense.t +--- perl.upstream/t/lib/commonsense.t ++++ perl/t/lib/commonsense.t +@@ -18,7 +18,7 @@ + BAIL_OUT("Perl configured without IO module"); + } + # hey, DOS users do not need this kind of common sense ;-) +-if ($^O ne 'dos' && ($Config{'extensions'} !~ /\bFile\/Glob\b/) ){ ++if ($^O ne 'dos' && ($Config{'extensions'} !~ /\bFile.Glob\b/) ){ + BAIL_OUT("Perl configured without File::Glob module"); + } + +diff -Paur --no-dereference -- perl.upstream/t/porting/checkcase.t perl/t/porting/checkcase.t +--- perl.upstream/t/porting/checkcase.t ++++ perl/t/porting/checkcase.t +@@ -25,6 +25,8 @@ + + # Special exemption for Makefile, makefile + return if $name =~ m!\A[Mm]akefile\z!; ++ # same for Configure, configure in perl-cross ++ return if $name =~ m!\A[Cc]onfigure\z!; + + if ($name eq '.git') { + # Don't scan the .git directory, as its contents are outside +diff -Paur --no-dereference -- perl.upstream/util.c perl/util.c +--- perl.upstream/util.c ++++ perl/util.c +@@ -2094,7 +2094,7 @@ + * For Solaris, setenv() and unsetenv() were introduced in Solaris 9, so + * testing for HAS UNSETENV is sufficient. + */ +-# if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV)) || defined(PERL_DARWIN) ++# if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV)) || defined(PERL_DARWIN) || defined(__sortix__) + # define MY_HAS_SETENV + # endif + +@@ -2102,7 +2102,7 @@ + * 'current' is non-null, with up to three sizes that are added together. + * It handles integer overflow. + */ +-# ifndef MY_HAS_SETENV ++/* PATCH: Support having only setenv/unsetenv and no putenv. */ + static char * + S_env_alloc(void *current, Size_t l1, Size_t l2, Size_t l3, Size_t size) + { +@@ -2127,7 +2127,6 @@ + panic: + croak_memory_wrap(); + } +-# endif + + + # if !defined(WIN32) && !defined(NETWARE) +diff -Paur --no-dereference -- perl.upstream/vutil.c perl/vutil.c +--- perl.upstream/vutil.c ++++ perl/vutil.c +@@ -702,12 +702,25 @@ + #endif + + if (sv) { ++/* PATCH: Sortix doesn't have floating point printing yet. */ ++#if defined(__sortix__) && !defined(__SORTIX_HAS_FORMAT_FLOAT__) ++ double d = SvNVX(ver); ++ Perl_sv_catpvf(aTHX_ sv, "%d.%09d", (int) d, ++ (int) ((long long)(d * 1000000000) % 1000000000)); ++#else + Perl_sv_catpvf(aTHX_ sv, "%.9" NVff, SvNVX(ver)); ++#endif + len = SvCUR(sv); + buf = SvPVX(sv); + } + else { ++#if defined(__sortix__) && !defined(__SORTIX_HAS_FORMAT_FLOAT__) ++ double d = SvNVX(ver); ++ len = my_snprintf(tbuf, sizeof(tbuf), "%d.%09d", (int) d, ++ (int) ((long long)(d * 1000000000) % 1000000000)); ++#else + len = my_snprintf(tbuf, sizeof(tbuf), "%.9" NVff, SvNVX(ver)); ++#endif + buf = tbuf; + } + +diff -Paur --no-dereference -- perl.upstream/win32/FindExt.pm perl/win32/FindExt.pm +--- perl.upstream/win32/FindExt.pm ++++ perl/win32/FindExt.pm +@@ -115,10 +115,6 @@ + $this_ext =~ s!-!/!g; + $leaf =~ s/.*-//; + +- # List/Util.xs lives in Scalar-List-Utils, Cwd.xs lives in PathTools +- $this_ext = 'List/Util' if $this_ext eq 'Scalar/List/Utils'; +- $this_ext = 'Cwd' if $this_ext eq 'PathTools'; +- + # Temporary hack to cope with smokers that are not clearing directories: + next if $ext{$this_ext}; + diff --git a/ports/perl/perl.port b/ports/perl/perl.port new file mode 100644 index 00000000..8285af52 --- /dev/null +++ b/ports/perl/perl.port @@ -0,0 +1,25 @@ +NAME=perl +BUILD_LIBRARIES= +VERSION=5.32.0 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=efeb1ce1f10824190ad1cadbcccf6fdb8a5d37007d0100d2d9ae5f2b5900c0b4 +UPSTREAM_SITE=https://www.cpan.org/src/5.0 +UPSTREAM_ARCHIVE=$ARCHIVE +VERSION_2=1.3.4 +DISTNAME_2=perl-cross-$VERSION_2 +COMPRESSION_2=tar.gz +ARCHIVE_2=$DISTNAME_2.$COMPRESSION_2 +SHA256SUM_2=755aa0ca8141a942188a269564f86c3c82349f82c346ed5c992495d7f35138ba +UPSTREAM_SITE_2=https://github.com/arsv/perl-cross/releases/download/$VERSION_2 +UPSTREAM_ARCHIVE_2=$ARCHIVE_2 +BUILD_SYSTEM=configure +CONFIGURE_ARGS=--all-static +DIRTY_FILE=config.sh +POST_INSTALL=../perl.post-install + +# This port uses upstream perl with perl-cross extracted onto it. The initial +# build using perl-cross will apply additionaly patches, and these difference +# are included in the patch for this port. The changes original to Sortix either +# say "PATCH:" or mention Sortix and the remainder are from perl-cross. diff --git a/ports/perl/perl.post-install b/ports/perl/perl.post-install new file mode 100755 index 00000000..3c432301 --- /dev/null +++ b/ports/perl/perl.post-install @@ -0,0 +1,24 @@ +#!/bin/sh +# The default perl installation is quite large (62 MB) but a lot of it isn't +# actually needed and there's a lot of value in keeping the Sortix build lean. +# This script isn't safe to run on an actual installation so make sure it's in +# the temporary destination directory. +if [ -n "$TIX_INSTALL_DIR" ]; then + # Retain only the section 1 manuals for the actual programs. There are also + # other useful manuals in that section, but there's a whole lot of stuff that + # don't need to be installed and take up space (11 MB). + for manpage in "$TIX_INSTALL_DIR$PREFIX/share/man/man1"/*; do + program=$(basename -- "$manpage" | sed -E 's/\.1$//') + if [ ! -e "$TIX_INSTALL_DIR$EXEC_PREFIX/bin/$program" ]; then + rm -f -- "$manpage" + fi + done + # The section 3 manuals are a whole lot and don't need to be installed and + # take up a bunch space (6 MB). + rm -rf -- "$TIX_INSTALL_DIR$PREFIX/share/man/man3" + # The pod documentation takes up space (9 MB). + PERLDIR="$TIX_INSTALL_DIR$PREFIX/lib/perl5/5."* + find -- "$PERLDIR" -name '*.pod' -delete + # The per-architecture statically linked modules aren't needed (16MB). + rm -rf -- "$PERLDIR/$HOST"/{CORE,auto} +fi diff --git a/ports/pkg-config/pkg-config.patch b/ports/pkg-config/pkg-config.patch new file mode 100644 index 00000000..7ae82016 --- /dev/null +++ b/ports/pkg-config/pkg-config.patch @@ -0,0 +1,24 @@ +diff -Paur --no-dereference -- pkg-config.upstream/config.sub pkg-config/config.sub +--- pkg-config.upstream/config.sub ++++ pkg-config/config.sub +@@ -1373,7 +1373,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- pkg-config.upstream/Makefile.in pkg-config/Makefile.in +--- pkg-config.upstream/Makefile.in ++++ pkg-config/Makefile.in +@@ -439,7 +439,7 @@ + rpmvercmp.h \ + main.c + +-@HOST_TOOL_TRUE@host_tool = $(host)-pkg-config$(EXEEXT) ++@HOST_TOOL_TRUE@host_tool = $(host_alias)-pkg-config$(EXEEXT) + + # Various data files + m4dir = $(datadir)/aclocal diff --git a/ports/pkg-config/pkg-config.port b/ports/pkg-config/pkg-config.port new file mode 100644 index 00000000..33451035 --- /dev/null +++ b/ports/pkg-config/pkg-config.port @@ -0,0 +1,12 @@ +NAME=pkg-config +BUILD_LIBRARIES=libglib +VERSION=0.29.2 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591 +UPSTREAM_SITE=https://pkgconfig.freedesktop.org/releases +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--with-system-include-path=/include --with-system-library-path=/lib --enable-indirect-deps=yes' +MAKE_VARS='V=1' diff --git a/ports/pkg-config/pkg-config.rmpatch b/ports/pkg-config/pkg-config.rmpatch new file mode 100644 index 00000000..cfb71e79 --- /dev/null +++ b/ports/pkg-config/pkg-config.rmpatch @@ -0,0 +1 @@ +rm -rf -- 'config.h.win32' diff --git a/ports/python/python.patch b/ports/python/python.patch new file mode 100644 index 00000000..356234d8 --- /dev/null +++ b/ports/python/python.patch @@ -0,0 +1,1216 @@ +diff -Paur --no-dereference -- python.upstream/config.sub python/config.sub +--- python.upstream/config.sub ++++ python/config.sub +@@ -1360,7 +1360,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- python.upstream/configure python/configure +--- python.upstream/configure ++++ python/configure +@@ -3253,6 +3253,9 @@ + *-*-cygwin*) + ac_sys_system=Cygwin + ;; ++ *-*-sortix*) ++ ac_sys_system=Sortix ++ ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" +@@ -3299,9 +3302,8 @@ + _host_cpu= + ;; + *) +- # for now, limit cross builds to known configurations +- MACHDEP="unknown" +- as_fn_error $? "cross build not supported for $host" "$LINENO" 5 ++ _host_cpu=$host_cpu ++ ;; + esac + _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" + fi +@@ -9279,7 +9281,9 @@ + CYGWIN*) + LDSHARED="gcc -shared -Wl,--enable-auto-image-base" + LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";; +- *) LDSHARED="ld";; ++ *) ++ LDSHARED='$(CC) -shared' ++ LDCXXSHARED='$(CXX) -shared';; + esac + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDSHARED" >&5 +@@ -9619,6 +9623,50 @@ + # pthread (first!) on Linux + fi + ++# check if we need libiconv for iconv functions ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libiconv in -liconv" >&5 ++$as_echo_n "checking for libiconv in -liconv... " >&6; } ++if ${ac_cv_lib_iconv_iconv+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-liconv $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char libiconv (); ++int ++main () ++{ ++return libiconv (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_iconv_libiconv=yes ++else ++ ac_cv_lib_iconv_libiconv=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iconv_libiconv" >&5 ++$as_echo "$ac_cv_lib_iconv_libiconv" >&6; } ++if test "x$ac_cv_lib_iconv_libiconv" = xyes; then : ++ ++$as_echo "#define WITH_LIBICONV 1" >>confdefs.h ++ ++ LIBS="-liconv $LIBS" ++fi ++ + # check if we need libintl for locale functions + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for textdomain in -lintl" >&5 + $as_echo_n "checking for textdomain in -lintl... " >&6; } +@@ -12709,7 +12757,7 @@ + if test "${enable_ipv6+set}" = set; then + ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6" + else +- ac_cv_buggy_getaddrinfo=yes ++ ac_cv_buggy_getaddrinfo="no -- because you assume correctness when cross-compiling" + fi + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -12808,7 +12856,7 @@ + if ac_fn_c_try_run "$LINENO"; then : + ac_cv_buggy_getaddrinfo=no + else +- ac_cv_buggy_getaddrinfo=yes ++ ac_cv_buggy_getaddrinfo="no -- because you assume correctness when cross-compiling" + fi + rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +@@ -15712,7 +15760,7 @@ + + # first curses header check + ac_save_cppflags="$CPPFLAGS" +-CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" ++# PATCH: Removed cross-compilation unsafe include path addition. + + for ac_header in curses.h ncurses.h + do : +@@ -15908,6 +15956,12 @@ + + if test "x$cross_compiling" = xyes; then + if test "${ac_cv_file__dev_ptmx+set}" != set; then ++ ac_cv_file__dev_ptmx=yes ++ fi ++ if test "${ac_cv_file__dev_ptc+set}" != set; then ++ ac_cv_file__dev_ptc=no ++ fi ++ if test "${ac_cv_file__dev_ptmx+set}" != set; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptmx" >&5 + $as_echo_n "checking for /dev/ptmx... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not set" >&5 +diff -Paur --no-dereference -- python.upstream/configure.ac python/configure.ac +--- python.upstream/configure.ac ++++ python/configure.ac +@@ -385,6 +385,9 @@ + *-*-cygwin*) + ac_sys_system=Cygwin + ;; ++ *-*-sortix*) ++ ac_sys_system=Sortix ++ ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" +@@ -431,9 +434,8 @@ + _host_cpu= + ;; + *) +- # for now, limit cross builds to known configurations +- MACHDEP="unknown" +- AC_MSG_ERROR([cross build not supported for $host]) ++ _host_cpu=$host_cpu ++ ;; + esac + _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" + fi +@@ -2535,7 +2537,9 @@ + CYGWIN*) + LDSHARED="gcc -shared -Wl,--enable-auto-image-base" + LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";; +- *) LDSHARED="ld";; ++ *) ++ LDSHARED='$(CC) -shared' ++ LDCXXSHARED='$(CXX) -shared';; + esac + fi + AC_MSG_RESULT($LDSHARED) +@@ -2679,6 +2683,12 @@ + # pthread (first!) on Linux + fi + ++# check if we need libiconv for iconv functions ++AC_CHECK_LIB(iconv, libiconv, ++ [AC_DEFINE(WITH_ICONV, 1, ++ [Define to 1 if libiconv is needed for iconv functions.]) ++ LIBS="-liconv $LIBS"]) ++ + # check if we need libintl for locale functions + AC_CHECK_LIB(intl, textdomain, + [AC_DEFINE(WITH_LIBINTL, 1, +@@ -3871,7 +3881,7 @@ + if test "${enable_ipv6+set}" = set; then + ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6" + else +- ac_cv_buggy_getaddrinfo=yes ++ ac_cv_buggy_getaddrinfo="no -- because you assume correctness when cross-compiling" + fi])) + fi + +@@ -4980,6 +4990,12 @@ + dnl NOTE: Inform user how to proceed with files when cross compiling. + if test "x$cross_compiling" = xyes; then + if test "${ac_cv_file__dev_ptmx+set}" != set; then ++ ac_cv_file__dev_ptmx=yes ++ fi ++ if test "${ac_cv_file__dev_ptc+set}" != set; then ++ ac_cv_file__dev_ptc=no ++ fi ++ if test "${ac_cv_file__dev_ptmx+set}" != set; then + AC_MSG_CHECKING([for /dev/ptmx]) + AC_MSG_RESULT([not set]) + AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling]) +diff -Paur --no-dereference -- python.upstream/Include/py_curses.h python/Include/py_curses.h +--- python.upstream/Include/py_curses.h ++++ python/Include/py_curses.h +@@ -48,18 +48,25 @@ + #include + #else + #include ++#endif ++/* PATCH: Some declarations are in term.h/termcap.h in Sortix's libcurses. */ + #ifdef HAVE_TERM_H + /* for tigetstr, which is not declared in SysV curses */ + #include ++#if __has_include() ++#include + #endif + #endif + + #ifdef HAVE_NCURSES_H + /* configure was checking , but we will + use , which has all these features. */ ++/* PATCH: Sortix's libcurses doesn't have a public _ISPAD */ ++#ifdef _ISPAD + #ifndef WINDOW_HAS_FLAGS + #define WINDOW_HAS_FLAGS 1 + #endif ++#endif + #ifndef MVWDELCH_IS_EXPRESSION + #define MVWDELCH_IS_EXPRESSION 1 + #endif +diff -Paur --no-dereference -- python.upstream/Lib/ctypes/__init__.py python/Lib/ctypes/__init__.py +--- python.upstream/Lib/ctypes/__init__.py ++++ python/Lib/ctypes/__init__.py +@@ -429,7 +429,15 @@ + elif _sys.platform == "cygwin": + pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2]) + else: +- pythonapi = PyDLL(None) ++ # PATCH: Sortix doesn't have dynamic linking yet, but parts of ctypes are ++ # still useful without it, so ignore an error. ++ try: ++ pythonapi = PyDLL(None) ++ except OSError: ++ if _sys.platform == "sortix": ++ pythonapi = None ++ else: ++ raise + + + if _os.name == "nt": +diff -Paur --no-dereference -- python.upstream/Makefile.pre.in python/Makefile.pre.in +--- python.upstream/Makefile.pre.in ++++ python/Makefile.pre.in +@@ -604,6 +604,7 @@ + *\ -s*|s*) quiet="-q";; \ + *) quiet="";; \ + esac; \ ++ test $(MACHDEP) = sortix || \ + $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build +@@ -1145,20 +1146,25 @@ + else true; \ + fi + (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python3$(EXE)) ++ -if test -f $(DESTDIR)$(BINDIR)/python$(EXE) -o -h $(DESTDIR)$(BINDIR)/python$(EXE); \ ++ then rm -f $(DESTDIR)$(BINDIR)/python$(EXE); \ ++ else true; \ ++ fi ++ (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python$(EXE)) + -if test "$(VERSION)" != "$(LDVERSION)"; then \ +- rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-config; \ +- (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(LDVERSION)-config python$(VERSION)-config); \ + rm -f $(DESTDIR)$(LIBPC)/python-$(LDVERSION).pc; \ + (cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python-$(LDVERSION).pc); \ + fi +- -rm -f $(DESTDIR)$(BINDIR)/python3-config +- (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python3-config) + -rm -f $(DESTDIR)$(LIBPC)/python3.pc + (cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python3.pc) + -rm -f $(DESTDIR)$(BINDIR)/idle3 + (cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3) ++ -rm -f $(DESTDIR)$(BINDIR)/idle ++ (cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle) + -rm -f $(DESTDIR)$(BINDIR)/pydoc3 + (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3) ++ -rm -f $(DESTDIR)$(BINDIR)/pydoc ++ (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc) + -rm -f $(DESTDIR)$(BINDIR)/2to3 + (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3) + -rm -f $(DESTDIR)$(BINDIR)/pyvenv +@@ -1411,7 +1417,6 @@ + $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup + $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh + $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py +- $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config + @if [ -s Modules/python.exp -a \ + "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \ + echo; echo "Installing support files for building shared extension modules on AIX:"; \ +@@ -1637,6 +1642,8 @@ + -o -name '*.orig' -o -name '*.rej' \ + -o -name '*.bak' ')' \ + -exec rm -f {} ';' ++ -rm -rf $(srcdir)/Lib/plat-sortix ++ -rm -f Misc/python-config.sh + + # Check for smelly exported symbols (not starting with Py/_Py) + smelly: all +diff -Paur --no-dereference -- python.upstream/Modules/_cursesmodule.c python/Modules/_cursesmodule.c +--- python.upstream/Modules/_cursesmodule.c ++++ python/Modules/_cursesmodule.c +@@ -116,7 +116,7 @@ + #defines many common symbols (such as "lines") which breaks the + curses module in other ways. So the code will just specify + explicit prototypes here. */ +-extern int setupterm(char *,int,int *); ++/* PATCH: We use term.h now so let that header declare setupterm. */ + #ifdef __sgi + #include + #endif +@@ -142,6 +142,14 @@ + + #include "clinic/_cursesmodule.c.h" + ++/* PATCH: Avoid conflict with as described above now that we use it. */ ++#ifdef lines ++#undef lines ++#endif ++#ifdef columns ++#undef columns ++#endif ++ + /* Definition of exception curses.error */ + + static PyObject *PyCursesError; +@@ -475,7 +483,10 @@ + Window_NoArgNoReturnVoidFunction(wclear) + + Window_OneArgNoReturnVoidFunction(idcok, int, "i;True(1) or False(0)") ++/* PATCH: Sortix's libcurses doesn't have these declarations. */ ++#ifndef __sortix__ + Window_OneArgNoReturnVoidFunction(immedok, int, "i;True(1) or False(0)") ++#endif + Window_OneArgNoReturnVoidFunction(wtimeout, int, "i;delay") + + Window_NoArg2TupleReturnFunction(getyx, int, "ii") +@@ -499,7 +510,9 @@ + Window_OneArgNoReturnFunction(notimeout, int, "i;True(1) or False(0)") + Window_OneArgNoReturnFunction(scrollok, int, "i;True(1) or False(0)") + Window_OneArgNoReturnFunction(winsdelln, int, "i;nlines") ++#ifndef __sortix__ + Window_OneArgNoReturnFunction(syncok, int, "i;True(1) or False(0)") ++#endif + + Window_TwoArgNoReturnFunction(mvwin, int, "ii;y,x") + Window_TwoArgNoReturnFunction(mvderwin, int, "ii;y,x") +@@ -2024,7 +2037,9 @@ + {"hline", (PyCFunction)PyCursesWindow_Hline, METH_VARARGS}, + {"idcok", (PyCFunction)PyCursesWindow_idcok, METH_VARARGS}, + {"idlok", (PyCFunction)PyCursesWindow_idlok, METH_VARARGS}, ++#ifndef __sortix__ + {"immedok", (PyCFunction)PyCursesWindow_immedok, METH_VARARGS}, ++#endif + {"inch", (PyCFunction)PyCursesWindow_InCh, METH_VARARGS}, + {"insch", (PyCFunction)PyCursesWindow_InsCh, METH_VARARGS}, + {"insdelln", (PyCFunction)PyCursesWindow_winsdelln, METH_VARARGS}, +@@ -2060,7 +2075,9 @@ + {"subpad", (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS}, + {"subwin", (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS}, + {"syncdown", (PyCFunction)PyCursesWindow_wsyncdown, METH_NOARGS}, ++#ifndef __sortix__ + {"syncok", (PyCFunction)PyCursesWindow_syncok, METH_VARARGS}, ++#endif + {"syncup", (PyCFunction)PyCursesWindow_wsyncup, METH_NOARGS}, + {"timeout", (PyCFunction)PyCursesWindow_wtimeout, METH_VARARGS}, + {"touchline", (PyCFunction)PyCursesWindow_TouchLine, METH_VARARGS}, +@@ -2152,6 +2169,7 @@ + NoArgNoReturnVoidFunction(flushinp) + NoArgNoReturnVoidFunction(noqiflush) + ++#ifndef __sortix__ + static PyObject * + PyCurses_filter(PyObject *self) + { +@@ -2161,6 +2179,7 @@ + Py_INCREF(Py_None); + return Py_None; + } ++#endif + + static PyObject * + PyCurses_Color_Content(PyObject *self, PyObject *args) +@@ -2232,6 +2251,7 @@ + return PyBytes_FromStringAndSize(&ch, 1); + } + ++#ifndef __sortix__ + static PyObject * + PyCurses_getsyx(PyObject *self) + { +@@ -2244,6 +2264,7 @@ + + return Py_BuildValue("(ii)", y, x); + } ++#endif + + #ifdef NCURSES_MOUSE_VERSION + static PyObject * +@@ -2355,6 +2376,7 @@ + } + + #ifndef STRICT_SYSV_CURSES ++#ifndef __sortix__ + /* No has_key! */ + static PyObject * PyCurses_has_key(PyObject *self, PyObject *args) + { +@@ -2371,6 +2393,7 @@ + Py_INCREF(Py_True); + return Py_True; + } ++#endif + #endif /* STRICT_SYSV_CURSES */ + + static PyObject * +@@ -2938,6 +2961,7 @@ + } + #endif /* HAVE_CURSES_RESIZE_TERM */ + ++#ifndef __sortix__ + static PyObject * + PyCurses_setsyx(PyObject *self, PyObject *args) + { +@@ -2957,6 +2981,7 @@ + Py_INCREF(Py_None); + return Py_None; + } ++#endif + + static PyObject * + PyCurses_Start_Color(PyObject *self) +@@ -3055,6 +3080,7 @@ + return PyBytes_FromString(result); + } + ++#ifndef __sortix__ + static PyObject * + PyCurses_TypeAhead(PyObject *self, PyObject *args) + { +@@ -3066,6 +3092,7 @@ + + return PyCursesCheckERR(typeahead( fd ), "typeahead"); + } ++#endif + + static PyObject * + PyCurses_UnCtrl(PyObject *self, PyObject *args) +@@ -3165,6 +3192,7 @@ + } + #endif + ++#ifndef __sortix__ + static PyObject * + PyCurses_Use_Env(PyObject *self, PyObject *args) + { +@@ -3183,6 +3211,7 @@ + Py_INCREF(Py_None); + return Py_None; + } ++#endif + + #ifndef STRICT_SYSV_CURSES + static PyObject * +@@ -3221,21 +3250,27 @@ + {"echo", (PyCFunction)PyCurses_echo, METH_VARARGS}, + {"endwin", (PyCFunction)PyCurses_endwin, METH_NOARGS}, + {"erasechar", (PyCFunction)PyCurses_EraseChar, METH_NOARGS}, ++#ifndef __sortix__ + {"filter", (PyCFunction)PyCurses_filter, METH_NOARGS}, ++#endif + {"flash", (PyCFunction)PyCurses_flash, METH_NOARGS}, + {"flushinp", (PyCFunction)PyCurses_flushinp, METH_NOARGS}, + #ifdef NCURSES_MOUSE_VERSION + {"getmouse", (PyCFunction)PyCurses_GetMouse, METH_NOARGS}, + {"ungetmouse", (PyCFunction)PyCurses_UngetMouse, METH_VARARGS}, + #endif ++#ifndef __sortix__ + {"getsyx", (PyCFunction)PyCurses_getsyx, METH_NOARGS}, ++#endif + {"getwin", (PyCFunction)PyCurses_GetWin, METH_O}, + {"has_colors", (PyCFunction)PyCurses_has_colors, METH_NOARGS}, + {"has_ic", (PyCFunction)PyCurses_has_ic, METH_NOARGS}, + {"has_il", (PyCFunction)PyCurses_has_il, METH_NOARGS}, ++#ifndef __sortix__ + #ifndef STRICT_SYSV_CURSES + {"has_key", (PyCFunction)PyCurses_has_key, METH_VARARGS}, + #endif ++#endif + {"halfdelay", (PyCFunction)PyCurses_HalfDelay, METH_VARARGS}, + {"init_color", (PyCFunction)PyCurses_Init_Color, METH_VARARGS}, + {"init_pair", (PyCFunction)PyCurses_Init_Pair, METH_VARARGS}, +@@ -3279,7 +3314,9 @@ + {"resize_term", (PyCFunction)PyCurses_Resize_Term, METH_VARARGS}, + #endif + {"savetty", (PyCFunction)PyCurses_savetty, METH_NOARGS}, ++#ifndef __sortix__ + {"setsyx", (PyCFunction)PyCurses_setsyx, METH_VARARGS}, ++#endif + {"setupterm", (PyCFunction)PyCurses_setupterm, + METH_VARARGS|METH_KEYWORDS}, + {"start_color", (PyCFunction)PyCurses_Start_Color, METH_NOARGS}, +@@ -3289,7 +3326,9 @@ + {"tigetnum", (PyCFunction)PyCurses_tigetnum, METH_VARARGS}, + {"tigetstr", (PyCFunction)PyCurses_tigetstr, METH_VARARGS}, + {"tparm", (PyCFunction)PyCurses_tparm, METH_VARARGS}, ++#ifndef __sortix__ + {"typeahead", (PyCFunction)PyCurses_TypeAhead, METH_VARARGS}, ++#endif + {"unctrl", (PyCFunction)PyCurses_UnCtrl, METH_VARARGS}, + {"ungetch", (PyCFunction)PyCurses_UngetCh, METH_VARARGS}, + #if defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM) +@@ -3298,7 +3337,9 @@ + #ifdef HAVE_NCURSESW + {"unget_wch", (PyCFunction)PyCurses_Unget_Wch, METH_VARARGS}, + #endif ++#ifndef __sortix__ + {"use_env", (PyCFunction)PyCurses_Use_Env, METH_VARARGS}, ++#endif + #ifndef STRICT_SYSV_CURSES + {"use_default_colors", (PyCFunction)PyCurses_Use_Default_Colors, METH_NOARGS}, + #endif +diff -Paur --no-dereference -- python.upstream/Modules/expat/xmlparse.c python/Modules/expat/xmlparse.c +--- python.upstream/Modules/expat/xmlparse.c ++++ python/Modules/expat/xmlparse.c +@@ -693,9 +693,15 @@ + static unsigned long + generate_hash_secret_salt(void) + { ++#if defined(__sortix__) ++ unsigned long result; ++ arc4random_buf(&result, sizeof(result)); ++ return result; ++#else + unsigned int seed = time(NULL) % UINT_MAX; + srand(seed); + return rand(); ++#endif + } + + static XML_Bool /* only valid for root parser */ +diff -Paur --no-dereference -- python.upstream/Modules/faulthandler.c python/Modules/faulthandler.c +--- python.upstream/Modules/faulthandler.c ++++ python/Modules/faulthandler.c +@@ -14,6 +14,10 @@ + # include + #endif + ++#if defined(__sortix__) && !defined(SIGSTKSZ) ++#define SIGSTKSZ (64 * 1024) /* just some value */ ++#endif ++ + /* Allocate at maximum 100 MB of the stack to raise the stack overflow */ + #define STACK_OVERFLOW_MAX_SIZE (100*1024*1024) + +diff -Paur --no-dereference -- python.upstream/Modules/fcntlmodule.c python/Modules/fcntlmodule.c +--- python.upstream/Modules/fcntlmodule.c ++++ python/Modules/fcntlmodule.c +@@ -288,6 +288,10 @@ + Py_BEGIN_ALLOW_THREADS + ret = flock(fd, code); + Py_END_ALLOW_THREADS ++#elif defined(__sortix__) ++ errno = ENOSYS; ++ PyErr_SetFromErrno(PyExc_IOError); ++ return NULL; + #else + + #ifndef LOCK_SH +@@ -371,6 +375,11 @@ + #define LOCK_UN 8 /* unlock */ + #endif /* LOCK_SH */ + { ++#if defined(__sortix__) ++ errno = ENOSYS; ++ PyErr_SetFromErrno(PyExc_IOError); ++ return NULL; ++#else + struct flock l; + if (code == LOCK_UN) + l.l_type = F_UNLCK; +@@ -410,6 +419,7 @@ + Py_BEGIN_ALLOW_THREADS + ret = fcntl(fd, (code & LOCK_NB) ? F_SETLK : F_SETLKW, &l); + Py_END_ALLOW_THREADS ++#endif + } + if (ret < 0) { + PyErr_SetFromErrno(PyExc_IOError); +diff -Paur --no-dereference -- python.upstream/Modules/getpath.c python/Modules/getpath.c +--- python.upstream/Modules/getpath.c ++++ python/Modules/getpath.c +@@ -131,6 +131,11 @@ + return err; + } + ++static const char* fix_empty_prefix(const char* path) ++{ ++ return path[0] ? path : "/"; ++} ++ + static void + reduce(wchar_t *dir) + { +@@ -492,8 +497,8 @@ + wchar_t *lib_python; + + _pythonpath = Py_DecodeLocale(PYTHONPATH, NULL); +- _prefix = Py_DecodeLocale(PREFIX, NULL); +- _exec_prefix = Py_DecodeLocale(EXEC_PREFIX, NULL); ++ _prefix = Py_DecodeLocale(fix_empty_prefix(PREFIX), NULL); ++ _exec_prefix = Py_DecodeLocale(fix_empty_prefix(EXEC_PREFIX), NULL); + lib_python = Py_DecodeLocale("lib/python" VERSION, NULL); + + if (!_pythonpath || !_prefix || !_exec_prefix || !lib_python) { +diff -Paur --no-dereference -- python.upstream/Modules/mmapmodule.c python/Modules/mmapmodule.c +--- python.upstream/Modules/mmapmodule.c ++++ python/Modules/mmapmodule.c +@@ -599,7 +599,7 @@ + + #ifdef MS_WINDOWS + return PyLong_FromLong((long) FlushViewOfFile(self->data+offset, size)); +-#elif defined(UNIX) ++#elif defined(UNIX) && !defined(__sortix__) + /* XXX semantics of return value? */ + /* XXX flags for msync? */ + if (-1 == msync(self->data + offset, size, MS_SYNC)) { +diff -Paur --no-dereference -- python.upstream/Modules/posixmodule.c python/Modules/posixmodule.c +--- python.upstream/Modules/posixmodule.c ++++ python/Modules/posixmodule.c +@@ -5734,15 +5734,6 @@ + #endif /* HAVE_SCHED_H */ + + +-/* AIX uses /dev/ptc but is otherwise the same as /dev/ptmx */ +-/* IRIX has both /dev/ptc and /dev/ptmx, use ptmx */ +-#if defined(HAVE_DEV_PTC) && !defined(HAVE_DEV_PTMX) +-#define DEV_PTY_FILE "/dev/ptc" +-#define HAVE_DEV_PTMX +-#else +-#define DEV_PTY_FILE "/dev/ptmx" +-#endif +- + #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_DEV_PTMX) + #ifdef HAVE_PTY_H + #include +@@ -5807,7 +5798,7 @@ + goto error; + + #else +- master_fd = open(DEV_PTY_FILE, O_RDWR | O_NOCTTY); /* open master */ ++ master_fd = posix_openpt(O_RDWR | O_NOCTTY); /* open master */ + if (master_fd < 0) + goto posix_error; + +@@ -8925,6 +8916,7 @@ + return posix_error(); + #endif + ++#ifdef HAVE_PUTENV + /* Remove the key from posix_putenv_garbage; + * this will cause it to be collected. This has to + * happen after the real unsetenv() call because the +@@ -8934,6 +8926,7 @@ + /* really not much we can do; just leak */ + PyErr_Clear(); + } ++#endif + Py_RETURN_NONE; + } + #endif /* HAVE_UNSETENV */ +diff -Paur --no-dereference -- python.upstream/Modules/resource.c python/Modules/resource.c +--- python.upstream/Modules/resource.c ++++ python/Modules/resource.c +@@ -9,6 +9,10 @@ + #include + #endif + ++#if defined(__sortix__) && !defined(RLIM_NLIMITS) ++#define RLIM_NLIMITS __RLIMIT_NUM_DECLARED ++#endif ++ + /* On some systems, these aren't in any header file. + On others they are, with inconsistent prototypes. + We declare the (default) return type, to shut up gcc -Wall; +@@ -83,6 +87,7 @@ + PyFloat_FromDouble(doubletime(ru.ru_utime))); + PyStructSequence_SET_ITEM(result, 1, + PyFloat_FromDouble(doubletime(ru.ru_stime))); ++#if !defined(__sortix__) + PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(ru.ru_maxrss)); + PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(ru.ru_ixrss)); + PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(ru.ru_idrss)); +@@ -97,6 +102,7 @@ + PyStructSequence_SET_ITEM(result, 13, PyLong_FromLong(ru.ru_nsignals)); + PyStructSequence_SET_ITEM(result, 14, PyLong_FromLong(ru.ru_nvcsw)); + PyStructSequence_SET_ITEM(result, 15, PyLong_FromLong(ru.ru_nivcsw)); ++#endif + + if (PyErr_Occurred()) { + Py_DECREF(result); +diff -Paur --no-dereference -- python.upstream/Modules/Setup.dist python/Modules/Setup.dist +--- python.upstream/Modules/Setup.dist ++++ python/Modules/Setup.dist +@@ -97,6 +97,8 @@ + COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH) + PYTHONPATH=$(COREPYTHONPATH) + ++# PATCH: Build all the modules into the python binary rather than shared libs. ++ + + # The modules listed here can't be built as shared libraries for + # various reasons; therefore they are listed here instead of in the +@@ -164,45 +166,44 @@ + # it, depending on your system -- see the GNU readline instructions. + # It's okay for this to be a shared library, too. + +-#readline readline.c -lreadline -ltermcap ++readline readline.c -lreadline -ltermcap + + + # Modules that should always be present (non UNIX dependent): + +-#array arraymodule.c # array objects +-#cmath cmathmodule.c _math.c # -lm # complex math library functions +-#math mathmodule.c _math.c # -lm # math library functions, e.g. sin() +-#_struct _struct.c # binary structure packing/unpacking +-#_weakref _weakref.c # basic weak reference support ++array arraymodule.c # array objects ++cmath cmathmodule.c # -lm # complex math library functions ++math mathmodule.c _math.c # -lm # math library functions, e.g. sin() ++_struct _struct.c # binary structure packing/unpacking + #_testcapi _testcapimodule.c # Python C API test module +-#_random _randommodule.c # Random number generator +-#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator +-#_pickle _pickle.c # pickle accelerator +-#_datetime _datetimemodule.c # datetime accelerator +-#_bisect _bisectmodule.c # Bisection algorithms +-#_heapq _heapqmodule.c # Heap queue algorithm +-#_asyncio _asynciomodule.c # Fast asyncio Future ++_random _randommodule.c # Random number generator ++_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator ++_pickle _pickle.c # pickle accelerator ++_datetime _datetimemodule.c # datetime accelerator ++_bisect _bisectmodule.c # Bisection algorithms ++_heapq _heapqmodule.c # Heap queue algorithm ++_asyncio _asynciomodule.c # Fast asyncio Future + +-#unicodedata unicodedata.c # static Unicode character database ++unicodedata unicodedata.c # static Unicode character database + + + # Modules with some UNIX dependencies -- on by default: + # (If you have a really backward UNIX, select and socket may not be + # supported...) + +-#fcntl fcntlmodule.c # fcntl(2) and ioctl(2) ++fcntl fcntlmodule.c # fcntl(2) and ioctl(2) + #spwd spwdmodule.c # spwd(3) +-#grp grpmodule.c # grp(3) +-#select selectmodule.c # select(2); not on ancient System V ++grp grpmodule.c # grp(3) ++select selectmodule.c # select(2); not on ancient System V + + # Memory-mapped files (also works on Win32). +-#mmap mmapmodule.c ++mmap mmapmodule.c + + # CSV file helper +-#_csv _csv.c ++_csv _csv.c + + # Socket module helper for socket(2) +-#_socket socketmodule.c ++_socket socketmodule.c + + # Socket module helper for SSL support; you must comment out the other + # socket line above, and possibly edit the SSL variable: +@@ -210,6 +211,7 @@ + #_ssl _ssl.c \ + # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ + # -L$(SSL)/lib -lssl -lcrypto ++_ssl _ssl.c -DUSE_SSL -lssl -lcrypto + + # The crypt module is now disabled by default because it breaks builds + # on many systems (where -lcrypt is needed), e.g. Linux (I believe). +@@ -223,10 +225,10 @@ + # are not supported by all UNIX systems: + + #nis nismodule.c -lnsl # Sun yellow pages -- not everywhere +-#termios termios.c # Steen Lumholt's termios module +-#resource resource.c # Jeremy Hylton's rlimit interface ++termios termios.c # Steen Lumholt's termios module ++resource resource.c # Jeremy Hylton's rlimit interface + +-#_posixsubprocess _posixsubprocess.c # POSIX subprocess module helper ++_posixsubprocess _posixsubprocess.c # POSIX subprocess module helper + + # Multimedia modules -- off by default. + # These don't work for 64-bit platforms!!! +@@ -242,17 +244,18 @@ + # The _md5 module implements the RSA Data Security, Inc. MD5 + # Message-Digest Algorithm, described in RFC 1321. + +-#_md5 md5module.c ++_md5 md5module.c + + + # The _sha module implements the SHA checksum algorithms. + # (NIST's Secure Hash Algorithms.) +-#_sha1 sha1module.c +-#_sha256 sha256module.c +-#_sha512 sha512module.c ++_sha1 sha1module.c ++_sha256 sha256module.c ++_sha512 sha512module.c ++_sha3 _sha3/sha3module.c + + # _blake module +-#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c ++_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c + + # The _tkinter module. + # +@@ -298,7 +301,7 @@ + # -lX11 + + # Lance Ellinghaus's syslog module +-#syslog syslogmodule.c # syslog daemon interface ++syslog syslogmodule.c # syslog daemon interface + + + # Curses support, requiring the System V version of curses, often +@@ -307,9 +310,9 @@ + # + # First, look at Setup.config; configure may have set this for you. + +-#_curses _cursesmodule.c -lcurses -ltermcap ++_curses _cursesmodule.c -lcurses -ltermcap + # Wrapper for the panel library that's part of ncurses and SYSV curses. +-#_curses_panel _curses_panel.c -lpanel -lncurses ++_curses_panel _curses_panel.c -lpanel -lncurses + + + # Modules that provide persistent dictionary-like semantics. You will +@@ -336,10 +339,10 @@ + + + # Helper module for various ascii-encoders +-#binascii binascii.c ++binascii binascii.c + + # Fred Drake's interface to the Python parser +-#parser parsermodule.c ++parser parsermodule.c + + + # Lee Busby's SIGFPE modules. +@@ -357,12 +360,12 @@ + #fpectl fpectlmodule.c ... + + # Test module for fpectl. No extra libraries needed. +-#fpetest fpetestmodule.c ++fpetest fpetestmodule.c + + # Andrew Kuchling's zlib module. + # This require zlib 1.1.3 (or later). + # See http://www.gzip.org/zlib/ +-#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz ++zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz + + # Interface to the Expat XML parser + # +@@ -375,22 +378,29 @@ + # + # More information on Expat can be found at www.libexpat.org. + # +-#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI ++pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI + + # Hye-Shik Chang's CJKCodecs + + # multibytecodec is required for all the other CJK codec modules +-#_multibytecodec cjkcodecs/multibytecodec.c ++_multibytecodec cjkcodecs/multibytecodec.c + +-#_codecs_cn cjkcodecs/_codecs_cn.c +-#_codecs_hk cjkcodecs/_codecs_hk.c +-#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c +-#_codecs_jp cjkcodecs/_codecs_jp.c +-#_codecs_kr cjkcodecs/_codecs_kr.c +-#_codecs_tw cjkcodecs/_codecs_tw.c ++_codecs_cn cjkcodecs/_codecs_cn.c ++_codecs_hk cjkcodecs/_codecs_hk.c ++_codecs_iso2022 cjkcodecs/_codecs_iso2022.c ++_codecs_jp cjkcodecs/_codecs_jp.c ++_codecs_kr cjkcodecs/_codecs_kr.c ++_codecs_tw cjkcodecs/_codecs_tw.c + + # Example -- included for reference only: + # xx xxmodule.c + + # Another example -- the 'xxsubtype' module shows C-level subtyping in action + xxsubtype xxsubtype.c ++ ++# PATCH: The rest of the modules that weren't mentioned in this file. ++_bz2 _bz2module.c -lbz2 ++_ctypes _ctypes/callbacks.c _ctypes/callproc.c _ctypes/cfield.c _ctypes/_ctypes.c _ctypes/_ctypes_test.c _ctypes/malloc_closure.c _ctypes/stgdict.c -lffi ++_lsprof _lsprof.c rotatingtree.c ++_lzma _lzmamodule.c -llzma ++_opcode _opcode.c +diff -Paur --no-dereference -- python.upstream/Modules/socketmodule.c python/Modules/socketmodule.c +--- python.upstream/Modules/socketmodule.c ++++ python/Modules/socketmodule.c +@@ -83,6 +83,17 @@ + + */ + ++#if defined(__sortix__) ++struct hostent ++{ ++ char *h_name; ++ char **h_aliases; ++ int h_addrtype; ++ int h_length; ++ char **h_addr_list; ++}; ++#endif ++ + #ifdef __APPLE__ + #include + /* for getaddrinfo thread safety test on old versions of OS X */ +@@ -479,6 +490,12 @@ + #define INADDR_NONE (-1) + #endif + ++#if defined(__sortix__) ++#define h_errno 0 ++#define gethostbyname(a) ((void) (a), (struct hostent*) NULL) ++#define gethostbyaddr(a, b, c) ((void) (a), (void) (b), (void) (c), (struct hostent*) NULL) ++#endif ++ + /* XXX There's a problem here: *static* functions are not supposed to have + a Py prefix (or use CapitalizedWords). Later... */ + +@@ -5628,6 +5645,10 @@ + static PyObject* + socket_inet_aton(PyObject *self, PyObject *args) + { ++/* PATCH: Sortix only has the modern inet_pton. */ ++#if defined(HAVE_INET_PTON) && !defined(HAVE_INET_ATON) && !defined(HAVE_INET_ADDR) ++ struct in_addr buf; ++#else + #ifdef HAVE_INET_ATON + struct in_addr buf; + #endif +@@ -5639,11 +5660,21 @@ + /* Have to use inet_addr() instead */ + unsigned int packed_addr; + #endif ++#endif + char *ip_addr; + + if (!PyArg_ParseTuple(args, "s:inet_aton", &ip_addr)) + return NULL; + ++#if defined(HAVE_INET_PTON) && !defined(HAVE_INET_ATON) && !defined(HAVE_INET_ADDR) ++ if (inet_pton(AF_INET, ip_addr, &buf)) ++ return PyBytes_FromStringAndSize((char *)(&buf), ++ sizeof(buf)); ++ ++ PyErr_SetString(PyExc_OSError, ++ "illegal IP address string passed to inet_aton"); ++ return NULL; ++#else + + #ifdef HAVE_INET_ATON + +@@ -5688,6 +5719,8 @@ + #endif + + #endif ++ ++#endif + } + + PyDoc_STRVAR(inet_ntoa_doc, +@@ -5700,6 +5733,7 @@ + { + Py_buffer packed_ip; + struct in_addr packed_addr; ++ char addr[INET_ADDRSTRLEN]; + + if (!PyArg_ParseTuple(args, "y*:inet_ntoa", &packed_ip)) { + return NULL; +@@ -5715,7 +5749,9 @@ + memcpy(&packed_addr, packed_ip.buf, packed_ip.len); + PyBuffer_Release(&packed_ip); + +- return PyUnicode_FromString(inet_ntoa(packed_addr)); ++ /* PATCH: Sortix only has the modern inet_ntop. */ ++ inet_ntop(AF_INET, &packed_addr, addr, sizeof(addr)); ++ return PyUnicode_FromString(addr); + } + + #if defined(HAVE_INET_PTON) || defined(MS_WINDOWS) +diff -Paur --no-dereference -- python.upstream/Modules/_ssl.c python/Modules/_ssl.c +--- python.upstream/Modules/_ssl.c ++++ python/Modules/_ssl.c +@@ -101,6 +101,9 @@ + + #if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER) + # define OPENSSL_VERSION_1_1 1 ++/* PATCH: The libressl shipped with Sortix is new enough.*/ ++#elif !defined(OPENSSL_VERSION_1_1) && defined(LIBRESSL_VERSION_NUMBER) && 0x3000200fL <= LIBRESSL_VERSION_NUMBER ++# define OPENSSL_VERSION_1_1 1 + #endif + + /* Openssl comes with TLSv1.1 and TLSv1.2 between 1.0.0h and 1.0.1 +diff -Paur --no-dereference -- python.upstream/Modules/timemodule.c python/Modules/timemodule.c +--- python.upstream/Modules/timemodule.c ++++ python/Modules/timemodule.c +@@ -1198,13 +1198,25 @@ + #if defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__) + PyObject *otz0, *otz1; + tzset(); ++#if defined(__sortix__) && !defined(__SORTIX_HAS_TIMEZONE__) ++ PyModule_AddIntConstant(m, "timezone", 0); ++#else + PyModule_AddIntConstant(m, "timezone", timezone); ++#endif + #ifdef HAVE_ALTZONE + PyModule_AddIntConstant(m, "altzone", altzone); + #else ++#if defined(__sortix__) && !defined(__SORTIX_HAS_ALTZONE__) ++ PyModule_AddIntConstant(m, "altzone", 0); ++#else + PyModule_AddIntConstant(m, "altzone", timezone-3600); + #endif ++#endif ++#if defined(__sortix__) && !defined(__SORTIX_HAS_DAYLIGHT__) ++ PyModule_AddIntConstant(m, "daylight", 0); ++#else + PyModule_AddIntConstant(m, "daylight", daylight); ++#endif + otz0 = PyUnicode_DecodeLocale(tzname[0], "surrogateescape"); + otz1 = PyUnicode_DecodeLocale(tzname[1], "surrogateescape"); + PyModule_AddObject(m, "tzname", Py_BuildValue("(NN)", otz0, otz1)); +diff -Paur --no-dereference -- python.upstream/Python/fileutils.c python/Python/fileutils.c +--- python.upstream/Python/fileutils.c ++++ python/Python/fileutils.c +@@ -1387,7 +1387,9 @@ + wchar_t *resolved_path, size_t resolved_path_size) + { + char *cpath; ++#if !defined(__sortix__) + char cresolved_path[MAXPATHLEN]; ++#endif + wchar_t *wresolved_path; + char *res; + size_t r; +@@ -1396,12 +1398,21 @@ + errno = EINVAL; + return NULL; + } ++#if defined(__sortix__) ++ res = realpath(cpath, NULL); ++#else + res = realpath(cpath, cresolved_path); ++#endif + PyMem_Free(cpath); + if (res == NULL) + return NULL; + ++#if defined(__sortix__) ++ wresolved_path = Py_DecodeLocale(res, &r); ++ free(res); ++#else + wresolved_path = Py_DecodeLocale(cresolved_path, &r); ++#endif + if (wresolved_path == NULL) { + errno = EINVAL; + return NULL; +@@ -1411,7 +1422,11 @@ + errno = EINVAL; + return NULL; + } ++#if defined(__sortix__) ++ wcslcpy(resolved_path, wresolved_path, resolved_path_size); ++#else + wcsncpy(resolved_path, wresolved_path, resolved_path_size); ++#endif + PyMem_RawFree(wresolved_path); + return resolved_path; + } +diff -Paur --no-dereference -- python.upstream/Python/random.c python/Python/random.c +--- python.upstream/Python/random.c ++++ python/Python/random.c +@@ -1,9 +1,15 @@ ++#if defined(__sortix__) ++#define HAVE_ARC4RANDOM ++#endif ++ + #include "Python.h" + #ifdef MS_WINDOWS + # include + /* All sample MSDN wincrypt programs include the header below. It is at least + * required with Min GW. */ + # include ++#elif defined(HAVE_ARC4RANDOM) ++# include + #else + # include + # ifdef HAVE_SYS_STAT_H +@@ -26,6 +32,7 @@ + static int _Py_HashSecret_Initialized = 0; + #endif + ++#ifndef HAVE_ARC4RANDOM + #ifdef MS_WINDOWS + static HCRYPTPROV hCryptProv = 0; + +@@ -351,6 +358,7 @@ + } + + #endif ++#endif /* !defined(HAVE_ARC4RANDOM) */ + + /* Fill buffer with pseudo-random bytes generated by a linear congruent + generator (LCG): +@@ -373,6 +381,7 @@ + } + } + ++#if !defined(HAVE_ARC4RANDOM) + /* If raise is zero: + - Don't raise exceptions on error + - Don't call PyErr_CheckSignals() on EINTR (retry directly the interrupted +@@ -401,6 +410,7 @@ + return dev_urandom(buffer, size, blocking, raise); + #endif + } ++#endif /* !defined(HAVE_ARC4RANDOM) */ + + /* Fill buffer with size pseudo-random bytes from the operating system random + number generator (RNG). It is suitable for most cryptographic purposes +@@ -414,7 +424,12 @@ + int + _PyOS_URandom(void *buffer, Py_ssize_t size) + { ++#ifdef HAVE_ARC4RANDOM ++ arc4random_buf(buffer, size); ++ return 0; ++#else + return pyurandom(buffer, size, 1, 1); ++#endif + } + + /* Fill buffer with size pseudo-random bytes from the operating system random +@@ -428,7 +443,12 @@ + int + _PyOS_URandomNonblock(void *buffer, Py_ssize_t size) + { ++#ifdef HAVE_ARC4RANDOM ++ arc4random_buf(buffer, size); ++ return 0; ++#else + return pyurandom(buffer, size, 0, 1); ++#endif + } + + void +@@ -469,6 +489,7 @@ + } + } + else { ++#ifndef HAVE_ARC4RANDOM + int res; + + /* _PyRandom_Init() is called very early in the Python initialization +@@ -480,6 +501,9 @@ + if (res < 0) { + Py_FatalError("failed to get random numbers to initialize Python"); + } ++#else ++ arc4random_buf(secret, secret_size); ++#endif + } + } + +@@ -491,7 +515,7 @@ + CryptReleaseContext(hCryptProv, 0); + hCryptProv = 0; + } +-#elif defined(PY_GETENTROPY) ++#elif defined(HAVE_ARC4RANDOM) || defined(PY_GETENTROPY) + /* nothing to clean */ + #else + dev_urandom_close(); diff --git a/ports/python/python.port b/ports/python/python.port new file mode 100644 index 00000000..8f370141 --- /dev/null +++ b/ports/python/python.port @@ -0,0 +1,20 @@ +NAME=python +BUILD_LIBRARIES='bzip2 libcurses libexpat libffi libreadline libssl libz xz libiconv? libintl? llibmpdec?' +VERSION=3.6.0 +DISTNAME=Python-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=b0c5f904f685e32d9232f7bdcbece9819a892929063b6e385414ad2dd6a23622 +UPSTREAM_SITE=https://www.python.org/ftp/python/$VERSION +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +USE_BOOTSTRAP=true +# Work around that pip always ends up in /usr despite the prefix and that this +# appears to be downloading and installing software from the internet. +CONFIGURE_ARGS=--without-ensurepip +POST_INSTALL=../python.post-install +BOOTSTRAP_BUILD_SYSTEM=configure +BOOTSTRAP_CONFIGURE_ARGS=--without-ensurepip +RELEASE_SEARCH_PAGE=https://www.python.org/downloads/source/ +RELEASE_SEARCH_REGEX='Python-([0-9]+\.[0-9]+(\.[0-9]+)*)(\.tar(\.(gz|bz2|xz)))' +NEED_WRITABLE=true diff --git a/ports/python/python.post-install b/ports/python/python.post-install new file mode 100755 index 00000000..c53f8e30 --- /dev/null +++ b/ports/python/python.post-install @@ -0,0 +1,13 @@ +#!/bin/sh -e +cd "$TIX_INSTALL_DIR/$PREFIX" +cd lib/python* +find . -type d -name __pycache__ -prune -exec rm -rf {} \; +find . -name '*.exe' -delete +rm -rf test +rm -rf ensurepip/_bundled +rm -f config*/*.a +cd "$TIX_INSTALL_DIR/$EXEC_PREFIX" +cd lib +rm -f libpython*.a +rm -f pkgconfig/python*.pc +rmdir pkgconfig || true diff --git a/ports/python/python.rmpatch b/ports/python/python.rmpatch new file mode 100644 index 00000000..982a38a8 --- /dev/null +++ b/ports/python/python.rmpatch @@ -0,0 +1,3 @@ +rm -rf -- 'Python/graminit.c' +rm -rf -- 'Python/importlib.h' +rm -rf -- 'Python/importlib_external.h' diff --git a/ports/qemu/qemu.patch b/ports/qemu/qemu.patch new file mode 100644 index 00000000..3008061a --- /dev/null +++ b/ports/qemu/qemu.patch @@ -0,0 +1,1278 @@ +diff -Paur --no-dereference -- qemu.upstream/block/raw-posix.c qemu/block/raw-posix.c +--- qemu.upstream/block/raw-posix.c ++++ qemu/block/raw-posix.c +@@ -94,6 +94,8 @@ + #include + #endif + ++#include ++ + #ifdef CONFIG_XFS + #include + #endif +diff -Paur --no-dereference -- qemu.upstream/configure qemu/configure +--- qemu.upstream/configure ++++ qemu/configure +@@ -246,12 +246,13 @@ + LDFLAGS_SHARED="-shared" + modules="no" + prefix="/usr/local" ++exec_prefix="/usr/local" + mandir="\${prefix}/share/man" + datadir="\${prefix}/share" + qemu_docdir="\${prefix}/share/doc/qemu" +-bindir="\${prefix}/bin" +-libdir="\${prefix}/lib" +-libexecdir="\${prefix}/libexec" ++bindir="\${exec_prefix}/bin" ++libdir="\${exec_prefix}/lib" ++libexecdir="\${exec_prefix}/libexec" + includedir="\${prefix}/include" + sysconfdir="\${prefix}/etc" + local_statedir="\${prefix}/var" +@@ -261,6 +262,7 @@ + bsd="no" + linux="no" + solaris="no" ++sortix="no" + profiler="no" + cocoa="no" + softmmu="yes" +@@ -320,6 +322,9 @@ + numa="" + tcmalloc="no" + jemalloc="no" ++param_build= ++param_host= ++param_target= + + # parse CC options first + for opt do +@@ -345,16 +350,29 @@ + ;; + --disable-debug-info) debug_info="no" + ;; ++ --build=*) param_build="$optarg" ++ ;; ++ --host=*) param_host="$optarg" ++ ;; ++ --target=*) param_target="$optarg" ++ ;; + esac + done + # OS specific + # Using uname is really, really broken. Once we have the right set of checks + # we can eliminate its usage altogether. + ++if test -n "${CC_FOR_BUILD}"; then ++ host_cc="${CC_FOR_BUILD}" ++fi ++ + # Preferred compiler: + # ${CC} (if set) + # ${cross_prefix}gcc (if cross-prefix specified) + # system compiler ++if [ x"${param_build}]" != x"${param_host}" ]; then ++ cross_prefix="${param_host}-" ++fi + if test -z "${CC}${cross_prefix}"; then + cc="$host_cc" + else +@@ -381,8 +399,8 @@ + "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" + } + pkg_config=query_pkg_config +-sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}" +-sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" ++sdl_config="${pkg_config} sdl" ++sdl2_config="${pkg_config} sdl2" + + # If the user hasn't specified ARFLAGS, default to 'rv', just as make does. + ARFLAGS="${ARFLAGS-rv}" +@@ -443,6 +461,8 @@ + targetos='SunOS' + elif check_define __HAIKU__ ; then + targetos='Haiku' ++elif check_define __sortix__ ; then ++ targetos='Sortix' + else + targetos=$(uname -s) + fi +@@ -666,6 +686,10 @@ + QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS" + LIBS="-lposix_error_mapper -lnetwork $LIBS" + ;; ++Sortix*) ++ audio_possible_drivers="sdl" ++ sortix="yes" ++;; + *) + audio_drv_list="oss" + audio_possible_drivers="oss alsa sdl pa" +@@ -731,6 +755,8 @@ + ;; + --prefix=*) prefix="$optarg" + ;; ++ --exec-prefix=*) exec_prefix="$optarg" ++ ;; + --interp-prefix=*) interp_prefix="$optarg" + ;; + --source-path=*) +@@ -1150,6 +1176,12 @@ + ;; + --enable-jemalloc) jemalloc="yes" + ;; ++ --build=*) ++ ;; ++ --host=*) ++ ;; ++ --target=*) ++ ;; + *) + echo "ERROR: unknown option $opt" + echo "Try '$0 --help' for more information" +@@ -1162,13 +1194,7 @@ + error_exit "Python not found. Use --python=/path/to/python" + fi + +-# Note that if the Python conditional here evaluates True we will exit +-# with status 1 which is a shell 'false' value. +-if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then +- error_exit "Cannot use '$python', Python 2.6 or later is required." \ +- "Note that Python 3 or later is not yet supported." \ +- "Use --python=/path/to/python to specify a supported Python." +-fi ++# PATCH: qemu has been patched to work with both Python 2 and 3. + + # Suppress writing compiled files + python="$python -B" +@@ -2288,14 +2314,15 @@ + fi + + has_libgcrypt_config() { +- if ! has "libgcrypt-config" ++ return 1 ++ if ! has "false" + then + return 1 + fi + + if test -n "$cross_prefix" + then +- host=$(libgcrypt-config --host) ++ host=$(false --host) + if test "$host-" != $cross_prefix + then + return 1 +@@ -2307,9 +2334,9 @@ + + if test "$gcrypt" != "no"; then + if has_libgcrypt_config; then +- gcrypt_cflags=$(libgcrypt-config --cflags) +- gcrypt_libs=$(libgcrypt-config --libs) +- # Debian has remove -lgpg-error from libgcrypt-config ++ gcrypt_cflags=$(false --cflags) ++ gcrypt_libs=$(false --libs) ++ # Debian has remove -lgpg-error from false + # as it "spreads unnecessary dependencies" which in + # turn breaks static builds... + if test "$static" = "yes" +@@ -2438,8 +2465,7 @@ + ########################################## + # SDL probe + +-# Look for sdl configuration program (pkg-config or sdl-config). Try +-# sdl-config even without cross prefix, and favour pkg-config over sdl-config. ++# Look for sdl configuration program (pkg-config). + + if test "$sdlabi" = ""; then + if $pkg_config --exists "sdl"; then +@@ -2478,9 +2504,6 @@ + fi + sdl=no + fi +-if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then +- echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2 +-fi + + sdl_too_old=no + if test "$sdl" != "no" ; then +@@ -2505,8 +2528,8 @@ + # static link with sdl ? (note: sdl.pc's --static --libs is broken) + if test "$sdl" = "yes" -a "$static" = "yes" ; then + if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then +- sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)" +- sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)" ++ sdl_libs="$sdl_libs $(false --static-libs 2>/dev/null)" ++ sdl_cflags="$sdl_cflags $(false --cflags 2>/dev/null)" + fi + if compile_prog "$sdl_cflags" "$sdl_libs" ; then + : +@@ -2893,9 +2916,8 @@ + cat > $TMPC << EOF + #include + int main(void) { +- const char *s = curses_version(); +- resize_term(0, 0); +- return s != 0; ++ /* PATCH: The old NetBSD libcurses on Sortix doesn't have these functions. */ ++ return 0; + } + EOF + IFS=: +@@ -2924,7 +2946,7 @@ + if $pkg_config libcurl --exists; then + curlconfig="$pkg_config libcurl" + else +- curlconfig=curl-config ++ curlconfig=false + fi + cat > $TMPC << EOF + #include +@@ -3970,7 +3992,7 @@ + fi + + if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \ +- "$aix" != "yes" -a "$haiku" != "yes" ; then ++ "$aix" != "yes" -a "$haiku" != "yes" -a "$sortix" != "yes" ; then + libs_softmmu="-lutil $libs_softmmu" + fi + +@@ -5006,6 +5028,9 @@ + if test "$haiku" = "yes" ; then + echo "CONFIG_HAIKU=y" >> $config_host_mak + fi ++if test "$sortix" = "yes" ; then ++ echo "CONFIG_SORTIX=y" >> $config_host_mak ++fi + if test "$static" = "yes" ; then + echo "CONFIG_STATIC=y" >> $config_host_mak + fi +diff -Paur --no-dereference -- qemu.upstream/cpus.c qemu/cpus.c +--- qemu.upstream/cpus.c ++++ qemu/cpus.c +@@ -1119,8 +1119,15 @@ + current_cpu = NULL; + qemu_mutex_unlock_iothread(); + do { ++/* PATCH: Sortix doesn't have sigwait() yet. */ ++#ifdef __sortix__ ++ sleep(1); ++ r = -1; ++ errno = EAGAIN; ++#else + int sig; + r = sigwait(&waitset, &sig); ++#endif + } while (r == -1 && (errno == EAGAIN || errno == EINTR)); + if (r == -1) { + perror("sigwait"); +@@ -1204,7 +1211,11 @@ + return; + } + cpu->thread_kicked = true; ++#if defined(__sortix__) ++ err = ENOSYS; ++#else + err = pthread_kill(cpu->thread->thread, SIG_IPI); ++#endif + if (err) { + fprintf(stderr, "qemu:%s: %s", __func__, strerror(err)); + exit(1); +diff -Paur --no-dereference -- qemu.upstream/hw/audio/fmopl.c qemu/hw/audio/fmopl.c +--- qemu.upstream/hw/audio/fmopl.c ++++ qemu/hw/audio/fmopl.c +@@ -499,7 +499,7 @@ + static inline void OPL_CALC_RH( OPL_CH *CH ) + { + UINT32 env_tam,env_sd,env_top,env_hh; +- int whitenoise = (rand()&1)*(WHITE_NOISE_db/EG_STEP); ++ int whitenoise = (arc4random()&1)*(WHITE_NOISE_db/EG_STEP); + INT32 tone8; + + OPL_SLOT *SLOT; +diff -Paur --no-dereference -- qemu.upstream/include/qemu/id.h qemu/include/qemu/id.h +--- qemu.upstream/include/qemu/id.h ++++ qemu/include/qemu/id.h +@@ -1,6 +1,9 @@ + #ifndef QEMU_ID_H + #define QEMU_ID_H + ++#ifdef ID_MAX /* Conflict with Sortix */ ++#undef ID_MAX ++#endif + typedef enum IdSubSystems { + ID_QDEV, + ID_BLOCK, +diff -Paur --no-dereference -- qemu.upstream/include/qemu/osdep.h qemu/include/qemu/osdep.h +--- qemu.upstream/include/qemu/osdep.h ++++ qemu/include/qemu/osdep.h +@@ -131,6 +131,73 @@ + #ifndef TIME_MAX + #define TIME_MAX LONG_MAX + #endif ++#ifdef __sortix__ ++#ifndef O_DSYNC ++#define O_SYNC 0 ++#endif ++#ifndef O_DIRECT ++#define O_DIRECT 0 ++#endif ++#ifndef PATH_MAX ++#define PATH_MAX 4096 ++#define PATH_MAX_IS_FAKE ++#endif ++#ifndef FILENAME_MAX ++#define FILENAME_MAX 256 ++#endif ++typedef unsigned char u_char; ++typedef unsigned short u_short; ++typedef unsigned int u_int; ++typedef unsigned long u_long; ++typedef void* caddr_t; ++/* PATCH: Sortix doesn't have file descriptor passing yet. */ ++#ifndef CMSG_DATA ++#define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1)) ++#define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg)) ++#define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ++ ++#define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1)) ++#define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) || \ ++ __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \ ++ ? 0 : (struct cmsghdr *)__CMSG_NEXT(cmsg)) ++#define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0) ++ ++#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) ++#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr))) ++#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) ++#endif ++/* PATCH: Sortix only has the modern inet_pton and inet_ntop. */ ++#define inet_aton(x, y) (inet_pton(AF_INET, (x), (y)) == 1 ? 1 : 0) ++__attribute__((unused)) ++static inline char* qemu_inet_ntoa(struct in_addr in) ++{ ++ static char buffer[INET_ADDRSTRLEN]; ++ inet_ntop(AF_INET, &in, buffer, sizeof(buffer)); ++ return buffer; ++} ++#define inet_ntoa qemu_inet_ntoa ++/* PATCH: Sortix doesn't have PATH_MAX and realpath with buffer is undefined. */ ++#ifdef PATH_MAX_IS_FAKE ++__attribute__((unused)) ++static inline char* realpathmax(const char* path, char* dest) ++{ ++ char* result = realpath(path, NULL); ++ if (!result) ++ return NULL; ++ if (!dest) ++ return result; ++ if (PATH_MAX <= strlen(result)) { ++ errno = ENAMETOOLONG; ++ free(result); ++ return NULL; ++ } ++ strcpy(dest, result); ++ free(result); ++ return dest; ++} ++#define realpath realpathmax ++#endif ++#endif + + /* HOST_LONG_BITS is the size of a native pointer in bits. */ + #if UINTPTR_MAX == UINT32_MAX +@@ -291,6 +358,12 @@ + #define FMT_pid "%ld" + #elif defined(WIN64) + #define FMT_pid "%" PRId64 ++#elif defined(__sortix__) ++#ifdef PRIdPID ++#define FMT_pid "%" PRIdPID ++#else ++#define FMT_pid "%ld" ++#endif + #else + #define FMT_pid "%d" + #endif +@@ -312,9 +385,12 @@ + ssize_t writev(int fd, const struct iovec *iov, int iov_cnt); + #else + #include ++#ifndef IOV_MAX ++#define IOV_MAX 1024 ++#endif + #endif + +-#ifdef _WIN32 ++#if defined(_WIN32) + static inline void qemu_timersub(const struct timeval *val1, + const struct timeval *val2, + struct timeval *res) +@@ -328,6 +404,18 @@ + } + } + #else ++#if !defined(timersub) /* From musl: */ ++#define timerisset(t) ((t)->tv_sec || (t)->tv_usec) ++#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0) ++#define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \ ++ (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec) ++#define timeradd(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \ ++ ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \ ++ ((a)->tv_usec -= 1000000, (a)->tv_sec++) ) ++#define timersub(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \ ++ ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \ ++ ((a)->tv_usec += 1000000, (a)->tv_sec--) ) ++#endif + #define qemu_timersub timersub + #endif + +diff -Paur --no-dereference -- qemu.upstream/main-loop.c qemu/main-loop.c +--- qemu.upstream/main-loop.c ++++ qemu/main-loop.c +@@ -83,7 +83,9 @@ + */ + sigemptyset(&set); + sigaddset(&set, SIG_IPI); ++#ifdef SIGIO + sigaddset(&set, SIGIO); ++#endif + sigaddset(&set, SIGALRM); + sigaddset(&set, SIGBUS); + /* SIGINT cannot be handled via signalfd, so that ^C can be used +diff -Paur --no-dereference -- qemu.upstream/Makefile qemu/Makefile +--- qemu.upstream/Makefile ++++ qemu/Makefile +@@ -396,6 +396,7 @@ + rm -f config.log + rm -f linux-headers/asm + rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr ++ rm -f trace-events-all qemu-version.h.tmp + for d in $(TARGET_DIRS); do \ + rm -rf $$d || exit 1 ; \ + done +diff -Paur --no-dereference -- qemu.upstream/migration/savevm.c qemu/migration/savevm.c +--- qemu.upstream/migration/savevm.c ++++ qemu/migration/savevm.c +@@ -1278,7 +1278,7 @@ + * a hostpage on it's own. + */ + error_report("Postcopy needs matching host page sizes (s=%d d=%d)", +- (int)remote_hps, getpagesize()); ++ (int)remote_hps, (int)getpagesize()); + return -1; + } + +diff -Paur --no-dereference -- qemu.upstream/net/Makefile.objs qemu/net/Makefile.objs +--- qemu.upstream/net/Makefile.objs ++++ qemu/net/Makefile.objs +@@ -10,6 +10,7 @@ + common-obj-$(CONFIG_SOLARIS) += tap-solaris.o + common-obj-$(CONFIG_AIX) += tap-aix.o + common-obj-$(CONFIG_HAIKU) += tap-haiku.o ++common-obj-$(CONFIG_SORTIX) += tap-haiku.o + common-obj-$(CONFIG_SLIRP) += slirp.o + common-obj-$(CONFIG_VDE) += vde.o + common-obj-$(CONFIG_NETMAP) += netmap.o +diff -Paur --no-dereference -- qemu.upstream/net/net.c qemu/net/net.c +--- qemu.upstream/net/net.c ++++ qemu/net/net.c +@@ -102,7 +102,6 @@ + int parse_host_port(struct sockaddr_in *saddr, const char *str) + { + char buf[512]; +- struct hostent *he; + const char *p, *r; + int port; + +@@ -113,14 +112,12 @@ + if (buf[0] == '\0') { + saddr->sin_addr.s_addr = 0; + } else { +- if (qemu_isdigit(buf[0])) { +- if (!inet_aton(buf, &saddr->sin_addr)) +- return -1; +- } else { +- if ((he = gethostbyname(buf)) == NULL) +- return - 1; +- saddr->sin_addr = *(struct in_addr *)he->h_addr; +- } ++ struct addrinfo hint = { 0 }; ++ hint.ai_family = AF_INET; ++ struct addrinfo* ai; ++ if (getaddrinfo(buf, NULL, &hint, &ai) != 0) ++ return -1; ++ saddr->sin_addr = ((struct sockaddr_in*)ai->ai_addr)->sin_addr; + } + port = strtol(p, (char **)&r, 0); + if (r == p) +diff -Paur --no-dereference -- qemu.upstream/net/socket.c qemu/net/socket.c +--- qemu.upstream/net/socket.c ++++ qemu/net/socket.c +@@ -211,14 +211,18 @@ + + static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr *localaddr) + { ++#ifdef IP_ADD_MEMBERSHIP + struct ip_mreq imr; ++#endif + int fd; + int val, ret; ++#ifdef IP_MULTICAST_LOOP + #ifdef __OpenBSD__ + unsigned char loop; + #else + int loop; + #endif ++#endif + + if (!IN_MULTICAST(ntohl(mcastaddr->sin_addr.s_addr))) { + fprintf(stderr, "qemu: error: specified mcastaddr \"%s\" (0x%08x) " +@@ -252,6 +256,7 @@ + goto fail; + } + ++#ifdef IP_ADD_MEMBERSHIP + /* Add host to multicast group */ + imr.imr_multiaddr = mcastaddr->sin_addr; + if (localaddr) { +@@ -266,8 +271,10 @@ + perror("setsockopt(IP_ADD_MEMBERSHIP)"); + goto fail; + } ++#endif + + /* Force mcast msgs to loopback (eg. several QEMUs in same host */ ++#ifdef IP_MULTICAST_LOOP + loop = 1; + ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, + &loop, sizeof(loop)); +@@ -275,7 +282,9 @@ + perror("setsockopt(SOL_IP, IP_MULTICAST_LOOP)"); + goto fail; + } ++#endif + ++#ifdef IP_MULTICAST_IF + /* If a bind address is given, only send packets from that address */ + if (localaddr != NULL) { + ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, +@@ -285,6 +294,7 @@ + goto fail; + } + } ++#endif + + qemu_set_nonblock(fd); + return fd; +@@ -590,7 +600,7 @@ + return -1; + + if (localaddr_str != NULL) { +- if (inet_aton(localaddr_str, &localaddr) == 0) ++ if (inet_pton(AF_INET, localaddr_str, &localaddr) < 1) + return -1; + param_localaddr = &localaddr; + } else { +diff -Paur --no-dereference -- qemu.upstream/net/tap.c qemu/net/tap.c +--- qemu.upstream/net/tap.c ++++ qemu/net/tap.c +@@ -30,7 +30,15 @@ + #include + #include + #include ++#if __has_include() + #include ++#endif ++#if defined(__sortix__) && !defined(IF_NAMESIZE) ++#define IF_NAMESIZE 32 ++#endif ++#if !defined(IFNAMSIZ) && defined(IF_NAMESIZE) ++#define IFNAMSIZ IF_NAMESIZE ++#endif + + #include "net/net.h" + #include "clients.h" +diff -Paur --no-dereference -- qemu.upstream/net/tap-haiku.c qemu/net/tap-haiku.c +--- qemu.upstream/net/tap-haiku.c ++++ qemu/net/tap-haiku.c +@@ -29,7 +29,11 @@ + int tap_open(char *ifname, int ifname_size, int *vnet_hdr, + int vnet_hdr_required, int mq_required, Error **errp) + { ++#ifdef __sortix__ ++ error_setg(errp, "no tap on Sortix"); ++#else + error_setg(errp, "no tap on Haiku"); ++#endif + return -1; + } + +diff -Paur --no-dereference -- qemu.upstream/os-posix.c qemu/os-posix.c +--- qemu.upstream/os-posix.c ++++ qemu/os-posix.c +@@ -169,16 +169,18 @@ + { + if (user_pwd) { + if (setgid(user_pwd->pw_gid) < 0) { +- fprintf(stderr, "Failed to setgid(%d)\n", user_pwd->pw_gid); ++ fprintf(stderr, "Failed to setgid(%jd)\n", (intmax_t)user_pwd->pw_gid); + exit(1); + } ++#if !defined(__sortix__) + if (initgroups(user_pwd->pw_name, user_pwd->pw_gid) < 0) { +- fprintf(stderr, "Failed to initgroups(\"%s\", %d)\n", +- user_pwd->pw_name, user_pwd->pw_gid); ++ fprintf(stderr, "Failed to initgroups(\"%s\", %jd)\n", ++ user_pwd->pw_name, (intmax_t)user_pwd->pw_gid); + exit(1); + } ++#endif + if (setuid(user_pwd->pw_uid) < 0) { +- fprintf(stderr, "Failed to setuid(%d)\n", user_pwd->pw_uid); ++ fprintf(stderr, "Failed to setuid(%jd)\n", (intmax_t)user_pwd->pw_uid); + exit(1); + } + if (setuid(0) != -1) { +@@ -308,10 +310,12 @@ + if (fd == -1) { + return -1; + } ++#ifdef F_TLOCK + if (lockf(fd, F_TLOCK, 0) == -1) { + close(fd); + return -1; + } ++#endif + len = snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid()); + if (write(fd, buffer, len) != len) { + close(fd); +@@ -331,10 +335,12 @@ + { + int ret = 0; + ++#if defined(MCL_CURRENT) && defined(MCL_FUTURE) + ret = mlockall(MCL_CURRENT | MCL_FUTURE); + if (ret < 0) { + perror("mlockall"); + } ++#endif + + return ret; + } +diff -Paur --no-dereference -- qemu.upstream/pc-bios/optionrom/kvmvapic.S qemu/pc-bios/optionrom/kvmvapic.S +--- qemu.upstream/pc-bios/optionrom/kvmvapic.S ++++ qemu/pc-bios/optionrom/kvmvapic.S +@@ -104,7 +104,8 @@ + reenable_vtpr + push %ecx + +- fs/movzbl pcr_cpu, %eax ++ # PATCH: Work around Sortix as(1) considering slashes as comment starters. ++ fs movzbl pcr_cpu, %eax + + mov vcpu_shift, %ecx ; fixup + shl %cl, %eax +@@ -178,7 +179,7 @@ + reenable_vtpr + + mp_set_tpr_failed: +- fs/movzbl pcr_cpu, %edx ++ fs movzbl pcr_cpu, %edx + + mov vcpu_shift, %ecx ; fixup + shl %cl, %edx +diff -Paur --no-dereference -- qemu.upstream/pc-bios/optionrom/Makefile qemu/pc-bios/optionrom/Makefile +--- qemu.upstream/pc-bios/optionrom/Makefile ++++ qemu/pc-bios/optionrom/Makefile +@@ -5,6 +5,13 @@ + include ../../config-host.mak + include $(SRC_PATH)/rules.mak + ++# TODO: Use system as because the cross as is version 2.24 and appears to have ++# problems assembling these roms correctly. linuxboot_dma.c uses the gcc ++# driver but contains inline assembly but fails with the cross as for the ++# same reason, so use system gcc instead as it will run the system as. ++CC = $(HOST_CC) ++AS = as ++ + $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom) + + .PHONY : all clean build-all +@@ -33,8 +40,11 @@ + QEMU_INCLUDES += -I$(SRC_PATH) + + Wa = -Wa, +-ASFLAGS += -32 +-QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), $(Wa)-32) ++# PATCH: Sortix as(1) currently considers slashes as a comment starter, which ++# should be fixed, but until then turn that behavior off as slashes are used for ++# division in this assembly. ++ASFLAGS += -32 --divide ++QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), $(Wa)-32 $(Wa)--divide) + + build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin + +diff -Paur --no-dereference -- qemu.upstream/qemu-char.c qemu/qemu-char.c +--- qemu.upstream/qemu-char.c ++++ qemu/qemu-char.c +@@ -50,7 +50,10 @@ + #include + #include + #include ++/* PATCH: Until Sortix networking is merged. */ ++#if __has_include() + #include ++#endif + #include + #include + #include +diff -Paur --no-dereference -- qemu.upstream/scripts/qapi.py qemu/scripts/qapi.py +--- qemu.upstream/scripts/qapi.py ++++ qemu/scripts/qapi.py +@@ -12,7 +12,8 @@ + # See the COPYING file in the top-level directory. + + import re +-from ordereddict import OrderedDict ++# PATCH: Valid Python 2 and 3. ++from collections import OrderedDict + import errno + import getopt + import os +@@ -1356,7 +1357,7 @@ + + def _make_members(self, data, info): + return [self._make_member(key, value, info) +- for (key, value) in data.iteritems()] ++ for (key, value) in data.items()] + + def _def_struct_type(self, expr, info): + name = expr['struct'] +@@ -1388,11 +1389,11 @@ + name, info, 'base', self._make_members(base, info))) + if tag_name: + variants = [self._make_variant(key, value) +- for (key, value) in data.iteritems()] ++ for (key, value) in data.items()] + members = [] + else: + variants = [self._make_simple_variant(key, value, info) +- for (key, value) in data.iteritems()] ++ for (key, value) in data.items()] + typ = self._make_implicit_enum_type(name, info, + [v.name for v in variants]) + tag_member = QAPISchemaObjectTypeMember('type', typ, False) +@@ -1407,7 +1408,7 @@ + name = expr['alternate'] + data = expr['data'] + variants = [self._make_variant(key, value) +- for (key, value) in data.iteritems()] ++ for (key, value) in data.items()] + tag_member = QAPISchemaObjectTypeMember('type', 'QType', False) + self._def_entity( + QAPISchemaAlternateType(name, info, +@@ -1516,7 +1517,11 @@ + type_name = prefix + return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper() + +-c_name_trans = string.maketrans('.-', '__') ++# PATCH: Python 3 with a Python 2 fallback ++try: ++ c_name_trans = str.maketrans('.-', '__') ++except: ++ c_name_trans = string.maketrans('.-', '__') + + + # Map @name to a valid C identifier. +@@ -1778,8 +1783,13 @@ + if really: + return open(name, opt) + else: +- import StringIO +- return StringIO.StringIO() ++ # PATCH: Python 2 with Python 3 fallback. ++ try: ++ import StringIO ++ return StringIO.StringIO() ++ except: ++ import io ++ return io.StringIO() + + fdef = maybe_open(do_c, c_file, 'w') + fdecl = maybe_open(do_h, h_file, 'w') +diff -Paur --no-dereference -- qemu.upstream/scripts/signrom.py qemu/scripts/signrom.py +--- qemu.upstream/scripts/signrom.py ++++ qemu/scripts/signrom.py +@@ -18,7 +18,7 @@ + fout = open(sys.argv[2], 'wb') + + magic = fin.read(2) +-if magic != '\x55\xaa': ++if magic != b'\x55\xaa': + sys.exit("%s: option ROM does not begin with magic 55 aa" % sys.argv[1]) + + size_byte = ord(fin.read(1)) +@@ -33,7 +33,7 @@ + # Add padding if necessary, rounding the whole input to a multiple of + # 512 bytes according to the third byte of the input. + # size-1 because a final byte is added below to store the checksum. +- data = data.ljust(size-1, '\0') ++ data = data.ljust(size-1, b'\0') + else: + if ord(data[-1:]) != 0: + sys.stderr.write('WARNING: ROM includes nonzero checksum\n') +diff -Paur --no-dereference -- qemu.upstream/scripts/tracetool/backend/log.py qemu/scripts/tracetool/backend/log.py +--- qemu.upstream/scripts/tracetool/backend/log.py ++++ qemu/scripts/tracetool/backend/log.py +@@ -39,8 +39,8 @@ + out(' if (%(cond)s) {', + ' struct timeval _now;', + ' gettimeofday(&_now, NULL);', +- ' qemu_log_mask(LOG_TRACE, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",', +- ' getpid(),', ++ ' qemu_log_mask(LOG_TRACE, "%%jd@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",', ++ ' (intmax_t)getpid(),', + ' (size_t)_now.tv_sec, (size_t)_now.tv_usec', + ' %(argnames)s);', + ' }', +diff -Paur --no-dereference -- qemu.upstream/slirp/ip6_icmp.c qemu/slirp/ip6_icmp.c +--- qemu.upstream/slirp/ip6_icmp.c ++++ qemu/slirp/ip6_icmp.c +@@ -10,6 +10,10 @@ + #include "qemu/error-report.h" + #include "qemu/log.h" + ++#ifndef IPPROTO_ICMPV6 ++#define IPPROTO_ICMPV6 58 ++#endif ++ + #define NDP_Interval g_rand_int_range(slirp->grand, \ + NDP_MinRtrAdvInterval, NDP_MaxRtrAdvInterval) + +diff -Paur --no-dereference -- qemu.upstream/slirp/ip6_input.c qemu/slirp/ip6_input.c +--- qemu.upstream/slirp/ip6_input.c ++++ qemu/slirp/ip6_input.c +@@ -7,6 +7,10 @@ + #include "slirp.h" + #include "ip6_icmp.h" + ++#ifndef IPPROTO_ICMPV6 ++#define IPPROTO_ICMPV6 58 ++#endif ++ + /* + * IP initialization: fill in IP protocol switch table. + * All protocols not implemented in kernel go to raw IP protocol handler. +diff -Paur --no-dereference -- qemu.upstream/slirp/mbuf.c qemu/slirp/mbuf.c +--- qemu.upstream/slirp/mbuf.c ++++ qemu/slirp/mbuf.c +@@ -159,12 +159,12 @@ + if(m->m_size>size) return; + + if (m->m_flags & M_EXT) { +- datasize = m->m_data - m->m_ext; ++ datasize = (char*)m->m_data - m->m_ext; + m->m_ext = (char *)realloc(m->m_ext,size); + m->m_data = m->m_ext + datasize; + } else { + char *dat; +- datasize = m->m_data - m->m_dat; ++ datasize = (char*)m->m_data - m->m_dat; + dat = (char *)malloc(size); + memcpy(dat, m->m_dat, m->m_size); + +diff -Paur --no-dereference -- qemu.upstream/slirp/mbuf.h qemu/slirp/mbuf.h +--- qemu.upstream/slirp/mbuf.h ++++ qemu/slirp/mbuf.h +@@ -53,9 +53,9 @@ + * How much room is in the mbuf, from m_data to the end of the mbuf + */ + #define M_ROOM(m) ((m->m_flags & M_EXT)? \ +- (((m)->m_ext + (m)->m_size) - (m)->m_data) \ ++ (((m)->m_ext + (m)->m_size) - (char*)((m)->m_data)) \ + : \ +- (((m)->m_dat + (m)->m_size) - (m)->m_data)) ++ (((m)->m_dat + (m)->m_size) - (char*)((m)->m_data))) + + /* + * How much free room there is +@@ -75,7 +75,7 @@ + int m_size; /* Size of data */ + struct socket *m_so; + +- caddr_t m_data; /* Location of data */ ++ char* m_data; /* Location of data */ + int m_len; /* Amount of data in this mbuf */ + + Slirp *slirp; +diff -Paur --no-dereference -- qemu.upstream/slirp/misc.c qemu/slirp/misc.c +--- qemu.upstream/slirp/misc.c ++++ qemu/slirp/misc.c +@@ -144,8 +144,7 @@ + dup2(s, 0); + dup2(s, 1); + dup2(s, 2); +- for (s = getdtablesize() - 1; s >= 3; s--) +- close(s); ++ closefrom(3); + + i = 0; + bptr = g_strdup(ex); /* No need to free() this */ +diff -Paur --no-dereference -- qemu.upstream/slirp/slirp.c qemu/slirp/slirp.c +--- qemu.upstream/slirp/slirp.c ++++ qemu/slirp/slirp.c +@@ -31,8 +31,13 @@ + #include "qemu/cutils.h" + + #ifndef _WIN32 ++#if __has_include() + #include + #endif ++#if __has_include() ++#include ++#endif ++#endif + + /* host loopback address */ + struct in_addr loopback_addr; +@@ -49,6 +54,7 @@ + static QTAILQ_HEAD(slirp_instances, Slirp) slirp_instances = + QTAILQ_HEAD_INITIALIZER(slirp_instances); + ++#if !__has_include() + static struct in_addr dns_addr; + #ifndef _WIN32 + static struct in6_addr dns6_addr; +@@ -57,6 +63,7 @@ + #ifndef _WIN32 + static u_int dns6_addr_time; + #endif ++#endif + + #define TIMEOUT_FAST 2 /* milliseconds */ + #define TIMEOUT_SLOW 499 /* milliseconds */ +@@ -120,6 +127,39 @@ + WSACleanup(); + } + ++#elif __has_include() ++ ++/* TODO: This only uses the first suitable DNS server. */ ++ ++int get_dns_addr(struct in_addr *pdns_addr) ++{ ++ struct dnsconfig cfg; ++ if (getdnsconfig(&cfg) < 0) { ++ return -1; ++ } ++ for (size_t i = 0; i < cfg.servers_count; i++) { ++ if (cfg.servers[i].family != AF_INET) continue; ++ pdns_addr->s_addr = cfg.servers[i].addr.in.s_addr; ++ return 1; ++ } ++ return -1; ++} ++ ++int get_dns6_addr(struct in6_addr *pdns6_addr, uint32_t *scope_id) ++{ ++ struct dnsconfig cfg; ++ if (getdnsconfig(&cfg) < 0) { ++ return -1; ++ } ++ for (size_t i = 0; i < cfg.servers_count; i++) { ++ if (cfg.servers[i].family != AF_INET6) continue; ++ memcpy(pdns6_addr, &cfg.servers[i].addr.in6, sizeof(struct in6_addr)); ++ *scope_id = 0; ++ return 1; ++ } ++ return -1; ++} ++ + #else + + static int get_dns_addr_cached(void *pdns_addr, void *cached_addr, +@@ -167,7 +207,12 @@ + if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) { + char *c = strchr(buff2, '%'); + if (c) { ++#if __has_include() + if_index = if_nametoindex(c + 1); ++#else ++ errno = ENOSYS; ++ if_index = 0; ++#endif + *c = '\0'; + } else { + if_index = 0; +diff -Paur --no-dereference -- qemu.upstream/slirp/socket.c qemu/slirp/socket.c +--- qemu.upstream/slirp/socket.c ++++ qemu/slirp/socket.c +@@ -522,10 +522,14 @@ + */ + len = M_FREEROOM(m); + /* if (so->so_fport != htons(53)) { */ ++#ifdef FIONREAD + ioctlsocket(so->s, FIONREAD, &n); ++#else ++ n = 65527; ++#endif + + if (n > len) { +- n = (m->m_data - m->m_dat) + m->m_len + n + 1; ++ n = ((char*)m->m_data - m->m_dat) + m->m_len + n + 1; + m_inc(m, n); + len = M_FREEROOM(m); + } +diff -Paur --no-dereference -- qemu.upstream/tests/Makefile.include qemu/tests/Makefile.include +--- qemu.upstream/tests/Makefile.include ++++ qemu/tests/Makefile.include +@@ -645,7 +645,7 @@ + rmdir $(INITRD_WORK_DIR) + + ifeq ($(CONFIG_POSIX),y) +-LIBS += -lutil ++#LIBS += -lutil + endif + + # QTest rules +diff -Paur --no-dereference -- qemu.upstream/ui/curses.c qemu/ui/curses.c +--- qemu.upstream/ui/curses.c ++++ qemu/ui/curses.c +@@ -114,12 +114,7 @@ + static volatile sig_atomic_t got_sigwinch; + static void curses_winch_check(void) + { +- struct winsize { +- unsigned short ws_row; +- unsigned short ws_col; +- unsigned short ws_xpixel; /* unused */ +- unsigned short ws_ypixel; /* unused */ +- } ws; ++ struct winsize ws; + + if (!got_sigwinch) { + return; +@@ -130,7 +125,11 @@ + return; + } + ++/* PATCH: libcurses seems to be out of date, newer NetBSD libcurses seems to ++ have resize_term. */ ++#if !defined(__sortix__) + resize_term(ws.ws_row, ws.ws_col); ++#endif + invalidate = 1; + } + +diff -Paur --no-dereference -- qemu.upstream/ui/sdl.c qemu/ui/sdl.c +--- qemu.upstream/ui/sdl.c ++++ qemu/ui/sdl.c +@@ -210,7 +210,7 @@ + + /* specific keyboard conversions from scan codes */ + +-#if defined(_WIN32) ++#if defined(_WIN32) || defined(__sortix__) + + static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev) + { +diff -Paur --no-dereference -- qemu.upstream/ui/vnc.c qemu/ui/vnc.c +--- qemu.upstream/ui/vnc.c ++++ qemu/ui/vnc.c +@@ -2481,10 +2481,8 @@ + { + int i; + +- srand(time(NULL)+getpid()+getpid()*987654+rand()); +- + for (i = 0 ; i < sizeof(vs->challenge) ; i++) +- vs->challenge[i] = (int) (256.0*rand()/(RAND_MAX+1.0)); ++ vs->challenge[i] = (int) (256.0*arc4random()/(UINT32_MAX+1.0)); + } + + static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len) +diff -Paur --no-dereference -- qemu.upstream/ui/vnc-enc-tight.c qemu/ui/vnc-enc-tight.c +--- qemu.upstream/ui/vnc-enc-tight.c ++++ qemu/ui/vnc-enc-tight.c +@@ -40,6 +40,12 @@ + #include + #endif + #ifdef CONFIG_VNC_JPEG ++/* PATCH: libglib's FALSE and TRUE definitions collide with libjpeg's enum ++ boolean because everything is terrible and everyone should be ashamed ++ of themselves. The HAVE_BOOLEAN macro intended to work around this ++ situation doesn't work. */ ++#undef FALSE ++#undef TRUE + #include + #endif + +diff -Paur --no-dereference -- qemu.upstream/util/compatfd.c qemu/util/compatfd.c +--- qemu.upstream/util/compatfd.c ++++ qemu/util/compatfd.c +@@ -31,6 +31,11 @@ + struct sigfd_compat_info *info = opaque; + + while (1) { ++/* PATCH: Sortix doesn't have sigwait() yet. */ ++#if defined(__sortix__) ++ (void) info; ++ sleep(1); ++#else + int sig; + int err; + +@@ -63,7 +68,9 @@ + offset += len; + } + } ++#endif + } ++ return NULL; + } + + static int qemu_signalfd_compat(const sigset_t *mask) +diff -Paur --no-dereference -- qemu.upstream/util/coroutine-sigaltstack.c qemu/util/coroutine-sigaltstack.c +--- qemu.upstream/util/coroutine-sigaltstack.c ++++ qemu/util/coroutine-sigaltstack.c +@@ -203,7 +203,13 @@ + * called. + */ + coTS->tr_called = 0; ++#if defined(__sortix__) ++ pthread_sigmask(SIG_UNBLOCK, &sigs, NULL); ++ raise(SIGUSR2); ++ pthread_sigmask(SIG_BLOCK, &sigs, NULL); ++#else + pthread_kill(pthread_self(), SIGUSR2); ++#endif + sigfillset(&sigs); + sigdelset(&sigs, SIGUSR2); + while (!coTS->tr_called) { +diff -Paur --no-dereference -- qemu.upstream/util/oslib-posix.c qemu/util/oslib-posix.c +--- qemu.upstream/util/oslib-posix.c ++++ qemu/util/oslib-posix.c +@@ -37,7 +37,7 @@ + #include "qapi/error.h" + #include "qemu/sockets.h" + #include +-#include ++#include + #include "qemu/cutils.h" + + #ifdef CONFIG_LINUX +@@ -61,7 +61,36 @@ + + int qemu_daemon(int nochdir, int noclose) + { ++#if defined(__sortix__) /* From musl: */ ++ if (!nochdir && chdir("/")) ++ return -1; ++ if (!noclose) { ++ int fd, failed = 0; ++ if ((fd = open("/dev/null", O_RDWR)) < 0) return -1; ++ if (dup2(fd, 0) < 0 || dup2(fd, 1) < 0 || dup2(fd, 2) < 0) ++ failed++; ++ if (fd > 2) close(fd); ++ if (failed) return -1; ++ } ++ ++ switch(fork()) { ++ case 0: break; ++ case -1: return -1; ++ default: _exit(0); ++ } ++ ++ if (setsid() < 0) return -1; ++ ++ switch(fork()) { ++ case 0: break; ++ case -1: return -1; ++ default: _exit(0); ++ } ++ ++ return 0; ++#else + return daemon(nochdir, noclose); ++#endif + } + + void *qemu_oom_check(void *ptr) +@@ -90,6 +119,9 @@ + } + #elif defined(CONFIG_BSD) + ptr = valloc(size); ++#elif defined(__sortix__) ++ /* TODO: Sortix doesn't have memalign, hope 16-byte alignment is fine. */ ++ ptr = malloc(size); + #else + ptr = memalign(alignment, size); + #endif +@@ -189,6 +221,9 @@ + + int qemu_utimens(const char *path, const struct timespec *times) + { ++#if defined(__sortix__) ++ return utimens(path, times); ++#else + struct timeval tv[2], tv_now; + struct stat st; + int i; +@@ -232,6 +267,7 @@ + } + + return utimes(path, &tv[0]); ++#endif + } + + char * +diff -Paur --no-dereference -- qemu.upstream/util/path.c qemu/util/path.c +--- qemu.upstream/util/path.c ++++ qemu/util/path.c +@@ -4,7 +4,6 @@ + The assumption is that this area does not change. + */ + #include "qemu/osdep.h" +-#include + #include + #include "qemu-common.h" + #include "qemu/cutils.h" +diff -Paur --no-dereference -- qemu.upstream/util/qemu-openpty.c qemu/util/qemu-openpty.c +--- qemu.upstream/util/qemu-openpty.c ++++ qemu/util/qemu-openpty.c +@@ -47,6 +47,9 @@ + #elif defined CONFIG_SOLARIS + # include + # include ++#elif defined(__sortix__) ++# include ++# include + #else + # include + #endif +@@ -93,7 +96,10 @@ + close(mfd); + return -1; + } ++#endif + ++// TODO: Sortix cfmakeraw. ++#if defined(__sun__) || defined(__sortix__) + static void cfmakeraw (struct termios *termios_p) + { + termios_p->c_iflag &= +diff -Paur --no-dereference -- qemu.upstream/util/rcu.c qemu/util/rcu.c +--- qemu.upstream/util/rcu.c ++++ qemu/util/rcu.c +@@ -319,6 +319,10 @@ + rcu_register_thread(); + } + ++#if defined(__sortix__) ++#undef CONFIG_POSIX ++#endif ++ + #ifdef CONFIG_POSIX + static void rcu_init_lock(void) + { diff --git a/ports/qemu/qemu.port b/ports/qemu/qemu.port new file mode 100644 index 00000000..0c89c97f --- /dev/null +++ b/ports/qemu/qemu.port @@ -0,0 +1,12 @@ +NAME=qemu +BUILD_LIBRARIES='libstdc++ libz libglib libpixman bzip2? libSDL? libcurses? libcurl? libGL? libgtk? libssh2? libgcrypt? libtasn1?' +VERSION=2.7.0 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.bz2 +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=326e739506ba690daf69fc17bd3913a6c313d9928d743bd8eddb82f403f81e53 +UPSTREAM_SITE=https://download.qemu.org +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--target-list="i386-softmmu x86_64-softmmu"' +MAKE_VARS='V=1' diff --git a/ports/sed/sed.patch b/ports/sed/sed.patch new file mode 100644 index 00000000..78ce7b3d --- /dev/null +++ b/ports/sed/sed.patch @@ -0,0 +1,12 @@ +diff -Paur --no-dereference -- sed.upstream/build-aux/config.sub sed/build-aux/config.sub +--- sed.upstream/build-aux/config.sub ++++ sed/build-aux/config.sub +@@ -1264,7 +1264,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --git a/ports/sed/sed.port b/ports/sed/sed.port new file mode 100644 index 00000000..234eeda0 --- /dev/null +++ b/ports/sed/sed.port @@ -0,0 +1,11 @@ +NAME=sed +BUILD_LIBRARIES='libiconv?' +VERSION=4.2 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.bz2 +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=ee7755e3ab038e7deecebdf44fd43ad65a96890962c3b44206cce672368b45c8 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/sed +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_VARS='gt_cv_locale_fr=false gt_cv_locale_ja=false gt_cv_locale_fr_utf8=false gt_cv_locale_ja_utf8=false gt_cv_locale_tr_utf8=false gt_cv_locale_zh_CN=false' diff --git a/ports/sed/sed.rmpatch b/ports/sed/sed.rmpatch new file mode 100644 index 00000000..ed860fd9 --- /dev/null +++ b/ports/sed/sed.rmpatch @@ -0,0 +1 @@ +rm -rf -- 'bootstrap.sh' diff --git a/ports/tar/tar.patch b/ports/tar/tar.patch new file mode 100644 index 00000000..f274f840 --- /dev/null +++ b/ports/tar/tar.patch @@ -0,0 +1,201 @@ +diff -Paur --no-dereference -- tar.upstream/build-aux/config.sub tar/build-aux/config.sub +--- tar.upstream/build-aux/config.sub ++++ tar/build-aux/config.sub +@@ -1356,7 +1356,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- tar.upstream/configure tar/configure +--- tar.upstream/configure ++++ tar/configure +@@ -1,4 +1,123 @@ + #! /bin/sh ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes # Not needed since February 2015 ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypotl_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for GNU tar 1.28. + # +diff -Paur --no-dereference -- tar.upstream/gnu/getgroups.c tar/gnu/getgroups.c +--- tar.upstream/gnu/getgroups.c ++++ tar/gnu/getgroups.c +@@ -32,7 +32,7 @@ + /* Provide a stub that fails with ENOSYS, since there is no group + information available on mingw. */ + int +-getgroups (int n _GL_UNUSED, GETGROUPS_T *groups _GL_UNUSED) ++getgroups (int n _GL_UNUSED, gid_t *groups _GL_UNUSED) + { + errno = ENOSYS; + return -1; +diff -Paur --no-dereference -- tar.upstream/lib/rtapelib.c tar/lib/rtapelib.c +--- tar.upstream/lib/rtapelib.c ++++ tar/lib/rtapelib.c +@@ -424,8 +424,10 @@ + } + } + ++#if !defined(__sortix__) + /* FIXME: Should somewhat validate the decoding, here. */ + if (gethostbyname (remote_host) == NULL) ++#endif + error (EXIT_ON_EXEC_ERROR, 0, _("Cannot connect to %s: resolve failed"), + remote_host); + +diff -Paur --no-dereference -- tar.upstream/lib/xattr-at.c tar/lib/xattr-at.c +--- tar.upstream/lib/xattr-at.c ++++ tar/lib/xattr-at.c +@@ -31,6 +31,8 @@ + + #include "openat-priv.h" + ++#if defined(HAVE_XATTRS) && !(defined(__sortix__) && __has_include()) ++ + /* setxattrat */ + #define AT_FUNC_NAME setxattrat + #define AT_FUNC_F1 setxattr +@@ -108,3 +110,5 @@ + #undef AT_FUNC_RESULT + #undef AT_FUNC_POST_FILE_PARAM_DECLS + #undef AT_FUNC_POST_FILE_ARGS ++ ++#endif +diff -Paur --no-dereference -- tar.upstream/lib/xattr-at.h tar/lib/xattr-at.h +--- tar.upstream/lib/xattr-at.h ++++ tar/lib/xattr-at.h +@@ -30,6 +30,7 @@ + # define ENOATTR ENODATA /* No such attribute */ + #endif + ++#if !(defined(__sortix__) && __has_include()) + /* These are the dir-fd-relative variants of the functions without the + "at" suffix. For example, setxattrat (AT_FDCWD, path, name, value, size, + flags &c) is usually equivalent to setxattr (file, name, value, size, +@@ -70,5 +71,6 @@ + except when DIR_FD and FILE specify a symlink: llistxattr operates on the + symlink, while the listxattrat operates on the referent of the symlink. */ + ssize_t llistxattrat (int dir_fd, const char *path, char *list, size_t size); ++#endif + + #endif /* XATTRS_AT_H */ diff --git a/ports/tar/tar.port b/ports/tar/tar.port new file mode 100644 index 00000000..fb755d49 --- /dev/null +++ b/ports/tar/tar.port @@ -0,0 +1,11 @@ +NAME=tar +BUILD_LIBRARIES='libiconv? gettext?' +VERSION=1.28 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=64ee8d88ec1b47a0961033493f919d27218c41b580138fd6802327462aff22f2 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/tar +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +MAKE_VARS='V=1' diff --git a/ports/tar/tar.rmpatch b/ports/tar/tar.rmpatch new file mode 100644 index 00000000..c06153ab --- /dev/null +++ b/ports/tar/tar.rmpatch @@ -0,0 +1 @@ +rm -rf -- 'doc/stamp-vti' diff --git a/ports/texinfo/texinfo.patch b/ports/texinfo/texinfo.patch new file mode 100644 index 00000000..18cddbfc --- /dev/null +++ b/ports/texinfo/texinfo.patch @@ -0,0 +1,141 @@ +diff -Paur --no-dereference -- texinfo.upstream/configure texinfo/configure +--- texinfo.upstream/configure ++++ texinfo/configure +@@ -1,4 +1,124 @@ + #! /bin/sh ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes # Not needed since February 2015 ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypotl_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. ++export ac_cv_func_realloc_0_nonnull=yes # TODO: Investigate this, found in flex. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.71 for GNU Texinfo 6.8. + # +diff -Paur --no-dereference -- texinfo.upstream/Makefile.in texinfo/Makefile.in +--- texinfo.upstream/Makefile.in ++++ texinfo/Makefile.in +@@ -1795,6 +1795,9 @@ + distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile ++ # PATCH: Empty .deps directories are left behind. ++ find -type d -name .deps -prune -exec rm -rf '{}' ';' ++ rm -rf gnulib/lib/sys + distclean-am: clean-am distclean-generic distclean-hdr distclean-local \ + distclean-tags + diff --git a/ports/texinfo/texinfo.port b/ports/texinfo/texinfo.port new file mode 100644 index 00000000..3dc6938d --- /dev/null +++ b/ports/texinfo/texinfo.port @@ -0,0 +1,12 @@ +NAME=texinfo +BUILD_LIBRARIES='libiconv? libintl?' +VERSION=6.8 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=8eb753ed28bca21f8f56c1a180362aed789229bd62fff58bf8368e9beb59fec4 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/texinfo +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS=--disable-perl-xs +MAKE_VARS='V=1' diff --git a/ports/texinfo/texinfo.rmpatch b/ports/texinfo/texinfo.rmpatch new file mode 100644 index 00000000..f1f0f557 --- /dev/null +++ b/ports/texinfo/texinfo.rmpatch @@ -0,0 +1,3 @@ +rm -rf -- 'doc/Makefile.gdoc' +rm -rf -- 'doc/stamp-1' +rm -rf -- 'doc/stamp-vti' diff --git a/ports/video-player/video-player.patch b/ports/video-player/video-player.patch new file mode 100644 index 00000000..fd444a6a --- /dev/null +++ b/ports/video-player/video-player.patch @@ -0,0 +1,357 @@ +diff -Paur --no-dereference -- video-player.upstream/Makefile video-player/Makefile +--- video-player.upstream/Makefile ++++ video-player/Makefile +@@ -0,0 +1,36 @@ ++include ../../../build-aux/compiler.mak ++include ../../../build-aux/version.mak ++include ../../../build-aux/dirs.mak ++ ++PKG_CONFIG?=pkg-config ++ ++OPTLEVEL?=-g -O2 ++CXXFLAGS?=$(OPTLEVEL) ++ ++CPPFLAGS:=$(CPPFLAGS) ++CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti ++ ++BINARY:=video-player ++LIBS!=$(PKG_CONFIG) --libs libavcodec libavformat libswscale ++ ++DISPLAY:=$(shell $(LD) -ldisplay -o /dev/null 2>/dev/null && echo 1) ++ifeq ($(DISPLAY),1) ++LIBS:=$(LIBS) -ldisplay ++CPPFLAGS:=$(CPPFLAGS) -DDISPLAY ++else ++LIBS:=$(LIBS) -ldispd ++endif ++ ++all: $(BINARY) ++ ++.PHONY: all install clean ++ ++%: %.cpp ++ $(CXX) -std=gnu++11 $(CXXFLAGS) $(CPPFLAGS) $< -o $@ $(LIBS) ++ ++install: all ++ mkdir -p $(DESTDIR)$(BINDIR) ++ install $(BINARY) $(DESTDIR)$(BINDIR) ++ ++clean: ++ rm -f $(BINARY) +diff -Paur --no-dereference -- video-player.upstream/video-player.cpp video-player/video-player.cpp +--- video-player.upstream/video-player.cpp ++++ video-player/video-player.cpp +@@ -0,0 +1,313 @@ ++#define __STDC_CONSTANT_MACROS ++#define __STDC_LIMIT_MACROS ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifdef DISPLAY ++#include ++#else ++#include ++#endif ++ ++extern "C" { ++#include ++#include ++#include ++} // extern "C" ++ ++uint32_t WINDOW_ID = 0; ++uint32_t WINDOW_WIDTH = 0; ++uint32_t WINDOW_HEIGHT = 0; ++ ++bool need_show = true; ++bool need_exit = false; ++ ++uint32_t* framebuffer = NULL; ++size_t framebuffer_size = 0; ++ ++void on_disconnect(void*) ++{ ++ need_exit = true; ++} ++ ++void on_quit(void*, uint32_t window_id) ++{ ++ if ( window_id != WINDOW_ID ) ++ return; ++ need_exit = true; ++} ++ ++void on_resize(void*, uint32_t window_id, uint32_t width, uint32_t height) ++{ ++ if ( window_id != WINDOW_ID ) ++ return; ++ WINDOW_WIDTH = width; ++ WINDOW_HEIGHT = height; ++} ++ ++void on_keyboard(void*, uint32_t window_id, uint32_t) ++{ ++ if ( window_id != WINDOW_ID ) ++ return; ++} ++ ++#ifdef DISPLAY ++static void DisplayVideoFrame(AVFrame* frame, struct display_connection* connection) ++#else ++static void DisplayVideoFrame(AVFrame* frame, struct dispd_window* window) ++#endif ++{ ++#ifdef DISPLAY ++ size_t framebuffer_needed = sizeof(uint32_t) * WINDOW_WIDTH * WINDOW_HEIGHT; ++ if ( framebuffer_size != framebuffer_needed ) ++ { ++ framebuffer = (uint32_t*) realloc(framebuffer, framebuffer_size = framebuffer_needed); ++ memset(framebuffer, 255, framebuffer_needed); ++ } ++ uint32_t width = WINDOW_WIDTH; ++ uint32_t height = WINDOW_HEIGHT; ++#else ++ struct dispd_framebuffer* window_fb = dispd_begin_render(window); ++ uint32_t width = dispd_get_framebuffer_width(window_fb); ++ uint32_t height = dispd_get_framebuffer_height(window_fb); ++ uint32_t* framebuffer = (uint32_t*) dispd_get_framebuffer_data(window_fb); ++#endif ++ ++ SwsContext* sws_ctx = sws_getContext(frame->width, frame->height, ++ (AVPixelFormat) frame->format, width, ++ height, AV_PIX_FMT_RGB32, SWS_BILINEAR, ++ NULL, NULL, NULL); ++ assert(sws_ctx); ++ ++ uint8_t* data_arr[1] = { (uint8_t*) framebuffer }; ++ int stride_arr[1] = { (int) (sizeof(framebuffer[0]) * width) }; ++ sws_scale(sws_ctx, frame->data, frame->linesize, 0, frame->height, data_arr, ++ stride_arr); ++ ++ sws_freeContext(sws_ctx); ++ ++#ifdef DISPLAY ++ display_render_window(connection, WINDOW_ID, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, framebuffer); ++ ++ struct display_event_handlers handlers; ++ memset(&handlers, 0, sizeof(handlers)); ++ handlers.disconnect_handler = on_disconnect; ++ handlers.quit_handler = on_quit; ++ handlers.resize_handler = on_resize; ++ handlers.keyboard_handler = on_keyboard; ++ while ( display_poll_event(connection, &handlers) == 0 ); ++#else ++ dispd_finish_render(window_fb); ++#endif ++} ++ ++#ifdef DISPLAY ++bool PlayVideo(const char* path, struct display_connection* connection) ++#else ++bool PlayVideo(const char* path, struct dispd_window* connection) ++#endif ++{ ++ bool ret = false; ++ int av_error; ++ AVFormatContext* format_ctx = NULL; ++ int video_stream_id; ++ int audio_stream_id; ++ AVStream* video_stream = NULL; ++ AVStream* audio_stream = NULL; ++ AVCodec* video_codec = NULL; ++ AVCodec* audio_codec = NULL; ++ AVCodecContext* video_codec_ctx = NULL; ++ AVCodecContext* audio_codec_ctx = NULL; ++ AVFrame* video_frame = NULL; ++ AVFrame* audio_frame = NULL; ++ AVPacket packet; ++ ++ if ( (av_error = avformat_open_input(&format_ctx, path, NULL, NULL)) < 0 ) ++ { ++ error(0, 0, "%s: cannot open: %i\n", path, av_error); ++ goto cleanup_done; ++ } ++ ++ if ( (av_error = avformat_find_stream_info(format_ctx, NULL)) < 0 ) ++ { ++ error(0, 0, "%s: avformat_find_stream_info: %i\n", path, av_error); ++ goto cleanup_input; ++ } ++ ++ video_stream_id = av_find_best_stream(format_ctx, AVMEDIA_TYPE_VIDEO, -1, ++ -1, &video_codec, 0); ++ audio_stream_id = av_find_best_stream(format_ctx, AVMEDIA_TYPE_AUDIO, -1, ++ -1, &audio_codec, 0); ++ ++ if ( 0 <= video_stream_id ) ++ video_stream = format_ctx->streams[video_stream_id]; ++ if ( 0 <= audio_stream_id ) ++ audio_stream = format_ctx->streams[audio_stream_id]; ++ ++ if ( !video_stream ) ++ { ++ error(0, 0, "%s: no video stream found\n", path); ++ goto cleanup_input; ++ } ++ ++ if ( video_codec && !(video_codec_ctx = avcodec_alloc_context3(video_codec))) ++ goto cleanup_input; ++ if ( audio_codec && !(audio_codec_ctx = avcodec_alloc_context3(audio_codec))) ++ goto cleanup_video_codec_ctx; ++ ++ if ( video_codec_ctx ) ++ { ++ video_codec_ctx->extradata = video_stream->codec->extradata; ++ video_codec_ctx->extradata_size = video_stream->codec->extradata_size; ++ if ( (av_error = avcodec_open2(video_codec_ctx, NULL, NULL)) < 0 ) ++ goto cleanup_audio_codec_ctx; ++ } ++ if ( audio_codec_ctx ) ++ { ++ audio_codec_ctx->extradata = audio_stream->codec->extradata; ++ audio_codec_ctx->extradata_size = audio_stream->codec->extradata_size; ++ if ( (av_error = avcodec_open2(audio_codec_ctx, NULL, NULL)) < 0 ) ++ goto cleanup_audio_codec_ctx; ++ } ++ ++ if ( !(video_frame = av_frame_alloc()) ) ++ goto cleanup_audio_codec_ctx; ++ if ( !(audio_frame = av_frame_alloc()) ) ++ goto cleanup_video_frame; ++ ++ struct timespec next_frame_at; ++ clock_gettime(CLOCK_MONOTONIC, &next_frame_at); ++ ++ while ( !need_exit && 0 <= (av_error = av_read_frame(format_ctx, &packet)) ) ++ { ++ int stream_index = packet.stream_index; ++ int packet_off = 0; ++ while ( stream_index == video_stream->index && packet_off < packet.size ) ++ { ++ packet.data += packet_off; packet.size -= packet_off; ++ int got_frame; ++ int bytes_used = avcodec_decode_video2(video_codec_ctx, video_frame, ++ &got_frame, &packet); ++ packet.data -= packet_off; packet.size += packet_off; ++ ++ if ( (av_error = bytes_used) < 0 ) ++ goto break_decode_loop; ++ if ( !got_frame ) ++ break; ++ packet_off += bytes_used; ++ ++ struct timespec now; ++ clock_gettime(CLOCK_MONOTONIC, &now); ++ while ( timespec_le(now, next_frame_at) ) ++ { ++ struct timespec left = timespec_sub(next_frame_at, now); ++ clock_nanosleep(CLOCK_MONOTONIC, 0, &left, NULL); ++ clock_gettime(CLOCK_MONOTONIC, &now); ++ } ++ ++ DisplayVideoFrame(video_frame, connection); ++ ++ uintmax_t usecs = video_codec_ctx->ticks_per_frame * 1000000 * ++ video_codec_ctx->time_base.num / ++ video_codec_ctx->time_base.den; ++ next_frame_at = timespec_add(next_frame_at, timespec_make(0, usecs * 1000)); ++ } ++ while ( stream_index == audio_stream->index && packet_off < packet.size ) ++ { ++ // TODO: Add sound support when an backend is available. ++ packet_off = packet.size; ++ } ++ } ++break_decode_loop: ++ ++ // TODO: Determine whether the are here because of EOF or whether an error ++ // occured and we need to print an error. ++ // TODO: Do we need to clean up the last packet or does the av_read_frame ++ // function do that for us upon error? ++ ret = true; ++ ++goto cleanup_audio_frame; ++cleanup_audio_frame: ++ if ( audio_frame ) ++ av_frame_free(&audio_frame); ++cleanup_video_frame: ++ if ( video_frame ) ++ av_frame_free(&video_frame); ++cleanup_audio_codec_ctx: ++ if ( audio_codec_ctx ) ++ { ++ audio_codec_ctx->extradata = NULL; ++ avcodec_close(audio_codec_ctx); ++ av_free(audio_codec_ctx); ++ } ++cleanup_video_codec_ctx: ++ if ( video_codec_ctx ) ++ { ++ video_codec_ctx->extradata = NULL; ++ avcodec_close(video_codec_ctx); ++ av_free(video_codec_ctx); ++ } ++cleanup_input: ++ avformat_close_input(&format_ctx); ++cleanup_done: ++ return ret; ++} ++ ++int main(int argc, char* argv[]) ++{ ++#ifdef DISPLAY ++ struct display_connection* connection = display_connect_default(); ++ if ( !connection ) ++ error(1, errno, "Could not connect to display server"); ++#else ++ if ( !isatty(0) ) ++ error(1, errno, "standard input"); ++ if ( !dispd_initialize(&argc, &argv) ) ++ error(1, 0, "couldn't initialize dispd library"); ++ struct dispd_session* session = dispd_attach_default_session(); ++ if ( !session ) ++ error(1, 0, "couldn't attach to dispd default session"); ++ if ( !dispd_session_setup_game_rgba(session) ) ++ error(1, 0, "couldn't setup dispd rgba session"); ++ struct dispd_window* window = dispd_create_window_game_rgba(session); ++ if ( !window ) ++ error(1, 0, "couldn't create dispd rgba window"); ++ struct dispd_window* connection = window; ++#endif ++ av_register_all(); ++ ++#ifdef DISPLAY ++ WINDOW_WIDTH = 800; ++ WINDOW_HEIGHT = 450; ++ ++ display_create_window(connection, WINDOW_ID); ++ display_resize_window(connection, WINDOW_ID, WINDOW_WIDTH, WINDOW_HEIGHT); ++ display_show_window(connection, WINDOW_ID); ++#endif ++ ++ for ( int i = 1; i < argc; i++ ) ++ { ++#ifdef DISPLAY ++ display_title_window(connection, WINDOW_ID, argv[i]); ++#endif ++ if ( !PlayVideo(argv[i], connection) ) ++ return 1; ++ } ++ ++#ifdef DISPLAY ++ display_disconnect(connection); ++#else ++ dispd_destroy_window(window); ++ dispd_detach_session(session); ++#endif ++ ++ return 0; ++} diff --git a/ports/video-player/video-player.port b/ports/video-player/video-player.port new file mode 100644 index 00000000..485ac491 --- /dev/null +++ b/ports/video-player/video-player.port @@ -0,0 +1,3 @@ +NAME=video-player +BUILD_LIBRARIES=libavcodec +BUILD_SYSTEM=sortix-usual-makefile diff --git a/ports/vim/vim.patch b/ports/vim/vim.patch new file mode 100644 index 00000000..6ce0372f --- /dev/null +++ b/ports/vim/vim.patch @@ -0,0 +1,183 @@ +diff -Paur --no-dereference -- vim.upstream/src/auto/configure vim/src/auto/configure +--- vim.upstream/src/auto/configure ++++ vim/src/auto/configure +@@ -10140,7 +10140,9 @@ + + if test "$cross_compiling" = yes; then : + +- as_fn_error $? "cross-compiling: please set 'vim_cv_toupper_broken'" "$LINENO" 5 ++ # PATCH: Assume the best when cross-compiling. ++ #as_fn_error $? "cross-compiling: please set 'vim_cv_toupper_broken'" "$LINENO" 5 ++ vim_cv_toupper_broken=no + + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -11362,7 +11364,7 @@ + + if test "x$olibs" != "x$LIBS"; then + if test "$cross_compiling" = yes; then : +- res="FAIL" ++ res="OK" + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -11405,6 +11407,10 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + ++#ifdef HAVE_TERMCAP_H ++# include ++#endif ++ + int + main () + { +@@ -11433,7 +11439,8 @@ + + if test "$cross_compiling" = yes; then : + +- as_fn_error $? "cross-compiling: please set 'vim_cv_terminfo'" "$LINENO" 5 ++ #as_fn_error $? "cross-compiling: please set 'vim_cv_terminfo'" "$LINENO" 5 ++ vim_cv_terminfo=yes + + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -11486,7 +11493,8 @@ + + if test "$cross_compiling" = yes; then : + +- as_fn_error $? "failed to compile test program." "$LINENO" 5 ++ #as_fn_error $? "failed to compile test program." "$LINENO" 5 ++ vim_cv_tgent=zero + + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -11715,6 +11723,8 @@ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + ++#include ++ + int + main () + { +@@ -11957,7 +11967,8 @@ + + if test "$cross_compiling" = yes; then : + +- as_fn_error $? "cross-compiling: please set 'vim_cv_getcwd_broken'" "$LINENO" 5 ++ #as_fn_error $? "cross-compiling: please set 'vim_cv_getcwd_broken'" "$LINENO" 5 ++ vim_cv_getcwd_broken=no + + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -12324,7 +12335,8 @@ + + if test "$cross_compiling" = yes; then : + +- as_fn_error $? "cross-compiling: please set 'vim_cv_stat_ignores_slash'" "$LINENO" 5 ++ #as_fn_error $? "cross-compiling: please set 'vim_cv_stat_ignores_slash'" "$LINENO" 5 ++ vim_cv_stat_ignores_slash=no + + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -13325,8 +13337,8 @@ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking uint32_t is 32 bits" >&5 + $as_echo_n "checking uint32_t is 32 bits... " >&6; } + if test "$cross_compiling" = yes; then : +- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check uint32_t when cross-compiling." >&5 +-$as_echo "$as_me: WARNING: cannot check uint32_t when cross-compiling." >&2;} ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: obviously" >&5 ++$as_echo "obviously" >&6; } + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +@@ -13337,6 +13349,7 @@ + #ifdef HAVE_INTTYPES_H + # include + #endif ++#include + main() { + uint32_t nr1 = (uint32_t)-1; + uint32_t nr2 = (uint32_t)0xffffffffUL; +@@ -13386,7 +13399,8 @@ + + if test "$cross_compiling" = yes; then : + +- as_fn_error $? "cross-compiling: please set 'vim_cv_memmove_handles_overlap'" "$LINENO" 5 ++ #as_fn_error $? "cross-compiling: please set 'vim_cv_memmove_handles_overlap'" "$LINENO" 5 ++ vim_cv_memmove_handles_overlap=yes + + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +diff -Paur --no-dereference -- vim.upstream/src/Makefile vim/src/Makefile +--- vim.upstream/src/Makefile ++++ vim/src/Makefile +@@ -2202,6 +2202,8 @@ + # install targets + + install: $(GUI_INSTALL) ++ ln -s ../../etc/vimrc $(DEST_VIM)/vimrc ++ ln -s ../../etc/gvimrc $(DEST_VIM)/gvimrc + + install_normal: installvim installtools $(INSTALL_LANGS) install-icons + +diff -Paur --no-dereference -- vim.upstream/src/memfile.c vim/src/memfile.c +--- vim.upstream/src/memfile.c ++++ vim/src/memfile.c +@@ -613,7 +613,7 @@ + /* OpenNT is strictly POSIX (Benzinger) */ + /* Tandem/Himalaya NSK-OSS doesn't have sync() */ + /* No sync() on Stratus VOS */ +-# if defined(__OPENNT) || defined(__TANDEM) || defined(__VOS__) ++# if defined(__OPENNT) || defined(__TANDEM) || defined(__VOS__) || defined(__sortix__) + fflush(NULL); + # else + sync(); +diff -Paur --no-dereference -- vim.upstream/src/regexp.c vim/src/regexp.c +--- vim.upstream/src/regexp.c ++++ vim/src/regexp.c +@@ -189,6 +189,7 @@ + #define KWORD 25 /* Match keyword char */ + #define SKWORD 26 /* Match word char but no digit */ + #define FNAME 27 /* Match file name char */ ++#undef SFNAME /* namespace issue */ + #define SFNAME 28 /* Match file name char but no digit */ + #define PRINT 29 /* Match printable char */ + #define SPRINT 30 /* Match printable char but no digit */ +diff -Paur --no-dereference -- vim.upstream/src/sha256.c vim/src/sha256.c +--- vim.upstream/src/sha256.c ++++ vim/src/sha256.c +@@ -380,20 +380,6 @@ + return failures > 0 ? FAIL : OK; + } + +- static unsigned int +-get_some_time(void) +-{ +-# ifdef HAVE_GETTIMEOFDAY +- struct timeval tv; +- +- /* Using usec makes it less predictable. */ +- gettimeofday(&tv, NULL); +- return (unsigned int)(tv.tv_sec + tv.tv_usec); +-# else +- return (unsigned int)time(NULL); +-# endif +-} +- + /* + * Fill "header[header_len]" with random_data. + * Also "salt[salt_len]" when "salt" is not NULL. +@@ -410,10 +396,7 @@ + char_u sha256sum[32]; + context_sha256_T ctx; + +- srand(get_some_time()); +- +- for (i = 0; i < (int)sizeof(random_data) - 1; i++) +- random_data[i] = (char_u)((get_some_time() ^ rand()) & 0xff); ++ arc4random_buf(random_data, sizeof(random_data)); + sha256_start(&ctx); + sha256_update(&ctx, (char_u *)random_data, sizeof(random_data)); + sha256_finish(&ctx, sha256sum); diff --git a/ports/vim/vim.port b/ports/vim/vim.port new file mode 100644 index 00000000..f33d2661 --- /dev/null +++ b/ports/vim/vim.port @@ -0,0 +1,13 @@ +NAME=vim +BUILD_LIBRARIES=libcurses +VERSION=8.0.002 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.bz2 +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=acab24b07d9e87a1c1581cf5ecfe0439562ff7e111d0d2dbd274260490cb64e8 +UPSTREAM_SITE=http://ftp.vim.org/pub/vim/unix +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--enable-multibyte --with-modified-by=sortie@maxsi.org' +# TODO: Consider vim_cv_tty_group and vim_cv_tty_mode. +CONFIGURE_VARS='vim_cv_tty_group=world vim_cv_tty_mode=0620' diff --git a/ports/wget/wget.patch b/ports/wget/wget.patch new file mode 100644 index 00000000..f91f6d37 --- /dev/null +++ b/ports/wget/wget.patch @@ -0,0 +1,320 @@ +diff -Paur --no-dereference -- wget.upstream/configure wget/configure +--- wget.upstream/configure ++++ wget/configure +@@ -1,4 +1,124 @@ + #! /bin/sh ++# Make gnulib assume the best about unknown operating systems when cross-compiling. ++export ac_cv_func_calloc_0_nonnull=yes ++export ac_cv_func_chown_works=yes ++export ac_cv_func_getgroups_works=yes ++export ac_cv_func_malloc_0_nonnull=yes ++export gl_cv_func_cbrtl_ieee=yes ++export gl_cv_func_ceilf_ieee=yes ++export gl_cv_func_ceil_ieee=yes ++export gl_cv_func_ceill_ieee=yes ++export gl_cv_func_chown_ctime_works=yes ++export gl_cv_func_chown_slash_works=yes ++export gl_cv_func_exp2l_ieee=yes ++export gl_cv_func_expm1_ieee=yes ++export gl_cv_func_fcntl_f_dupfd_works=yes # Not needed since February 2015 ++export gl_cv_func_fdopendir_works=yes ++export gl_cv_func_floorf_ieee=yes ++export gl_cv_func_fmaf_works=yes ++export gl_cv_func_fmal_works=yes ++export gl_cv_func_fma_works=yes ++export gl_cv_func_fmodf_ieee=yes ++export gl_cv_func_fmod_ieee=yes ++export gl_cv_func_fmodl_ieee=yes ++export gl_cv_func_fpurge_works=yes ++export gl_cv_func_futimens_works=yes ++export gl_cv_func_futimesat_works=yes ++export gl_cv_func_getgroups_works=yes ++export gl_cv_func_gettimeofday_clobber=no ++export gl_cv_func_hypotf_ieee=yes ++export gl_cv_func_hypotl_ieee=yes ++export gl_cv_func_hypot_ieee=yes ++export gl_cv_func_isfinitel_works=yes ++export gl_cv_func_isnanl_works=yes ++export gl_cv_func_linkat_slash=yes ++export gl_cv_func_link_works=yes ++export gl_cv_func_log10f_ieee=yes ++export gl_cv_func_log10_ieee=yes ++export gl_cv_func_log1pf_ieee=yes ++export gl_cv_func_log1p_ieee=yes ++export gl_cv_func_log1pl_ieee=yes ++export gl_cv_func_log2f_ieee=yes ++export gl_cv_func_log2_ieee=yes ++export gl_cv_func_logf_ieee=yes ++export gl_cv_func_log_ieee=yes ++export gl_cv_func_lstat_dereferences_slashed_symlink=yes ++export gl_cv_func_mbrlen_empty_input=yes ++export gl_cv_func_mbrtowc_empty_input=yes ++export gl_cv_func_memchr_works=yes ++export gl_cv_func_memmem_works_fast=yes ++export gl_cv_func_mkdir_trailing_dot_works=yes ++export gl_cv_func_mkdir_trailing_slash_works=yes ++export gl_cv_func_mkfifo_works=yes ++export gl_cv_func_mknod_works=yes ++export gl_cv_func_modff_ieee=yes ++export gl_cv_func_modf_ieee=yes ++export gl_cv_func_modfl_ieee=yes ++export gl_cv_func_nanosleep=yes ++export gl_cv_func_open_directory_works=yes ++export gl_cv_func_perror_works=yes ++export gl_cv_func_printf_directive_a=yes ++export gl_cv_func_printf_directive_f=yes ++export gl_cv_func_printf_directive_n=yes ++export gl_cv_func_printf_enomem=yes ++export gl_cv_func_printf_flag_zero=yes ++export gl_cv_func_printf_infinite_long_double=yes ++export gl_cv_func_printf_infinite=yes ++export gl_cv_func_printf_sizes_c99=yes ++export gl_cv_func_pselect_detects_ebadf=yes ++export gl_cv_func_ptsname_sets_errno=yes ++export gl_cv_func_readlink_works=yes ++export gl_cv_func_realpath_works=yes ++export gl_cv_func_remainderf_ieee=yes ++export gl_cv_func_remainder_ieee=yes ++export gl_cv_func_remainderl_ieee=yes ++export gl_cv_func_rename_dest_works=yes ++export gl_cv_func_rename_link_works=yes ++export gl_cv_func_rename_slash_dst_works=yes ++export gl_cv_func_rename_slash_src_works=yes ++export gl_cv_func_rmdir_works=yes ++export gl_cv_func_roundf_ieee=yes ++export gl_cv_func_round_ieee=yes ++export gl_cv_func_select_detects_ebadf=yes ++export gl_cv_func_setenv_works=yes ++export gl_cv_func_signbit_gcc=yes ++export gl_cv_func_signbit=yes ++export gl_cv_func_sleep_works=yes ++export gl_cv_func_snprintf_directive_n=yes ++export gl_cv_func_snprintf_retval_c99=yes ++export gl_cv_func_snprintf_truncation_c99=yes ++export gl_cv_func_stat_dir_slash=yes ++export gl_cv_func_stat_file_slash=yes ++export gl_cv_func_stpncpy=yes ++export gl_cv_func_strcasestr_linear=yes ++export gl_cv_func_strchrnul_works=yes ++export gl_cv_func_strerror_0_works=yes ++export gl_cv_func_strstr_linear=yes ++export gl_cv_func_strtod_works=yes ++export gl_cv_func_svid_putenv=yes ++export gl_cv_func_symlink_works=yes ++export gl_cv_func_tdelete_works=yes ++export gl_cv_func_truncf_ieee=yes ++export gl_cv_func_trunc_ieee=yes ++export gl_cv_func_truncl_ieee=yes ++export gl_cv_func_tzset_clobber=no ++export gl_cv_func_ungetc_works=yes ++export gl_cv_func_unlink_honors_slashes=yes ++export gl_cv_func_unsetenv_works=yes ++export gl_cv_func_usleep_works=yes ++export gl_cv_func_utimensat_works=yes ++export gl_cv_func_vsnprintf_posix=yes ++export gl_cv_func_vsnprintf_zerosize_c99=yes ++export gl_cv_func_vsprintf_posix=yes ++export gl_cv_func_wcwidth_works=yes ++export gl_cv_func_working_getdelim=yes ++export gl_cv_func_working_mkstemp=yes ++export gl_cv_func_working_mktime=yes ++export gl_cv_func_working_strerror=yes ++export ac_cv_func___fseterr=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_func_getcwd_null=yes # Only if the OS actually supports this, Sortix does. ++export gl_cv_struct_dirent_d_ino=yes # Only if the OS actually supports this, Sortix does. ++export ac_cv_func_realloc_0_nonnull=yes # TODO: Investigate this, found in flex. + # Guess values for system-dependent variables and create Makefiles. + # Generated by GNU Autoconf 2.69 for wget 1.18. + # +@@ -39179,6 +39299,8 @@ + esac + fi + GPGME_CONFIG=$ac_cv_path_GPGME_CONFIG ++# PATCH: Not cross-compile safe. ++GPGME_CONFIG=no + if test -n "$GPGME_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GPGME_CONFIG" >&5 + $as_echo "$GPGME_CONFIG" >&6; } +@@ -39841,7 +39963,7 @@ + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_idn_stringprep_check_version" >&5 + $as_echo "$ac_cv_lib_idn_stringprep_check_version" >&6; } + if test "x$ac_cv_lib_idn_stringprep_check_version" = xyes; then : +- iri=yes LIBS="${LIBS} -lidn" ++ iri=yes LIBS="${LIBS} -lidn $LIBINTL" + else + iri=no + fi +diff -Paur --no-dereference -- wget.upstream/lib/flock.c wget/lib/flock.c +--- wget.upstream/lib/flock.c ++++ wget/lib/flock.c +@@ -211,6 +211,16 @@ + return r; + } + ++# elif defined (__sortix__) ++ ++int ++flock (int fd, int operation) ++{ ++ (void) fd; ++ (void) operation; ++ return 0; ++} ++ + # else /* !HAVE_STRUCT_FLOCK_L_TYPE */ + + # error "This platform lacks flock function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib." +diff -Paur --no-dereference -- wget.upstream/src/hsts.c wget/src/hsts.c +--- wget.upstream/src/hsts.c ++++ wget/src/hsts.c +@@ -325,9 +325,9 @@ + struct hsts_kh *kh = (struct hsts_kh *) it.key; + struct hsts_kh_info *khi = (struct hsts_kh_info *) it.value; + +- if (fprintf (fp, "%s\t%d\t%d\t%lu\t%lu\n", ++ if (fprintf (fp, "%s\t%d\t%d\t%lli\t%lli\n", + kh->host, kh->explicit_port, khi->include_subdomains, +- khi->created, khi->max_age) < 0) ++ (long long)khi->created, (long long)khi->max_age) < 0) + { + logprintf (LOG_ALWAYS, "Could not write the HSTS database correctly.\n"); + break; +diff -Paur --no-dereference -- wget.upstream/src/init.c wget/src/init.c +--- wget.upstream/src/init.c ++++ wget/src/init.c +@@ -39,13 +39,6 @@ + #include + #include + #include +-/* not all systems provide PATH_MAX in limits.h */ +-#ifndef PATH_MAX +-# include +-# ifndef PATH_MAX +-# define PATH_MAX MAXPATHLEN +-# endif +-#endif + + #include + #ifdef HAVE_LIBPCRE +diff -Paur --no-dereference -- wget.upstream/src/progress.c wget/src/progress.c +--- wget.upstream/src/progress.c ++++ wget/src/progress.c +@@ -311,9 +311,15 @@ + if (dp->rows == dp->initial_length / ROW_BYTES) + bytes_this_row -= dp->initial_length % ROW_BYTES; + rate = calc_rate (bytes_this_row, dltime - dp->last_timer_value, &units); ++#if defined(__sortix__) ++ /* PATCH: HACK: Sortix doesn't support floating point printf right now. */ ++ logprintf (LOG_PROGRESS, " %4lli%c", ++ (long long)rate, names[units]); ++#else + logprintf (LOG_PROGRESS, " %4.*f%c", + rate >= 99.95 ? 0 : rate >= 9.995 ? 1 : 2, + rate, names[units]); ++#endif + dp->last_timer_value = dltime; + } + +@@ -1093,8 +1099,14 @@ + wgint dlquant = hist->total_bytes + bp->recent_bytes; + double dltime = hist->total_time + (dl_total_time - bp->recent_start); + double dlspeed = calc_rate (dlquant, dltime, &units); ++#if defined(__sortix__) ++ /* PATCH: HACK: Sortix doesn't support floating point printf right now. */ ++ p += sprintf (p, " %4lli%s", ++ (long long)dlspeed, !opt.report_bps ? short_units[units] : short_units_bits[units]); ++#else + p += sprintf (p, " %4.*f%s", dlspeed >= 99.95 ? 0 : dlspeed >= 9.995 ? 1 : 2, + dlspeed, !opt.report_bps ? short_units[units] : short_units_bits[units]); ++#endif + } + else + APPEND_LITERAL (" --.-KB/s"); +diff -Paur --no-dereference -- wget.upstream/src/retr.c wget/src/retr.c +--- wget.upstream/src/retr.c ++++ wget/src/retr.c +@@ -634,9 +634,15 @@ + double dlrate = calc_rate (bytes, secs, &units); + /* Use more digits for smaller numbers (regardless of unit used), + e.g. "1022", "247", "12.5", "2.38". */ ++#if defined(__sortix__) ++ /* PATCH: HACK: Sortix doesn't support floating point printf right now. */ ++ sprintf (res, "%lli %s", (long long)dlrate, ++ !opt.report_bps ? rate_names[units]: rate_names_bits[units]); ++#else + sprintf (res, "%.*f %s", + dlrate >= 99.95 ? 0 : dlrate >= 9.995 ? 1 : 2, + dlrate, !opt.report_bps ? rate_names[units]: rate_names_bits[units]); ++#endif + + return res; + } +diff -Paur --no-dereference -- wget.upstream/src/utils.c wget/src/utils.c +--- wget.upstream/src/utils.c ++++ wget/src/utils.c +@@ -505,7 +505,9 @@ + } + + /* child: give up the privileges and keep running. */ ++#if !defined(__sortix__) + setsid (); ++#endif + if (freopen ("/dev/null", "r", stdin) == NULL) + DEBUGP (("Failed to redirect stdin to /dev/null.\n")); + if (freopen ("/dev/null", "w", stdout) == NULL) +@@ -1583,8 +1585,13 @@ + double val = n / 1024.0; + /* Print values smaller than the accuracy level (acc) with (decimal) + * decimal digits, and others without any decimals. */ ++#if defined(__sortix__) ++ /* PATCH: HACK: Sortix doesn't support floating point printf right now. */ ++ snprintf (buf, sizeof (buf), "%lli%c", (long long)val, powers[i]); ++#else + snprintf (buf, sizeof (buf), "%.*f%c", + val < acc ? decimals : 0, val, powers[i]); ++#endif + return buf; + } + n /= 1024; +@@ -1843,9 +1850,11 @@ + #endif /* neither TIOCGWINSZ nor WINDOWS */ + } + ++#if !defined(__sortix__) + /* Whether the rnd system (either rand or [dl]rand48) has been + seeded. */ + static int rnd_seeded; ++#endif + + /* Return a random number between 0 and MAX-1, inclusive. + +@@ -1862,7 +1871,9 @@ + int + random_number (int max) + { +-#ifdef HAVE_RANDOM ++#if defined(__sortix__) ++ return arc4random_uniform(max); ++#elif defined HAVE_RANDOM + if (!rnd_seeded) + { + srandom ((long) time (NULL) ^ (long) getpid ()); +@@ -2444,6 +2455,10 @@ + static char buf[32]; + double n = number >= 0 ? number : -number; + ++#if defined(__sortix__) ++ /* PATCH: HACK: Sortix doesn't support floating point printf right now. */ ++ snprintf (buf, sizeof buf, "%lld", (long long) number); ++#else + if (n >= 9.95) + /* Cut off at 9.95 because the below %.1f would round 9.96 to + "10.0" instead of "10". OTOH 9.94 will print as "9.9". */ +@@ -2458,6 +2473,7 @@ + else + /* print numbers close to 0 as 0, not 0.000 */ + strcpy (buf, "0"); ++#endif + + return buf; + } diff --git a/ports/wget/wget.port b/ports/wget/wget.port new file mode 100644 index 00000000..465058c8 --- /dev/null +++ b/ports/wget/wget.port @@ -0,0 +1,12 @@ +NAME=wget +BUILD_LIBRARIES='libz libiconv? libintl? libssl libpsl? libmetalink? libuuid? libpcre? libidn?' +VERSION=1.18 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=b5b55b75726c04c06fe253daec9329a6f1a3c0c1878e3ea76ebfebc139ea9cc1 +UPSTREAM_SITE=https://ftp.gnu.org/gnu/wget +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--with-ssl=openssl' +MAKE_VARS='V=1' diff --git a/ports/wget/wget.rmpatch b/ports/wget/wget.rmpatch new file mode 100644 index 00000000..43fea873 --- /dev/null +++ b/ports/wget/wget.rmpatch @@ -0,0 +1,4 @@ +rm -rf -- 'doc/stamp-vti' +rm -rf -- 'src/build_info.c' +rm -rf -- 'src/css.c' +rm -rf -- 'src/css_.c' diff --git a/ports/xargs/xargs.patch b/ports/xargs/xargs.patch new file mode 100644 index 00000000..88b5c2a3 --- /dev/null +++ b/ports/xargs/xargs.patch @@ -0,0 +1,188 @@ +diff -Paur --no-dereference -- xargs.upstream/Makefile xargs/Makefile +--- xargs.upstream/Makefile ++++ xargs/Makefile +@@ -0,0 +1,25 @@ ++include ../../../build-aux/compiler.mak ++include ../../../build-aux/version.mak ++include ../../../build-aux/dirs.mak ++ ++OPTLEVEL?=-g -O2 ++CFLAGS?=$(OPTLEVEL) ++ ++CFLAGS:=$(CXXFLAGS) -Wall -Wextra ++CPPFLAGS:=$(CPPFLAGS) ++ ++BINARY:=xargs ++ ++all: $(BINARY) ++ ++.PHONY: all install clean ++ ++%: %.c ++ $(CC) -std=gnu11 $(CFLAGS) $(CPPFLAGS) $< -o $@ $(LIBS) ++ ++install: all ++ mkdir -p $(DESTDIR)$(BINDIR) ++ install $(BINARY) $(DESTDIR)$(BINDIR) ++ ++clean: ++ rm -f $(BINARY) +diff -Paur --no-dereference -- xargs.upstream/xargs.c xargs/xargs.c +--- xargs.upstream/xargs.c ++++ xargs/xargs.c +@@ -38,12 +38,10 @@ + #include + + #include +-#include ++#include + #include + #include +-#include + #include +-#include + #include + #include + #include +@@ -51,7 +49,62 @@ + #include + #include + +-#include "pathnames.h" ++#define err(eval, ...) error(eval, errno, __VA_ARGS__) ++#define errx(eval, ...) error(eval, 0, __VA_ARGS__) ++#define warn(...) error(0, errno, __VA_ARGS__) ++#define warnx(...) error(0, 0, __VA_ARGS__) ++ ++/* ++ * Replaces str with a string consisting of str with match replaced with ++ * replstr as many times as can be done before the constructed string is ++ * maxsize bytes large. It does not free the string pointed to by str, it ++ * is up to the calling program to be sure that the original contents of ++ * str as well as the new contents are handled in an appropriate manner. ++ * If replstr is NULL, then that internally is changed to a nil-string, so ++ * that we can still pretend to do somewhat meaningful substitution. ++ * No value is returned. ++ */ ++void ++strnsubst(char **str, const char *match, const char *replstr, size_t maxsize) ++{ ++ char *s1, *s2, *this; ++ size_t matchlen, repllen, s2len; ++ int n; ++ ++ (void) repllen; ++ ++ if ((s1 = *str) == NULL) ++ return; ++ if ((s2 = malloc(maxsize)) == NULL) ++ err(1, NULL); ++ ++ if (replstr == NULL) ++ replstr = ""; ++ ++ if (match == NULL || *match == '\0' || strlen(s1) >= maxsize) { ++ strlcpy(s2, s1, maxsize); ++ goto done; ++ } ++ ++ *s2 = '\0'; ++ s2len = 0; ++ matchlen = strlen(match); ++ repllen = strlen(replstr); ++ for (;;) { ++ if ((this = strstr(s1, match)) == NULL) ++ break; ++ n = snprintf(s2 + s2len, maxsize - s2len, "%.*s%s", ++ (int)(this - s1), s1, replstr); ++ if (n == -1 || n + s2len + strlen(this + matchlen) >= maxsize) ++ break; /* out of room */ ++ s2len += n; ++ s1 = this + matchlen; ++ } ++ strlcpy(s2 + s2len, s1, maxsize - s2len); ++done: ++ *str = s2; ++ return; ++} + + static void parse_input(int, char *[]); + static void prerun(int, char *[]); +@@ -100,8 +153,9 @@ + * probably not worthwhile. + */ + nargs = 5000; +- if ((arg_max = sysconf(_SC_ARG_MAX)) == -1) +- errx(1, "sysconf(_SC_ARG_MAX) failed"); ++ arg_max = 4096 * 16; ++ //if ((arg_max = sysconf(_SC_ARG_MAX)) == -1) ++ // errx(1, "sysconf(_SC_ARG_MAX) failed"); + nline = arg_max - 4 * 1024; + while (*ep != NULL) { + /* 1 byte for each '\0' */ +@@ -195,7 +249,7 @@ + * arguments. + */ + if (*argv == NULL) +- cnt = strlen(*bxp++ = _PATH_ECHO); ++ cnt = strlen(*bxp++ = "/bin/echo"); + else { + do { + if (Jflag && strcmp(*argv, replstr) == 0) { +@@ -515,17 +569,17 @@ + (void)fflush(stderr); + } + exec: +- switch (pid = vfork()) { ++ switch (pid = fork()) { + case -1: +- err(1, "vfork"); ++ err(1, "fork"); + case 0: + if (oflag) { +- if ((fd = open(_PATH_TTY, O_RDONLY)) == -1) { ++ if ((fd = open("/dev/tty", O_RDONLY)) == -1) { + warn("can't open /dev/tty"); + _exit(1); + } + } else { +- fd = open(_PATH_DEVNULL, O_RDONLY); ++ fd = open("/dev/null", O_RDONLY); + } + if (fd > STDIN_FILENO) { + if (dup2(fd, STDIN_FILENO) != 0) { +@@ -572,7 +626,7 @@ + if (WTERMSIG(status) != SIGPIPE) { + if (WTERMSIG(status) < NSIG) + warnx("%s terminated by SIG%s", name, +- sys_signame[WTERMSIG(status)]); ++ strsignal(WTERMSIG(status))); + else + warnx("%s terminated by signal %d", + name, WTERMSIG(status)); +@@ -590,13 +644,14 @@ + static int + prompt(void) + { ++#if 0 + regex_t cre; + size_t rsize; + int match; + char *response; + FILE *ttyfp; + +- if ((ttyfp = fopen(_PATH_TTY, "r")) == NULL) ++ if ((ttyfp = fopen("/dev/tty", "r")) == NULL) + return (2); /* Indicate that the TTY failed to open. */ + (void)fprintf(stderr, "?..."); + (void)fflush(stderr); +@@ -610,6 +665,9 @@ + (void)fclose(ttyfp); + regfree(&cre); + return (match == 0); ++#else ++ return 1; ++#endif + } + + static void diff --git a/ports/xargs/xargs.port b/ports/xargs/xargs.port new file mode 100644 index 00000000..c2a1ad6b --- /dev/null +++ b/ports/xargs/xargs.port @@ -0,0 +1,11 @@ +NAME=xargs +BUILD_LIBRARIES= +VERSION=2015-01-16 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=bd58272896a2ec751e06dfd49db175496733f043357e348e5554964094660ef5 +UPSTREAM_SITE=https://pub.sortix.org/fork/xargs +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=sortix-usual-makefile +VERSION_REGEX='([0-9]{4}-[0-9]{2}-[0-9]{2})' diff --git a/ports/xorriso/xorriso.patch b/ports/xorriso/xorriso.patch new file mode 100644 index 00000000..b42b46f1 --- /dev/null +++ b/ports/xorriso/xorriso.patch @@ -0,0 +1,537 @@ +diff -Paur --no-dereference -- xorriso.upstream/config.sub xorriso/config.sub +--- xorriso.upstream/config.sub ++++ xorriso/config.sub +@@ -1353,7 +1353,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- xorriso.upstream/configure xorriso/configure +--- xorriso.upstream/configure ++++ xorriso/configure +@@ -6166,7 +6166,6 @@ + #include + #include + #include +-#include + #include + int + main () +diff -Paur --no-dereference -- xorriso.upstream/libburn/async.c xorriso/libburn/async.c +--- xorriso.upstream/libburn/async.c ++++ xorriso/libburn/async.c +@@ -37,6 +37,7 @@ + #include "init.h" + #include "back_hacks.h" + ++#include + #include + #include + #include +@@ -718,9 +719,11 @@ + pthread_sigmask(SIG_SETMASK, &sigset, &oldset); + #endif /* Libburn_protect_fifo_threaD */ + ++#if !defined(__sortix__) + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old); + /* Note: Only burn_fifo_abort() shall cancel the fifo thread */ ++#endif + + burn_fifo_source_shoveller(w->u.fifo.source, w->u.fifo.flag); + remove_worker(pthread_self()); +@@ -775,7 +778,11 @@ + + pt= *((pthread_t *) fs->thread_handle); + remove_worker(pt); ++#if !defined(__sortix__) + ret = pthread_cancel(pt); ++#else ++ ret = (errno = ENOSYS, -1); ++#endif + return (ret == 0); + } + +diff -Paur --no-dereference -- xorriso.upstream/libburn/libdax_msgs.c xorriso/libburn/libdax_msgs.c +--- xorriso.upstream/libburn/libdax_msgs.c ++++ xorriso/libburn/libdax_msgs.c +@@ -34,14 +34,13 @@ + int ret; + struct libdax_msgs_item *o; + struct timeval tv; +- struct timezone tz; + + (*item)= o= + (struct libdax_msgs_item *) calloc(1, sizeof(struct libdax_msgs_item)); + if(o==NULL) + return(-1); + o->timestamp= 0.0; +- ret= gettimeofday(&tv,&tz); ++ ret= gettimeofday(&tv,NULL); + if(ret==0) + o->timestamp= tv.tv_sec+0.000001*tv.tv_usec; + o->process_id= getpid(); +diff -Paur --no-dereference -- xorriso.upstream/libburn/mmc.c xorriso/libburn/mmc.c +--- xorriso.upstream/libburn/mmc.c ++++ xorriso/libburn/mmc.c +@@ -739,7 +739,6 @@ + { + int usec= 0, need, reported_3s = 0, first_wait = 1; + struct timeval t0,tnow; +- struct timezone dummy_tz; + double max_fac, min_fac, waiting; + + /* Enable to get reported waiting activities and total time. +@@ -776,7 +775,7 @@ + /* There is need to inquire the buffer fill */ + d->pessimistic_writes++; + min_fac = ((double) d->wfb_min_percent) / 100.0; +- gettimeofday(&t0, &dummy_tz); ++ gettimeofday(&t0, NULL); + #ifdef Libburn_mmc_wfb_debuG + sleeplist[0]= 0; + sprintf(sleeplist,"(%d%s %d)", +@@ -797,7 +796,7 @@ + (d->pbf_altered ? "? -" : " -"), + (int) ((1.0 - min_fac) * d->progress.buffer_capacity)); + #endif +- gettimeofday(&tnow,&dummy_tz); ++ gettimeofday(&tnow,NULL); + waiting = (tnow.tv_sec - t0.tv_sec) + + ((double) (tnow.tv_usec - t0.tv_usec)) / 1.0e6; + if (d->pessimistic_buffer_free - buf->bytes >= +diff -Paur --no-dereference -- xorriso.upstream/libburn/write.c xorriso/libburn/write.c +--- xorriso.upstream/libburn/write.c ++++ xorriso/libburn/write.c +@@ -2744,16 +2744,15 @@ + int amount, int flag) + { + struct timeval tnow; +- struct timezone dummy_tz; + double to_wait; + + if (flag & 1) { +- gettimeofday(prev_time, &dummy_tz); ++ gettimeofday(prev_time, NULL); + return 1; + } + if(d->nominal_write_speed <= 0) + return 2; +- gettimeofday(&tnow, &dummy_tz); ++ gettimeofday(&tnow, NULL); + to_wait = ( ((double) amount) / (double) d->nominal_write_speed ) - + (double) ( tnow.tv_sec - prev_time->tv_sec ) - + (double) ( tnow.tv_usec - prev_time->tv_usec ) / 1.0e6 +@@ -2761,7 +2760,7 @@ + if (to_wait >= 0.0001) { + usleep((int) (to_wait * 1000000.0)); + } +- gettimeofday(prev_time, &dummy_tz); ++ gettimeofday(prev_time, NULL); + return 1; + } + +diff -Paur --no-dereference -- xorriso.upstream/libisofs/ecma119.c xorriso/libisofs/ecma119.c +--- xorriso.upstream/libisofs/ecma119.c ++++ xorriso/libisofs/ecma119.c +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + #include + + #ifdef Xorriso_standalonE +diff -Paur --no-dereference -- xorriso.upstream/libisofs/fs_image.c xorriso/libisofs/fs_image.c +--- xorriso.upstream/libisofs/fs_image.c ++++ xorriso/libisofs/fs_image.c +@@ -31,7 +31,6 @@ + #include + #include + #include +-#include + #include + #include + +diff -Paur --no-dereference -- xorriso.upstream/libisofs/libiso_msgs.c xorriso/libisofs/libiso_msgs.c +--- xorriso.upstream/libisofs/libiso_msgs.c ++++ xorriso/libisofs/libiso_msgs.c +@@ -30,19 +30,22 @@ + static int libiso_msgs_item_new(struct libiso_msgs_item **item, + struct libiso_msgs_item *link, int flag) + { ++#if 0 + int ret; ++#endif + struct libiso_msgs_item *o; + struct timeval tv; +- struct timezone tz; + + (*item)= o= + (struct libiso_msgs_item *) malloc(sizeof(struct libiso_msgs_item)); + if(o==NULL) + return(-1); + o->timestamp= 0.0; +- ret= gettimeofday(&tv,&tz); ++#if 0 ++ ret= gettimeofday(&tv,NULL); + if(ret==0) + o->timestamp= tv.tv_sec+0.000001*tv.tv_usec; ++#endif + o->process_id= getpid(); + o->origin= -1; + o->severity= LIBISO_MSGS_SEV_ALL; +diff -Paur --no-dereference -- xorriso.upstream/libisofs/make_isohybrid_mbr.c xorriso/libisofs/make_isohybrid_mbr.c +--- xorriso.upstream/libisofs/make_isohybrid_mbr.c ++++ xorriso/libisofs/make_isohybrid_mbr.c +@@ -146,7 +146,6 @@ + + /* For generating a weak random number */ + struct timeval tv; +- struct timezone tz; + + if (bin_lba < 0 || bin_lba >= (1 << 29)) + return (0); /* 1 TB limit of signed 32 bit addressing of 512 byte blocks */ +@@ -201,7 +200,7 @@ + from. An environment variable ? + 125: Whatever, i use some 32-bit random value with no crypto strength. + */ +- gettimeofday(&tv, &tz); ++ gettimeofday(&tv, NULL); + id = 0xffffffff & (tv.tv_sec ^ (tv.tv_usec * 2000)); + + /* +@@ -572,7 +571,6 @@ + int gpt_count = 0, gpt_idx[128], apm_count = 0, gpt_cursor; + /* For generating a weak random number */ + struct timeval tv; +- struct timezone tz; + + hd_img_blocks = ((off_t) *img_blocks) * (off_t) 4; + +@@ -608,7 +606,7 @@ + (here some 32-bit random value with no crypto strength) + */ + if (flag & 1) { +- gettimeofday(&tv, &tz); ++ gettimeofday(&tv, NULL); + id = 0xffffffff & (tv.tv_sec ^ (tv.tv_usec * 2000)); + lsb_to_buf(&wpt, id, 32, 0); + } else { +diff -Paur --no-dereference -- xorriso.upstream/libisofs/system_area.c xorriso/libisofs/system_area.c +--- xorriso.upstream/libisofs/system_area.c ++++ xorriso/libisofs/system_area.c +@@ -2061,7 +2061,6 @@ + static uint8_t uuid_urandom[16]; + uint32_t rnd, salt; + struct timeval tv; +- struct timezone tz; + pid_t pid; + static int counter = 0, use_urandom = 0; + int i, ret, fd; +@@ -2111,7 +2110,7 @@ + per day. + */ + memcpy(u, uuid_template, 16); +- gettimeofday(&tv, &tz); ++ gettimeofday(&tv, NULL); + for (i = 0; i < 4; i++) + u[i] = (salt >> (8 * i)) & 0xff; + for (i = 0; i < 2; i++) +diff -Paur --no-dereference -- xorriso.upstream/libisofs/util.c xorriso/libisofs/util.c +--- xorriso.upstream/libisofs/util.c ++++ xorriso/libisofs/util.c +@@ -28,7 +28,6 @@ + #include + #include + #include +-#include + + #include + +@@ -186,7 +185,11 @@ + { + if(libisofs_local_charset[0]) + return libisofs_local_charset; ++#if defined(__sortix__) ++ return "UTF-8"; ++#else + return nl_langinfo(CODESET); ++#endif + } + + int strconv(const char *str, const char *icharset, const char *ocharset, +@@ -1574,7 +1577,7 @@ + #else + if (tm.tm_isdst < 0) + tm.tm_isdst = 0; +- tzoffset = ( - timezone / 60 / 15 ) + 4 * tm.tm_isdst; ++ tzoffset = ( - 0 / 60 / 15 ) + 4 * tm.tm_isdst; + #endif + + if (tzoffset > 52 || tzoffset < -48 || always_gmt) { +@@ -1620,7 +1623,7 @@ + #else + if (tm.tm_isdst < 0) + tm.tm_isdst = 0; +- tzoffset = ( - timezone / 60 / 15 ) + 4 * tm.tm_isdst; ++ tzoffset = ( - 0 / 60 / 15 ) + 4 * tm.tm_isdst; + #endif + + if (tzoffset > 52 || tzoffset < -48 || always_gmt) { +diff -Paur --no-dereference -- xorriso.upstream/libjte/checksum.c xorriso/libjte/checksum.c +--- xorriso.upstream/libjte/checksum.c ++++ xorriso/libjte/checksum.c +@@ -327,7 +327,9 @@ + if (a->thread) + { + void *ret; ++#if !defined(__sortix__) + pthread_cancel(a->thread); ++#endif + pthread_join(a->thread, &ret); + a->thread = 0; + } +diff -Paur --no-dereference -- xorriso.upstream/xorriso/iso_manip.c xorriso/xorriso/iso_manip.c +--- xorriso.upstream/xorriso/iso_manip.c ++++ xorriso/xorriso/iso_manip.c +@@ -23,6 +23,12 @@ + #include + #include + ++#ifndef S_ISGID ++#define S_ISGID 02000 ++#endif ++#ifndef S_ISUID ++#define S_ISUID 04000 ++#endif + + #include "xorriso.h" + #include "xorriso_private.h" +diff -Paur --no-dereference -- xorriso.upstream/xorriso/lib_mgt.c xorriso/xorriso/lib_mgt.c +--- xorriso.upstream/xorriso/lib_mgt.c ++++ xorriso/xorriso/lib_mgt.c +@@ -35,7 +35,9 @@ + + /* for -charset */ + #include ++#if !defined(__sortix__) + #include ++#endif + + #ifdef Xorriso_standalonE + +@@ -471,7 +473,11 @@ + char *nl_charset; + iconv_t iconv_ret= (iconv_t) -1; + ++#if defined(__sortix__) ++ nl_charset= "UTF-8"; ++#else + nl_charset= nl_langinfo(CODESET); ++#endif + if(name == NULL) + name= nl_charset; + +diff -Paur --no-dereference -- xorriso.upstream/xorriso/misc_funct.c xorriso/xorriso/misc_funct.c +--- xorriso.upstream/xorriso/misc_funct.c ++++ xorriso/xorriso/misc_funct.c +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + + + #include "sfile.h" +@@ -644,7 +645,7 @@ + #else + if(result_tm.tm_isdst < 0) + result_tm.tm_isdst = 0; +- seconds-= timezone - result_tm.tm_isdst * 3600; ++ seconds-= 0 - result_tm.tm_isdst * 3600; + #endif + + } +diff -Paur --no-dereference -- xorriso.upstream/xorriso/opts_a_c.c xorriso/xorriso/opts_a_c.c +--- xorriso.upstream/xorriso/opts_a_c.c ++++ xorriso/xorriso/opts_a_c.c +@@ -26,7 +26,6 @@ + + /* for -charset */ + #include +-#include + #include + + +diff -Paur --no-dereference -- xorriso.upstream/xorriso/parse_exec.c xorriso/xorriso/parse_exec.c +--- xorriso.upstream/xorriso/parse_exec.c ++++ xorriso/xorriso/parse_exec.c +@@ -2045,9 +2045,8 @@ + char **argv= NULL; + double tdiff; + struct timeval tv; +- struct timezone tz; + +- gettimeofday(&tv,&tz); ++ gettimeofday(&tv,NULL); + Xorriso_reset_counters(xorriso,0); + xorriso->idle_time= 0.0; + tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec); +@@ -2064,7 +2063,7 @@ + ret= Xorriso_interpreter(xorriso, argc, argv, &idx, flag&0xffff); + if(ret<0) + goto ex; +- gettimeofday(&tv,&tz); ++ gettimeofday(&tv,NULL); + tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec)-tdiff-xorriso->idle_time; + if(tdiff<0.001) + tdiff= 0.001; +@@ -2814,7 +2813,7 @@ + + Xorriso_alloc_meM(prog, char, 5 * SfileadrL); + +- wait3(NULL,WNOHANG,NULL); /* just to remove any old dead child */ ++ waitpid(-1, NULL, WNOHANG); /* just to remove any old dead child */ + + if(flag & 2) { + ret= Xorriso_make_argv_with_null(xorriso, in_argc, in_argv, +diff -Paur --no-dereference -- xorriso.upstream/xorriso/read_run.c xorriso/xorriso/read_run.c +--- xorriso.upstream/xorriso/read_run.c ++++ xorriso/xorriso/read_run.c +@@ -721,7 +721,11 @@ + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + ret= 0; goto ex; + } ++#if defined(__sortix__) ++ ret= (errno = ENOSYS, -1); ++#else + ret= mknod(disk_path, mode, dev); ++#endif + l_errno= errno; + + } else if(LIBISO_ISBLK(node)) { +@@ -734,13 +738,21 @@ + goto ex; + if(dev == (dev_t) 1) + goto probably_damaged; ++#if defined(__sortix__) ++ ret= (errno = ENOSYS, -1); ++#else + ret= mknod(disk_path, mode, dev); ++#endif + l_errno= errno; + + } else if(LIBISO_ISFIFO(node)) { + what= "named pipe"; + mode= S_IFIFO | 0777; ++#if defined(__sortix__) ++ ret= (errno = ENOSYS, -1); ++#else + ret= mknod(disk_path, mode, dev); ++#endif + l_errno= errno; + + } else if(LIBISO_ISSOCK(node)) { +diff -Paur --no-dereference -- xorriso.upstream/xorriso/sfile.c xorriso/xorriso/sfile.c +--- xorriso.upstream/xorriso/sfile.c ++++ xorriso/xorriso/sfile.c +@@ -206,11 +206,16 @@ + + int Sfile_being_group_member(struct stat *stbuf, int flag) + { ++#if !defined(__sortix__) + int i, suppl_groups; + gid_t *suppl_glist; ++#endif + + if (getegid()==stbuf->st_gid) + return(1); ++#if defined(__sortix__) ++ return(0); ++#else + suppl_groups= getgroups(0, NULL); + suppl_glist= (gid_t *) malloc((suppl_groups + 1) * sizeof(gid_t)); + if (suppl_glist==NULL) +@@ -224,6 +229,7 @@ + } + free((char *) suppl_glist); + return(0); ++#endif + } + + +@@ -879,8 +885,8 @@ + double Sfile_microtime(int flag) + { + struct timeval tv; +- struct timezone tz; +- gettimeofday(&tv,&tz); ++ /*struct timezone tz;*/ ++ gettimeofday(&tv,NULL); + return((double) (tv.tv_sec+1.0e-6*tv.tv_usec)); + } + +diff -Paur --no-dereference -- xorriso.upstream/xorriso/text_io.c xorriso/xorriso/text_io.c +--- xorriso.upstream/xorriso/text_io.c ++++ xorriso/xorriso/text_io.c +@@ -29,7 +29,9 @@ + + /* for -charset */ + #include ++#if !defined(__sortix__) + #include ++#endif + #include + + +@@ -327,10 +329,9 @@ + #endif /* Xorriso_with_line_editoR */ + double tdiff; + struct timeval tv; +- struct timezone tz; + struct Xorriso_lsT *next_lst; + +- gettimeofday(&tv,&tz); ++ gettimeofday(&tv,NULL); + tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec); + + fflush(stdout); +@@ -475,7 +476,7 @@ + ex:; + if(cpt!=NULL) + free(cpt); +- gettimeofday(&tv,&tz); ++ gettimeofday(&tv,NULL); + xorriso->idle_time+= tv.tv_sec+(1.e-6*(double) tv.tv_usec)-tdiff; + return(ret); + } +@@ -3484,7 +3485,11 @@ + Xorriso_status_result(xorriso,filter,fp,flag&2); + + Xorriso_get_local_charset(xorriso, &local_charset, 0); ++#if defined(__sortix__) ++ nl_charset= "UTF-8"; ++#else + nl_charset= nl_langinfo(CODESET); ++#endif + is_default= (strcmp(local_charset, nl_charset) == 0); + sprintf(line, "-local_charset %s\n", Text_shellsafe(local_charset, sfe, 0)); + if(!(is_default && no_defaults)) +@@ -4126,8 +4131,12 @@ + adrpt= reply_pipe_adr; + ret= stat(adrpt, &stbuf); + if(ret == -1) { ++#if defined(__sortix__) ++ ret= (errno = ENOSYS, -1); ++#else + ret= mknod(adrpt, S_IFIFO | S_IRWXU | S_IRWXG | S_IRWXO | S_IRWXO, + (dev_t) 0); ++#endif + if(ret == -1) { + sprintf(xorriso->info_text, + "-launch_frontend: Cannot create named pipe %s", diff --git a/ports/xorriso/xorriso.port b/ports/xorriso/xorriso.port new file mode 100644 index 00000000..77583af0 --- /dev/null +++ b/ports/xorriso/xorriso.port @@ -0,0 +1,11 @@ +NAME=xorriso +BUILD_LIBRARIES='libiconv libz? bzip2? libreadline?' +VERSION=1.3.8 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=901204634651533f7cbd105eab560534702458258529aac4b2f0fc946992107e +UPSTREAM_SITE=https://ftp.gnu.org/gnu/xorriso +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--program-prefix=' diff --git a/ports/xorriso/xorriso.rmpatch b/ports/xorriso/xorriso.rmpatch new file mode 100644 index 00000000..02a6fec8 --- /dev/null +++ b/ports/xorriso/xorriso.rmpatch @@ -0,0 +1,2 @@ +rm -rf -- 'config.status' +rm -rf -- 'libtool' diff --git a/ports/xz/xz.patch b/ports/xz/xz.patch new file mode 100644 index 00000000..20c4182d --- /dev/null +++ b/ports/xz/xz.patch @@ -0,0 +1,49 @@ +diff -Paur --no-dereference -- xz.upstream/build-aux/config.sub xz/build-aux/config.sub +--- xz.upstream/build-aux/config.sub ++++ xz/build-aux/config.sub +@@ -1373,7 +1373,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -aos* | -aros* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ +diff -Paur --no-dereference -- xz.upstream/configure xz/configure +--- xz.upstream/configure ++++ xz/configure +@@ -18313,6 +18313,7 @@ + + #if defined(_WIN32) || defined(__CYGWIN__) || defined(__OS2__) \ + || defined(__DJGPP__) || defined(__VMS) \ ++ || defined(__sortix__) \ + || defined(AMIGA) || defined(__AROS__) + int main(void) { return 0; } + #else +diff -Paur --no-dereference -- xz.upstream/src/common/tuklib_physmem.c xz/src/common/tuklib_physmem.c +--- xz.upstream/src/common/tuklib_physmem.c ++++ xz/src/common/tuklib_physmem.c +@@ -67,6 +67,11 @@ + // This sysinfo() is Linux-specific. + #elif defined(TUKLIB_PHYSMEM_SYSINFO) + # include ++ ++// Sortix ++#elif defined(__sortix__) ++# include ++ + #endif + + +@@ -197,6 +202,10 @@ + struct sysinfo si; + if (sysinfo(&si) == 0) + ret = (uint64_t)si.totalram * si.mem_unit; ++#elif defined(__sortix__) ++ size_t ret_size_t; ++ memstat(NULL, &ret_size_t); ++ ret = ret_size_t; + #endif + + return ret; diff --git a/ports/xz/xz.port b/ports/xz/xz.port new file mode 100644 index 00000000..bb881912 --- /dev/null +++ b/ports/xz/xz.port @@ -0,0 +1,12 @@ +NAME=xz +BUILD_LIBRARIES='libiconv? gettext?' +VERSION=5.2.1 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.xz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=6ecdd4d80b12001497df0741d6037f918d270fa0f9a1ab4e2664bf4157ae323c +UPSTREAM_SITE=https://tukaani.org/xz +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +CONFIGURE_ARGS='--disable-lzmadec --disable-lzmainfo --disable-lzma-links' +POST_INSTALL=tix-eradicate-libtool-la diff --git a/share/man/man5/port.5 b/share/man/man5/port.5 new file mode 100644 index 00000000..15377818 --- /dev/null +++ b/share/man/man5/port.5 @@ -0,0 +1,356 @@ +.Dd March 19, 2022 +.Dt PORT 5 +.Os +.Sh NAME +.Nm port +.Nd port build instructions +.Sh SYNOPSIS +.Pa /src/ports/example/example.port +.Sh DESCRIPTION +The .port file format defines the build instructions for a piece of software +ported to this operating system as a package. +.Pp +This manual documents the file format and +.Xr porting 7 +is the guide on how to author a port. +.Pp +A port called +.Sy example +consists of the following adjacent files: +.Pp +.Bl -tag -width "example.execpatch" -compact +.It Pa example.port +build instructions and meta information. +.It Pa example.patch +optional +.Xr patch 1 +applied to the upstream release. +.It Pa example.execpatch +optional +.Xr tix-execpatch 8 +changing the executable bit on files. +.It Pa example.rmpatch +optional +.Xr tix-rmpatch 8 +deleting files from the upstream release. +.El +.Pp +The upstream release archive is downloaded and extracted into the +.Pa example +directory with each kind of patches applied, which is used as the working +directory when building the port. +Ports are extracted with read-only files and writable directories by default. +The +.Pa example.version +file is created with the version number and checksums of the above files. +.Pp +If the port is placed in the +.Pa /src/ports/example/ +directory then it's built as part of the operating system. +The port can be built directly using +.Xr tix-port 8 +which handles downloading and patching the source code, building the port, +and installing the binary package. +.Pp +The .port files define the meta information using a subset of the +.Xr sh 1 +language syntax for variable assignments as parsed by +.Xr tix-vars 8 . +Basic variable substitutions, escape sequences, single quotes, double quotes, +and comments are supported. +.Pp +The variables are as follows: +.Bl -tag -width "12345678" +.It Sy ALIAS_OF +Declares this port to be an empty port that's an alias for the named port. +.It Sy ARCHIVE +Extract the upstream archive by this file name if set, +usually +.Sy $DISTNAME.$COMPRESSION +where +$COMPRESSION +is normally tar.xz or the appropriate file extension. +.It Sy ARCHIVE_2 +A second +.Sy ARCHIVE +if set with its own set of similar variables. +.It Sy BUILD_LIBRARIES +Space delimited list of libraries (ports) linked with. +Optional dependencies are suffixed with a question mark +.Sq "?" . +.It Sy BUILD_PROGRAMS +Space delimited list of programs (ports) needed to build this port. +Optional dependencies are suffixed with a question mark +.Sq "?" . +.It Sy BUILD_SYSTEM +The build system used by this port: +.Bl -tag -width "configure" +.It Sy configure +A +.Pa ./configure +script following the GNU coding conventions communicated with using standard +command line options and standard environment variables. +.It Sy makefile +A +.Pa Makefile +using the below set of conventional environment variables. +.El +.It Sy CONFIGURE +The path to the configure script relative to the source directory. +(Default: +.Pa ./configure ) +.It Sy CONFIGURE_ARGS +Additional command line arguments passed to configure. +.It Sy CONFIGURE_USE_BUILD_DIRECTORY Ns = Ns Oo Sy false "|" true Oc +Whether to use a temporary working directory when building the port where the +object files will be placed instead of inside the source directory. +(Default: +.Sy false ) +.It Sy CONFIGURE_VARS +Additional environment variable assignments while configure is run. +.It Sy CONFIGURE_WITH_BUILD_SYSROOT Ns = Ns Oo Sy false "|" true Oc +Whether to tell configure where the system root is located during the build +using the +.Fl \-with-build-sysroot +option. +(Default: +.Sy false ) +.It Sy CONFIGURE_WITH_SYSROOT Ns = Ns Oo Sy false "|" true Oc +Whether to tell configure where the system root is located at runtime using the +.Fl \-with-sysroot +option. +(Default: +.Sy false ) +.It Sy CONFIGURE_WITH_SYSROOT_LD_BUG Ns = Ns Oo Sy false "|" true Oc +Whether the +.Fl \-with-sysroot +option doesn't understand the empty string as meaning no system root will be +used at runtime and +.Fl \-with-sysroot Ns = Ns / +should be used instead. +(Default: +.Sy false ) +.It Sy COMPRESSION Ns = Ns Oo Sy tar "|" tar.gz "|" tar.bz2 "|" tar.xz Oc +The file extension of +.Sy ARCHIVE +including the compression format. +.It Sy COMPRESSION_2 Ns = Ns Oo Sy tar "|" tar.gz "|" tar.bz2 "|" tar.xz Oc +For +.Sy ARCHIVE_2 . +.It Sy DEVELOPMENT Ns = Ns Oo Sy false "|" true Oc +Whether the port is in the development workflow per +.Xr porting 7 . +(Default: +.Sy false ) +.Pp +If +.Sy false , +the port is extracted with read-only files and writable directories. +The port's source directory is considered a cache that can be safely deleted +without data loss e.g. whenever the meta information or the patches change. +.Pp +If +.Sy true , +any old non-development extraction is deleted, and the archive is instead +extracted with writable permissions in development mode. +The port's source directory contains an in-progress port that's considered +valuable and will not be deleted under any circumstances as long as the port +remains in development mode. +If the port builds successfully, then the patches are regenerated by diffing the +upstream release with the source directory. +.It Sy DIRTY_FILE +The port doesn't need to be cleaned if this file doesn't exist. +(Default: +.Sy config.log , +.Sy Makefile , +and +.Sy makefile ) +.It Sy DISTNAME +The name of the upstream release, usually +.Sy $NAME-$VERSION . +.It Sy DISTNAME_2 +For +.Sy ARCHIVE_2 . +.It Sy DISTNAME_REGEX +Extended regular expression recognizing distnames of releases with the version +number matched in the first subexpression. +(Default: Automatically determined using +.Sy ARCHIVE +and +.Sy VERSION_REGEX ) +.It Sy LICENSE +Abbreviation of the license the port is released under. +.It Sy LOCATION_INDEPENDENT Ns = Ns Oo Sy false "|" true Oc +Whether binary packages are location independent, i.e. can be installed in +another prefix than one supplied at build time. +(Default: +.Sy false ) +.It Sy MAKE +The +.Xr make 1 +program to use. +(Default: Search the PATH for the program in the +.Ev MAKE +environment variable or +.Xr make 1 +as a fallback) +.It Sy MAKE_ARGS +Additional arguments passed to make. +.It Sy MAKE_BUILD_TARGET +Build the port by making this target. +(Default: +.Sy all ) +.It Sy MAKE_CLEAN_TARGET +Clean the port by making this target. +(Default: +.Sy distclean +if +.Sy BUILD_SYSTEM=configure +and +.Sy clean +otherwise) +.It Sy MAKE_IGNORE_CLEAN_FAILURE Ns = Ns Oo Sy false "|" true Oc +Whether to silently ignore if cleaning the port failed. +(Default: +.Sy true ) +.It Sy MAKE_INSTALL_TARGET +Install the port by making this target with the +.Ev DESTDIR +environment variable set to a temporary secondary prefix for the purpose of +installation-time packaging. +(Default: +.Sy install ) +.It Sy MAKE_VARS +Additional environment variable assignments while make is run. +.It Sy NAME +The name of the port. +.It Sy NEED_WRITABLE Ns = Ns Oo Sy false "|" true Oc +Whether to extract the port with writable files because the port couldn't be +fully normalized and the port actually needs to modify files shipped in the +upstream releases at build time. +(Default: +.Sy false ) +.It Sy POST_INSTALL +Optional program to invoke post-installation to fix up the installation. +The +.Sy TIX_BUILD_DIR , +.Sy TIX_SOURCE_DIR , +.Sy TIX_INSTALL_DIR , +.Sy TIX_SYSROOT , +.Sy BUILD , +.Sy HOST , +.Sy TARGET , +.Sy PREFIX , +and +.Sy EXEC_PREFIX +environment variables are set and unset appropriately. +.It Sy RELEASE_SEARCH_PAGE +Upstream URL listing the available versions of the port. +.It Sy RELEASE_SEARCH_REGEX +Locate new upstream versions of the port by searching +.Sy RELEASE_SEARCH_PAGE +using this regular expression matching the new version number in the first +subexpression. +.It Sy RUNTIME_DEPS +Space delimited list of libraries (ports) needed at run time. +Unsupported. +.It Sy RUNTIME_PROGRAMS +Space delimited list of programs (ports) needed at run time. +Unsupported. +.It Sy SHA256SUM +.Xr sha256sum 1 +of the upstream release. +.It Sy SHA256SUM_2 +For +.Sy ARCHIVE_2 . +.It Sy SOURCE_PORT +Use the named port's source code instead. +.It Sy SUBDIR +Run the build commands in this subdir. +.It Sy UPSTREAM_ARCHIVE +The filename of the upstream release on +.Sy UPSTREAM_SITE , +usually +.Sy $ARCHIVE +but may be different in cases where the upstream filename is poor (e.g. isn't +unique, lacking the name of the port and the version) and +.Sy ARCHIVE +is set to a unique filename for use in the mirror. +.It Sy UPSTREAM_ARCHIVE_2 +For +.Sy ARCHIVE_2 . +.It Sy UPSTREAM_SITE +Download releases from this upstream URL (without a trailing slash) in case the +mirror fails. +.It Sy UPSTREAM_SITE_2 +For +.Sy ARCHIVE_2 . +.It Sy USE_BOOTSTRAP Ns = Ns Oo Sy false "|" true Oc +Bootstrap a new version of this port by first building a local version installed +into a temporary directory in the +.Ev PATH +and then use it to build the final version. +(Default: +.Sy false ) +.Pp +This functionality is useful when e.g. cross-compiling a port requires the same +version of the port to already be locally installed. +The bootstrap phase uses its own set of variables prefixed with +.Sy BOOTSTRAP_ +with the same semantics as their counterparts, e.g.: +.Pp +.Bl -tag -compact -width "12345678" +.It Sy BOOTSTRAP_BUILD_SYSTEM +.It Sy BOOTSTRAP_CONFIGURE +.It Sy BOOTSTRAP_CONFIGURE_ARGS +.It Sy BOOTSTRAP_CONFIGURE_USE_BUILD_DIRECTORY +.It Sy BOOTSTRAP_CONFIGURE_VARS +.It Sy BOOTSTRAP_MAKE +.It Sy BOOTSTRAP_MAKE_ARGS +.It Sy BOOTSTRAP_MAKE_VARS +.El +.It Sy VERSION +The version of the port. +If the version number components are used individually, define them as +.Sy VERSION_MAJOR , +.Sy VERSION_MINOR , +and +.Sy VERSION_PATCH +and define +.Sy VERSION +as +.Sy $VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH . +.It Sy VERSION_2 +For +.Sy ARCHIVE_2 . +.It Sy VERSION_REGEX +Extended regular expression parsing the version number with the full version in +the first subexpression. +(Default: +.Sq ([0-9]+\.[0-9]+(\.[0-9]+)*) ) +.El +.Pp +The following environment variables are set by default during the port build: +.Bl -tag -width "12345678" +.It Ev CC +The C compiler. +.It Ev CFLAGS +Command line options when compiling C code. +.It Ev DESTDIR +An optional extra prefix used when installing the port for packaging. +.It Ev PKG_CONFIG +The +.Xr pkg-config 1 +to use for locating dependencies. +.El +.Sh SEE ALSO +.Xr development 7 , +.Xr porting 7 , +.Xr tix-vars 8 +.Sh HISTORY +The +.Nm +format originally appeared in Sortix 1.1 as the semantic continuation of the +former +.Pa tixbuildinfo +format introduced in Sortix 0.8. diff --git a/share/man/man7/cross-development.7 b/share/man/man7/cross-development.7 index 12936cd9..7eb4dc99 100644 --- a/share/man/man7/cross-development.7 +++ b/share/man/man7/cross-development.7 @@ -275,16 +275,21 @@ cross-compiler you can run: .Ed .Pp This creates a bootable -.Pa sortix.iso . +.Pa sortix.iso +including all ports of third party software. +To build only the minimal set of ports required for installation, set the +.Ev PACKAGES +environment variable to +.Sy minimal! +or set it to the empty string to only build the base system. +Cross-compiling the ports requires installing additional dependencies locally +in order to bootstrap the cross-compilation of some ports. .Ss Additional Required Reading The .Xr development 7 manual page documents how to develop Sortix and how to use the build system. This manual page only documents how to set up a cross-development environment -and is not sufficient to develop Sortix, or to make a fully functional and -installable Sortix system. -The above instructions only gives you a cross-compilation of the base system -without any of the nessesary ports of third party software. +and is not sufficient to develop Sortix. .Pp The .Xr following-development 7 @@ -310,5 +315,5 @@ in your case. .Xr development 7 , .Xr following-development 7 , .Xr installation 7 , -.Xr porting-guide 7 , +.Xr porting 7 , .Xr sysinstall 8 diff --git a/share/man/man7/development.7 b/share/man/man7/development.7 index 9c977e39..20fc0d0e 100644 --- a/share/man/man7/development.7 +++ b/share/man/man7/development.7 @@ -47,10 +47,11 @@ The build system creates a minimal root filesystem structure in the .Pa /src/sysroot and builds each operating system component in turn, installing them into the sysroot. -If the source code for ports are placed in +The ports in the .Pa /src/ports -then they are automatically built as well. -The result is a minimal system that can be turned into working system by adding +are built automatically by downloading the upstream releases and applying the +appropriate patches. +The result is a system image that can be turned into working system by adding important configuration such as .Xr passwd 5 . .Pp @@ -86,6 +87,8 @@ The important targets are: .Bl -tag -width "12345678" .It Sy all (default) Build each component in turn and install them into the sysroot. +.It Sy available-ports +Search for newer available versions of ports. .It Sy build-tools Make all build tools. .It Sy clean @@ -95,7 +98,15 @@ Clean the component directories and the port source code. Clean the directories of all build tools. .It Sy distclean Run every clean target such that the source code is ready for distribution. -.Sy ( clean-builds , clean-core , clean-ports , clean-release , clean-repository , clean-sysroot ) +.Sy ( clean-builds , clean-core , clean-mirror , clean-release , clean-repository , clean-sysroot , distclean-ports ) +.It Sy distclean-ports +Remove the port source code extractions. +.It Sy extract-ports +Extract the upstream release for each +.Xr port 5 +in +.Pa /src/ports +and apply the appropriate patches. .It Sy install-build-tools Install all build tools after making them. .It Sy iso @@ -103,9 +114,23 @@ Create a release iso in the .Pa /src/builds directory after making .Sy all . +.It Sy mirror +Download the upstream release for each +.Xr port 5 +in +.Pa /src/ports +from +.Ev SORTIX_PORTS_MIRROR +into the +.Pa /src/mirror +directory. +The operating system can be built without network connectivity once the mirror +is populated. +The local mirror has the same structure as the remote mirror and can be used as +a remote mirror. .It Sy mostlyclean -Clean everything except binary packages. -.Sy ( clean-builds , clean-core , clean-ports , clean-release , clean-sysroot ) +Clean everything except binary packages and the mirror of upstream releases. +.Sy ( clean-builds , clean-ports , clean-release , clean-sysroot , distclean-ports ) .It Sy presubmit Verify the coding style is followed .Sy ( verify-coding-style ) , @@ -153,6 +178,12 @@ Create the sysroot and install only the headers of the standard library and kernel into it. This is useful when bootstrapping the runtime libraries of the compiler that need to know about libc prior to building libc. +.It Sy upgrade-ports +Search for newer available versions of ports and update the +.Sy VERSION +variable in the +.Xr port 5 +and switch it into development mode. .El .Pp The important environment variables influencing the Makefile are: @@ -177,6 +208,19 @@ Specifies compiler optimization options that gets added to .Ev CFLAGS and .Ev CXXFLAGS . +.It Ev PACKAGES +Specifies which ports to build, or all ports if unset. +Suffixing a port with a +.Sq "!" +includes its mandatory dependencies, and suffixing it with +.Sq !! +includes the optional dependencies as well. +The sets of ports defined in +.Pa /src/build-aux/ports.conf +can be specified as well. +For instance +.Sy PACKAGES=minimal! +builds all the minimal ports with no optional dependencies. .It Ev SORTIX_INCLUDE_SOURCE Specifies whether the source code is included in the sysroot. This must be one of @@ -198,6 +242,10 @@ or .Sy xz and defaults to .Sy xz . +.It Ev SORTIX_PORTS_MIRROR +Upstream releases of ports are downloaded from this mirror, defaulting to the +official mirror, and falling back to the upstream release site if the mirror +failed. .El .Ss Components The operating systems components, such as libc and the kernel, each have their @@ -241,17 +289,24 @@ to make it install files there. In addition to the directories for each operating system component, there are these special directories: .Bl -tag -width "12345678" +.It Pa /src/builds +The build artifacts produced when building the operating system. +.It Pa /src/mirror +The upstream releases of ports are downloaded on the first use and cached inside +this mirror directory. .It Pa /src/ports -If this directory exists, each subdirectory can contain the source code for a -port that gets built along with the rest of the system. +Each subdirectory contains a +.Xr port 5 +which is automatically built along with the operating system per the +.Ev PACKAGES +environment variable. .It Pa /src/release The .Sy release root makefile target creates this directory and populates it with a directory structure suitable for online publishing of a release. .It Pa /src/repository -If ports are present, this directory is made when binary packages are built and -they are stored here. +This directory stores the binary packages and is created when they are built. This works as a cache so ports don't have to be rebuilt every time the operating system is. Packages are also copied from here rather than the sysroot when making releases. @@ -298,29 +353,23 @@ compiled tools are intended to run on the current system, and have not been built properly using .Pa /src/sysroot . .Ss Ports -You can place the source code for ports in -.Xr srctix 7 -format (has a -.Xr tixbuildinfo 7 -file) in the +Each +.Xr port 5 +in the .Pa /src/ports -directory and they will get built automatically when and installed into the -sysroot when building the whole operating system. +directory will get built automatically when and installed into the sysroot when +building the whole operating system. Installable binary packages are created in the .Pa /src/repository/$HOST directory using -.Xr tix-build 8 -directory and can be installed with +.Xr tix-port 8 +and can be installed with .Xr tix-install 8 . -If an existing binary package exists in the repository, it is used instead of -the building the port again. +If an existing binary package with the right version exists in the repository, +it is used instead of the building the port again. .Pp -Ports are currently made using -.Xr cross-development 7 -as not all ports can be built natively yet. -.Pp -The ports system is described in detail in -.Xr porting-guide 7 . +The ports system workflow is described in +.Xr porting 7 . .Ss Patches The source code is managed as a .Xr git 1 @@ -383,10 +432,11 @@ source code. .Sh SEE ALSO .Xr git 1 , .Xr make 1 , +.Xr port 5 , .Xr cross-development 7 , .Xr following-development 7 , .Xr installation 7 , -.Xr porting-guide 7 , +.Xr porting 7 , .Xr serial-transfer 7 , .Xr upgrade 7 , .Xr sysinstall 8 , diff --git a/share/man/man7/following-development.7 b/share/man/man7/following-development.7 index a6e46054..7568d817 100644 --- a/share/man/man7/following-development.7 +++ b/share/man/man7/following-development.7 @@ -69,6 +69,40 @@ releasing Sortix x.y, foo." to allow the maintainer to easily .Xr grep 1 for it after a release. .Sh CHANGES +.Ss Add ports to the Sortix repository +The ports have been moved from the porttix/srctix repositories into the +.Pa ports/ +subdirectory in the main repository. +The upstream releases are downloaded from the appropriate mirror when built and +patched with the patches in the +.Pa ports/ +subdirectory. +.Pp +Any existing manually created +.Pa ports/ +directory should be removed before checking out the new source code. +.Pp +Tix must be upgraded to build the new ports: +.Bd -literal + cd /src/tix && + make clean && + make install +.Ed +.Pp +If not developing natively, set +.Ev PREFIX +to the desired location. +.Pp +All ports are built by default and the +.Ev PACKAGES +environment variable configures which ports are built. +.Pp +Sortix 1.0 has a broken +.Xr patch 1 +and the +.Sy extract-ports +makefile target should be invoked on another system in order to bootstrap the +new version. .Ss Implement file descriptor passing The .Dv SCM_RIGHTS diff --git a/share/man/man7/portability.7 b/share/man/man7/portability.7 new file mode 100644 index 00000000..091263ed --- /dev/null +++ b/share/man/man7/portability.7 @@ -0,0 +1,301 @@ +.Dd March 28, 2022 +.Dt PORTABILITY 7 +.Os +.Sh NAME +.Nm portability +.Nd standard library portability information +.Sh DESCRIPTION +This manual documents replacements for interfaces not available in the standard +library or with special portability notes. +.Pp +Software written for other operating systems can be ported by replacing uses of +obsolete interfaces with the modern replacements and working around any missing +functionality. +The standard library attemps to implement the relevant parts of the C and POSIX +standards with useful extensions and tends to omit non-standard extensions found +on other operating systems whenever standard interfaces exists. +.Ss alloca +.Xr alloca 3 +and variable length arrays are implemented by the compiler, however the main +thread stack size is fixed and does not grow unlike other operating systems, and +large stack uses should instead use +.Xr malloc 3 +or set the stack size explicitly for another thread using +.Xr pthread_attr_setstacksize 2 . +.Ss asctime, asctime_r +.Xr strftime 3 +is the standard replacement. +.Ss bcopy +.Xr memcpy 3 +is the standard replacement. +Note how the order of the source and destination parameters is swapped. +.Ss bzero +.Xr memset 3 +is the standard replacement. +.Ss caddr_t +.Vt void * +is the standard type. +.Ss clock +.Xr clock 3 +is implemented but can overflow, and +.Xr clock_gettime 2 +.Dv CLOCK_PROCESS_CPUTIME_ID +is the modern replacement with nanosecond precision. +.Ss ctime, ctime_r +.Xr strftime 3 +is the standard replacement. +.Ss daemon +Daemons should not background by double forking but rather stay in the +foreground and be managed by +.Xr init 8 . +.Ss __dead +.Dv noreturn +from +.In stdnoreturn.h +is the modern standard replacement or the +.Sy __attribute__((noreturn)) +extension can be used. +.Ss flock, fcntl F_UNLCK, F_WRLCK, F_GETLK, F_SETLK, F_SETLKW, lockf +POSIX advisory locks are not implemented due to their flawed design of being +process-wide instead of being per file description. +The superior +.Xr flock 2 +is not currently implemented. +It might be safe enough to omit the file locking as a workaround. +.Ss ftime +.Xr clock_gettime 2 +is the standard replacement. +.Ss getdtablesize +The file descriptor table is unbounded and file descriptors above a certain +value can be closed using +.Xr closefrom 2 +and iterated using +.Xr psctl 2 . +.Ss getgroups, setgroups, initgroups +Supplementary groups are not implemented yet. +It may be possible to remove invocations as a workaround. +.Ss gethostbyaddr +.Xr getnameinfo 3 +is the standard modern replacement. +.Ss gethostbyname +.Xr getaddrinfo 3 +is the standard modern replacement. +.Ss getitimer, setitimer +.Xr timer_create 2 +is the modern standard replacement. +.Ss getpgrp, setpgrp +.Xr getpgid 3 +and +.Xr setpgid 3 +are the standard portable replacements without disagreement on the function +signatures. +.Ss gettimeofday +.Xr gettimeofday 2 +is implemented but the second parameter is defunct and is typed +.Vt void * +per POSIX instead of +.Vt struct timezone * . +.Xr clock_gettime 2 +is the modern replacement with nanosecond precision. +.Ss gid_t +.Vt gid_t +is 64-bit unsigned and can be formatted portably cast to a +.Vt uintmax_t +using +.Dq %ju . +.Ss inet_addr, inet_aton +.Xr inet_pton 3 +and +.Xr getaddrinfo 3 +are the modern standard replacements, however they don't support the unusual +IPv4 notations. +.Ss inet_ntoa +.Xr inet_ntop 3 +and +.Xr getnameinfo 3 +are the modern standard replacements. +.Ss +.In limits.h +is currently implemented by the compiler instead of the standard library and it +does not define everything required by POSIX. +.In sortix/limits.h +can be included instead as a temporary workaround if the required definitions +are absent. +.Ss makedev, major, minor +The kernel does not have a concept of major and minor device numbers. +.Ss mkfifo +.Xr mkfifo 2 +named pipes are not currently implemented but unnamed pipes are available using +.Xr pipe 2 , +or alternatively +.Dv AF_UNIX +sockets can be used instead. +.Ss mknod +Devices in the +.Pa /dev +filesystem are created by the kernel and cannot be manually created. +.Ss mmap +.Xr mmap 2 +is implemented, but +.Dv MAP_SHARED +shared memory mappings are not implemented yet. +.Ss off_t +.Vt off_t +is 64-bit signed and can be formatted portably cast to an +.Vt intmax_t +using +.Dq %jd . +.Ss PATH_MAX +The +.Dv PATH_MAX +limit does not currently exist and may be added in the future. +Applications should be written as if this limit does not exist, but if required, +it can be defined to 4096 as a fallback. +.Ss pid_t +.Vt pid_t +is 64-bit signed and can be formatted portably cast to an +.Vt intmax_t +using +.Dq %jd . +.Ss poll +.Xr poll 2 +is implemented in +.In poll.h +per POSIX, however some operating systems have a +.In sys/poll.h +alias which is not implemented. +.Ss printf +.Xr printf 3 +is implemented, however floating point formatting is not currently implemented +and the format specifier will instead be output verbatim. +Position parameters are also not implemented yet. +.Ss pthread_cancel +Pthread cancellation is not implemented and threads instead have to +.Xr pthread_exit 3 +voluntarily. +.Ss pthread_kill +Sending a signal to a particular thread is not implemented. +.Ss putenv +.Xr setenv 3 +is the standard replacement. +Note how the string provided could technically be modified at a later time. +.Ss rand, srand +.Xr rand 3 +and +.Xr srand 3 +are implemented, however invocations will warn that the functions are not +random, and +.Xr arc4random 3 , +.Xr arc4random_uniform 3 , +or +.Xr arc4random_buf 3 +should be used instead for random numbers. +.Ss realpath +.Xr realpath 3 +with a non-null second parameter is undefined behavior as there is no +.Dv PATH_MAX +limit, and should always be invoked with a null second parameter which allocates +a destination buffer of the appropriate size using +.Xr malloc 3 . +.Ss +.In resolv.h +is currently not implemented and +.Xr getaddrinfo 2 +can be used instead. +.Ss sbrk +.Xr malloc 3 +and +.Xr mmap 2 +are the standard interfaces for memory allocation. +.Ss select +.Xr select 2 +is implemented, but is defined in +.In sys/select.h +instead of +.In sys/time.h +per POSIX, however the superior +.Xr poll 2 +should be used instead as the +.Vt fdset_t +type overflows on file descriptors whose value is too large. +.Ss sigaction SA_RESTART +Restarting system calls after signal delivery is not currently implemented and +system calls instead fail with +.Er EINTR . +.Ss socklen_t +.Vt socklen_t +is typedef to +.Vt size_t +instead of +.Vt int +or +.Vt unsigned int +as on other operating systems. +.Ss sprintf +.Xr sprintf 3 +is implemented, however invocations will warn the function is dangerous as it +does not know the size of the destination buffer and may buffer overflow if the +output is unexpectedly large. +.Xr snprintf 3 +should be use instead as the destination buffer size should always be known, +otherwise the invocation is suspicious. +The superior alternative is to combine allocation and initialization using +.Xr asprintf 3 . +.Ss strptime +.Xr strptime 3 +is not currently implemented. +.Ss +.In sys/param.h +is not implemented as there is little agreement on what it's supposed to contain +and all the contents have standard replacements or can be provided by the +application itself. +Inclusions are almost always unnecessary and can be removed. +.Ss times +.Xr times 2 +is implemented, however the +.Vt clock_t +type may overflow, and the +.Xr timens 2 +non-standard extension with +.Vt struct timespec +precision can be used instead. +.Ss time_t +.Vt time_t +is 64-bit signed and can be formatted portably cast to an +.Vt intmax_t +using +.Dq %ji +or with +.Xr strftime 3 +and such. +.Pp +.Dv CLOCK_REALTIME +counts the number of seconds since the epoch including leap seconds, unlike +other operating systems and in violation of POSIX. +.Ss u_char, u_short, u_int, u_long +.Vt unsigned char , +.Vt unsigned short , +.Vt unsigned int , +and +.Vt unsigned long +are the standard types. +Applications can supply the typedefs themselves if desired. +.Ss uid_t +.Vt uid_t +is 64-bit unsigned and can be formatted portably cast to a +.Vt uintmax_t +using +.Dq %ju . +.Ss u_int8_t, u_int16_t, u_int32_t, u_int64_t +.Vt uint8_t , +.Vt uint16_t , +.Vt uint32_t , +and +.Vt uint64_t +are the standard types. +Applications can supply the typedefs themselves if desired. +.Ss wait3, wait4 +.Xr waitpid 2 +is the standard replacement. +.Sh SEE ALSO +.Xr porting 7 diff --git a/share/man/man7/porting.7 b/share/man/man7/porting.7 new file mode 100644 index 00000000..7afc0fba --- /dev/null +++ b/share/man/man7/porting.7 @@ -0,0 +1,657 @@ +.Dd March 19, 2022 +.Dt PORTING 7 +.Os +.Sh NAME +.Nm porting +.Nd guide for porting software +.Sh SYNOPSIS +.Pa /src/ports/example/example.port +.Sh DESCRIPTION +This manual documents how to port software to this operating system as packaged +ports in the +.Xr port 5 format. +.Ss Philosophy +The ports collection is maintained according to a set of principles designed to +uphold quality, keep the ports maintainable, and to enable giving back +improvements to the upstream projects. +.Pp +Ports are usually named after their primary program or library if relevant. +Libraries should always be prefixed with lib. +The port should be ideally split if it happens to contain both a major program +and a major library. +.Pp +Upstream projects should consider this operating system to be yet another +unknown operating system implementing the standard interfaces. +Explicit support for this operating system should generally not be upstreamed +and should instead be maintained in the patches. +This policy is to avoid burdening upstreams with maintaining support that is +subject to change. +Simply registering the operating system as existing is exempted, but preferably +the software should be patched to compile for any unknown operating system that +has the needed interfaces. +.Pp +Patches should ideally be of upstreamable quality, although it may not be +reasonably practical to make a general solution the upstream could accept. +Non-trivial patches should be prefaced with a comment explaining the rationale +for the patch. +.Pp +Third party software should be selected into the ports collection with care, +ideally because they're widely considered high quality and stable. +Low quality software with poor code quality should preferably not be ported, +instead a better replacement should be standardized on. +.Pp +The build system is expected to follow the relevant conventions, such as the +GNU coding conventions for +.Pa ./configure +and +.Pa Makefile +scripts and the de-facto conventional behavior. +Deficiencies are fixed via patches instead of being worked around. +Ports with their own custom build system implementation should be improved if +they don't implement the interface correctly. +.Pp +Generated files are preferably patched instead of their input files due to the +difficulty regenerating them. +For instance +.Pa configure +should be patched directly instead of +.Pa configure.ac +and likewise +.Pa Makefile.in +instead of +.Pa Makefile.am . +.Pp +Ports must not bundle their dependencies as it's problematic to silently have +multiple stale versions of the same library. +If a port bundles a dependency unless it's installed, then the dependency must +be made mandatory. +.Pp +Ports must both compile natively and cross-compile. +Ports must assume the best about the host operating system when cross-compiling +and unable to test for bugs. +.Pp +It must be possible to reasonably boostrap the latest ports collection from the +latest stable release. +.Ss Metadata +A port named +.Sy example +can be built along with the operating system by creating the +.Pa /src/ports/example/example.port +file with the meta information documented in +.Xr port 5 . +.Pp +Start the port by defining how to get the latest stable version of the upstream +release: +.Bd -literal -offset indent +NAME=example +BUILD_LIBRARIES='libfoo libbar? libqux?' +VERSION=1.2.3 +DISTNAME=$NAME-$VERSION +COMPRESSION=tar.gz +ARCHIVE=$DISTNAME.$COMPRESSION +SHA256SUM=b8d67e37894726413f0d180b2c5a8369b02d4a2961bb50d2a8ab6f553f430976 +UPSTREAM_SITE=https://example.com/pub/example +UPSTREAM_ARCHIVE=$ARCHIVE +BUILD_SYSTEM=configure +LICENSE=example +DEVELOPMENT=true +.Ed +.Pp +The upstream website usually contains the needed information. +Guides such as Beyond Linux from Scratch and the packaging metadata for other +systems may contain useful information on how to port and patch the software. +.Pp +.Sy UPSTREAM_SITE +is the upstream primary download directory without a trailing slash and should +download via a secure connection insofar possible. +.Pp +.Sy SHA256SUM +is the +.Xr sha256sum 1 +of the upstream release, which should be verified with other reputable packaging +systems. +It can be left as the wrong value, and the download will fail and mention which +hash it found instead. +.Pp +.Sy BUILD_LIBRARIES +is the build time library dependencies (space delimited with a +.Sq "?" +suffix for optional dependencies). +It can be left empty until known. +The dependencies can likely be found in the documentation, running +.Sq ./configure --help , +or noticing what the software looks for while being built. +The above example defines a mandatory build time dependency on +.Sy libfoo +and optional build time dependencies on +.Sy libbar +and +.Sy libqux . +Mandatory dependencies need to be ported first. +.Pp +.Sy BUILD_SYSTEM +is set here to a standard configure script. +.Pp +.Sy LICENSE +can be set to the abbreviation of the software's license. +.Pp +.Sy DEVELOPMENT +is set to +.Sy true +to switch the port into development mode, where the port's working directory has +writable files that can be patched during the build. +The +.Pa example.patch , +.Pa example.execpatch , +and +.Pa example.rmpatch +patch files are regenerated when the port builds successfully. +If the upstream release works out of the box without any patches, then the port +is already completed and the development mode can be skipped. +The port's working directory will never be deleted automatically when it is in +development mode. +The +.Sy DEVELOPMENT +variable must be removed before submitting the finished port. +.Ss Building +The port can be finished by repeatedly trying to build it and iteratively fixing +any issues that occur per +.Xr development 7 : +.Bd -literal -offset indent +cd /src +make clean-sysroot +make PACKAGES='example!' +.Ed +.Pp +The +.Sy PACKAGES +environment variable builds only the mentioned ports and the +.Sq "!" +suffix includes the port's mandatory dependencies as well. +The top level makefile uses a sysroot when building the ports which can be used +to determine which dependencies are mandatory. +The mandatory ports can be found by starting with an empty list of build +libraries and a clean sysroot, and then trying to build the port and adding the +dependencies whose absense is causing the build to fail. +.Pp +The higher level +.Xr tix-port 8 +program manages the build by downloading the source code, patching it, +building the port, and installing the binary package. +The lower level +.Xr tix-build 8 +program will abort with an interactive menu if the port fails to build. +See the section below for how to troubleshoot common situations. +.Pp +The binary package +.Pa repository/$HOST/example.tix.tar.xz +is cached when built and the +.Pa repository/$HOST/example.version +file is used to rebuild the binary package when the version changes. +The files should be manually removed to force a rebuild when the port has been +modified while in the development mode. +.Bd -literal -offset indent +rm -f repository/*/example.tix.tar.xz # delete stale binary package +rm -f repository/*/example.version # optional +make clean-repository # or: remove all binary packages +.Ed +.Pp +The port's patch files are regenerated whenever the port builds successfully. +It's recommended to add them to a work-in-progress git commit when working to +keep track of the progress. +.Ss Finishing +The port can be finished by testing it thoroughly and reviewing the details. +.Pp +Test the port works with all the optional dependencies: +.Bd -literal -offset indent +make clean-sysroot +make PACKAGES='example!!' +.Ed +.Pp +The +.Sq "!!" +suffix includes the port's optional dependencies as well. +.Pp +Read all the configure and makefile output and look for anything where it looks +like a wrong conclusion was made or an optional dependency was not used. +.Pp +Review the size of the binary package and whether it installs any large +unnecessary files: +.Bd -literal -offset indent +du -h repository/*/example.tix.tar.xz +tar -t -f repository/*/example.tix.tar.xz +.Ed +.Pp +Review the +.Pa .patch , +.Pa .execpatch +and +.Pa .rmpatch +files (if any) and clean them up as needed by updating the port's source code +and forcing a rebuild to regenerate the patches. +.Pp +Consider installing a cross-compiler for a second architecture and testing the +port works everywhere per +.Xr cross-development 7 . +.Pp +Comments about the port should go in comments at the end of the .port file using +shell-style comments. +Non-trivial patches and aspects should be documented this way. +.Pp +Finally remove the +.Sy DEVELOPMENT +variable and submit the port for review. +.Ss Upgrading ports +Ports can be upgraded by switching the port back in development mode with +a updated version number and checksum. +.Bd -literal -offset indent +make available-ports # Search for newly available versions of ports +make upgrade-ports PACKAGES=example # Update example port +make PACKAGES='example!!' # Find the new sha256sum +# Verify the new sha256sum is authentic. +make PACKAGES='example!!' # Any old patches may fail to apply. +find ports/example -name '*.rej' -o -name '*.orig' +make PACKAGES='example!!' # Regenerate patches on a successful build. +sed -E '/^DEVELOPMENT=true$/d' ports/example/example.port +make PACKAGES='example!!' # Final build and testing. +.Ed +.Pp +The +.Sy available-ports +top-level makefile target can be used to search for ports with newly available +versions, while +.Sy upgrade-ports +updates +.Sy VERSION +to the latest available version and switches the port into development mode. +The +.Ev PACKAGES +environment variable can be set to a subset of ports to upgrade. +The build will fail and report the sha256sum observed upstream and the +.Sy SHA256SUM +variable must be manually updated once it has been verified as as authentic. +.Pp +The old patch will be reapplied and the build will fail if any hunks could +not be applied. +In that case, the +.Pa .rej +files contains the rejected hunks and the merge conflicts need to be resolved. +Delete any +.Pa .rej +and +.Pa .orig +files afterwards and continue the build. +The patch files with be regenerated on a successful build as usual. +.Pp +Finally perform the quality assurance and testing of new ports. +.Sh EXAMPLES +This section describes common situations and portability issues and how to +resolve them. +.Ss config.sub +The +.Pa config.sub +file parses the build/host/target triplet and is duplicated into all software +using autoconf. +If the port ships a version older than 2015-08-20, configure will fail to parse +the operating system: +.Bd -literal -offset indent +checking host system type... Invalid configuration `x86_64-sortix': system `sortix' not recognized +.Ed +.Pp +Fix the situation by adding an entry for the operating system to the +.Pa config.sub +file which is usually in the +.Pa build-aux +subdirectory: +.Bd -literal -offset indent + | -aos* | -aros* | -cloudabi* | -sortix* \\ +.Ed +.Ss Configure +If the configure script fails, then autoconf configure scripts produce a +.Pa config.log +file which contain useful diagnostic information, such as which programs were +compiled to check for a particular feature and what happened when they were +compiled, linked, and executed. +This information can be used to locate the relevant logic in the configure +script. +.Ss Non-verbose make +Some ports default to a non-verbose make mode that doesn't show the commands +being run. +Ports should show the commands invoked by make, which can done with an +environment variable assignment +.Ev V=1 +which can be made permanent using +.Sy MAKE_VARS=V=1 . +.Ss Patching +The build may fail or warn for various reasons which needs to be patched, or the +port may need extra support for the operating system. +The sources become writable once the port is in development mode and can simply +be edited to fix the problem. +The patch files are regenerated whenever the port builds successfully. +.Pp +Non-trivial patches should contain a +.Dq "// PATCH:" +comment explaining why the patch had to be made and make it clear whether the +patch fixes a problem in the upstream release or is specific to the operating +system. +Patches may be read by many people, including upstream developers, and the +context helps them understand if they want the patch too. +.Pp +Ports should ideally continue to work on good operating systems after being +patched. +If the port uses an obsolete function, the port should be patched to +unconditionally use the modern replacement instead. +If the patch is specific to the operating system, the patch should be guarded +with the operating system preprocessor macro. +.Bd -literal -offset indent +// PATCH: Use foo instead because bar doesn't work yet. +#ifdef __sortix__ + foo(); +#else + bar(); +#endif +.Ed +.Pp +If the port tries to use a system header that might be added in the future and +it doesn't have a macro for whether it exists, then +.Sy __has_include +extension can be used: +.Bd -literal -offset indent +#if __has_include() +#include +#endif +.Ed +.Ss Configuration files +Configuration files in +.Pa /etc +belongs to the system administrator and must not be installed by ports, as local +changes will otherwise be undone whenever the port is upgraded. +.Pp +Ports shipping default configuration files should instead install them in +.Pa /etc/default +and search this directory as a fallback if the system administrator has not made +their own file. +Example configuration files can be installed in +.Pa /etc/example . +.Ss Portability issues +The port might not be portable and requires patching. +Often the port uses a non-standard interface when a standard interface is +available and should be used instead. +Other times the operating system is missing functionality which should ideally +be implemented before proceeding with the port, or perhaps the absence can be +worked around. +.Pp +Common portability problems and their resolution are documented in +.Xr portability 7 . +.Ss libtool .la files +Libraries using libtool may install +.Pa /lib/*.la +files which are unnecessary and contain absolute paths which cause +cross-compilation to fail. +Ports should never install such files and instead rely on +.Xr pkg-config 1 +for locating dependencies. +.Pp +The +.Xr tix-eradicate-libtool-la 1 +program can be used to remove any installed +.Pa .la +files in the +.Sy DESTDIR +as a post-install script: +.Bd -literal -offset indent +POST_INSTALL=tix-eradicate-libtool-la +.Ed +.Ss Post-install command +Ports may install files with an unconventional directory layout or may install +unnecessary large files. +Ideally the makefile should be patched to install correctly in the first place, +but if doing so is impractical, then a post-install command can be used to fix +up the installation in the +.Sy DESTDIR +before the binary package is created. +An executable +.Pa example.post-install +script can be placed next to the +.Pa example.port +files: +.Bd -literal -offset indent +POST_INSTALL=../example.post-install +.Ed +.Pp +The script must fail if any errors occur and protect against being accidentally +invoked without the appropriate environment variables being set. +E.g.: +.Bd -literal -offset indent +#!/bin/sh +set -e +[ -n "$TIX_INSTALL_DIR" ] +mv "$TIX_INSTALL_DIR$PREFIX/share/foo" "$TIX_INSTALL_DIR$PREFIX/share/bar" +.Ed +.Ss Splitting into multiple ports +Upstream releases might have multiple parts, such as a program that also comes +with a library, which should be split into multiple ports whenever reasonable. +.Pp +The port whose name matches the upstream release should be the source package, +and the other ports can use the +.Sy SOURCE_PORT +variable to reuse its source code. +.Pp +The +.Sy SUBDIR +variable can be used to build inside a subdirectory, if the port has already +been logically organized. +.Pp +.Sy CONFIGURE_ARGS +variable can be used to pass options to configure to request the subset of +functionality. +.Sy MAKE_BUILD_TARGET +and +.Sy MAKE_INSTALL_TARGET +can be used to make a subset of the port. +.Ss Gnulib +Gnulib is a GNU portability layer that has three purposes: +.Bl -bullet -compact +.It +Providing fallback implementations of missing standard library interfaces. +.It +Replacing buggy implementations of standard library interfaces. +.It +Sharing common utility functions between projects. +.El +.Pp +Unfortunately the replacement of standard library functionality is problematic: +.Bl -bullet -compact +.It +The replacement implementations tend to be non-portable and one is supposed to +modify the source code to rely on private standard library details that may be +subject to change. +.It +Gnulib is highly forked by design and adding support for new operating systems +needs to be done upstream and it may take years for the support to reach new +downstream releases. +.It +Gnulib has assumed the worst in the past when cross-compiling, assuming unknown +operating systems are buggy, injecting a non-portable replacement that doesn't +compile, even when the standard library function is correct and could just have +been used. +.It +Replacing standard library functions can hide bugs that would otherwise have +found and fixed. +.It +Gnulib is not organized into the three categories and it's non-trivial to find +out whether any interface has been replaced that shouldn't have been. +.It +There is no way to satisfy gnulib by correctly implementing the standard library +without contributing explicit support upstream for new systems and committing +to private implementation details. +.El +.Pp +Meanwhile the shared utility functions means gnulib is tightly integrated into +the software and cannot be disabled. +.Pp +Consequently a lot of software using gnulib does not cross-compile to new +operating systems and the compilation fails asking for standard library +implementation details. +.Pp +Gnulib can be effectively disabled by copying the autoconf cache environment +variables set at the top of the patched configure script in an existing port +with gnulib. +Each variable is used to say the standard library does not have a particular +bug. +Modern versions of gnulib has improved to assume the best when cross-compiling +but it may still be an obstacle for some ports. +.Ss Custom configure script +Configure scripts generated by autoconf are useful because they have a +consistent interface. +Ports with a hand-written configure script can fail if they fail to implement +the autoconf configure interface correctly. +The best solution is modify the configure script to implement the missing parts +of the interface. +.Pp +Custom configure scripts sometimes fail to implement the +.Fl \-prefix +and +.Fl \-exec-prefix +options correctly, failing to discern between an unset option and the empty +value, which matters for the prefix where the default prefix +.Pa ( /usr/local ) +is different from the empty prefix (the root directory). +.Pp +Custom configure scripts sometimes fail to implement cross-compilation using the +.Fl \-build , +.Fl \-host , +and +.Fl \-target +options to locate the compiler and cross-compiler. +.Ss Makefile +Ports might not have a configure script and only a makefile: +.Bd -literal -offset indent +BUILD_SYSTEM=makefile +.Ed +.Pp +The build environment is communicated to the makefile using conventional +environment variables, however loose makefiles vary wildly and likely needs to +be patched to support the variables used by +.Xr tix-build 8 . +In some cases, it may be preferable to write a new makefile from scratch. +.Ss Running cross-compiled program +Ports may contain logic errors and attempt to execute a cross-compiled program +during the build, which fails because the program can't run on the current +system. +.Pp +If the program is supposed to check whether a feature works at runtime, then the +right solution is to simply assume it's correct when cross-compiling or to have +a suitable runtime fallback. +.Pp +If the program is part of the compilation process, then it should be compiled +with the build machine's compiler instead, which can be located using the +.Ev CC_FOR_BUILD +environment variable instead of +.Ev CC +before falling back to a standard program. +Likewise each toolchain variable has a counterpart for the build machine instead +of the host machine, such as +.Ev CFLAGS_FOR_BUILD +and +.Ev CPPFLAGS_FOR_BUILD . +.Ss pkg-config +Ports are supposed to locate locate dependencies for the host machine using +the +.Ev PKG_CONFIG +environment variable, and if unset, then using the +.Fl \-host +option to locate a cross-pkg-config, and finally falling back on invoking +.Xr pkg-config 1 +directly . +Dependencies for the build machine should likewise be located using the +.Ev PKG_CONFIG_FOR_BUILD +environment variable. +.Pp +Ports failing to use this search order may fail to cross-compile as they +accidentally use dependencies from the build machine when cross-compiling to the +host machine. +The easiest fix is to use a shell parameter expansion: +.Bd -literal -offset indent +${PKG_CONFIG:-pkg-config} +${PKG_CONFIG_FOR_BUILD:-${PKG_CONFIG:-pkg-config}} +.Ed +.Ss foo-config instead of pkg-config +Ports are supposed to use +.Xr pkg-config 1 +as above for dependencies as it's a general solution with cross-compilation +support, but some ports install their own +.Pa foo-config +program in the +.Ev PATH . +These programs are inherently unable to support cross-compilation, as they +provide answers about the build machine, and the host machine's bin directory +cannot be executed on the current machine. +.Pp +Ports installing +.Pa foo-config +programs must be patched to not install them. +.Xr pkg-config 1 +configuration files should be installed instead. +.Pp +Ports invoking +.Pa foo-config +programs, even as a fallback, must be patched to unconditionally use +.Xr pkg-config 1 +instead. +.Ss Bootstrap +Ports may require the same version of the port to be installed on the build +machine when cross-compiling. +Such ports can cross-compiled with a bootstrap phase: +.Bd -literal -offset indent +USE_BOOTSTRAP=true +.Ed +.Pp +This configuration builds the port in two phases, first building it for the +build machine and installing it into a temporary directory, which is in the +.Ev PATH +while the port is cross-compiled during the second phase. +.Ss DESTDIR +The makefile install target must support the +.Ev DESTDIR +environment variable as a secondary temporary prefix during the installation. +The makefile may need to be patched to inherit the variable from the environment +and to use it during the installation phase. +The build will erroneously attempt to install onto the root directory of the +build machine if the environment variable isn't respected. +.Ss make distclean +The upstream release is to supposed to be distclean, i.e. not contain any files +that are recreated during the compilation, and the distclean makefile target +is supposed to properly clean up. +If it isn't, then the patch may contain spurious hunks adding, removing, or +modifying generated files which may be large. +.Pp +The makefile distclean target should be patched to delete any temporary files +produced during the build to avoid spurious files in the patch. +.Ss Dynamic linking +Dynamic linking is not currently implemented in the standard library and the +compiler toolchain does not support dynamic linking. +Ports with libraries should check whether the toolchain supports dynamic linking +and otherwise fall back on static linking. +.Pp +Ports may be difficult if they use shared libraries for modules. +It may be possible to link the modules statically instead using a supported +mechanism or with additional patching. +If there is no simple solution, it may be possible to statically link the +modules and implement a fake dlopen that iterates a table of entry points for +each module. +.Ss Other problems +Portability issues are very varied and ports often don't properly implement the +conventional interface. +.Xr portability 7 +lists common differences in the standard library. +.Xr port 5 +documents the advanced features useful for certain situations. +Ports may fail at runtime instead of during compilation. +Resolving these issues can require troubleshooting, debugging, research, and +seeking help from the operating system developers and the upstream. +Missing operating system functionality may need to be implemented. +.Sh SEE ALSO +.Xr port 5 , +.Xr development 7 , +.Xr portability 7 diff --git a/tix/.gitignore b/tix/.gitignore index 3af392ae..cfaeced1 100644 --- a/tix/.gitignore +++ b/tix/.gitignore @@ -1,10 +1,9 @@ -porttix-create -srctix-create tix tix-build tix-collection tix-execdiff tix-execpatch tix-install -tix-object-insert +tix-rmdiff tix-rmpatch +tix-vars diff --git a/tix/Makefile b/tix/Makefile index e97353e3..ff714318 100644 --- a/tix/Makefile +++ b/tix/Makefile @@ -14,15 +14,15 @@ ifeq ($(HOST_IS_SORTIX),0) endif BINARIES:=\ -porttix-create \ -srctix-create \ tix \ tix-build \ tix-collection \ tix-execdiff \ tix-execpatch \ tix-install \ +tix-rmdiff \ tix-rmpatch \ +tix-vars \ PROGRAMS:=\ $(BINARIES) \ @@ -30,11 +30,20 @@ tix-eradicate-libtool-la \ tix-iso-add \ tix-iso-bootconfig \ tix-iso-liveconfig \ +tix-port \ MANPAGES8=\ +tix-build.8 \ +tix-eradicate-libtool-la.8 \ +tix-execdiff.8 \ +tix-execpatch.8 \ tix-iso-add.8 \ tix-iso-bootconfig.8 \ tix-iso-liveconfig.8 \ +tix-port.8 \ +tix-rmdiff.8 \ +tix-rmpatch.8 \ +tix-vars.8 \ all: $(PROGRAMS) diff --git a/tix/porttix-create.c b/tix/porttix-create.c deleted file mode 100644 index 9b36eafc..00000000 --- a/tix/porttix-create.c +++ /dev/null @@ -1,464 +0,0 @@ -/* - * Copyright (c) 2013, 2015, 2016, 2021 Jonas 'Sortie' Termansen. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * porttix-create.c - * Creates a port tix by generating patches using source code and tarballs. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "util.h" - -int redirect(const char* path, int flags, mode_t mode) -{ - int fd = open(path, flags, mode); - if ( fd < 0 ) - return -1; - dup2(fd, 1); - close(fd); - return 0; -} - -static void help(FILE* fp, const char* argv0) -{ - fprintf(fp, "Usage: %s [OPTION]... --tarball=TARBALL --normalized=NORMALIZED SOURCE-TIX\n", argv0); - fprintf(fp, "Creates a port tix by generating patches using source code and tarballs.\n"); -} - -static void version(FILE* fp, const char* argv0) -{ - fprintf(fp, "%s (Sortix) %s\n", argv0, VERSIONSTR); -} -int main(int argc, char* argv[]) -{ - char* input_normalized_path = NULL; - char* input_tarball_path = NULL; - char* input_tarball2_path = NULL; - char* output_directory = strdup("."); - char* output = NULL; - char* tmp = strdup(getenv_def("TMPDIR", "/tmp")); - - const char* argv0 = argv[0]; - for ( int i = 0; i < argc; i++ ) - { - const char* arg = argv[i]; - if ( arg[0] != '-' || !arg[1] ) - continue; - argv[i] = NULL; - if ( !strcmp(arg, "--") ) - break; - if ( arg[1] != '-' ) - { - char c; - while ( (c = *++arg) ) switch ( c ) - { - default: - fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c); - help(stderr, argv0); - exit(1); - } - } - else if ( !strcmp(arg, "--help") ) - help(stdout, argv0), exit(0); - else if ( !strcmp(arg, "--version") ) - version(stdout, argv0), exit(0); - else if ( GET_OPTION_VARIABLE("--normalized", &input_normalized_path) ) { } - else if ( GET_OPTION_VARIABLE("--output-directory", &output_directory) ) { } - else if ( GET_OPTION_VARIABLE("--output", &output) ) { } - else if ( GET_OPTION_VARIABLE("--tarball", &input_tarball_path) ) { } - else if ( GET_OPTION_VARIABLE("--tarball2", &input_tarball2_path) ) { } - else if ( GET_OPTION_VARIABLE("--tmp", &tmp) ) { } - else - { - fprintf(stderr, "%s: unknown option: %s\n", argv0, arg); - help(stderr, argv0); - exit(1); - } - } - - if ( argc == 1 ) - { - help(stdout, argv0); - exit(0); - } - - compact_arguments(&argc, &argv); - - if ( argc <= 1 ) - { - fprintf(stderr, "%s: no source tix specified\n", argv0); - help(stderr, argv0); - exit(1); - } - - if ( 3 <= argc ) - { - fprintf(stderr, "%s: unexpected extra operand `%s'\n", argv0, argv[2]); - help(stderr, argv0); - exit(1); - } - - const char* input_srctix_path = argv[1]; - - if ( !IsDirectory(input_srctix_path) ) - err(1, "`%s'", input_srctix_path); - - char* tixbuildinfo_path = print_string("%s/tixbuildinfo", input_srctix_path); - - string_array_t package_info = string_array_make(); - if ( !dictionary_append_file_path(&package_info, tixbuildinfo_path) ) - { - if ( errno == ENOENT ) - fprintf(stderr, "%s: `%s' doesn't appear to be a source tix:\n", - argv0, input_srctix_path); - err(1, "`%s'", tixbuildinfo_path); - } - - const char* package_name = strdup(dictionary_get(&package_info, "pkg.name")); - - if ( !output ) - output = print_string("%s/%s.porttix.tar.xz", output_directory, package_name); - - initialize_tmp(tmp, "porttix"); - - const char* tarball_basename = - input_tarball_path ? non_modify_basename(input_tarball_path) : NULL; - const char* tarball2_basename = - input_tarball2_path ? non_modify_basename(input_tarball2_path) : NULL; - - char* rel_srctix_path = print_string("%s.srctix", package_name); - char* rel_normalized_path = print_string("%s.normalized", package_name); - - char* porttix_path = print_string("%s/%s", tmp_root, package_name); - if ( mkdir_p(porttix_path, 0755) != 0 ) - err(1, "mkdir: `%s'", porttix_path); - - char* srctix_path = print_string("%s/%s", tmp_root, rel_srctix_path); - if ( mkdir_p(srctix_path, 0755) != 0 ) - err(1, "mkdir: `%s'", srctix_path); - - char* normalized_path = print_string("%s/%s", tmp_root, rel_normalized_path); - if ( mkdir_p(normalized_path, 0755) != 0 ) - err(1, "mkdir: `%s'", normalized_path); - - // Create the porttixinfo file. - char* porttixinfo_path = join_paths(porttix_path, "porttixinfo"); - FILE* porttixinfo_fp = fopen(porttixinfo_path, "w"); - if ( !porttixinfo_fp ) - err(1, "`%s'", porttixinfo_path); - fprintf(porttixinfo_fp, "package_name %s\n", package_name); - - // Copy the input source tix to the temporary root. - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "cp", - "-HRT", - "--preserve=timestamps,links", - "--", - input_srctix_path, - srctix_path, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - - // If no tarball exists, then package up the source directory! - if ( !input_tarball_path ) - { - input_tarball_path = print_string("%s/%s.tar.xz", tmp_root, package_name); - if ( fork_and_wait_or_death() ) - { - char* work_dir = dirname(strdup(srctix_path)); - char* subdir_name = dirname(strdup(srctix_path)); - if ( chdir(work_dir) != 0 ) - err(1, "chdir: `%s'", work_dir); - const char* cmd_argv[] = - { - "tar", - "--create", - "--xz", - "--directory", input_normalized_path, - "--file", input_tarball_path, - "--", - subdir_name, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - } - - // Copy the normalized directory (if one exists) to the temporary root. - if ( input_normalized_path ) - { - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "cp", - "-HRT", - "--preserve=timestamps,links", - "--", - input_normalized_path, - normalized_path, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - } - - // There is no input normalized directory, so just extract the tarball here. - else - { - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "tar", - "--extract", - "--directory", normalized_path, - "--file", input_tarball_path, - "--strip-components=1", - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - - if ( input_tarball2_path && fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "tar", - "--extract", - "--directory", normalized_path, - "--file", input_tarball2_path, - "--strip-components=1", - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - } - - // Copy the tarball into the port tix. - char* porttix_tarball_path = - print_string("%s/%s", porttix_path, tarball_basename); - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "cp", - "--", - input_tarball_path, - porttix_tarball_path, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - fprintf(porttixinfo_fp, "tar_extract %s\n", tarball_basename); - - if ( input_tarball2_path ) - { - char* porttix_tarball2_path = - print_string("%s/%s", porttix_path, tarball2_basename); - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "cp", - "--", - input_tarball2_path, - porttix_tarball2_path, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - fprintf(porttixinfo_fp, "tar_extract %s\n", tarball2_basename); - } - - // Create the normalization patch. - int normalized_fd = open(normalized_path, O_RDONLY | O_DIRECTORY); - if ( normalized_fd < 0 ) - err(1, "`%s'", normalized_path); - - char* patch_normalize_path = join_paths(porttix_path, "patch.normalize"); - FILE* patch_normalize_fp = fopen(patch_normalize_path, "w"); - if ( !patch_normalize_fp ) - err(1, "`%s'", patch_normalize_path); - - int pipes[2]; - if ( pipe(pipes) ) - err(1, "pipe"); - pid_t tar_pid = fork_or_death(); - if ( !tar_pid ) - { - dup2(pipes[1], 1); - close(pipes[1]); - close(pipes[0]); - const char* cmd_argv[] = - { - "tar", - "--list", - "--file", porttix_tarball_path, - "--strip-components=1", - NULL - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - close(pipes[1]); - FILE* tar_fp = fdopen(pipes[0], "r"); - - char* line = NULL; - size_t line_size = 0; - ssize_t line_len; - while ( 0 < (line_len = getline(&line, &line_size, tar_fp)) ) - { - if ( line[line_len-1] == '\n' ) - line[--line_len] = '\0'; - const char* path = line; - while ( *path && *path != '/' ) - path++; - if ( *path == '/' ) - path++; - if ( !*path ) - continue; - struct stat st; - if ( fstatat(normalized_fd, path, &st, 0) != 0 && errno == ENOENT ) - { - fprintf(patch_normalize_fp, "rm -rf -- '"); - for ( size_t i = 0; path[i]; i++ ) - if ( path[i] == '\'' ) - fprintf(patch_normalize_fp, "'\\''"); - else - fputc(path[i], patch_normalize_fp); - fprintf(patch_normalize_fp, "'\n"); - } - } - free(line); - if ( ferror(tar_fp) ) - err(1, "getline: tar"); - - fclose(tar_fp); - int tar_exit_status; - waitpid(tar_pid, &tar_exit_status, 0); - if ( !WIFEXITED(tar_exit_status) || WEXITSTATUS(tar_exit_status) != 0 ) - { - errx(1, "Unable to list contents of `%s'.", porttix_tarball_path); - exit(WEXITSTATUS(tar_exit_status)); - } - - fclose(patch_normalize_fp); - free(patch_normalize_path); - fprintf(porttixinfo_fp, "apply_normalize patch.normalize\n"); - - close(normalized_fd); - - // Create the patch between the source tix and the normalized tree. - char* patch_path = join_paths(porttix_path, "patch.patch"); - if ( fork_and_wait_or_death_def(false) ) - { - close(1); - if ( open(patch_path, O_WRONLY | O_CREAT | O_TRUNC, 0644) != 1 ) - err(1, "`%s'", patch_path); - if ( chdir(tmp_root) != 0 ) - err(1, "chdir(`%s')", tmp_root); - const char* cmd_argv[] = - { - "diff", - "--no-dereference", - "-Naur", - "--", - rel_normalized_path, - rel_srctix_path, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - free(patch_path); - fprintf(porttixinfo_fp, "apply_patch patch.patch\n"); - - // Created the execpatch between the source tix and the normalized tree. - char* patch_exec_path = join_paths(porttix_path, "patch.execpatch"); - if ( fork_and_wait_or_death_def(false) ) - { - if ( redirect(patch_exec_path, O_WRONLY | O_CREAT | O_TRUNC, 0644) != 0 ) - err(1, "`%s'", patch_exec_path); - if ( chdir(tmp_root) != 0 ) - err(1, "chdir(`%s')", tmp_root); - const char* cmd_argv[] = - { - "tix-execdiff", - "--", - rel_normalized_path, - rel_srctix_path, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - free(patch_exec_path); - fprintf(porttixinfo_fp, "apply_execpatch patch.execpatch\n"); - - // Close the porttixinfo file. - fclose(porttixinfo_fp); - free(porttixinfo_path); - - // Package up the output archived port tix. - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "tar", - "--create", - "--xz", - "--directory", tmp_root, - "--file", output, - "--", - package_name, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - - return 0; -} diff --git a/tix/srctix-create.c b/tix/srctix-create.c deleted file mode 100644 index 8984bd99..00000000 --- a/tix/srctix-create.c +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (c) 2013, 2015, 2016 Jonas 'Sortie' Termansen. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * srctix-create.c - * Converts an archived port tix into an archived source tix. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "util.h" - -static void help(FILE* fp, const char* argv0) -{ - fprintf(fp, "Usage: %s [OPTION]... PORT-TIX\n", argv0); - fprintf(fp, "Converts an archived port tix into an archived source tix.\n"); -} - -static void version(FILE* fp, const char* argv0) -{ - fprintf(fp, "%s (Sortix) %s\n", argv0, VERSIONSTR); -} - -bool is_file_name(const char* path) -{ - return !(strchr(path, '/') || !strcmp(path, ".") || !strcmp(path, "..")); -} - -int main(int argc, char* argv[]) -{ - char* output_directory = strdup("."); - char* output = NULL; - char* tmp = strdup(getenv_def("TMPDIR", "/tmp")); - - const char* argv0 = argv[0]; - for ( int i = 0; i < argc; i++ ) - { - const char* arg = argv[i]; - if ( arg[0] != '-' || !arg[1] ) - continue; - argv[i] = NULL; - if ( !strcmp(arg, "--") ) - break; - if ( arg[1] != '-' ) - { - char c; - while ( (c = *++arg) ) switch ( c ) - { - default: - fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c); - help(stderr, argv0); - exit(1); - } - } - else if ( !strcmp(arg, "--help") ) - help(stdout, argv0), exit(0); - else if ( !strcmp(arg, "--version") ) - version(stdout, argv0), exit(0); - else if ( GET_OPTION_VARIABLE("--output-directory", &output_directory) ) { } - else if ( GET_OPTION_VARIABLE("--output", &output) ) { } - else if ( GET_OPTION_VARIABLE("--tmp", &tmp) ) { } - else - { - fprintf(stderr, "%s: unknown option: %s\n", argv0, arg); - help(stderr, argv0); - exit(1); - } - } - - if ( argc == 1 ) - { - help(stdout, argv0); - exit(0); - } - - compact_arguments(&argc, &argv); - - if ( argc <= 1 ) - errx(1, "No archived port tix specified"); - - if ( 3 <= argc ) - errx(1, "extra operand"); - - initialize_tmp(tmp, "srctix"); - - const char* porttix_path = argv[1]; - - char* tmp_in_root = print_string("%s/in", tmp_root); - if ( mkdir(tmp_in_root, 0777) < 0 ) - err(1, "mkdir: %s", tmp_in_root); - - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "tar", - "--extract", - "--directory", tmp_in_root, - "--file", porttix_path, - "--strip-components=1", - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - - char* porttixinfo_path = join_paths(tmp_in_root, "porttixinfo"); - FILE* porttixinfo_fp = fopen(porttixinfo_path, "r"); - if ( !porttixinfo_fp ) - { - if ( errno == ENOENT ) - warnx("`%s' doesn't appear to be an archived port tix", - porttix_path); - err(1, "`%s'", porttixinfo_path); - } - - char* tmp_out_root = print_string("%s/out", tmp_root); - if ( mkdir(tmp_out_root, 0777) < 0 ) - err(1, "mkdir: %s", tmp_out_root); - - char* package_name = NULL; - char* srctix_path = NULL; - - char* line = NULL; - size_t line_size = 0; - ssize_t line_len; - while ( 0 < (line_len = getline(&line, &line_size, porttixinfo_fp)) ) - { - if ( line[line_len-1] == '\n' ) - line[--line_len] = '\0'; - char* first_space = strchr(line, ' '); - if ( !first_space ) - err(1, "`%s`: malformed line `%s'", porttixinfo_path, line); - *first_space = '\0'; - const char* function = line; - const char* parameter = first_space + 1; - - if ( !strcmp(function, "package_name") ) - { - if ( package_name ) - err(1, "`%s`: unexpected additional package name `%s'", - porttixinfo_path, parameter); - if ( !is_file_name(parameter) ) - err(1, "`%s`: malformed package name `%s'", - porttixinfo_path, parameter); - package_name = strdup(parameter); - srctix_path = join_paths(tmp_out_root, package_name); - if ( mkdir_p(srctix_path, 0755) != 0 ) - err(1, "mkdir: `%s'", srctix_path); - } - else if ( !package_name ) - err(1, "`%s`: expected package name before `%s'", - porttixinfo_path, function); - else if ( !strcmp(function, "tar_extract") ) - { - if ( !is_file_name(parameter) ) - err(1, "`%s`: malformed tarball filename `%s'", - porttixinfo_path, parameter); - char* tarball_path = join_paths(tmp_in_root, parameter); - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "tar", - "--extract", - "--directory", srctix_path, - "--file", tarball_path, - "--strip-components=1", - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - free(tarball_path); - } - else if ( !strcmp(function, "apply_normalize") ) - { - if ( !is_file_name(parameter) ) - err(1, "`%s`: malformed normalize filename `%s'", - porttixinfo_path, parameter); - char* rmpatch_path = join_paths(tmp_in_root, parameter); - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "tix-rmpatch", - "--directory", srctix_path, - "--", - rmpatch_path, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - free(rmpatch_path); - } - else if ( !strcmp(function, "apply_patch") ) - { - if ( !is_file_name(parameter) ) - err(1, "`%s`: malformed patch filename `%s'", - porttixinfo_path, parameter); - char* patch_path = join_paths(tmp_in_root, parameter); - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "patch", - "--strip=1", - "--silent", - "--directory", srctix_path, - "--input", patch_path, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - free(patch_path); - } - else if ( !strcmp(function, "apply_execpatch") ) - { - if ( !is_file_name(parameter) ) - err(1, "`%s`: malformed execpatch filename `%s'", - porttixinfo_path, parameter); - char* execpatch_path = join_paths(tmp_in_root, parameter); - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "tix-execpatch", - "--directory", srctix_path, - "--", - execpatch_path, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - free(execpatch_path); - } - else - err(1, "`%s`: unsupported function `%s'", - porttixinfo_path, function); - } - free(line); - if ( ferror(porttixinfo_fp) ) - err(1, "%s", porttixinfo_path); - - fclose(porttixinfo_fp); - free(porttixinfo_path); - - if ( !output ) - output = print_string("%s/%s.srctix.tar.xz", output_directory, package_name); - - if ( fork_and_wait_or_death() ) - { - const char* cmd_argv[] = - { - "tar", - "--create", - "--xz", - "--directory", tmp_out_root, - "--file", output, - "--", - package_name, - NULL, - }; - execvp(cmd_argv[0], (char* const*) cmd_argv); - err(127, "%s", cmd_argv[0]); - } - - free(srctix_path); - free(package_name); - - return 0; -} diff --git a/tix/tix-build.8 b/tix/tix-build.8 new file mode 100644 index 00000000..d6821160 --- /dev/null +++ b/tix/tix-build.8 @@ -0,0 +1,169 @@ +.Dd April 12, 2022 +.Dt TIX-BUILD 8 +.Os +.Sh NAME +.Nm tix-build +.Nd build a port +.Sh SYNOPSIS +.Nm +.Op Fl \-build Ns = Ns Ar triplet +.Op Fl \-destination Ns = Ns Ar directory +.Op Fl \-end Ns = Ns Ar step +.Op Fl \-exec-prefix Ns = Ns Ar prefix +.Op Fl \-generation Ns = Ns Ar level +.Op Fl \-host Ns = Ns Ar triplet +.Op Fl \-make Ns = Ns Ar path +.Op Fl \-makeflags Ns = Ns Ar makeflags +.Op Fl \-prefix Ns = Ns Ar prefix +.Op Fl \-source-package Ns = Ns Ar source-package +.Op Fl \-source-port Ns = Ns Ar source-port +.Op Fl \-start Ns = Ns Ar step +.Op Fl \-sysroot Ns = Ns Ar directory +.Op Fl \-tar Ns = Ns Ar path +.Op Fl \-target Ns = Ns Ar triplet +.Op Fl \-tmp Ns = Ns Ar directory +.Ar port +.Sh DESCRIPTION +.Nm +builds a source code directory containing a +.Xr port 5 +of software for this operating system. +.Nm +is usually invoked through the higher level +.Xr tix-port 7 . +.Pp +The mandatory +.Ar port +argument is the directory containing the source code. +The +.Xr port 5 +file containing the build instruction is found by adding +.Pa .port +to this path, or if it does not exist then +.Pa tix.port +inside the directory. +.Pp +The options are as follows: +.Bl -tag -width "12345678" +.It Fl \-build Ns = Ns Ar triplet +The platform +.Ar triplet +for the machine the port is built on. +(Default: Automatically detected.) +.It Fl \-destination Ns = Ns Ar directory +The binary package is placed inside this +.Ar directory . +.It Fl \-end Ns = Ns Ar step +Stop the build after this +.Ar step : +.Pp +.Bl -tag -width "clean, pre-clean" -compact +.It start +The start step before anything has happened. +.It clean, pre-clean +Clean the source directory before the build. +.It configure +Configure the port. +.It build +Build the port. +.It install +Install the port into the +.Ev DESTDIR . +.It post-install +Run the post-installation script. +.It post-clean +Clean the source code after the port. +.It package +Create the binary package. +.It end +The end step after everything has happened. +(Default) +.El +.It Fl \-exec-prefix Ns = Ns Ar prefix +The +.Ar prefix +where architecture dependent files are installed. +(Default: +.Fl \-prefix ) +.It Fl \-generation Ns = Ns Ar generation +Create a binary package in the format of this tix generation +.Ar level . +(Default: 2) +.It Fl \-host Ns = Ns Ar triplet +The platform +.Ar triplet +for the machine the port will run on. +(Default: +.Fl \-build ) +.It Fl \-make Ns = Ns Ar path +Which +.Xr make 1 +to use. +(Default: +.Ev MAKE +if set and otherwise +.Xr make 1 ) +.It Fl \-makeflags Ns = Ns Ar makeflags +Override the +.Ev MAKEFLAGS +variable inherited by make. +.It Fl \-prefix Ns = Ns Ar prefix +Build the port into this +.Ar prefix . +(Default: The empty prefix designating the root directory) +.\" After releasing Sortix 1.1, remove this option. +.It Fl \-source-package Ns = Ns Ar source-port +Deprecated alias for +.Fl \-source-port +that will be removed after the next release. +.It Fl \-source-port Ns = Ns Ar source-port +The source code for the +.Sy SOURCE_PORT +per +.Xr port 5 +is found in the +.Ar source-port +directory. +.\" TODO: This is different from tix-port(8). +.\"(Default: ../$SOURCE_PORT/$SOURCE_PORT) +(Default: $SOURCE_PORT) +.It Fl \-start Ns = Ns Ar step +Start the build at this step (see +.Fl \-end ) . +(Default: +.Sy start ) +.It Fl \-sysroot Ns = Ns Ar directory +The system root to use while building and installing the port. +The toolchain is wrapped to transparently use this sysroot during the build. +.It Fl \-tar Ns = Ns Ar path +Which +.Xr tar 1 +to use during the build. +(Default: +.Xr tar 1 ) +.It Fl \-target Ns = Ns Ar triplet +The port's outputs targets this platform +.Ar triplet . +(Default: +.Fl \-host ) +.It Fl \-tmp Ns = Ns Ar directory +Place temporary files in this +.Ar directory . +(Default: +.Ev TMPDIR +if set otherwise +.Pa /tmp ) +.El +.Sh EXIT STATUS +.Nm +will exit 0 on success and non-zero otherwise. +.Sh SEE ALSO +.Xr port 5 , +.Xr development 7 , +.Xr porting 7 , +.Xr tix-collection 8 , +.Xr tix-install 8 , +.Xr tix-port 8 +.Sh HISTORY +.Nm +originally appeared in Sortix 0.8. diff --git a/tix/tix-build.c b/tix/tix-build.c index a3b1db3f..d56a9139 100644 --- a/tix/tix-build.c +++ b/tix/tix-build.c @@ -142,8 +142,37 @@ struct metainfo enum build_step end_step; bool bootstrapping; bool cross; + // TODO: After releasing Sortix 1.1, remove tixbuildinfo support. + bool tixbuildinfo; }; +static const char* metainfo_get_def(const struct metainfo* minfo, + const char* key, + const char* old_key, + const char* def) +{ + return dictionary_get_def((string_array_t*) &minfo->package_info, + !minfo->tixbuildinfo ? key : old_key, def); +} + +static const char* metainfo_get(const struct metainfo* minfo, + const char* key, + const char* old_key) +{ + return metainfo_get_def(minfo, key, old_key, NULL); +} + +static const char* metainfo_verify(struct metainfo* minfo, + const char* key, + const char* old_key) +{ + const char* ret = metainfo_get(minfo, key, old_key); + if ( !ret ) + errx(1, "error: `%s': no `%s' variable declared", + minfo->package_info_path, !minfo->tixbuildinfo ? key : old_key); + return ret; +} + static bool has_in_path(const char* program) { pid_t child_pid = fork(); @@ -343,13 +372,15 @@ static void SetNeedVariableBuildTool(struct metainfo* minfo, const char* variable, const char* value) { - string_array_t* pkg_info = &minfo->package_info; const char* needed_vars = - dictionary_get_def(pkg_info, "pkg.make.needed-vars", "true"); - char* key = print_string("pkg.make.needed-vars.%s", variable); + metainfo_get_def(minfo, "MAKE_NEEDED_VARS", "pkg.make.needed-vars", + "true"); + char* key = minfo->tixbuildinfo ? + print_string("pkg.make.needed-vars.%s", variable) : + print_string("MAKE_NEEDED_VARS_%s", variable); if ( !key ) err(1, "malloc"); - const char* needed_var = dictionary_get_def(pkg_info, key, needed_vars); + const char* needed_var = metainfo_get_def(minfo, key, key, needed_vars); free(key); if ( !parse_boolean(needed_var) ) return; @@ -413,10 +444,10 @@ static void Configure(struct metainfo* minfo) { if ( !fork_and_wait_or_recovery() ) return; - string_array_t* pkg_info = &minfo->package_info; - const char* subdir = dictionary_get(pkg_info, "pkg.subdir"); + const char* subdir = metainfo_get(minfo, "SUBDIR", "pkg.subdir"); const char* configure_raw = - dictionary_get_def(pkg_info, "pkg.configure.cmd", "./configure"); + metainfo_get_def(minfo, "CONFIGURE", "pkg.configure.cmd", + "./configure"); char* configure; if ( strcmp(minfo->build_dir, minfo->package_dir) == 0 ) configure = strdup(configure_raw); @@ -425,22 +456,22 @@ static void Configure(struct metainfo* minfo) if ( !configure ) err(1, "malloc"); const char* conf_extra_args = - dictionary_get_def(pkg_info, "pkg.configure.args", ""); + metainfo_get_def(minfo, "CONFIGURE_ARGS", "pkg.configure.args", ""); const char* conf_extra_vars = - dictionary_get_def(pkg_info, "pkg.configure.vars", ""); + metainfo_get_def(minfo, "CONFIGURE_VARS", "pkg.configure.vars", ""); bool with_sysroot = - parse_boolean(dictionary_get_def(pkg_info, - "pkg.configure.with-sysroot", "false")); + parse_boolean(metainfo_get_def(minfo, + "CONFIGURE_WITH_SYSROOT", "pkg.configure.with-sysroot", "false")); // TODO: I am unclear if this issue still affects gcc, I might have // forgotten to set pkg.configure.with-sysroot-ld-bug=true there. const char* with_sysroot_ld_bug_default = "false"; if ( !strcmp(minfo->package_name, "gcc") ) with_sysroot_ld_bug_default = "true"; bool with_sysroot_ld_bug = - parse_boolean(dictionary_get_def(pkg_info, + parse_boolean(metainfo_get_def(minfo, "CONFIGURE_WITH_SYSROOT_LD_BUG", "pkg.configure.with-sysroot-ld-bug", with_sysroot_ld_bug_default )); bool with_build_sysroot = - parse_boolean(dictionary_get_def(pkg_info, + parse_boolean(metainfo_get_def(minfo, "CONFIGURE_WITH_BUILD_SYSROOT", "pkg.configure.with-build-sysroot", "false")); if ( chdir(minfo->build_dir) != 0 ) err(1, "chdir: `%s'", minfo->build_dir); @@ -523,9 +554,8 @@ static bool TestDirty(struct metainfo* minfo, static bool IsDirty(struct metainfo* minfo) { - string_array_t* pkg_info = &minfo->package_info; - const char* dirty_file = dictionary_get(pkg_info, "pkg.dirty-file"); - const char* subdir = dictionary_get(pkg_info, "pkg.subdir"); + const char* dirty_file = metainfo_get(minfo, "DIRTY_FILE", "pkg.dirty-file"); + const char* subdir = metainfo_get(minfo, "SUBDIR", "pkg.subdir"); if ( dirty_file ) return TestDirty(minfo, subdir, dirty_file); return TestDirty(minfo, subdir, "config.log") || @@ -544,17 +574,16 @@ static void Make(struct metainfo* minfo, fork_and_wait_or_death_def(false)) ) return; - string_array_t* pkg_info = &minfo->package_info; char* make = strdup(minfo->make); - const char* override_make = dictionary_get(pkg_info, "pkg.make.cmd"); + const char* override_make = metainfo_get(minfo, "MAKE", "pkg.make.cmd"); const char* make_extra_args = - dictionary_get_def(pkg_info, "pkg.make.args", ""); + metainfo_get_def(minfo, "MAKE_ARGS", "pkg.make.args", ""); const char* make_extra_vars = - dictionary_get_def(pkg_info, "pkg.make.vars", ""); + metainfo_get_def(minfo, "MAKE_VARS", "pkg.make.vars", ""); if ( override_make ) { free(make); - make = join_paths(minfo->package_dir, override_make); + make = strdup(override_make); } SetNeededVariables(minfo); if ( chdir(minfo->build_dir) != 0 ) @@ -612,17 +641,17 @@ static void Make(struct metainfo* minfo, static void Clean(struct metainfo* minfo) { - string_array_t* pinfo = &minfo->package_info; - const char* subdir = dictionary_get(pinfo, "pkg.subdir"); + const char* subdir = metainfo_get(minfo, "SUBDIR", "pkg.subdir"); const char* build_system = - dictionary_get_def(pinfo, "pkg.build-system", "none"); + metainfo_get_def(minfo, "BUILD_SYSTEM", "pkg.build-system", "none"); const char* default_clean_target = !strcmp(build_system, "configure") ? "distclean" : "clean"; const char* clean_target = - dictionary_get_def(pinfo, "pkg.make.clean-target", - default_clean_target); + metainfo_get_def(minfo, "MAKE_CLEAN_TARGET", "pkg.make.clean-target", + default_clean_target); const char* ignore_clean_failure_var = - dictionary_get_def(pinfo, "pkg.make.ignore-clean-failure", "true"); + metainfo_get_def(minfo, "MAKE_IGNORE_CLEAN_FAILURE", + "pkg.make.ignore-clean-failure", "true"); bool ignore_clean_failure = parse_boolean(ignore_clean_failure_var); Make(minfo, clean_target, NULL, !ignore_clean_failure, subdir); @@ -630,10 +659,10 @@ static void Clean(struct metainfo* minfo) static void Build(struct metainfo* minfo) { - string_array_t* pinfo = &minfo->package_info; - const char* subdir = dictionary_get(pinfo, "pkg.subdir"); + const char* subdir = metainfo_get(minfo, "SUBDIR", "pkg.subdir"); const char* build_target = - dictionary_get_def(pinfo, "pkg.make.build-target", "all"); + metainfo_get_def(minfo, "MAKE_BUILD_TARGET", "pkg.make.build-target", + "all"); Make(minfo, build_target, NULL, true, subdir); } @@ -658,10 +687,10 @@ static void CreateDestination(void) static void Install(struct metainfo* minfo) { - string_array_t* pinfo = &minfo->package_info; - const char* subdir = dictionary_get(pinfo, "pkg.subdir"); + const char* subdir = metainfo_get(minfo, "SUBDIR", "pkg.subdir"); const char* install_target = - dictionary_get_def(pinfo, "pkg.make.install-target", "install"); + metainfo_get_def(minfo, "MAKE_INSTALL_TARGET", + "pkg.make.install-target", "install"); char* tardir_rel = join_paths(tmp_root, "tix"); char* destdir_rel = join_paths(tardir_rel, "data"); char* destdir = realpath(destdir_rel, NULL); @@ -677,16 +706,15 @@ static void Install(struct metainfo* minfo) static void PostInstall(struct metainfo* minfo) { - string_array_t* pinfo = &minfo->package_info; const char* post_install_cmd = - dictionary_get(pinfo, "pkg.post-install.cmd"); + metainfo_get(minfo, "POST_INSTALL", "pkg.post-install.cmd"); if ( !post_install_cmd ) return; if ( !fork_and_wait_or_recovery() ) return; - const char* subdir = dictionary_get(pinfo, "pkg.subdir"); + const char* subdir = metainfo_get(minfo, "SUBDIR", "pkg.subdir"); char* tardir_rel = join_paths(tmp_root, "tix"); char* destdir_rel = join_paths(tardir_rel, "data"); char* destdir = realpath(destdir_rel, NULL); @@ -727,18 +755,18 @@ static void PostInstall(struct metainfo* minfo) static void TixInfo(struct metainfo* minfo) { - string_array_t* pinfo = &minfo->package_info; char* tardir_rel = join_paths(tmp_root, "tix"); if ( !tardir_rel ) err(1, "malloc"); char* tixinfo_rel = join_paths(tardir_rel, "tix/tixinfo"); if ( !tixinfo_rel ) err(1, "malloc"); - const char* alias = dictionary_get(pinfo, "pkg.alias-of"); - const char* runtime_deps = dictionary_get(pinfo, "pkg.runtime-deps"); + const char* alias = metainfo_get(minfo, "ALIAS_OF", "pkg.alias-of"); + const char* runtime_deps = + metainfo_get(minfo, "RUNTIME_DEPS", "pkg.runtime-deps"); bool location_independent = - parse_boolean(dictionary_get_def(pinfo, - "pkg.location-independent", "false")); + parse_boolean(metainfo_get_def(minfo, + "LOCATION_INDEPENDENT", "pkg.location-independent", "false")); FILE* tixinfo_fp = fopen(tixinfo_rel, "w"); if ( !tixinfo_fp ) @@ -803,16 +831,16 @@ static void Package(struct metainfo* minfo) static void Compile(struct metainfo* minfo) { - string_array_t* pinfo = &minfo->package_info; - // Detect which build system we are interfacing with. - const char* build_system = dictionary_get(pinfo, "pkg.build-system"); + const char* build_system = + metainfo_get(minfo, "BUILD_SYSTEM", "pkg.build-system"); if ( !build_system ) errx(1, "%s: pkg.build-system was not found", minfo->package_info_path); // Determine whether need to do an out-of-directory build. const char* use_build_dir_var = - dictionary_get_def(pinfo, "pkg.configure.use-build-directory", "false"); + metainfo_get_def(minfo, "CONFIGURE_USE_BUILD_DIRECTORY", + "pkg.configure.use-build-directory", "false"); bool use_build_dir = parse_boolean(use_build_dir_var); if ( use_build_dir ) { @@ -876,15 +904,21 @@ static void Bootstrap(struct metainfo* minfo) newinfo.tar = minfo->tar; newinfo.target = minfo->host; newinfo.tmp = minfo->tmp; + const char* bootstrap_prefix = + minfo->tixbuildinfo ? "bootstrap." : "BOOTSTRAP_"; for ( size_t i = 0; i < minfo->package_info.length; i++ ) { const char* string = minfo->package_info.strings[i]; - if ( !strncmp(string, "pkg.", strlen("pkg.")) ) + if ( minfo->tixbuildinfo ? + !strncmp(string, "pkg.", strlen("pkg.")) : + strncmp(string, bootstrap_prefix, strlen(bootstrap_prefix)) != 0 ) continue; - if ( !strncmp(string, "bootstrap.", strlen("bootstrap.")) ) + if ( !strncmp(string, bootstrap_prefix, strlen(bootstrap_prefix)) ) { - const char* rest = string + strlen("bootstrap."); - char* newstring = print_string("pkg.%s", rest); + const char* rest = string + strlen(bootstrap_prefix); + char* newstring = minfo->tixbuildinfo ? + print_string("pkg.%s", rest) : + strdup(rest); if ( !newstring ) err(1, "malloc"); if ( !string_array_append(&newinfo.package_info, newstring) ) @@ -924,15 +958,13 @@ static void Bootstrap(struct metainfo* minfo) static void BuildPackage(struct metainfo* minfo) { - string_array_t* pinfo = &minfo->package_info; - // Whether this is just an alias for another package. - const char* alias = dictionary_get(pinfo, "pkg.alias-of"); + const char* alias = metainfo_get(minfo, "ALIAS_OF", "pkg.alias-of"); // Determine if the package is location independent. bool location_independent = - parse_boolean(dictionary_get_def(pinfo, "pkg.location-independent", - "false")); + parse_boolean(metainfo_get_def(minfo, "LOCATION_INDEPENDENT", + "pkg.location-independent", "false")); if ( !alias && !location_independent && !minfo->prefix ) errx(1, "error: %s is not location independent and you need to " "specify the intended destination prefix using --prefix", @@ -945,7 +977,7 @@ static void BuildPackage(struct metainfo* minfo) // handle this case entirely themselves. There's a few packages that need // the exact same version around natively in order to cross-compile. const char* use_bootstrap_var = - dictionary_get_def(pinfo, "pkg.use-bootstrap", "false"); + metainfo_get_def(minfo, "USE_BOOTSTRAP", "pkg.use-bootstrap", "false"); bool use_bootstrap = parse_boolean(use_bootstrap_var); if ( !alias && use_bootstrap && strcmp(minfo->build, minfo->host) != 0 && SHOULD_DO_BUILD_STEP(BUILD_STEP_CONFIGURE, minfo) ) @@ -965,22 +997,26 @@ static void BuildPackage(struct metainfo* minfo) static void VerifySourceTixInformation(struct metainfo* minfo) { - const char* pipath = minfo->package_info_path; - string_array_t* pinfo = &minfo->package_info; - const char* tix_version = VerifyInfoVariable(pinfo, "tix.version", pipath); - if ( atoi(tix_version) != 1 ) - errx(1, "error: `%s': tix version `%s' not supported", pipath, - tix_version); - const char* tix_class = VerifyInfoVariable(pinfo, "tix.class", pipath); - if ( !strcmp(tix_class, "tix") ) - errx(1, "error: `%s': this object is a binary tix and is already " - "compiled.\n", pipath); - if ( strcmp(tix_class, "srctix") ) - errx(1, "error: `%s': tix class `%s' is not `srctix': this object " - "is not suitable for compilation.", pipath, tix_class); - VerifyInfoVariable(pinfo, "pkg.name", pipath); - if ( !dictionary_get(pinfo, "pkg.alias-of") ) - VerifyInfoVariable(pinfo, "pkg.build-system", pipath); + if ( minfo->tixbuildinfo ) + { + const char* pipath = minfo->package_info_path; + string_array_t* pinfo = &minfo->package_info; + const char* tix_version = + VerifyInfoVariable(pinfo, "tix.version", pipath); + if ( atoi(tix_version) != 1 ) + errx(1, "error: `%s': tix version `%s' not supported", pipath, + tix_version); + const char* tix_class = VerifyInfoVariable(pinfo, "tix.class", pipath); + if ( !strcmp(tix_class, "tix") ) + errx(1, "error: `%s': this object is a binary tix and is already " + "compiled.\n", pipath); + if ( strcmp(tix_class, "srctix") ) + errx(1, "error: `%s': tix class `%s' is not `srctix': this object " + "is not suitable for compilation.", pipath, tix_class); + } + metainfo_verify(minfo, "NAME", "pkg.name"); + if ( !metainfo_get(minfo, "ALIAS_OF", "pkg.alias-of") ) + metainfo_verify(minfo, "BUILD_SYSTEM", "pkg.build-system"); } // TODO: The MAKEFLAGS variable is actually not in the same format as the token @@ -1017,15 +1053,32 @@ static void PurifyMakeflags(void) string_array_reset(&makeflags); } -static void help(FILE* fp, const char* argv0) +static char* FindPortFile(char* package_dir) { - fprintf(fp, "Usage: %s [OPTION]... PACKAGE\n", argv0); - fprintf(fp, "Compile a source tix into a tix suitable for installation.\n"); + char* path = print_string("%s.port", package_dir); + if ( !path ) + err(1, "malloc"); + if ( !access(path, F_OK) ) + return path; + free(path); + path = join_paths(package_dir, "tix.port"); + if ( !path ) + err(1, "malloc"); + if ( !access(path, F_OK) ) + return path; + free(path); + return NULL; } -static void version(FILE* fp, const char* argv0) +static char* FindTixBuildInfo(char* package_dir) { - fprintf(fp, "%s (Sortix) %s\n", argv0, VERSIONSTR); + char* path = join_paths(package_dir, "tixbuildinfo"); + if ( !path ) + err(1, "malloc"); + if ( !access(path, F_OK) ) + return path; + free(path); + return NULL; } int main(int argc, char* argv[]) @@ -1048,7 +1101,7 @@ int main(int argc, char* argv[]) char* tmp = strdup(getenv_def("TMPDIR", "/tmp")); char* start_step_string = strdup("start"); char* end_step_string = strdup("end"); - char* source_package = NULL; + char* source_port = NULL; const char* argv0 = argv[0]; for ( int i = 0; i < argc; i++ ) @@ -1065,36 +1118,28 @@ int main(int argc, char* argv[]) while ( (c = *++arg) ) switch ( c ) { default: - fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c); - help(stderr, argv0); - exit(1); + errx(1, "unknown option -- '%c'", c); } } - else if ( !strcmp(arg, "--help") ) - help(stdout, argv0), exit(0); - else if ( !strcmp(arg, "--version") ) - version(stdout, argv0), exit(0); else if ( GET_OPTION_VARIABLE("--build", &minfo.build) ) { } else if ( GET_OPTION_VARIABLE("--destination", &minfo.destination) ) { } else if ( GET_OPTION_VARIABLE("--end", &end_step_string) ) { } - else if ( GET_OPTION_VARIABLE("--host", &minfo.host) ) { } - else if ( GET_OPTION_VARIABLE("--generation", &generation_string) ) { } - else if ( GET_OPTION_VARIABLE("--makeflags", &minfo.makeflags) ) { } - else if ( GET_OPTION_VARIABLE("--make", &minfo.make) ) { } - else if ( GET_OPTION_VARIABLE("--prefix", &minfo.prefix) ) { } else if ( GET_OPTION_VARIABLE("--exec-prefix", &minfo.exec_prefix) ) { } - else if ( GET_OPTION_VARIABLE("--source-package", &source_package) ) { } + else if ( GET_OPTION_VARIABLE("--generation", &generation_string) ) { } + else if ( GET_OPTION_VARIABLE("--host", &minfo.host) ) { } + else if ( GET_OPTION_VARIABLE("--make", &minfo.make) ) { } + else if ( GET_OPTION_VARIABLE("--makeflags", &minfo.makeflags) ) { } + else if ( GET_OPTION_VARIABLE("--prefix", &minfo.prefix) ) { } + // TODO: After releasing Sortix 1.1, remove this option. + else if ( GET_OPTION_VARIABLE("--source-package", &source_port) ) { } + else if ( GET_OPTION_VARIABLE("--source-port", &source_port) ) { } else if ( GET_OPTION_VARIABLE("--start", &start_step_string) ) { } else if ( GET_OPTION_VARIABLE("--sysroot", &minfo.sysroot) ) { } - else if ( GET_OPTION_VARIABLE("--target", &minfo.target) ) { } else if ( GET_OPTION_VARIABLE("--tar", &minfo.tar) ) { } + else if ( GET_OPTION_VARIABLE("--target", &minfo.target) ) { } else if ( GET_OPTION_VARIABLE("--tmp", &minfo.tmp) ) { } else - { - fprintf(stderr, "%s: unknown option: %s\n", argv0, arg); - help(stderr, argv0); - exit(1); - } + errx(1, "unknown option: %s", arg); } minfo.generation = atoi(generation_string); @@ -1112,12 +1157,6 @@ int main(int argc, char* argv[]) exit(1); } - if ( argc == 1 ) - { - help(stdout, argv0); - exit(0); - } - compact_arguments(&argc, &argv); if ( minfo.prefix && !strcmp(minfo.prefix, "/") ) @@ -1164,38 +1203,50 @@ int main(int argc, char* argv[]) if ( !IsDirectory(minfo.package_dir) ) err(1, "`%s'", minfo.package_dir); - minfo.package_info_path = join_paths(minfo.package_dir, "tixbuildinfo"); - if ( !minfo.package_info_path ) - err(1, "malloc"); - - minfo.package_info = string_array_make(); - string_array_t* package_info = &minfo.package_info; - if ( !dictionary_append_file_path(package_info, minfo.package_info_path) ) + if ( (minfo.package_info_path = FindPortFile(minfo.package_dir)) ) { - if ( errno == ENOENT ) - warnx("`%s' doesn't appear to be a source .tix", minfo.package_dir); - err(1, "`%s'", minfo.package_info_path); + minfo.tixbuildinfo = false; + minfo.package_info = string_array_make(); + string_array_t* package_info = &minfo.package_info; + int ret = variables_append_file_path(package_info, + minfo.package_info_path); + if ( ret == -1 ) + err(1, "`%s'", minfo.package_info_path); + else if ( ret == -2 ) + errx(1, "`%s': Syntax error", minfo.package_info_path); } + else if ( (minfo.package_info_path = FindTixBuildInfo(minfo.package_dir)) ) + { + minfo.tixbuildinfo = true; + minfo.package_info = string_array_make(); + string_array_t* package_info = &minfo.package_info; + if ( !dictionary_append_file_path(package_info, + minfo.package_info_path) ) + err(1, "`%s'", minfo.package_info_path); + } + else + err(1, "Failed to find: %s.port or %s/tix.port or %s/tixbuildinfo", + minfo.package_dir, minfo.package_dir, minfo.package_dir); VerifySourceTixInformation(&minfo); - minfo.package_name = strdup(dictionary_get(package_info, "pkg.name")); + minfo.package_name = strdup(metainfo_get(&minfo, "NAME", "pkg.name")); - const char* pkg_source_package = - dictionary_get(package_info, "pkg.source-package"); - if ( pkg_source_package && !source_package ) + const char* pkg_source_port = + metainfo_get(&minfo, "SOURCE_PORT", "pkg.source-package"); + if ( pkg_source_port && !source_port ) { - source_package = print_string("%s/../%s", srctix, pkg_source_package); - if ( !source_package ) + // TODO: Change this default location to match tix-port(8)? + source_port = print_string("%s/../%s", srctix, pkg_source_port); + if ( !source_port ) err(1, "malloc"); } - if ( source_package ) + if ( source_port ) { free(minfo.package_dir); - minfo.package_dir = realpath(source_package, NULL); + minfo.package_dir = realpath(source_port, NULL); if ( !minfo.package_dir ) - err(1, "%s: looking for source package: %s", - srctix, source_package); + err(1, "%s: looking for source port: %s", srctix, source_port); } BuildPackage(&minfo); diff --git a/tix/tix-eradicate-libtool-la.8 b/tix/tix-eradicate-libtool-la.8 new file mode 100644 index 00000000..9b8f843f --- /dev/null +++ b/tix/tix-eradicate-libtool-la.8 @@ -0,0 +1,25 @@ +.Dd June 6, 2022 +.Dt TIX-ERADICATE-LIBTOOL-LA 8 +.Os +.Sh NAME +.Nm tix-eradicate-libtool-la +.Nd remove unnecessary .la files from the staging directory +.Sh SYNOPSIS +.Nm +.Sh DESCRIPTION +.Nm +is a +.Xr port 5 +.Sy POST_INSTALL +command that recursively removes all .la files from the installation staging +directory named by the +.Ev TIX_INSTALL_DIR +environment variable. +.Sh EXIT STATUS +.Nm +will exit 0 on success and non-zero otherwise. +.Sh SEE ALSO +.Xr port 5 +.Sh HISTORY +.Nm +originally appeared in Sortix 0.8. diff --git a/tix/tix-execdiff.8 b/tix/tix-execdiff.8 new file mode 100644 index 00000000..1a7ad89e --- /dev/null +++ b/tix/tix-execdiff.8 @@ -0,0 +1,47 @@ +.Dd June 6, 2022 +.Dt TIX-EXECDIFF 8 +.Os +.Sh NAME +.Nm tix-execdiff +.Nd compare executable permissions between two trees +.Sh SYNOPSIS +.Nm +.Ar old +.Ar new +.Sh DESCRIPTION +.Nm +recursively finds the files with different executable permissions between the +.Ar old +and +.Ar new +directory trees. +.Nm +writes a shell script that transforms the permissions of old tree into that of +the new tree, which can be applied using +.Xr tix-execpatch 8 . +.Pp +Files are considered executable if the current user has executable permission +and directories are omitted from the output. +.Pp +Additions of executable permissions are written shell single quoted as: +.Bd -ragged -offset indent +chmod +x -- 'path' +.Ed +.Pp +Removals of executable permissions are written shell single quoted as: +.Bd -ragged -offset indent +chmod -x -- 'path' +.Ed +.Sh EXIT STATUS +.Nm +will exit 0 on success and non-zero otherwise. +.Sh SEE ALSO +.Xr diff 1 , +.Xr patch 1 , +.Xr port 5 , +.Xr tix-execpatch 8 , +.Xr tix-rmdiff 8 , +.Xr tix-rmpatch 8 +.Sh HISTORY +.Nm +originally appeared in Sortix 0.8. diff --git a/tix/tix-execdiff.c b/tix/tix-execdiff.c index 38b6b336..84e3559f 100644 --- a/tix/tix-execdiff.c +++ b/tix/tix-execdiff.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016 Jonas 'Sortie' Termansen. + * Copyright (c) 2013, 2016, 2022 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -14,7 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * tix-execdiff.c - * Reports which files have had the executable bit changed between two trees. + * Compare executable permissions between two trees. */ #include @@ -39,7 +39,7 @@ #include "util.h" -DIR* fdopendupdir(int fd) +static DIR* fdopendupdir(int fd) { int newfd = dup(fd); if ( newfd < 0 ) @@ -50,7 +50,7 @@ DIR* fdopendupdir(int fd) return result; } -int ftestexecutableat(int dirfd, const char* path) +static int ftestexecutableat(int dirfd, const char* path) { struct stat st; if ( fstatat(dirfd, path, &st, AT_SYMLINK_NOFOLLOW) != 0 ) @@ -65,31 +65,36 @@ int ftestexecutableat(int dirfd, const char* path) return -1; } -void execdiff(int tree_a, const char* tree_a_path, - int tree_b, const char* tree_b_path, - const char* relpath) +static void execdiff(int tree_a, const char* tree_a_path, + int tree_b, const char* tree_b_path, + const char* relpath) { DIR* dir_b = fdopendupdir(tree_b); if ( !dir_b ) - err(1, "fdopendupdir(`%s`)", tree_b_path); + err(1, "fdopendupdir: %s", tree_b_path); struct dirent* entry; while ( (entry = readdir(dir_b)) ) { if ( !strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..") ) continue; - char* subrelpath = join_paths(relpath, entry->d_name); + char* subrelpath = relpath[0] ? join_paths(relpath, entry->d_name) : + strdup(entry->d_name); + if ( !subrelpath ) + err(1, "malloc"); int diropenflags = O_RDONLY | O_DIRECTORY | O_NOFOLLOW; int subtree_b = openat(tree_b, entry->d_name, diropenflags); if ( 0 <= subtree_b ) { char* subtree_b_path = join_paths(tree_b_path, entry->d_name); + if ( !subtree_b_path ) + err(1, "malloc"); int subtree_a = openat(tree_a, entry->d_name, diropenflags); if ( subtree_a < 0 ) { if ( !(errno == ENOTDIR || errno == ELOOP || errno == ENOENT) ) - err(1, "`%s/%s`", tree_b_path, entry->d_name); + err(1, "%s/%s", tree_b_path, entry->d_name); execdiff(-1, NULL, subtree_b, subtree_b_path, subrelpath); free(subtree_b_path); close(subtree_b); @@ -97,6 +102,8 @@ void execdiff(int tree_a, const char* tree_a_path, continue; } char* subtree_a_path = join_paths(tree_a_path, entry->d_name); + if ( !subtree_a_path ) + err(1, "malloc"); execdiff(subtree_a, subtree_a_path, subtree_b, subtree_b_path, subrelpath); free(subtree_a_path); @@ -107,7 +114,7 @@ void execdiff(int tree_a, const char* tree_a_path, continue; } else if ( !(errno == ENOTDIR || errno == ELOOP) ) - err(1, "`%s/%s`", tree_b_path, entry->d_name); + err(1, "%s/%s", tree_b_path, entry->d_name); int a_executableness = ftestexecutableat(tree_a, entry->d_name); int b_executableness = ftestexecutableat(tree_b, entry->d_name); @@ -135,81 +142,41 @@ void execdiff(int tree_a, const char* tree_a_path, } free(subrelpath); - continue; } closedir(dir_b); } -static void help(FILE* fp, const char* argv0) -{ - fprintf(fp, "Usage: %s [OPTION]... TREE-A TREE-B\n", argv0); - fprintf(fp, "Reports which files have had the executable bit changed between two trees.\n"); -} - -static void version(FILE* fp, const char* argv0) -{ - fprintf(fp, "%s (Sortix) %s\n", argv0, VERSIONSTR); -} - int main(int argc, char* argv[]) { - const char* argv0 = argv[0]; - for ( int i = 0; i < argc; i++ ) + int opt; + while ( (opt = getopt(argc, argv, "")) != -1 ) { - const char* arg = argv[i]; - if ( arg[0] != '-' || !arg[1] ) - continue; - argv[i] = NULL; - if ( !strcmp(arg, "--") ) - break; - if ( arg[1] != '-' ) + switch ( opt ) { - char c; - while ( (c = *++arg) ) switch ( c ) - { - default: - fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c); - help(stderr, argv0); - exit(1); - } - } - else if ( !strcmp(arg, "--help") ) - help(stdout, argv0), exit(0); - else if ( !strcmp(arg, "--version") ) - version(stdout, argv0), exit(0); - else - { - fprintf(stderr, "%s: unknown option: %s\n", argv0, arg); - help(stderr, argv0); - exit(1); + default: return 1; } } - if ( argc == 1 ) - { - help(stdout, argv0); - exit(0); - } + if ( argc - optind < 2 ) + errx(1, "expected two directories"); - compact_arguments(&argc, &argv); + if ( 2 < argc - optind ) + errx(1, "unexpected extra operand"); - if ( argc < 3 ) - errx(1, "You need to specify two directories"); - - if ( 3 < argc ) - errx(1, "extra operand"); - - const char* tree_a_path = argv[1]; + const char* tree_a_path = argv[optind + 0]; int tree_a = open(tree_a_path, O_RDONLY | O_DIRECTORY); if ( tree_a < 0 ) - err(1, "`%s'", tree_a_path); + err(1, "%s", tree_a_path); - const char* tree_b_path = argv[2]; + const char* tree_b_path = argv[optind + 1]; int tree_b = open(tree_b_path, O_RDONLY | O_DIRECTORY); if ( tree_b < 0 ) - err(1, "`%s'", tree_b_path); + err(1, "%s", tree_b_path); - execdiff(tree_a, tree_a_path, tree_b, tree_b_path, "."); + execdiff(tree_a, tree_a_path, tree_b, tree_b_path, ""); + + if ( ferror(stdout) || fflush(stdout) == EOF ) + err(1, "stdout"); return 0; } diff --git a/tix/tix-execpatch.8 b/tix/tix-execpatch.8 new file mode 100644 index 00000000..5983fb86 --- /dev/null +++ b/tix/tix-execpatch.8 @@ -0,0 +1,43 @@ +.Dd June 6, 2022 +.Dt TIX-EXECPATCH 8 +.Os +.Sh NAME +.Nm tix-execpatch +.Nd apply executable permissions per the execpatch +.Sh SYNOPSIS +.Nm +.Op Fl \-check +.Op Fl \-directory Ns = Ns Ar directory +.Ar execpatch +.Sh DESCRIPTION +.Nm +updates the executable permissions in the working directory per an execpatch +produced by +.Xr tix-execdiff 8 . +The execpatch is checked for validity and absolute paths and paths containing +.Sq .. +components are rejected. +The executable permissions are updated per the umask. +.Pp +The options are as follows: +.Bl -tag -width "12345678" +.It Fl \-check +Check only the execpatch is valid and don't update any permissions. +.It Fl \-directory Ns = Ns Ar directory +Apply permission changes inside +.Ar directory +instead of the working directory. +.El +.Sh EXIT STATUS +.Nm +will exit 0 on success and non-zero otherwise. +.Sh SEE ALSO +.Xr diff 1 , +.Xr patch 1 , +.Xr port 5 , +.Xr tix-execdiff 8 , +.Xr tix-rmdiff 8 , +.Xr tix-rmpatch 8 +.Sh HISTORY +.Nm +originally appeared in Sortix 0.8. diff --git a/tix/tix-port b/tix/tix-port new file mode 100755 index 00000000..54ac486f --- /dev/null +++ b/tix/tix-port @@ -0,0 +1,527 @@ +#!/bin/sh +# Copyright (c) 2022 Jonas 'Sortie' Termansen. +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# +# tix-port +# Download, patch, build, install, and clean ports. + +set -e + +unset build +cache_package=false +unset collection +destination=. +unset end +unset exec_prefix +unset generation +unset host +unset make +unset makeflags +unset prefix +unset source_port +unset start +unset sysroot +unset tar +unset target +unset tmp +unset mirror +unset mirror_directory + +unset port + +operand=1 +dashdash= +previous_option= +for argument do + if [ -n "$previous_option" ]; then + eval $previous_option=\$argument + previous_option= + continue + fi + + case $argument in + *=?*) parameter=$(expr "X$argument" : '[^=]*=\(.*\)' || true) ;; + *=) parameter= ;; + *) parameter=yes ;; + esac + + case $dashdash$argument in + --) dashdash=yes ;; + --build=*) build=$parameter ;; + --build) previous_option=build ;; + --cache-package) cache_package=true ;; + --collection=*) collection=$parameter ;; + --collection) previous_option=collection ;; + --destination=*) destination=$parameter ;; + --destination) previous_option=destination ;; + --end=*) end=$parameter ;; + --end) previous_option=end ;; + --exec-prefix=*) exec_prefix=$parameter ;; + --exec-prefix) previous_option=exec_prefix ;; + --generation=*) generation=$parameter ;; + --generation) previous_option=generation ;; + --host=*) host=$parameter ;; + --host) previous_option=host ;; + --make=*) make=$parameter ;; + --make) previous_option=make ;; + --makeflags=*) makeflags=$parameter ;; + --makeflags) previous_option=makeflags ;; + --prefix=*) prefix=$parameter ;; + --prefix) previous_option=prefix ;; + --source-port=*) source_port=$parameter ;; + --source-port) previous_option=source_port ;; + --start=*) start=$parameter ;; + --start) previous_option=start ;; + --sysroot=*) sysroot=$parameter ;; + --sysroot) previous_option=sysroot ;; + --tar=*) tar=$parameter ;; + --tar) previous_option=tar ;; + --target=*) target=$parameter ;; + --target) previous_option=target ;; + --tmp=*) tmp=$parameter ;; + --tmp) previous_option=tmp ;; + --mirror=*) mirror=$parameter ;; + --mirror) previous_option=mirror ;; + --mirror-directory=*) mirror_directory=$parameter ;; + --mirror-directory) previous_option=mirror_directory ;; + -*) echo "$0: unrecognized option $argument" >&2 + exit 1 ;; + *) + if [ $operand = 1 ]; then + port="$argument" + operand=2 + else + echo "$0: unexpected extra operand $argument" >&2 + exit 1 + fi + ;; + esac +done + +if [ -n "$previous_option" ]; then + echo "$0: option '$argument' requires an argument" >&2 + exit 1 +fi + +if [ -z "$port" ]; then + echo "$0: error: No port was specified" >&2 + exit 1 +fi + +if [ ! -e "$port.port" ]; then + echo "$0: error: Port file doesn't exist: $port.port" >&2 + exit 1 +fi + +port_dirname=$(dirname -- "$port" ) + +if [ "${collection+x}" = "" -a \ + '(' "${sysroot+x}" = x -o "${prefix+x}" = x ')' ]; then + collection="$sysroot$prefix" +fi + +NAME=$(tix-vars "$port.port" NAME) +SOURCE_PORT=$(tix-vars -d '' "$port.port" SOURCE_PORT) +DEVELOPMENT=$(tix-vars -d false "$port.port" DEVELOPMENT) + +if [ -z "$NAME" ]; then + echo "$0: error: NAME must be set: $port.port" >&2 + exit 1 +fi + +if [ -n "$SOURCE_PORT" ]; then + if [ -z "${source_port+x}" ]; then + source_port="$port_dirname/../$SOURCE_PORT/$SOURCE_PORT" + fi + if [ ! -e "$source_port.port" ]; then + echo "$0: error: Port file for source port $SOURCE_PORT doesn't exist:" \ + "$source_port.port" >&2 + exit 1 + fi +fi + +step_number() { + nl << EOF | grep -E -- " $1$" | grep -Eo '[0-9]+' +start +download +extract +tix-build-start +clean +pre-clean +configure +build +install +post-install +post-clean +package +tix-build-end +strip +diff +tix-install +end +EOF +} + +if [ -n "$start" ] && [ -z "$(step_number "$start")" ]; then + echo "$0: error: Invalid --start: $start" >&2 + exit 1 +fi + +if [ -n "$end" ] && [ -z "$(step_number "$end")" ]; then + echo "$0: error: Invalid --end: $end" >&2 + exit 1 +fi + +should_run_step() { + ([ -z "$start" ] || [ $(step_number "$start") -le $(step_number "$1") ]) && + ([ -z "$end" ] || [ $(step_number "$end") -ge $(step_number "$1") ]) +} + +announce() { + cat << EOF +================================================================================ +==== $1 +================================================================================ +EOF +} + +download_archive_from_url() {( + port="$1" + name="$2" + archive="$3" + url="$4" + sha256sum="$5" + if [ -z "$mirror_directory" ]; then + mirror_directory="$port.mirror/$name" + fi + mirror_directory="$mirror_directory/$name" + mkdir -p -- "$mirror_directory" + if [ ! -e "$mirror_directory/$archive.sha256sum" ]; then + announce "Downloading $1: $archive" + (if echo "$url" | grep -Eq '^[a-z][a-z0-9.+-]*://'; then + if ! wget -O "$mirror_directory/$archive.untrusted" -- "$url"; then + echo "$0: warning: Failed to download $archive from $url" >&2 + exit 1 + fi + else + if ! cp -- "$url" "$mirror_directory/$archive.untrusted"; then + echo "$0: warning: Failed to copy $archive from $url" >&2 + exit 1 + fi + fi + if ! echo "$sha256sum $mirror_directory/$archive.untrusted" | \ + sha256sum -c; then + sha256sum "$mirror_directory/$archive.untrusted" + echo "$0: warning: $port.port: Wrong sha256sum downloading $archive from $url" >&2 + exit 1 + fi + mv "$mirror_directory/$archive.untrusted" "$mirror_directory/$archive" + echo "$url" > "$mirror_directory/$archive.url" + echo "$SHA256SUM $archive" > "$mirror_directory/$archive.sha256sum.new" + mv "$mirror_directory/$archive.sha256sum.new" \ + "$mirror_directory/$archive.sha256sum" + ) || ( + rm -f "$mirror_directory/$archive.untrusted" + rm -f "$mirror_directory/$archive.url" + rm -f "$mirror_directory/$archive.sha256sum.new" + rm -f "$mirror_directory/$archive.sha256sum" + exit 1 + ) + fi +)} + +download_archive() {( + port="$1" + name="$2" + archive="$3" + upstream_site="$4" + upstream_archive="$5" + sha256sum="$6" + if ! ([ -n "$mirror" ] && + download_archive_from_url "$port" "$name" "$archive" \ + "$mirror/$name/$archive" "$sha256sum") && + ! download_archive_from_url "$port" "$name" "$archive" \ + "$upstream_site/$upstream_archive" \ + "$sha256sum"; then + echo "$0: error: Failed to download $archive with sha256sum $sha256sum" >&2 + false + fi +)} + +download_port() {( + port="$1" + NAME=$(tix-vars "$port.port" NAME) + ARCHIVE=$(tix-vars -d '' "$port.port" ARCHIVE) + if [ -n "$ARCHIVE" ]; then + UPSTREAM_SITE=$(tix-vars "$port.port" UPSTREAM_SITE) + UPSTREAM_ARCHIVE=$(tix-vars "$port.port" UPSTREAM_ARCHIVE) + SHA256SUM=$(tix-vars "$port.port" SHA256SUM) + download_archive "$port" "$NAME" "$ARCHIVE" "$UPSTREAM_SITE" \ + "$UPSTREAM_ARCHIVE" "$SHA256SUM" + ARCHIVE_2=$(tix-vars -d '' "$port.port" ARCHIVE_2) + if [ -n "$ARCHIVE_2" ]; then + UPSTREAM_SITE_2=$(tix-vars "$port.port" UPSTREAM_SITE_2) + UPSTREAM_ARCHIVE_2=$(tix-vars "$port.port" UPSTREAM_ARCHIVE_2) + SHA256SUM_2=$(tix-vars "$port.port" SHA256SUM_2) + download_archive "$port" "$NAME" "$ARCHIVE_2" \ + "$UPSTREAM_SITE_2" "$UPSTREAM_ARCHIVE_2" "$SHA256SUM_2" + fi + fi +)} + +desired_version() {( + port="$1" + ARCHIVE=$(tix-vars -d '' "$port.port" ARCHIVE) + stamp="$NAME" + if [ -n "$ARCHIVE" ]; then + VERSION=$(tix-vars "$port.port" VERSION) + SHA256SUM=$(tix-vars "$port.port" SHA256SUM) + stamp="$stamp.$VERSION.$SHA256SUM" + ARCHIVE_2=$(tix-vars -d '' "$port.port" ARCHIVE_2) + if [ -n "$ARCHIVE_2" ]; then + VERSION_2=$(tix-vars "$port.port" VERSION_2) + SHA256SUM_2=$(tix-vars "$port.port" SHA256SUM_2) + stamp="$stamp.$VERSION_2.$SHA256SUM_2" + fi + fi + if [ -f "$port.patch" ]; then + stamp="$stamp.$(cat "$port.patch" | sha256sum | grep -Eo '^[^ ]*')" + fi + if [ -f "$port.execpatch" ]; then + stamp="$stamp.$(cat "$port.execpatch" | sha256sum | grep -Eo '^[^ ]*')" + fi + if [ -f "$port.rmpatch" ]; then + stamp="$stamp.$(cat "$port.rmpatch" | sha256sum | grep -Eo '^[^ ]*')" + fi + DEVELOPMENT=$(tix-vars -d false "$port.port" DEVELOPMENT) + if [ "$DEVELOPMENT" = true ]; then + stamp="$stamp.development" + fi + echo "$stamp" +)} + +diff_package() {( + port="$1" + cd "$(dirname -- "$port")" + base=$(basename -- "$port") + if [ -e "$base.upstream" ]; then + announce "diff $base.upstream $base" + diff -Paur --no-dereference -- "$base.upstream" "$base" | + sed -E -e '/^Only in.*$/d' -e 's/^((---|\+\+\+)[^\t]+)\t.*/\1/' \ + > "$base.patch" + if [ ! -s "$base.patch" ]; then rm "$base.patch"; fi + tix-execdiff -- "$base.upstream" "$base" | + LC_ALL=C sort > "$base.execpatch" + if [ ! -s "$base.execpatch" ]; then rm "$base.execpatch"; fi + tix-rmdiff -- "$base.upstream" "$base" | + LC_ALL=C sort > "$base.rmpatch" + if [ ! -s "$base.rmpatch" ]; then rm "$base.rmpatch"; fi + desired_version "$port" > "$base.version" + fi +)} + +extract_package() {( + port="$1" + NAME=$(tix-vars "$port.port" NAME) + DEVELOPMENT=$(tix-vars -d false "$port.port" DEVELOPMENT) + NEED_WRITABLE=$(tix-vars -d false "$port.port" NEED_WRITABLE) + ARCHIVE=$(tix-vars -d '' "$port.port" ARCHIVE) + ARCHIVE_2=$(tix-vars -d '' "$port.port" ARCHIVE_2) + if [ -z "$mirror_directory" ]; then + mirror_directory="$port.mirror" + fi + mirror_directory="$mirror_directory/$NAME" + version_stamp="$(desired_version "$port")" + if [ ! -e "$port.version" ] || + [ "$(cat "$port.version")" != "$version_stamp" ] || + [ ! -e "$port.version" ]; then + if [ -e "$port.version" ]; then + old_version_stamp="$(cat "$port.version")" + case "$old_version_stamp" in + *.development) + if [ "$DEVELOPMENT" = true ]; then + echo "$0: error: $NAME: Refusing to delete port in development" >&2 + echo "$0: error: $NAME: .version is currently: $old_version_stamp" >&2 + echo "$0: error: $NAME: .version should be: $version_stamp" >&2 + exit 1 + fi + esac + fi + echo "$version_stamp" > "$port.version.new" + rm -rf "$port" + rm -rf "$port.upstream" + mkdir "$port" + if [ "$DEVELOPMENT" = true ]; then + mkdir "$port.upstream" + fi + if [ -n "$ARCHIVE" ]; then + announce "Extracting $1: $ARCHIVE" + tar -C "$port" -xf "$mirror_directory/$ARCHIVE" --strip-components=1 + if [ "$DEVELOPMENT" = true ]; then + tar -C "$port.upstream" -xf "$mirror_directory/$ARCHIVE" \ + --strip-components=1 + fi + if [ -n "$ARCHIVE_2" ]; then + announce "Extracting $1: $ARCHIVE_2" + tar -C "$port" -xf "$mirror_directory/$ARCHIVE_2" --strip-components=1 + if [ "$DEVELOPMENT" = true ]; then + tar -C "$port.upstream" -xf "$mirror_directory/$ARCHIVE_2" \ + --strip-components=1 + fi + fi + fi + if [ -f "$port.patch" ]; then + if [ "$DEVELOPMENT" = true ]; then + patch -f -d "$port" -p1 < "$port.patch" || true + # .rej files might already have been applied + (cd "$port" && + find \ + -name '*.rej' \ + -exec sh -c 'patch -fRs -p0 --dry-run < "$0" >/dev/null 2>&1' \ + '{}' ';' -delete) + # .orig files aren't useful unless part of the patch got rejected. + find "$port" \ + -name '*.orig' \ + -exec sh -c 'test ! -e "$(echo "$0" | sed -E "s,\\.orig$,.rej,")"' \ + '{}' ';' -delete + else + patch -d "$port" -p1 < "$port.patch" + fi + fi + if [ -f "$port.execpatch" ]; then + tix-execpatch --directory "$port" "$port.execpatch" + fi + if [ -f "$port.rmpatch" ]; then + tix-rmpatch --directory "$port" "$port.rmpatch" + fi + if [ "$DEVELOPMENT" != true -a "$NEED_WRITABLE" != true ]; then + find "$port" '!' -type d -exec chmod a-w '{}' + + fi + mv "$port.version.new" "$port.version" + if [ "$DEVELOPMENT" = true ]; then + REJECTS="$(find "$port" -name '*.rej' -o -name '*.orig' | sort)" + if [ -n "$REJECTS" ]; then + echo >&2 + echo "$REJECTS" >&2 + echo "$0: error: $NAME: The above patch hunks were rejected" >&2 + exit 1 + fi + fi + fi +)} + +# TODO: This adds another decompression and compression to the build time, this +# should be done as a tix post installation step. Also this might miss +# programs in unusual locations, so a thorough search and strip is needed. +strip_tix() {( + strip=${host+$host-}strip + dir=$(mktemp -d) + tar -C "$dir" -xf "$1" + $strip -d "$dir/data/bin/"* 2>/dev/null || true + $strip -d "$dir/data/lib/"* 2>/dev/null || true + $strip -d "$dir/data/libexec"* 2>/dev/null || true + $strip -d "$dir/data/libexec/git-core/"* 2>/dev/null || true + $strip -d "$dir/data/sbin/"* 2>/dev/null || true + (cd "$dir" && tar --numeric-owner --owner=0 --group=0 -cJf port.tar.tix.xz tix data) + cp "$dir/port.tar.tix.xz" "$1" + rm -rf "$dir" +)} + +if $cache_package && + [ -f "$destination/$NAME.tix.tar.xz" -a \ + -f "$destination/$NAME.version" ] && + [ "$(cat $destination/$NAME.version)" = "$(desired_version $port)" ]; then + start=tix-install +fi + +if should_run_step download; then + if [ -n "$SOURCE_PORT" ]; then + download_port "$source_port" + fi + download_port "$port" +fi + +if should_run_step extract; then + if [ -n "$SOURCE_PORT" ]; then + extract_package "$source_port" + fi + extract_package "$port" +fi + +update_version=false +if [ $(step_number "${start-start}") -lt $(step_number tix-build-end) ] && + [ $(step_number "${end-end}") -gt $(step_number tix-build-start) ]; then + announce "Building $NAME" + unset tix_build_start + unset tix_build_end + if [ -n "$start" ]; then + if [ $(step_number "$start") -le $(step_number tix-build-start) ]; then + tix_build_start=start + else + tix_build_start="$start" + fi + fi + if [ -n "$end" ]; then + if [ $(step_number "$end") -ge $(step_number tix-build-end) ]; then + tix_build_end=end + else + tix_build_end="$end" + fi + fi + if should_run_step package; then + mkdir -p "$destination" + fi + tix-build \ + ${build+--build="$build"} \ + ${destination+--destination="$destination"} \ + ${tix_build_end+--end="$tix_build_end"} \ + ${exec_prefix+--exec-prefix="$exec_prefix"} \ + ${generation+--generation="$generation"} \ + ${host+--host="$host"} \ + ${make+--make="$make"} \ + ${makeflags+--makeflags="$makeflags"} \ + ${prefix+--prefix="$prefix"} \ + ${source_port+--source-port="$source_port"} \ + ${tix_build_start+--start="$tix_build_start"} \ + ${sysroot+--sysroot="$sysroot"} \ + ${tar+--tar="$tar"} \ + ${target+--target="$target"} \ + ${tmp+--tmp="$tmp"} \ + "$port" + update_version=true +fi + +if should_run_step strip; then + strip_tix "$destination/$NAME.tix.tar.xz" + update_version=true +fi + +if should_run_step diff; then + if [ "$DEVELOPMENT" = true ]; then + diff_package "$port" + fi + update_version=true +fi + +if $update_version; then + cp "$port.version" "$destination/$NAME.version" +fi + +if should_run_step tix-install; then + announce "Installing $NAME" + tix-install \ + ${collection+--collection="$collection"} \ + --reinstall \ + "$destination/$NAME.tix.tar.xz" +fi diff --git a/tix/tix-port.8 b/tix/tix-port.8 new file mode 100644 index 00000000..bec660e4 --- /dev/null +++ b/tix/tix-port.8 @@ -0,0 +1,262 @@ +.Dd April 10, 2022 +.Dt TIX-PORT 8 +.Os +.Sh NAME +.Nm tix-port +.Nd download, patch, build, install, and clean a port +.Sh SYNOPSIS +.Nm +.Op Fl \-build Ns = Ns Ar triplet +.Op Fl \-cache-package +.Op Fl \-collection Ns = Ns Ar collection +.Op Fl \-destination Ns = Ns Ar directory +.Op Fl \-end Ns = Ns Ar step +.Op Fl \-exec-prefix Ns = Ns Ar prefix +.Op Fl \-generation Ns = Ns Ar level +.Op Fl \-host Ns = Ns Ar triplet +.Op Fl \-make Ns = Ns Ar path +.Op Fl \-makeflags Ns = Ns Ar makeflags +.Op Fl \-prefix Ns = Ns Ar prefix +.Op Fl \-source-port Ns = Ns Ar source-port +.Op Fl \-start Ns = Ns Ar step +.Op Fl \-sysroot Ns = Ns Ar directory +.Op Fl \-tar Ns = Ns Ar path +.Op Fl \-target Ns = Ns Ar triplet +.Op Fl \-tmp Ns = Ns Ar directory +.Op Fl \-mirror Ns = Ns Ar url +.Op Fl \-mirror-directory Ns = Ns Ar directory +.Ar port +.Sh DESCRIPTION +.Nm +manages the build of a +.Xr port 5 +of software for this operating system by downloading the source code, applying +the patches, building the port, and installing the binary package. +Many of the options are forwarded to the low-level +.Xr tix-build 8 +which performs the build once the source code has been prepared. +.Nm +is usually invoked through +.Xr development 7 +for the official ports. +.Pp +The mandatory +.Ar port +argument is the directory where the port's source code will be placed and the +.Xr port 5 +file is found by adding +.Pa .port +to this path. +The downloaded upstream releases are placed in the created +.Pa port.mirror +cache directory, the source code is extracted in the +.Ar port +directory with the +.Pa port.patch , +.Pa port.execpatch , +and +.Pa port.rmpatch +patches applied if they exist, and the +.Pa port.version +stamp file is created to avoid reextracting the port if the right version is +already extracted. +.Pp +The options are as follows: +.Bl -tag -width "12345678" +.It Fl \-build Ns = Ns Ar triplet +The platform +.Ar triplet +for the machine the port is built on. +(Default: Automatically detected.) +.It Fl \-cache-package +Skip the build if the binary package already exists and is the right version. +.It Fl \-collection Ns = Ns Ar collection +Install the binary package into this +.Ar collection +created with +.Xr tix-collection 8 . +(Default: +.Fl \-sysroot +plus +.Fl \-prefix ) +.It Fl \-destination Ns = Ns Ar directory +The binary package is placed inside this +.Ar directory . +.It Fl \-end Ns = Ns Ar step +Stop the build after this +.Ar step : +.Pp +.Bl -tag -width "clean, pre-clean" -compact +.It start +The start step before anything has happened. +.It download +Download the source code. +.It extract +Extract the source code and apply patches. +.It tix-build-start +The start step in +.Xr tix-build 8 . +.It clean, pre-clean +Clean the source directory before the build. +.It configure +Configure the port. +.It build +Build the port. +.It install +Install the port into the +.Ev DESTDIR . +.It post-install +Run the post-installation script. +.It post-clean +Clean the source code after the port. +.It package +Create the binary package. +.It tix-build-end +The end step in +.Xr tix-build 8 . +.It strip +Strip the executables in the binary package. +.It diff +Regenerate the patches if in development. +.It tix-install +Install the binary package. +.It end +The end step after everything has happened. +(Default) +.El +.It Fl \-exec-prefix Ns = Ns Ar prefix +The +.Ar prefix +where architecture dependent files are installed. +(Default: +.Fl \-prefix ) +.It Fl \-generation Ns = Ns Ar generation +Create a binary package in the format of this tix generation +.Ar level . +(Default: 2) +.It Fl \-host Ns = Ns Ar triplet +The platform +.Ar triplet +for the machine the port will run on. +(Default: +.Fl \-build ) +.It Fl \-make Ns = Ns Ar path +Which +.Xr make 1 +to use. +(Default: +.Ev MAKE +if set and otherwise +.Xr make 1 ) +.It Fl \-makeflags Ns = Ns Ar makeflags +Override the +.Ev MAKEFLAGS +variable inherited by make. +.It Fl \-prefix Ns = Ns Ar prefix +Build the port into this +.Ar prefix . +(Default: The empty prefix designating the root directory) +.It Fl \-source-port Ns = Ns Ar source-port +The source code for the +.Sy SOURCE_PORT +per +.Xr port 5 +will be placed in the +.Ar source-port +directory along with the mirror and version file where the source port's file is +found by adding +.Pa .port +to this path. +(Default: ../$SOURCE_PORT/$SOURCE_PORT) +.It Fl \-start Ns = Ns Ar step +Start the build at this step (see +.Fl \-end ) . +(Default: +.Sy start ) +.It Fl \-sysroot Ns = Ns Ar directory +The system root to use while building and installing the port. +The toolchain is wrapped to transparently use this sysroot during the build. +.It Fl \-tar Ns = Ns Ar path +Which +.Xr tar 1 +to use during the build. +(Default: +.Xr tar 1 ) +.It Fl \-target Ns = Ns Ar triplet +The port's outputs targets this platform +.Ar triplet . +(Default: +.Fl \-host ) +.It Fl \-tmp Ns = Ns Ar directory +Place temporary files in this +.Ar directory . +(Default: +.Ev TMPDIR +if set otherwise +.Pa /tmp ) +.It Fl \-mirror Ns = Ns Ar url +First attempt to download the upstream releases from the port's source code +mirror at +.Ar url +before attempting the upstream site. +The files are copied from the filesystem if the +.Ar url +has no schema. +.It Fl \-mirror-directory Ns = Ns Ar directory +Place the downloaded upstream releases in this +.Ar directory +in the layout that can be used as a mirror for the +.Fl \-mirror +option. +(Default: +.Ar port Ns Pa .mirror ) +.El +.Sh EXIT STATUS +.Nm +will exit 0 on success and non-zero otherwise. +.Sh EXAMPLES +A +.Xr port 5 +called +.Pa example.port +with optional patches +.Pa example.patch , +.Pa example.execpatch , +and +.Pa example.rmpatch +can be downloaded, extracted, patched, built and installed into the +.Pa /local +prefix for non-system software by running: +.Bd -literal -offset indent +mkdir -p /local # if not already done +tix-collection /local create # if not already done +tix-port --prefix=/local example +.Ed +.Pp +This command makes a +.Pa example +directory with the patched source code, a +.Pa example.version +version stamp file to avoid unnecessary reextractions, a +.Pa example.mirror +cache directory with the downloaded upstream release, and the +.Pa example.tix.tar.xz +binary package, which is installed into +.Pa /local . +The +.Fl \-end=strip +option can be used to just get the binary package (and not install it) +by stopping after the binary package has been stripped. +.Sh SEE ALSO +.Xr port 5 , +.Xr development 7 , +.Xr porting 7 , +.Xr tix-build 8 , +.Xr tix-collection 8 , +.Xr tix-install 8 +.Sh HISTORY +.Nm +originally appeared in Sortix 1.1 as a networked higher level interface around +the lower level +.Xr tix-build 8 +from Sortix 0.8. diff --git a/tix/tix-rmdiff.8 b/tix/tix-rmdiff.8 new file mode 100644 index 00000000..ed92581d --- /dev/null +++ b/tix/tix-rmdiff.8 @@ -0,0 +1,39 @@ +.Dd June 6, 2022 +.Dt TIX-RMDIFF 8 +.Os +.Sh NAME +.Nm tix-rmdiff +.Nd compare removed files between two trees +.Sh SYNOPSIS +.Nm +.Ar old +.Ar new +.Sh DESCRIPTION +.Nm +recursively finds the files and directories that have been removed between the +.Ar old +and +.Ar new +directory trees. +.Nm +writes a shell script that transforms the old tree into the new tree by deleting +the removed files and directories, which can be applied using +.Xr tix-rmpatch 8 . +.Pp +Removals are written shell single quoted as: +.Bd -ragged -offset indent +rm -rf -- 'path' +.Ed +.Sh EXIT STATUS +.Nm +will exit 0 on success and non-zero otherwise. +.Sh SEE ALSO +.Xr diff 1 , +.Xr patch 1 , +.Xr port 5 , +.Xr tix-execdiff 8 , +.Xr tix-execpatch 8 , +.Xr tix-rmpatch 8 +.Sh HISTORY +.Nm +originally appeared in Sortix 1.1. diff --git a/tix/tix-rmdiff.c b/tix/tix-rmdiff.c new file mode 100644 index 00000000..266999cd --- /dev/null +++ b/tix/tix-rmdiff.c @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2013, 2016, 2022 Jonas 'Sortie' Termansen. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * tix-rmdiff.c + * Compare removed files between two trees. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" + +static DIR* fdopendupdir(int fd) +{ + int newfd = dup(fd); + if ( newfd < 0 ) + return NULL; + DIR* result = fdopendir(newfd); + if ( !result ) + return close(newfd), (DIR*) NULL; + return result; +} + +static void rmdiff(int tree_a, const char* tree_a_path, + int tree_b, const char* tree_b_path, + const char* relpath) +{ + DIR* dir_a = fdopendupdir(tree_a); + if ( !dir_a ) + err(1, "fdopendupdir: %s", tree_a_path); + struct dirent* entry; + while ( (entry = readdir(dir_a)) ) + { + if ( !strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..") ) + continue; + + char* subrelpath = relpath[0] ? join_paths(relpath, entry->d_name) : + strdup(entry->d_name); + if ( !subrelpath ) + err(1, "malloc"); + + int diropenflags = O_RDONLY | O_DIRECTORY | O_NOFOLLOW; + int subtree_b = openat(tree_b, entry->d_name, diropenflags); + if ( 0 <= subtree_b ) + { + char* subtree_b_path = join_paths(tree_b_path, entry->d_name); + if ( !subtree_b_path ) + err(1, "malloc"); + int subtree_a = openat(tree_a, entry->d_name, diropenflags); + if ( subtree_a < 0 ) + { + if ( !(errno == ENOTDIR || errno == ELOOP || errno == ENOENT) ) + err(1, "%s/%s", tree_b_path, entry->d_name); + free(subtree_b_path); + close(subtree_b); + free(subrelpath); + continue; + } + char* subtree_a_path = join_paths(tree_a_path, entry->d_name); + if ( !subtree_a_path ) + err(1, "malloc"); + rmdiff(subtree_a, subtree_a_path, subtree_b, subtree_b_path, + subrelpath); + free(subtree_a_path); + close(subtree_a); + free(subtree_b_path); + close(subtree_b); + free(subrelpath); + continue; + } + else if ( errno == ENOENT ) + { + printf("rm -rf -- '"); + for ( size_t i = 0; subrelpath[i]; i++ ) + if ( subrelpath[i] == '\'' ) + printf("'\\''"); + else + putchar(subrelpath[i]); + printf("'\n"); + } + + free(subrelpath); + } + closedir(dir_a); +} + +int main(int argc, char* argv[]) +{ + int opt; + while ( (opt = getopt(argc, argv, "")) != -1 ) + { + switch ( opt ) + { + default: return 1; + } + } + + if ( argc - optind < 2 ) + errx(1, "expected two directories"); + + if ( 2 < argc - optind ) + errx(1, "unexpected extra operand"); + + const char* tree_a_path = argv[optind + 0]; + int tree_a = open(tree_a_path, O_RDONLY | O_DIRECTORY); + if ( tree_a < 0 ) + err(1, "%s", tree_a_path); + + const char* tree_b_path = argv[optind + 1]; + int tree_b = open(tree_b_path, O_RDONLY | O_DIRECTORY); + if ( tree_b < 0 ) + err(1, "%s", tree_b_path); + + rmdiff(tree_a, tree_a_path, tree_b, tree_b_path, ""); + + if ( ferror(stdout) || fflush(stdout) == EOF ) + err(1, "stdout"); + + return 0; +} diff --git a/tix/tix-rmpatch.8 b/tix/tix-rmpatch.8 new file mode 100644 index 00000000..0e6f287b --- /dev/null +++ b/tix/tix-rmpatch.8 @@ -0,0 +1,42 @@ +.Dd June 6, 2022 +.Dt TIX-RMPATCH 8 +.Os +.Sh NAME +.Nm tix-rmpatch +.Nd remove files and directories per the rmpatch +.Sh SYNOPSIS +.Nm +.Op Fl \-check +.Op Fl \-directory Ns = Ns Ar directory +.Ar rmpatch +.Sh DESCRIPTION +.Nm +recursively removes the files and directories per an rmpatch +produced by +.Xr tix-rmdiff 8 . +The rmpatch is checked for validity and absolute paths and paths containing +.Sq .. +components are rejected. +.Pp +The options are as follows: +.Bl -tag -width "12345678" +.It Fl \-check +Check only the rmpatch is valid and don't remove any files or directories. +.It Fl \-directory Ns = Ns Ar directory +Remove inside +.Ar directory +instead of the working directory. +.El +.Sh EXIT STATUS +.Nm +will exit 0 on success and non-zero otherwise. +.Sh SEE ALSO +.Xr diff 1 , +.Xr patch 1 , +.Xr port 5 , +.Xr tix-execdiff 8 , +.Xr tix-execpatch 8 , +.Xr tix-rmdiff 8 +.Sh HISTORY +.Nm +originally appeared in Sortix 0.8. diff --git a/tix/tix-vars.8 b/tix/tix-vars.8 new file mode 100644 index 00000000..0612c7cb --- /dev/null +++ b/tix/tix-vars.8 @@ -0,0 +1,52 @@ +.Dd June 5, 2022 +.Dt TIX-VARS 8 +.Os +.Sh NAME +.Nm tix-vars +.Nd evaluate variables in port files +.Sh SYNOPSIS +.Nm +.Op Fl t +.Op Fl d Ar default +.Ar file +.Op Ar variable ... +.Sh DESCRIPTION +.Nm +evaluates the variables in the +.Xr port 5 +named by +.Ar file +or the standard input if +.Ar file +is +.Sq - . +If any +.Ar variables +are requested then their raw values are written as lines. +Otherwise all the variables are written in a normalized form as lines with an +equals sign +.Sq = +separating the variable name and the raw value. +.Pp +The options are as follows: +.Bl -tag -width "12345678" +.It Fl d Ar default +Use the +.Ar default +value instead if the variable is unset. +.It Fl t +Test quietly whether the file is syntactically correct and whether the variables +are set without writing their contents. +.El +.Sh EXIT STATUS +.Nm +will exit 0 on success, +exit 1 on a syntax error or if the requested variable is unset, +and exit 2 otherwise. +.Sh SEE ALSO +.Xr port 5 , +.Xr tix-build 8 , +.Xr tix-port 8 +.Sh HISTORY +.Nm +originally appeared in Sortix 1.1. diff --git a/tix/tix-vars.c b/tix/tix-vars.c new file mode 100644 index 00000000..22df77d7 --- /dev/null +++ b/tix/tix-vars.c @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2022 Jonas 'Sortie' Termansen. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * tix-vars.c + * Evaluate variables in port files. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" + +int main(int argc, char* argv[]) +{ + const char* def = NULL; + bool test = false; + + int opt; + while ( (opt = getopt(argc, argv, "d:t")) != -1 ) + { + switch ( opt ) + { + case 'd': def = optarg; break; + case 't': test = true; break; + default: return 1; + } + } + + if ( optind == argc ) + errx(2, "expected port file"); + const char* path = argv[optind++]; + string_array_t sa = string_array_make(); + int status = !strcmp(path, "-") ? + variables_append_file(&sa, stdin) : + variables_append_file_path(&sa, path); + if ( status == -1 ) + err(2, "%s", path); + else if ( status == -2 ) + errx(2, "%s: Syntax error", path); + + if ( optind == argc ) + { + if ( test ) + return 0; + for ( size_t i = 0; i < sa.length; i++ ) + if ( puts(sa.strings[i]) < 0 ) + err(2, "stdout"); + } + else for ( int i = optind; i < argc; i++ ) + { + const char* variable = argv[i]; + const char* value = dictionary_get_def(&sa, variable, def); + if ( !value && test ) + exit(1); + else if ( !value ) + errx(1, "%s: Variable is unset: %s", path, variable); + if ( !test && puts(value) < 0 ) + err(2, "stdout"); + } + + if ( ferror(stdout) || fflush(stdout) == EOF ) + err(2, "stdout"); + + return 0; +} diff --git a/tix/util.h b/tix/util.h index d22b0115..d91690c4 100644 --- a/tix/util.h +++ b/tix/util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, 2016 Jonas 'Sortie' Termansen. + * Copyright (c) 2013, 2015, 2016, 2022 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -354,6 +354,169 @@ bool dictionary_append_file_path(string_array_t* sa, const char* path) return true; } +bool is_identifier_char(char c) +{ + return ('a' <= c && c <= 'z') || + ('A' <= c && c <= 'Z') || + ('0' <= c && c <= '9') || + c == '_'; +} + +// 0 on success, -1 on error, -2 on syntax error. +int variables_parse_fp(string_array_t* sa, const char* line, FILE* fp) +{ + size_t i = 0; + while ( isspace((unsigned char) line[i]) ) + i++; + if ( !line[i] || line[i] == '#' ) + return 0; + if ( line[i] == '=' ) + return -2; + size_t keylen = 0; + while ( line[i + keylen] && + line[i + keylen] != '=' && + line[i + keylen] != '#' && + !isspace((unsigned char) line[i + keylen]) ) + { + if ( fputc((unsigned char) line[i + keylen++], fp) == EOF ) + return -1; + } + i += keylen; + if ( line[i++] != '=' ) + return -2; + fputc('=', fp); + bool escaped = false; + bool singly_quote = false; + bool doubly_quote = false; + while ( true ) + { + unsigned char c = (unsigned char) line[i++]; + if ( !c ) + { + i--; + break; + } + else if ( !escaped && !singly_quote && c == '\\' ) + escaped = true; + else if ( !escaped && !doubly_quote && c == '\'' ) + singly_quote = !singly_quote; + else if ( !escaped && !singly_quote && c == '"' ) + doubly_quote = !doubly_quote; + else if ( !escaped && !singly_quote && c == '$' && + (is_identifier_char(line[i]) || line[i] == '{') ) + { + size_t start = i; + size_t keylen = 0; + if ( line[start] == '{' ) + { + start++; + while ( line[start + keylen] && line[start + keylen] != '}' ) + keylen++; + if ( !keylen ) + return -2; + if ( line[start + keylen] != '}' ) + return -2; + i = start + keylen + 1; + } + else + { + while ( line[start + keylen] && + is_identifier_char(line[start + keylen]) ) + keylen++; + i = start + keylen; + } + const char* key = line + start; + const char* value = NULL; + for ( size_t n = 0; !value && n < sa->length; n++ ) + { + const char* entry = sa->strings[n]; + if ( strncmp(key, entry, keylen) != 0 ) + continue; + if ( entry[keylen] != '=' ) + continue; + value = entry + keylen + 1; + } + if ( !value ) + return -2; + size_t length = strlen(value); + if ( fwrite(value, 1, length, fp) != length ) + return -1; + } + else + { + if ( !escaped && !singly_quote && !doubly_quote && isspace(c) ) + { + i--; + break; + } + if ( fputc(c, fp) == EOF ) + return -1; + escaped = false; + } + } + while ( isspace((unsigned char) line[i]) ) + i++; + if ( line[i] && line[i] != '#' ) + return -2; + return 1; +} + +int variables_parse(string_array_t* sa, const char* line, char** out_ptr) +{ + size_t out_size; + FILE* fp = open_memstream(out_ptr, &out_size); + if ( !fp ) + return -1; + int result = variables_parse_fp(sa, line, fp); + if ( fclose(fp) == EOF ) + result = -1; + if ( result <= 0 ) + free(*out_ptr); + return result; +} + +int variables_append_file(string_array_t* sa, FILE* fp) +{ + char* line = NULL; + size_t line_size = 0; + ssize_t line_length; + while ( 0 < (line_length = getline(&line, &line_size, fp)) ) + { + if ( line[line_length-1] == '\n' ) + line[--line_length] = '\0'; + char* entry; + int result = variables_parse(sa, line, &entry); + if ( result == 0 ) + continue; + if ( result < 0 ) + { + free(line); + return result; + } + if ( !string_array_append(sa, entry) ) + { + free(entry); + free(line); + return -1; + } + free(entry); + } + free(line); + if ( ferror(fp) ) + return -1; + return 0; +} + +int variables_append_file_path(string_array_t* sa, const char* path) +{ + FILE* fp = fopen(path, "r"); + if ( !fp ) + return -1; + int result = variables_append_file(sa, fp); + fclose(fp); + return result; +} + __attribute__((format(printf, 1, 2))) char* print_string(const char* format, ...) {