mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-19 13:31:28 +02:00
app-alternatives/awk: Sync with Gentoo
It's from Gentoo commit d4c96a45f9e0c5401a6d4df4867dc85348fd7989.
This commit is contained in:
parent
fed5a37dec
commit
54dc427086
@ -3,53 +3,68 @@
|
||||
|
||||
EAPI=8
|
||||
|
||||
DESCRIPTION="/bin/awk and /usr/bin/awk symlinks"
|
||||
HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Base/Alternatives"
|
||||
SRC_URI=""
|
||||
S=${WORKDIR}
|
||||
ALTERNATIVES=(
|
||||
gawk:sys-apps/gawk
|
||||
busybox:sys-apps/busybox
|
||||
mawk:sys-apps/mawk
|
||||
nawk:sys-apps/nawk
|
||||
)
|
||||
|
||||
LICENSE="CC0-1.0"
|
||||
SLOT="0"
|
||||
inherit app-alternatives
|
||||
|
||||
DESCRIPTION="/bin/awk and /usr/bin/awk symlinks"
|
||||
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
|
||||
IUSE="busybox +gawk mawk nawk split-usr"
|
||||
REQUIRED_USE="^^ ( busybox gawk mawk nawk )"
|
||||
IUSE="split-usr"
|
||||
|
||||
RDEPEND="
|
||||
busybox? ( sys-apps/busybox )
|
||||
gawk? ( sys-apps/gawk )
|
||||
mawk? ( sys-apps/mawk )
|
||||
nawk? ( sys-apps/nawk )
|
||||
!app-eselect/eselect-awk
|
||||
"
|
||||
|
||||
src_install() {
|
||||
local alt=$(get_alternative)
|
||||
local root_prefix=
|
||||
use split-usr && root_prefix=../../bin/
|
||||
|
||||
# We could consider setting AWK=... like we do for yacc & lex,
|
||||
# but it would need some testing with a fair amount of packages first,
|
||||
# as autoconf prefers gawk.
|
||||
if use busybox; then
|
||||
case ${alt} in
|
||||
busybox)
|
||||
dosym "${root_prefix}busybox" /usr/bin/awk
|
||||
newman - awk.1 <<<".so busybox.1"
|
||||
elif use gawk; then
|
||||
dosym gawk /usr/bin/awk
|
||||
newman - awk.1 <<<".so gawk.1"
|
||||
elif use mawk; then
|
||||
dosym mawk /usr/bin/awk
|
||||
newman - awk.1 <<<".so mawk.1"
|
||||
elif use nawk; then
|
||||
dosym nawk /usr/bin/awk
|
||||
newman - awk.1 <<<".so nawk.1"
|
||||
else
|
||||
die "Invalid USE flag combination (broken REQUIRED_USE?)"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
dosym "${alt}" /usr/bin/awk
|
||||
;;
|
||||
esac
|
||||
|
||||
newman - awk.1 <<<".so ${alt}.1"
|
||||
|
||||
if use split-usr; then
|
||||
dosym ../usr/bin/awk /bin/awk
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_preinst() {
|
||||
local v
|
||||
for v in ${REPLACING_VERSIONS}; do
|
||||
# if we are upgrading from a new enough version, leftover manpage
|
||||
# symlink cleanup was done already
|
||||
if ver_test "${v}" -ge 3; then
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
# otherwise, remove leftover files/symlinks created by eselect-awk (sic!)
|
||||
shopt -s nullglob
|
||||
local files=( "${EROOT}"/usr/share/man/man1/awk.1* )
|
||||
shopt -u nullglob
|
||||
|
||||
if [[ ${files[@]} ]]; then
|
||||
einfo "Cleaning up leftover manpage symlinks from eselect-awk ..."
|
||||
rm -v "${files[@]}" || die
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_postrm() {
|
||||
# make sure we don't leave the user without the symlinks, since
|
||||
# they've not been owned by any other package
|
Loading…
x
Reference in New Issue
Block a user