xarblu / xarblu-overlay

My personal overlay of Gentoo GNU/Linux ebuilds
11 stars 2 forks source link

sys-kernel/scx: add a live ebuild #474

Closed Username404-59 closed 1 month ago

Username404-59 commented 2 months ago

This still needs the specific commits for bpftool & libbpf but works

get_clang_ver was fixed in scx so I removed usage of the patch too.

xarblu commented 2 months ago

It's not pretty but this src_unpack seems to work:

src_unpack() {
    # main src
    git-r3_src_unpack

    # bpf src
    (
        EGIT_REPO_URI="${BPFTOOL_REPO_URI}"
        EGIT_CHECKOUT_DIR="${WORKDIR}/bpftool"
        EGIT_COMMIT="${BPFTOOL_COMMIT}"
        git-r3_src_unpack
        EGIT_REPO_URI="${LIBBPF_REPO_URI}"
        EGIT_CHECKOUT_DIR="${WORKDIR}/libbpf"
        EGIT_COMMIT="${LIBBPF_COMMIT}"
        git-r3_src_unpack
    )

    # rust src
    # vendor each to it's own dir...
    shopt -s globstar
    for manifest in ${S}/**/Cargo.toml; do
        (
            S="${manifest%/*}"
            ECARGO_VENDOR="${ECARGO_VENDOR}-${S##*/}"
            cargo() {
                local args=( "${@}" )
                case "${args[0]}" in
                    vendor) /usr/bin/cargo vendor --versioned-dirs "${args[@]:1}";;
                    *) /usr/bin/cargo "${args[@]}";;
                esac
            }
            einfo "Vendoring ${ECARGO_VENDOR}"
            cargo_live_src_unpack
        )
    done
    shopt -u globstar

    # ...then merge
    einfo "Merging ECARGO_VENDOR dirs"
    mkdir -p "${ECARGO_VENDOR}" || die
    for dir in "${ECARGO_VENDOR}"-*; do
        for crate in "${dir}"/*; do
            if [[ ! -d "${ECARGO_VENDOR}/${crate##*/}" ]]; then
                einfo ">>> ${crate##*/}"
                mv "${crate}" "${ECARGO_VENDOR}" || die
            fi
        done
        rm -rf "${dir}" || die
    done
    cargo_gen_config
}

cargo vendor removes everything not required by the current project from ECARGO_VENDOR directory so we need to unpack each project separately and then merge them together

xarblu commented 1 month ago

Sorry for the wait. Looks good now!