summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2022-12-01 18:26:45 +0100
committerMichał Górny <mgorny@gentoo.org>2022-12-02 04:47:23 +0100
commitd3a446d11fd0061c5826f18c0dc5d5a4b49dc4c1 (patch)
tree11c8c4ca998501e2282289f4f888dc52affa1314 /app-alternatives
parentMove {virtual → app-alternatives}/awk (diff)
downloadgentoo-d3a446d11fd0061c5826f18c0dc5d5a4b49dc4c1.tar.gz
gentoo-d3a446d11fd0061c5826f18c0dc5d5a4b49dc4c1.tar.bz2
gentoo-d3a446d11fd0061c5826f18c0dc5d5a4b49dc4c1.zip
app-alternatives/awk: New package to control awk symlinks
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'app-alternatives')
-rw-r--r--app-alternatives/awk/awk-2.ebuild59
-rw-r--r--app-alternatives/awk/metadata.xml20
2 files changed, 78 insertions, 1 deletions
diff --git a/app-alternatives/awk/awk-2.ebuild b/app-alternatives/awk/awk-2.ebuild
new file mode 100644
index 000000000000..01e69d65fbd1
--- /dev/null
+++ b/app-alternatives/awk/awk-2.ebuild
@@ -0,0 +1,59 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="/bin/awk and /usr/bin/awk symlinks"
+HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Base/Alternatives"
+SRC_URI=""
+S=${WORKDIR}
+
+LICENSE="CC0-1.0"
+SLOT="0"
+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 )"
+
+RDEPEND="
+ busybox? ( sys-apps/busybox )
+ gawk? ( sys-apps/gawk )
+ mawk? ( sys-apps/mawk )
+ nawk? ( sys-apps/nawk )
+ !app-eselect/eselect-awk
+"
+
+src_install() {
+ local root_prefix=
+ use split-usr && root_prefix=../../bin/
+
+ if use busybox; then
+ 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
+
+ if use split-usr; then
+ dosym ../usr/bin/awk /bin/awk
+ fi
+}
+
+pkg_postrm() {
+ # make sure we don't leave the user without the symlinks, since
+ # they've not been owned by any other package
+ if [[ ! -h ${EROOT}/usr/bin/awk ]]; then
+ ln -s gawk "${EROOT}/usr/bin/awk" || die
+ fi
+ if [[ ! -h ${EROOT}/bin/awk ]]; then
+ ln -s ../usr/bin/awk "${EROOT}/bin/awk" || die
+ fi
+}
diff --git a/app-alternatives/awk/metadata.xml b/app-alternatives/awk/metadata.xml
index 38ea143badef..0cf5fbf0d2f2 100644
--- a/app-alternatives/awk/metadata.xml
+++ b/app-alternatives/awk/metadata.xml
@@ -9,5 +9,23 @@
<email>base-system@gentoo.org</email>
<name>Gentoo Base System</name>
</maintainer>
- <stabilize-allarches/>
+ <maintainer type="person">
+ <email>mgorny@gentoo.org</email>
+ <name>Michał Górny</name>
+ </maintainer>
+ <use>
+ <flag name="busybox">
+ Symlink to <pkg>sys-apps/busybox</pkg>
+ </flag>
+ <flag name="gawk">
+ Symlink to <pkg>sys-apps/gawk</pkg>
+ </flag>
+ <flag name="mawk">
+ Symlink to <pkg>sys-apps/mawk</pkg> (warning: mawk is
+ not fully POSIX-compliant)
+ </flag>
+ <flag name="nawk">
+ Symlink to <pkg>sys-apps/nawk</pkg>
+ </flag>
+ </use>
</pkgmetadata>