From 1b2218612a71b019c7dc1db680c254c697c4ec6b Mon Sep 17 00:00:00 2001 From: Zach van Rijn Date: Mon, 30 Oct 2023 17:31:53 -0500 Subject: user/kbuild: new package. --- user/kbuild/APKBUILD | 58 ++++++++++++++++++++++++ user/kbuild/add-power-support.patch | 14 ++++++ user/kbuild/allperms.patch | 44 ++++++++++++++++++ user/kbuild/fix-nodes-newline-escape.patch | 18 ++++++++ user/kbuild/kobjcache.patch | 10 +++++ user/kbuild/maintain | 72 ++++++++++++++++++++++++++++++ user/kbuild/obstack.patch | 12 +++++ user/kbuild/os-linux.patch | 26 +++++++++++ user/kbuild/sys-types.patch | 14 ++++++ 9 files changed, 268 insertions(+) create mode 100644 user/kbuild/APKBUILD create mode 100644 user/kbuild/add-power-support.patch create mode 100644 user/kbuild/allperms.patch create mode 100644 user/kbuild/fix-nodes-newline-escape.patch create mode 100644 user/kbuild/kobjcache.patch create mode 100755 user/kbuild/maintain create mode 100644 user/kbuild/obstack.patch create mode 100644 user/kbuild/os-linux.patch create mode 100644 user/kbuild/sys-types.patch diff --git a/user/kbuild/APKBUILD b/user/kbuild/APKBUILD new file mode 100644 index 000000000..fec3fed4e --- /dev/null +++ b/user/kbuild/APKBUILD @@ -0,0 +1,58 @@ +# Contributor: Natanael Copa +# Maintainer: Zach van Rijn +pkgname=kbuild +pkgver=0.1.9998.3600 +pkgrel=0 +pkgdesc="A cross-platform build environment" +url="https://trac.netlabs.org/kbuild/wiki" +arch="all" +license="GPL-3.0-only" +depends="" +makedepends="autoconf automake flex byacc texinfo" +subpackages="$pkgname-doc" +source="https://distfiles.adelielinux.org/source/$pkgname/$pkgname-$pkgver.tar.gz + fix-nodes-newline-escape.patch + add-power-support.patch + + allperms.patch + sys-types.patch + kobjcache.patch + obstack.patch + os-linux.patch + " + +prepare() { + update_config_guess + update_config_sub + default_prepare + + # Add a file with the svn revision this package was pulled from + printf '%s\n' "KBUILD_SVN_REV := ${pkgver##*.}" > SvnInfo.kmk + + for k in src/kmk src/sed; do + ( + cd "$builddir"/${k} + aclocal -I config && autoheader && autoconf && automake --add-missing + ) + done +} + +build() { + kBuild/env.sh --full make -f bootstrap.gmk AUTORECONF=true +} + +check() { + kBuild/env.sh kmk check +} + +package() { + kBuild/env.sh kmk NIX_INSTALL_DIR=/usr PATH_INS="$pkgdir" install +} +sha512sums="4d4ddfd6d3a6b2f040e459a846c81bf224e152af4a2789a27145a3f99afcf2002c1af5e689db6e32f2ac78fdc7e1f97b268416666b34ee18337a11823ecb12a3 kbuild-0.1.9998.3600.tar.gz +e25b0c55b00028d4ecbced6f6266d85db6503bc038e1086e73913bd9192e11935e4eb77135587dcf51df1ecea25d123d6335e7f28bba8c28d6e5703d1e75e3c5 fix-nodes-newline-escape.patch +6dd8b55c0aa5f6285201d7812ebf64ea6fbe030f731797a95d5815b827a5dd138ede2b0524953f4401783f26127500cf4b12f05bcbd32e197f9080647826e2f1 add-power-support.patch +959673eac4239c1886d9f1ef17eb81ea179bcfc539289bd36b19152ba6b6094b13218593afe6a4245957e3b343aeaa5a38edc167d6fedfeeff386eb7ae675aef allperms.patch +58ae3ec4a1535fddd4af67803c081c9ca4cd66244ea2a7ddfbf59eb5b849421377116376d893d5e643a15413b902463affa51153afeb2d2217bac135122b66a5 sys-types.patch +7afcc78589ee66c60dd7a73819b4776531a4fc0f73c8a8824f4b53967f7c903095206455d2b113288ad4cf337e67c0dc82cd679b994096c5d9270f83d55689ad kobjcache.patch +9f7a2baa250baf8da686d52d16cacae3648e70b044c812bfb3e33100675a1de010b86cf2bdd39d86b957c5ccd16790c443918d0f0a66dfd5b5d7209b667a255b obstack.patch +042dee4ff7720708bee55982c876ce48645f856c902481317dad9abacc405aede40b9c4f7078bf0fe3a8fa85c788de029e7bbc6b1c5ad668a842265f6a9a873e os-linux.patch" diff --git a/user/kbuild/add-power-support.patch b/user/kbuild/add-power-support.patch new file mode 100644 index 000000000..44b6e8495 --- /dev/null +++ b/user/kbuild/add-power-support.patch @@ -0,0 +1,14 @@ +diff -ur a/src/lib/kStuff/include/k/kHlpAssert.h b/src/lib/kStuff/include/k/kHlpAssert.h +--- a/src/lib/kStuff/include/k/kHlpAssert.h 2023-10-30 23:33:28.276905143 +0000 ++++ b/src/lib/kStuff/include/k/kHlpAssert.h 2023-10-30 23:33:56.297474625 +0000 +@@ -55,6 +55,10 @@ + # define kHlpAssertBreakpoint() do { __asm__ __volatile__ ("int3"); } while (0) + #elif defined(__GNUC__) && (K_ARCH == K_ARCH_ARM_64 || K_ARCH == K_ARCH_ARM_32) /* probably not supported by older ARM CPUs */ + # define kHlpAssertBreakpoint() do { __asm__ __volatile__ ("brk #0x1"); } while (0) ++#elif defined(__GNUC__) && (K_ARCH == K_ARCH_POWERPC_32) ++# define kHlpAssertBreakpoint() do { __asm__ __volatile__ ("trap"); } while (0) ++#elif defined(__GNUC__) && (K_ARCH == K_ARCH_POWERPC_64) ++# define kHlpAssertBreakpoint() do { __asm__ __volatile__ ("trap"); } while (0) + #elif defined(__GNUC__) && (K_ARCH == K_ARCH_SPARC_32) + # define kHlpAssertBreakpoint() do { __asm__ __volatile__ ("unimp 0"); } while (0) /*??*/ + #elif defined(__GNUC__) && (K_ARCH == K_ARCH_SPARC_64) diff --git a/user/kbuild/allperms.patch b/user/kbuild/allperms.patch new file mode 100644 index 000000000..afe97f4cb --- /dev/null +++ b/user/kbuild/allperms.patch @@ -0,0 +1,44 @@ +diff -ur a/src/kash/shfile.h b/src/kash/shfile.h +--- a/src/kash/shfile.h 2023-11-01 02:51:07.351017278 +0000 ++++ b/src/kash/shfile.h 2023-11-01 02:51:24.339486663 +0000 +@@ -78,7 +78,6 @@ + # define S_IXOTH 0000001 + # define S_ISUID 0004000 + # define S_ISGID 0002000 +-# define ALLPERMS 0000777 + + # define F_DUPFD 0 + # define F_GETFD 1 +diff -ur a/src/kmk/kmkbuiltin/solfakes.h b/src/kmk/kmkbuiltin/solfakes.h +--- a/src/kmk/kmkbuiltin/solfakes.h 2023-11-01 02:51:07.359017498 +0000 ++++ b/src/kmk/kmkbuiltin/solfakes.h 2023-11-01 02:51:29.631632963 +0000 +@@ -34,7 +34,6 @@ + #endif + + #define _PATH_DEVNULL "/dev/null" +-#define ALLPERMS 0000777 + #define lutimes(path, tvs) utimes(path, tvs) + #define lchmod sol_lchmod + #define MAX(a,b) ((a) >= (b) ? (a) : (b)) +diff -ur a/src/lib/nt/ntstat.h b/src/lib/nt/ntstat.h +--- a/src/lib/nt/ntstat.h 2023-11-01 02:51:07.347017167 +0000 ++++ b/src/lib/nt/ntstat.h 2023-11-01 02:51:35.055782967 +0000 +@@ -138,7 +138,6 @@ + #define S_IXOTH 0000001 + #define S_ISUID 0004000 + #define S_ISGID 0002000 +-#define ALLPERMS 0000777 + + #endif + +diff -ur a/src/kmk/kmkbuiltin.h b/src/kmk/kmkbuiltin.h +--- a/src/kmk/kmkbuiltin.h 2023-11-01 02:53:53.623629217 +0000 ++++ b/src/kmk/kmkbuiltin.h 2023-11-01 02:55:04.813614454 +0000 +@@ -180,5 +180,7 @@ + extern void kmk_builtin_print_stats(FILE *pOutput, const char *pszPrefix); + #endif + ++#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */ ++ + #endif + diff --git a/user/kbuild/fix-nodes-newline-escape.patch b/user/kbuild/fix-nodes-newline-escape.patch new file mode 100644 index 000000000..7f61e87fd --- /dev/null +++ b/user/kbuild/fix-nodes-newline-escape.patch @@ -0,0 +1,18 @@ +Without this patch, the newline is swallowed and +the generated 'nodes.c' will not be compilable. + +The bug is in whatever code parses this file, but +this may be the only occurrence of this behavior. + +diff -ur a/src/kash/nodes.c.pat b/src/kash/nodes.c.pat +--- a/src/kash/nodes.c.pat 2023-10-30 22:27:23.308897026 +0000 ++++ b/src/kash/nodes.c.pat 2023-10-30 22:27:36.781294302 +0000 +@@ -77,7 +77,7 @@ + #ifdef KASH_SEPARATE_PARSER_ALLOCATOR + if (n != NULL) { + unsigned refs = pstackretain(n->pblock); +- TRACE2((psh, "copyfunc: %p - %u refs\n", n->pblock, refs)); K_NOREF(refs); ++ TRACE2((psh, "copyfunc: %p - %u refs\\n", n->pblock, refs)); K_NOREF(refs); + } + return n; + #else diff --git a/user/kbuild/kobjcache.patch b/user/kbuild/kobjcache.patch new file mode 100644 index 000000000..4fb4e0255 --- /dev/null +++ b/user/kbuild/kobjcache.patch @@ -0,0 +1,10 @@ +--- ./src/kObjCache/kObjCache.c.orig ++++ ./src/kObjCache/kObjCache.c +@@ -38,6 +38,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/user/kbuild/maintain b/user/kbuild/maintain new file mode 100755 index 000000000..95b8c0522 --- /dev/null +++ b/user/kbuild/maintain @@ -0,0 +1,72 @@ +#!/bin/sh -e + +## +# README +# ------ +# +# This script produces a tarball containing +# the kbuild source, including vendored deps, +# but without binaries that upstream provides. +# +# The result is a small tarball suitable for +# distribution. Note that line endings may be +# different between tarball and SVN checkout! +# +# (1) Edit APKBUILD to have the SVN revision +# that you want to target; +# +# (2) Run this script; +# +# (3) Upload the resulting tarball to a mirror +# suitable for your distribution; +# +# (4) Proceed as normal for package maintenance. +# + +HERE="$(dirname $(readlink -f ${0}))"; + +## +# Sanity checks. +# +command -v svn 2>&1 >/dev/null || (printf "E: 'svn' not found!\n" && exit 1); + + +## +# Pull version from APKBUILD, which +# must be updated first. +# +. "${HERE}"/APKBUILD; +REVISION=${pkgver##*.}; + + +## +# SVN branch to get. +# +CHECKOUT=trunk; + + +## +# Customize this at your own risk. +# +tmp=$(mktemp -d); +( +cd "${t}"; +svn co -r ${REVISION} http://svn.netlabs.org/repos/kbuild/${CHECKOUT}; +mv ${CHECKOUT} $pkgname-$pkgver; + +for k in .svn kBuild/bin; do + rm -fr $pkgname-$pkgver/${k}; +done + +tar -pczf "${HERE}"/$pkgname-$pkgver.tar.gz $pkgname-$pkgver; +) +rm -fr "${tmp}"; + + +## +# Done. +# +printf "Please upload '%s' to distfiles/source/%s/.\n" \ + "$pkgname-$pkgver.tar.gz" \ + "$pkgname" \ + ; diff --git a/user/kbuild/obstack.patch b/user/kbuild/obstack.patch new file mode 100644 index 000000000..9c2d0a317 --- /dev/null +++ b/user/kbuild/obstack.patch @@ -0,0 +1,12 @@ +diff --git a/src/sed/Makefile.kmk b/src/sed/Makefile.kmk +index f34b3e8..1734c59 100644 +--- a/src/sed/Makefile.kmk ++++ b/src/sed/Makefile.kmk +@@ -57,6 +57,7 @@ kmk_sed_SOURCES = \ + sed/mbcs.c \ + lib/getopt1.c \ + lib/getopt.c \ ++ lib/obstack.c \ + lib/utils.c + kmk_sed_SOURCES.darwin = \ + lib/strverscmp.c \ diff --git a/user/kbuild/os-linux.patch b/user/kbuild/os-linux.patch new file mode 100644 index 000000000..73d132059 --- /dev/null +++ b/user/kbuild/os-linux.patch @@ -0,0 +1,26 @@ +diff --git a/src/kmk/kmkbuiltin/fts.c b/src/kmk/kmkbuiltin/fts.c +index cdf2209..040f836 100644 +--- a/src/kmk/kmkbuiltin/fts.c ++++ b/src/kmk/kmkbuiltin/fts.c +@@ -76,7 +76,7 @@ __RCSID("$NetBSD: __fts13.c,v 1.44 2005/01/19 00:59:48 mycroft Exp $"); + #endif + + #if ! HAVE_NBTOOL_CONFIG_H +-# if !defined(__sun__) && !defined(__gnu_linux__) && !defined(__HAIKU__) ++# if !defined(__sun__) && !defined(__linux__) && !defined(__HAIKU__) + # define HAVE_STRUCT_DIRENT_D_NAMLEN 1 + # endif + #endif +diff --git a/src/lib/kStuff/include/k/kDefs.h b/src/lib/kStuff/include/k/kDefs.h +index fdaecb7..093b9b4 100644 +--- a/src/lib/kStuff/include/k/kDefs.h ++++ b/src/lib/kStuff/include/k/kDefs.h +@@ -94,7 +94,7 @@ + # define K_OS K_OS_GNU_KFBSD + # elif defined(__gnu_hurd__) + # define K_OS K_OS_GNU_HURD +-# elif defined(__gnu_linux__) ++# elif defined(__linux__) + # define K_OS K_OS_LINUX + # elif defined(__NetBSD__) /*??*/ + # define K_OS K_OS_NETBSD diff --git a/user/kbuild/sys-types.patch b/user/kbuild/sys-types.patch new file mode 100644 index 000000000..dccb48a23 --- /dev/null +++ b/user/kbuild/sys-types.patch @@ -0,0 +1,14 @@ +diff --git a/src/kmk/kmkbuiltin/ftsfake.h b/src/kmk/kmkbuiltin/ftsfake.h +index 2518d30..5410256 100644 +--- a/src/kmk/kmkbuiltin/ftsfake.h ++++ b/src/kmk/kmkbuiltin/ftsfake.h +@@ -38,6 +38,9 @@ + # include "kmkbuiltin/mscfakes.h" + #endif + ++/* for u_int */ ++#include ++ + typedef struct { + struct _ftsent *fts_cur; /* current node */ + struct _ftsent *fts_child; /* linked list of children */ -- cgit v1.2.3-70-g09d2