# TODO Fix coreutils i18n/l10n behavior on Redox
# TODO Fix locale init bug on aarch64 before removing patches
# TODO https://github.com/uutils/coreutils/commit/e6f7ad06 broke locales on x86_64
[source]
git = "https://github.com/uutils/coreutils"
rev = "1f7c81f5d2d3e56c518349c0392158871a1ea9ec"
patches = [
  "redox.patch"
]

[build]
template = "custom"
script = """
DYNAMIC_INIT
# TODO: upstream changes, consider using feat_require_unix_core if relibc is ready?
CARGO_PROFILE_RELEASE_LTO=thin cookbook_cargo --no-default-features --features feat_os_unix_redox,kill,nice --bin coreutils

BINS=(
    '['
    b2sum
    b3sum
    base32
    base64
    basename
    basenc
    cat
    chmod
    cksum
    comm
    cp
    csplit
    cut
    date
    dd
    #df not working, use redox coreutils
    dir
    dircolors
    dirname
    du
    echo
    env
    expand
    expr
    factor
    false
    fmt
    fold
    hashsum
    head
    join
    install
    kill
    link
    ln
    ls
    md5sum
    mkdir
    mktemp
    more
    mv
    nl
    nice
    nproc
    numfmt
    od
    paste
    pr
    printenv
    printf
    ptx
    pwd
    readlink
    realpath
    rm
    rmdir
    seq
    sha1sum
    sha224sum
    sha256sum
    sha3-224sum
    sha3-256sum
    sha3-384sum
    sha3-512sum
    sha384sum
    sha3sum
    sha512sum
    shake128sum
    shake256sum
    shred
    shuf
    sleep
    sort
    split
    stat
    sum
    tac
    tail
    tee
    test
    touch
    tr
    true
    truncate
    tsort
    unexpand
    uname
    uniq
    unlink
    vdir
    wc
    yes
)

for bin in "${BINS[@]}"
do
  ln -sv coreutils "${COOKBOOK_STAGE}/usr/bin/$bin"
done
"""
