commit: 701d1b0d36845e90a9c17e68938d7e30cf86e506
parent a6dbef0e2d84fa57fb0757d0aa4c8c34b32bbddc
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 7 Sep 2024 13:39:45 +0200
pkg/utils-std: new
Diffstat:
8 files changed, 127 insertions(+), 6 deletions(-)
diff --git a/.gitmodules b/.gitmodules
@@ -401,3 +401,6 @@
path = pkg/zstd/src
url = https://github.com/facebook/zstd
ignore = all
+[submodule "pkg/utils-std/src"]
+ path = pkg/utils-std/src
+ url = https://anongit.hacktivis.me/git/utils-std.git
diff --git a/pkg/binutils/gen.lua b/pkg/binutils/gen.lua
@@ -194,7 +194,6 @@ sub('binutils.ninja', function()
cc('binutils/objdump.c', nil, {cflags='$cflags -D OBJDUMP_PRIVATE_VECTORS='})
exe('bin/size', [[binutils/size.c libcommon.a.d]])
exe('bin/objcopy', [[binutils/(objcopy.c not-strip.c) libcommon.a.d]])
- exe('bin/strings', [[binutils/strings.c libcommon.a.d]])
exe('bin/readelf', [[binutils/(readelf.c unwind-ia64.c) libcommon.a.d]])
exe('bin/elfedit', [[binutils/elfedit.c libcommon.a.d]])
exe('bin/strip', [[binutils/(objcopy.c.o is-strip.c) libcommon.a.d]])
@@ -212,7 +211,7 @@ sub('binutils.ninja', function()
exe('bin/ar', {arobjs, 'binutils/not-ranlib.c'})
exe('bin/ranlib', {arobjs, 'binutils/is-ranlib.c'})
- for _, tool in ipairs{'size', 'objcopy', 'strings', 'readelf', 'elfedit', 'strip', 'nm', 'objdump', 'addr2line', 'ar', 'ranlib'} do
+ for _, tool in ipairs{'size', 'objcopy', 'readelf', 'elfedit', 'strip', 'nm', 'objdump', 'addr2line', 'ar', 'ranlib'} do
file('bin/'..tool, '755', '$outdir/bin/'..tool)
man{'binutils/doc/'..tool..'.1'}
sym(string.format('bin/%s-%s', config.target.platform, tool), tool)
diff --git a/pkg/gen.lua b/pkg/gen.lua
@@ -132,6 +132,7 @@ subgen 'usbids'
subgen 'u-boot'
subgen 'utf8proc'
subgen 'util-linux'
+subgen 'utils-std'
subgen 'velox'
subgen 'vis'
subgen 'wayland'
diff --git a/pkg/ubase/gen.lua b/pkg/ubase/gen.lua
@@ -31,7 +31,7 @@ local tools = {
{'chvt', 1},
{'clear', 1},
{'ctrlaltdel', 8},
- {'df', 1},
+ -- {'df', 1},
{'dmesg', 1},
{'eject', 1},
{'fallocate', 1},
@@ -41,7 +41,7 @@ local tools = {
{'getty', 8},
{'halt', 8},
{'hwclock', 8},
- {'id', 1},
+ -- {'id', 1},
{'insmod', 8},
{'killall5', 8},
{'last'},
@@ -70,7 +70,7 @@ local tools = {
{'swapon', 8},
{'switch_root', 8},
{'sysctl', 8},
- {'truncate', 1},
+ -- {'truncate', 1},
{'umount', 8},
{'unshare', 1},
{'uptime', 1},
diff --git a/pkg/utils-std/gen.lua b/pkg/utils-std/gen.lua
@@ -0,0 +1,116 @@
+cflags{
+ '-std=c99', '-Wall', '-Wwrite-strings',
+}
+
+rule('sys_signame', '$srcdir/lib/sys_signame.sh >$out')
+build('sys_signame', '$outdir/lib/sys_signame.c', {'|', '$srcdir/lib/sys_signame.sh'})
+
+lib('lib.a', [[lib/(
+ bytes2hex.c
+ consent.c
+ fs.c
+ humanize.c
+ iso_parse.c
+ mkdir.c
+ mode.c
+ sha1.c
+ strtodur.c
+ symbolize_mode.c
+ tr_str.c
+ truncation.c
+ user_group_parse.c
+)]])
+
+local cmds = {
+ 'arch',
+ 'base64',
+ 'basename',
+ 'cat',
+ 'chmod',
+ 'chown',
+ 'chroot',
+ 'cksum',
+ 'cmp',
+ 'cut',
+ 'date',
+ 'df',
+ 'dirname',
+ 'echo',
+ 'env',
+ 'false',
+ 'head',
+ 'id',
+ 'install',
+ 'join',
+ 'link',
+ 'ln',
+ 'logname',
+ 'mkdir',
+ 'mkfifo',
+ 'mknod',
+ 'mktemp',
+ 'mv',
+ 'nice',
+ 'nohup',
+ 'nproc',
+ 'pathchk',
+ 'printf',
+ 'pwd',
+ 'realpath',
+ 'rm',
+ 'rmdir',
+ 'seq',
+ 'sha1sum',
+ 'sleep',
+ 'split',
+ 'strings',
+ 'sync',
+ 'tee',
+ 'test',
+ 'time',
+ 'touch',
+ 'tr',
+ 'true',
+ 'truncate',
+ 'tty',
+ 'uname',
+ 'uniq',
+ 'unlink',
+ 'wc',
+ 'which',
+ 'yes',
+}
+for _, cmd in ipairs(cmds) do
+ local src = cmd
+ local deps
+ file('bin/'..cmd, '755', exe(cmd, {'cmd/'..src..'.c', 'lib.a'}, deps))
+ local out = '$outdir/'..cmd..'.1.gz'
+ -- build('gzip', out, '$srcdir/cmd/'..src..'.1')
+ -- file('share/man/man1/'..cmd..'.1.gz', '644', out)
+end
+
+sym('bin/[', 'test')
+sym('bin/chgrp', 'chown')
+sym('bin/readlink', 'realpath')
+
+sub('expr.ninja', function()
+ cflags{'-D_POSIX_C_SOURCE=200809L'}
+ yacc('cmd/expr', 'cmd/expr.y')
+ exe('expr', [[
+ $outdir/cmd/expr.tab.c
+ lib.a
+ ]])
+ file('bin/expr', '755', '$outdir/expr')
+end)
+
+file('bin/timeout', '755',
+ exe('timeout', {'cmd/timeout.c', 'lib.a',
+ cc('$outdir/lib/sys_signame.c', {}, {cflags='-I $srcdir/lib/'})
+ })
+)
+
+-- TODO: binutils' config/lib-ld.m4 should use AC_REQUIRE([AC_PROG_EGREP]) and
+-- $EGREP instead of egrep.
+--file('bin/egrep', '755', '$dir/egrep')
+
+fetch 'git'
diff --git a/pkg/utils-std/src b/pkg/utils-std/src
@@ -0,0 +1 @@
+Subproject commit 9028fdf9b20566fe6836fc72b8b28e4405f5f7b1
diff --git a/pkg/utils-std/ver b/pkg/utils-std/ver
@@ -0,0 +1 @@
+9028fdf r0
diff --git a/sets.lua b/sets.lua
@@ -22,7 +22,6 @@ return {
'pigz',
'rc',
'samurai',
- 'sbase',
'sdhcp',
'sinit',
'skeleton',
@@ -30,6 +29,7 @@ return {
'tz',
'ubase',
'util-linux',
+ 'utils-std',
'xz',
},
extra={