Gentoo Archives: gentoo-dev

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-dev@l.g.o
Cc: "Ulrich Müller" <ulm@g.o>
Subject: [gentoo-dev] [PATCH] wrapper.eclass: Drop support for EAPIs 0 to 4
Date: Thu, 31 Mar 2022 07:40:57
Message-Id: 20220331074037.11095-1-ulm@gentoo.org
1 - Add EAPI conditional
2 - Drop unnecessary die statements
3 - Use sed instead of cat, to preserve indentation of output
4
5 Signed-off-by: Ulrich Müller <ulm@g.o>
6 ---
7 eclass/wrapper.eclass | 17 +++++++++++------
8 1 file changed, 11 insertions(+), 6 deletions(-)
9
10 diff --git a/eclass/wrapper.eclass b/eclass/wrapper.eclass
11 index 399c7cc269d4..8d3d273d81c6 100644
12 --- a/eclass/wrapper.eclass
13 +++ b/eclass/wrapper.eclass
14 @@ -1,59 +1,64 @@
15 -# Copyright 1999-2020 Gentoo Authors
16 +# Copyright 1999-2022 Gentoo Authors
17 # Distributed under the terms of the GNU General Public License v2
18
19 # @ECLASS: wrapper.eclass
20 # @MAINTAINER:
21 # base-system@g.o
22 +# @SUPPORTED_EAPIS: 5 6 7 8
23 # @BLURB: create a shell wrapper script
24
25 +case ${EAPI} in
26 + 5|6|7|8) ;;
27 + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
28 +esac
29 +
30 if [[ -z ${_WRAPPER_ECLASS} ]]; then
31 _WRAPPER_ECLASS=1
32
33 # @FUNCTION: make_wrapper
34 # @USAGE: <wrapper> <target> [chdir] [libpaths] [installpath]
35 # @DESCRIPTION:
36 # Create a shell wrapper script named wrapper in installpath
37 # (defaults to the bindir) to execute target (default of wrapper)
38 # by first optionally setting LD_LIBRARY_PATH to the colon-delimited
39 # libpaths followed by optionally changing directory to chdir.
40 make_wrapper() {
41 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5
42 local tmpwrapper="${T}/tmp.wrapper.${wrapper##*/}"
43 - has "${EAPI:-0}" 0 1 2 && local EPREFIX=""
44
45 (
46 echo '#!/bin/sh'
47 if [[ -n ${libdir} ]] ; then
48 local var
49 if [[ ${CHOST} == *-darwin* ]] ; then
50 var=DYLD_LIBRARY_PATH
51 else
52 var=LD_LIBRARY_PATH
53 fi
54 - cat <<-EOF
55 + sed 's/^X//' <<-EOF || die
56 if [ "\${${var}+set}" = "set" ] ; then
57 - export ${var}="\${${var}}:${EPREFIX}${libdir}"
58 + X export ${var}="\${${var}}:${EPREFIX}${libdir}"
59 else
60 - export ${var}="${EPREFIX}${libdir}"
61 + X export ${var}="${EPREFIX}${libdir}"
62 fi
63 EOF
64 fi
65 [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}"
66 # We don't want to quote ${bin} so that people can pass complex
67 # things as ${bin} ... "./someprog --args"
68 printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}"
69 ) > "${tmpwrapper}"
70 chmod go+rx "${tmpwrapper}"
71
72 if [[ -n ${path} ]] ; then
73 (
74 exeopts -m 0755
75 exeinto "${path}"
76 newexe "${tmpwrapper}" "${wrapper}"
77 ) || die
78 else
79 - newbin "${tmpwrapper}" "${wrapper}" || die
80 + newbin "${tmpwrapper}" "${wrapper}"
81 fi
82 }
83
84 fi
85 --
86 2.35.1