blob: 973b722ba321d147feb695a0d4d0add4d7175125 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001# Copyright (c) 2022, Snap Inc.
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4PROVIDES = "coreutils"
5RPROVIDES:${PN} = "coreutils"
6
7PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)}"
8
9PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux"
10
11CARGO_BUILD_FLAGS += "--features unix"
12CARGO_BUILD_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'selinux', '--features feat_selinux', '', d)}"
13
14DEPENDS += "${@bb.utils.contains('PACKAGECONFIG', 'selinux', 'clang-native libselinux-native', '', d)}"
15
16export LIBCLANG_PATH = "${WORKDIR}/recipe-sysroot-native${libdir}"
17export SELINUX_LIB_DIR = "${WORKDIR}/recipe-sysroot-native${libdir}"
18export SELINUX_INCLUDE_DIR = "${WORKDIR}/recipe-sysroot-native${includedir}"
19
20# The code which follows is strongly inspired from the GNU coreutils bitbake recipe:
21
22# [ df mktemp nice printenv base64 gets a special treatment and is not included in this
23bindir_progs = "[ arch basename cksum comm csplit cut dir dircolors dirname du \
24 env expand expr factor fmt fold groups head hostid id install \
25 join link logname md5sum mkfifo nl nohup nproc od paste pathchk \
26 pinky pr printf ptx readlink realpath seq sha1sum sha224sum sha256sum \
27 sha384sum sha512sum shred shuf sort split sum tac tail tee test timeout \
28 tr truncate tsort tty unexpand uniq unlink uptime users vdir wc who whoami yes"
29
30bindir_progs += "${@bb.utils.contains('PACKAGECONFIG', 'selinux', 'chcon runcon', '', d)}"
31
32base_bindir_progs = "cat chgrp chmod chown cp date dd echo false hostname kill ln ls mkdir \
33 mknod mv pwd rm rmdir sleep stty sync touch true uname stat"
34
35sbindir_progs= "chroot"
36
37inherit update-alternatives
38
39# Higher than busybox (which uses 50)
40ALTERNATIVE_PRIORITY = "100"
41
42# Higher than net-tools (which uses 100)
43ALTERNATIVE_PRIORITY[hostname] = "110"
44
45ALTERNATIVE:${PN} = "${bindir_progs} ${base_bindir_progs} ${sbindir_progs} base32 base64 nice printenv mktemp df"
46
47# Use the multicall binary named "coreutils" for symlinks
48ALTERNATIVE_TARGET = "${bindir}/coreutils"
49
50python __anonymous() {
51 for prog in d.getVar('base_bindir_progs').split():
52 d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('base_bindir'), prog))
53
54 for prog in d.getVar('sbindir_progs').split():
55 d.setVarFlag('ALTERNATIVE_LINK_NAME', prog, '%s/%s' % (d.getVar('sbindir'), prog))
56}