dev-php/pecl-ssh2: Remove masked version
[gentoo.git] / eclass / kde5-functions.eclass
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: kde5-functions.eclass
5 # @MAINTAINER:
6 # kde@gentoo.org
7 # @SUPPORTED_EAPIS: 7
8 # @BLURB: Common ebuild functions for packages based on KDE Frameworks 5.
9 # @DESCRIPTION:
10 # This eclass contains functions shared by the other KDE eclasses and forms
11 # part of their public API.
12 #
13 # This eclass must not be inherited directly by an ebuild.
14
15 if [[ -z ${_KDE5_FUNCTIONS_ECLASS} ]]; then
16 _KDE5_FUNCTIONS_ECLASS=1
17
18 case ${EAPI} in
19         7) ;;
20         *) die "EAPI=${EAPI:-0} is not supported" ;;
21 esac
22
23 # @ECLASS-VARIABLE: QT_MINIMAL
24 # @DESCRIPTION:
25 # Minimum version of Qt to require. This affects add_qt_dep.
26 : ${QT_MINIMAL:=5.12.3}
27
28 # @ECLASS-VARIABLE: FRAMEWORKS_MINIMAL
29 # @DESCRIPTION:
30 # Minimum version of Frameworks to require. This affects add_frameworks_dep.
31 : ${FRAMEWORKS_MINIMAL:=5.60.0}
32
33 # @ECLASS-VARIABLE: PLASMA_MINIMAL
34 # @DESCRIPTION:
35 # Minimum version of Plasma to require. This affects add_plasma_dep.
36 : ${PLASMA_MINIMAL:=5.15.5}
37
38 # @ECLASS-VARIABLE: KDE_APPS_MINIMAL
39 # @DESCRIPTION:
40 # Minimum version of KDE Applications to require. This affects add_kdeapps_dep.
41 : ${KDE_APPS_MINIMAL:=19.04.3}
42
43 # @FUNCTION: _add_category_dep
44 # @INTERNAL
45 # @DESCRIPTION:
46 # Implementation of add_plasma_dep, add_frameworks_dep, add_kdeapps_dep,
47 # and finally, add_qt_dep.
48 _add_category_dep() {
49         debug-print-function ${FUNCNAME} "$@"
50
51         local category=${1}
52         local package=${2}
53         local use=${3}
54         local version=${4}
55         local slot=${5}
56
57         if [[ -n ${use} ]] ; then
58                 local use="[${use}]"
59         fi
60
61         if [[ -n ${version} ]] ; then
62                 local operator=">="
63                 local version="-${version}"
64         fi
65
66         if [[ -n ${slot} ]] ; then
67                 slot=":${slot}"
68         elif [[ ${SLOT%\/*} = 5 ]] ; then
69                 slot=":${SLOT%\/*}"
70         fi
71
72         echo " ${operator}${category}/${package}${version}${slot}${use}"
73 }
74
75 # @FUNCTION: add_frameworks_dep
76 # @USAGE: <package name> [USE flags] [minimum version] [slot + operator]
77 # @DESCRIPTION:
78 # Create proper dependency for kde-frameworks/ dependencies.
79 # This takes 1 to 4 arguments. The first being the package name, the optional
80 # second is additional USE flags to append, and the optional third is the
81 # version to use instead of the automatic version (use sparingly). In addition,
82 # the optional fourth argument defines slot+operator instead of automatic slot
83 # (use even more sparingly).
84 # The output of this should be added directly to DEPEND/RDEPEND, and may be
85 # wrapped in a USE conditional (but not an || conditional without an extra set
86 # of parentheses).
87 # PORTING: no replacement
88 add_frameworks_dep() {
89         debug-print-function ${FUNCNAME} "$@"
90
91         if [[ $# -gt 4 ]]; then
92                 die "${FUNCNAME} was called with too many arguments"
93         fi
94
95         local version
96
97         if [[ -n ${3} ]]; then
98                 version=${3}
99         elif [[ ${CATEGORY} = kde-frameworks ]]; then
100                 version=$(ver_cut 1-2)
101         elif [[ -z ${3} ]] ; then
102                 version=${FRAMEWORKS_MINIMAL}
103         fi
104
105         _add_category_dep kde-frameworks "${1}" "${2}" "${version}" "${4}"
106 }
107
108 # @FUNCTION: add_plasma_dep
109 # @USAGE: <package name> [USE flags] [minimum version] [slot + operator]
110 # @DESCRIPTION:
111 # Create proper dependency for kde-plasma/ dependencies.
112 # This takes 1 to 4 arguments. The first being the package name, the optional
113 # second is additional USE flags to append, and the optional third is the
114 # version to use instead of the automatic version (use sparingly). In addition,
115 # the optional fourth argument defines slot+operator instead of automatic slot
116 # (use even more sparingly).
117 # The output of this should be added directly to DEPEND/RDEPEND, and may be
118 # wrapped in a USE conditional (but not an || conditional without an extra set
119 # of parentheses).
120 # PORTING: no replacement
121 add_plasma_dep() {
122         debug-print-function ${FUNCNAME} "$@"
123
124         if [[ $# -gt 4 ]]; then
125                 die "${FUNCNAME} was called with too many arguments"
126         fi
127
128         local version
129
130         if [[ -n ${3} ]]; then
131                 version=${3}
132         elif [[ ${CATEGORY} = kde-plasma ]]; then
133                 version=$(ver_cut 1-3)
134         elif [[ -z ${3} ]] ; then
135                 version=${PLASMA_MINIMAL}
136         fi
137
138         _add_category_dep kde-plasma "${1}" "${2}" "${version}" "${4}"
139 }
140
141 # @FUNCTION: add_kdeapps_dep
142 # @USAGE: <package name> [USE flags] [minimum version] [slot + operator]
143 # @DESCRIPTION:
144 # Create proper dependency for kde-apps/ dependencies.
145 # This takes 1 to 4 arguments. The first being the package name, the optional
146 # second is additional USE flags to append, and the optional third is the
147 # version to use instead of the automatic version (use sparingly). In addition,
148 # the optional fourth argument defines slot+operator instead of automatic slot
149 # (use even more sparingly).
150 # The output of this should be added directly to DEPEND/RDEPEND, and may be
151 # wrapped in a USE conditional (but not an || conditional without an extra set
152 # of parentheses).
153 # PORTING: no replacement
154 add_kdeapps_dep() {
155         debug-print-function ${FUNCNAME} "$@"
156
157         if [[ $# -gt 4 ]]; then
158                 die "${FUNCNAME} was called with too many arguments"
159         fi
160
161         local version
162
163         if [[ -n ${3} ]]; then
164                 version=${3}
165         elif [[ ${CATEGORY} = kde-apps ]]; then
166                 version=$(ver_cut 1-3)
167         elif [[ -z ${3} ]] ; then
168                 version=${KDE_APPS_MINIMAL}
169         fi
170
171         _add_category_dep kde-apps "${1}" "${2}" "${version}" "${4}"
172 }
173
174 # @FUNCTION: add_qt_dep
175 # @USAGE: <package name> [USE flags] [minimum version] [slot + operator]
176 # @DESCRIPTION:
177 # Create proper dependency for dev-qt/ dependencies.
178 # This takes 1 to 4 arguments. The first being the package name, the optional
179 # second is additional USE flags to append, and the optional third is the
180 # version to use instead of the automatic version (use sparingly). In addition,
181 # the optional fourth argument defines slot+operator instead of automatic slot
182 # (use even more sparingly).
183 # The output of this should be added directly to DEPEND/RDEPEND, and may be
184 # wrapped in a USE conditional (but not an || conditional without an extra set
185 # of parentheses).
186 # PORTING: no replacement
187 add_qt_dep() {
188         debug-print-function ${FUNCNAME} "$@"
189
190         if [[ $# -gt 4 ]]; then
191                 die "${FUNCNAME} was called with too many arguments"
192         fi
193
194         local version=${3}
195         local slot=${4}
196
197         if [[ -z ${version} ]]; then
198                 version=${QT_MINIMAL}
199         fi
200         if [[ -z ${slot} ]]; then
201                 slot="5"
202         fi
203
204         _add_category_dep dev-qt "${1}" "${2}" "${version}" "${slot}"
205 }
206
207 # @FUNCTION: punt_bogus_dep
208 # @USAGE: <prefix> <dependency>
209 # @DESCRIPTION:
210 # Removes a specified dependency from a find_package call with multiple components.
211 # PORTING: Use ecm_punt_bogus_dep from ecm.eclass instead.
212 punt_bogus_dep() {
213         local prefix=${1}
214         local dep=${2}
215
216         if [[ ! -e "CMakeLists.txt" ]]; then
217                 return
218         fi
219
220         pcregrep -Mni "(?s)find_package\s*\(\s*${prefix}[^)]*?${dep}.*?\)" CMakeLists.txt > "${T}/bogus${dep}"
221
222         # pcregrep returns non-zero on no matches/error
223         if [[ $? != 0 ]] ; then
224                 return
225         fi
226
227         local length=$(wc -l "${T}/bogus${dep}" | cut -d " " -f 1)
228         local first=$(head -n 1 "${T}/bogus${dep}" | cut -d ":" -f 1)
229         local last=$(( ${length} + ${first} - 1))
230
231         sed -e "${first},${last}s/${dep}//" -i CMakeLists.txt || die
232
233         if [[ ${length} = 1 ]] ; then
234                 sed -e "/find_package\s*(\s*${prefix}\(\s\+\(REQUIRED\|CONFIG\|COMPONENTS\|\${[A-Z0-9_]*}\)\)\+\s*)/Is/^/# removed by kde5-functions.eclass - /" -i CMakeLists.txt || die
235         fi
236 }
237
238 fi