gexcite wrote:Na tą chwilę tak właśnie mam. Chciałem to wpakować w jeden, aby było bardziej elegancko. Mam wrażenie, że takie rozwiązanie widziałem, ale za nic nie mogę go znaleźć.
Eblit?
np glibc:
Code: Select all
/var/portage/gentoo/sys-libs/glibc/files/eblits/common.eblit
/var/portage/gentoo/sys-libs/glibc/files/eblits/pkg_postinst.eblit
/var/portage/gentoo/sys-libs/glibc/files/eblits/pkg_preinst.eblit
/var/portage/gentoo/sys-libs/glibc/files/eblits/pkg_pretend.eblit
/var/portage/gentoo/sys-libs/glibc/files/eblits/pkg_setup.eblit
/var/portage/gentoo/sys-libs/glibc/files/eblits/src_compile.eblit
/var/portage/gentoo/sys-libs/glibc/files/eblits/src_configure.eblit
/var/portage/gentoo/sys-libs/glibc/files/eblits/src_install.eblit
/var/portage/gentoo/sys-libs/glibc/files/eblits/src_prepare.eblit
/var/portage/gentoo/sys-libs/glibc/files/eblits/src_test.eblit
/var/portage/gentoo/sys-libs/glibc/files/eblits/src_unpack.eblit
W ebuildzie sys-libs/glibc-2.23-r3:
Code: Select all
eblit-include() {
local skipable=false
[[ $1 == "--skip" ]] && skipable=true && shift
[[ $1 == pkg_* ]] && skipable=true
local e v func=$1 ver=$2
[[ -z ${func} ]] && die "Usage: eblit-include <function> [version]"
for v in ${ver:+-}${ver} -${PVR} -${PV} "" ; do
e="${FILESDIR}/eblits/${func}${v}.eblit"
if [[ -e ${e} ]] ; then
source "${e}"
return 0
fi
done
${skipable} && return 0
die "Could not locate requested eblit '${func}' in ${FILESDIR}/eblits/"
}
# eblit-run-maybe <function>
# run the specified function if it is defined
eblit-run-maybe() {
[[ $(type -t "$@") == "function" ]] && "$@"
}
# eblit-run <function> [version]
# aka: src_unpack() { eblit-run src_unpack ; }
eblit-run() {
eblit-include --skip common "${*:2}"
eblit-include "$@"
eblit-run-maybe eblit-$1-pre
eblit-${PN}-$1
eblit-run-maybe eblit-$1-post
}
Pozdro
