dev-libs/gmime: default enable USE=vala
[gentoo.git] / eclass / kde.org.eclass
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: kde.org.eclass
5 # @MAINTAINER:
6 # kde@gentoo.org
7 # @SUPPORTED_EAPIS: 7
8 # @BLURB: Support eclass for packages that are hosted on kde.org infrastructure.
9 # @DESCRIPTION:
10 # This eclass is mainly providing facilities for the upstream release groups
11 # Frameworks, Plasma, Applications to assemble default SRC_URI for tarballs,
12 # set up git-r3.eclass for stable/master branch versions or restrict access to
13 # unreleased (packager access only) tarballs in Gentoo KDE overlay, but it may
14 # be also used by any other package hosted on kde.org.
15 # It also contains default meta variables for settings not specific to any
16 # particular build system.
17
18 if [[ -z ${_KDE_ORG_ECLASS} ]]; then
19 _KDE_ORG_ECLASS=1
20
21 # @ECLASS-VARIABLE: KDE_BUILD_TYPE
22 # @DESCRIPTION:
23 # If PV matches "*9999*", this is automatically set to "live".
24 # Otherwise, this is automatically set to "release".
25 KDE_BUILD_TYPE="release"
26 if [[ ${PV} = *9999* ]]; then
27         KDE_BUILD_TYPE="live"
28 fi
29 export KDE_BUILD_TYPE
30
31 if [[ ${KDE_BUILD_TYPE} = live ]]; then
32         inherit git-r3
33 fi
34
35 EXPORT_FUNCTIONS pkg_nofetch src_unpack
36
37 # @ECLASS-VARIABLE: KDE_ORG_NAME
38 # @DESCRIPTION:
39 # If unset, default value is set to ${PN}.
40 # Name of the package as hosted on kde.org mirrors.
41 : ${KDE_ORG_NAME:=$PN}
42
43 # @ECLASS-VARIABLE: KDE_RELEASE_SERVICE
44 # @DESCRIPTION:
45 # If set to "false", do nothing.
46 # If set to "true", set SRC_URI accordingly and apply KDE_UNRELEASED.
47 : ${KDE_RELEASE_SERVICE:=false}
48
49 # @ECLASS-VARIABLE: KDE_SELINUX_MODULE
50 # @DESCRIPTION:
51 # If set to "none", do nothing.
52 # For any other value, add selinux to IUSE, and depending on that useflag
53 # add a dependency on sec-policy/selinux-${KDE_SELINUX_MODULE} to (R)DEPEND.
54 : ${KDE_SELINUX_MODULE:=none}
55
56 case ${KDE_SELINUX_MODULE} in
57         none)   ;;
58         *)
59                 IUSE+=" selinux"
60                 RDEPEND+=" selinux? ( sec-policy/selinux-${KDE_SELINUX_MODULE} )"
61                 ;;
62 esac
63
64 # @ECLASS-VARIABLE: KDE_UNRELEASED
65 # @INTERNAL
66 # @DESCRIPTION
67 # An array of $CATEGORY-$PV pairs of packages that are unreleased upstream.
68 # Any package matching this will have fetch restriction enabled, and receive
69 # a proper error message via pkg_nofetch.
70 KDE_UNRELEASED=( )
71
72 HOMEPAGE="https://kde.org/"
73
74 case ${CATEGORY} in
75         kde-apps)
76                 KDE_RELEASE_SERVICE=true
77                 ;;
78         kde-plasma)
79                 HOMEPAGE="https://kde.org/plasma-desktop"
80                 ;;
81         kde-frameworks)
82                 HOMEPAGE="https://kde.org/products/frameworks/"
83                 SLOT=5/${PV}
84                 [[ ${KDE_BUILD_TYPE} = release ]] && SLOT=$(ver_cut 1)/$(ver_cut 1-2)
85                 ;;
86         *) ;;
87 esac
88
89 _kde.org_is_unreleased() {
90         local pair
91         for pair in "${KDE_UNRELEASED[@]}" ; do
92                 if [[ "${pair}" = "${CATEGORY}-${PV}" ]]; then
93                         return 0
94                 elif [[ ${KDE_RELEASE_SERVICE} = true ]]; then
95                         if [[ "${pair/kde-apps/${CATEGORY}}" = "${CATEGORY}-${PV}" ]]; then
96                                 return 0
97                         fi
98                 fi
99         done
100
101         return 1
102 }
103
104 # Determine fetch location for released tarballs
105 _kde.org_calculate_src_uri() {
106         debug-print-function ${FUNCNAME} "$@"
107
108         local _src_uri="mirror://kde/"
109
110         if [[ ${KDE_RELEASE_SERVICE} = true ]]; then
111                 case ${PV} in
112                         ??.??.[6-9]? )
113                                 _src_uri+="unstable/release-service/${PV}/src/"
114                                 RESTRICT+=" mirror"
115                                 ;;
116                         *) _src_uri+="stable/release-service/${PV}/src/" ;;
117                 esac
118         fi
119
120         case ${CATEGORY} in
121                 kde-frameworks)
122                         _src_uri+="stable/frameworks/$(ver_cut 1-2)/"
123                         case ${PN} in
124                                 kdelibs4support | \
125                                 kdesignerplugin | \
126                                 kdewebkit | \
127                                 khtml | \
128                                 kjs | \
129                                 kjsembed | \
130                                 kmediaplayer | \
131                                 kross)
132                                         _src_uri+="portingAids/"
133                                         ;;
134                         esac
135                         ;;
136                 kde-plasma)
137                         case ${PV} in
138                                 5.??.[6-9]?* )
139                                         _src_uri+="unstable/plasma/$(ver_cut 1-3)/"
140                                         RESTRICT+=" mirror"
141                                         ;;
142                                 *) _src_uri+="stable/plasma/$(ver_cut 1-3)/" ;;
143                         esac
144                         ;;
145         esac
146
147         if [[ ${PN} = kdevelop* ]]; then
148                 case ${PV} in
149                         *.*.[6-9]? )
150                                 _src_uri+="unstable/kdevelop/${PV}/src/"
151                                 RESTRICT+=" mirror"
152                                 ;;
153                         *) _src_uri+="stable/kdevelop/${PV}/src/" ;;
154                 esac
155         fi
156
157         SRC_URI="${_src_uri}${KDE_ORG_NAME}-${PV}.tar.xz"
158
159         if _kde.org_is_unreleased ; then
160                 RESTRICT+=" fetch"
161         fi
162 }
163
164 # Determine fetch location for live sources
165 _kde.org_calculate_live_repo() {
166         debug-print-function ${FUNCNAME} "$@"
167
168         SRC_URI=""
169
170         # @ECLASS-VARIABLE: EGIT_MIRROR
171         # @DESCRIPTION:
172         # This variable allows easy overriding of default kde mirror service
173         # (anongit) with anything else you might want to use.
174         EGIT_MIRROR=${EGIT_MIRROR:=https://anongit.kde.org}
175
176         if [[ ${PV} == ??.??.49.9999 && ${KDE_RELEASE_SERVICE} = true ]]; then
177                 EGIT_BRANCH="release/$(ver_cut 1-2)"
178         fi
179
180         if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
181                 EGIT_BRANCH="Plasma/$(ver_cut 1-2)"
182         fi
183
184         if [[ ${PV} != 9999 && ${PN} = kdevelop* ]]; then
185                 EGIT_BRANCH="$(ver_cut 1-2)"
186         fi
187
188         # @ECLASS-VARIABLE: EGIT_REPONAME
189         # @DESCRIPTION:
190         # This variable allows overriding of default repository
191         # name. Specify only if this differs from PN and KDE_ORG_NAME.
192         EGIT_REPO_URI="${EGIT_MIRROR}/${EGIT_REPONAME:=$KDE_ORG_NAME}"
193 }
194
195 case ${KDE_BUILD_TYPE} in
196         live) _kde.org_calculate_live_repo ;;
197         *)
198                 _kde.org_calculate_src_uri
199                 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
200                 ;;
201 esac
202
203
204 if [[ ${KDE_BUILD_TYPE} = release ]]; then
205         S=${WORKDIR}/${KDE_ORG_NAME}-${PV}
206 fi
207
208 # @FUNCTION: kde.org_pkg_nofetch
209 # @DESCRIPTION:
210 # Intended for use in the KDE overlay. If this package matches something in
211 # KDE_UNRELEASED, display a giant warning that the package has not yet been
212 # released upstream and should not be used.
213 kde.org_pkg_nofetch() {
214         if ! _kde.org_is_unreleased ; then
215                 return
216         fi
217
218         local sched_uri="https://community.kde.org/Schedules"
219         case ${CATEGORY} in
220                 kde-frameworks) sched_uri+="/Frameworks" ;;
221                 kde-plasma) sched_uri+="/Plasma_5" ;;
222                 kde-apps) sched_uri+="/Applications/$(ver_cut 1-2)_Release_Schedule" ;;
223         esac
224
225         eerror " _   _ _   _ ____  _____ _     _____    _    ____  _____ ____  "
226         eerror "| | | | \ | |  _ \| ____| |   | ____|  / \  / ___|| ____|  _ \ "
227         eerror "| | | |  \| | |_) |  _| | |   |  _|   / _ \ \___ \|  _| | | | |"
228         eerror "| |_| | |\  |  _ <| |___| |___| |___ / ___ \ ___) | |___| |_| |"
229         eerror " \___/|_| \_|_| \_\_____|_____|_____/_/   \_\____/|_____|____/ "
230         eerror "                                                               "
231         eerror " ____   _    ____ _  __    _    ____ _____ "
232         eerror "|  _ \ / \  / ___| |/ /   / \  / ___| ____|"
233         eerror "| |_) / _ \| |   | ' /   / _ \| |  _|  _|  "
234         eerror "|  __/ ___ \ |___| . \  / ___ \ |_| | |___ "
235         eerror "|_| /_/   \_\____|_|\_\/_/   \_\____|_____|"
236         eerror
237         eerror "${CATEGORY}/${P} has not been released to the public yet"
238         eerror "and is only available to packagers right now."
239         eerror ""
240         eerror "This is not a bug. Please do not file bugs or contact upstream about this."
241         eerror ""
242         eerror "Please consult the upstream release schedule to see when this "
243         eerror "package is scheduled to be released:"
244         eerror "${sched_uri}"
245 }
246
247 # @FUNCTION: kde.org_src_unpack
248 # @DESCRIPTION:
249 # Unpack the sources, automatically handling both release and live ebuilds.
250 kde.org_src_unpack() {
251         debug-print-function ${FUNCNAME} "$@"
252
253         if [[ ${KDE_BUILD_TYPE} = live ]]; then
254                 git-r3_src_unpack
255         else
256                 default
257         fi
258 }
259
260 fi