Gentoo Archives: gentoo-commits

From: Michael Palimaka <kensington@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/kde:master commit in: eclass/
Date: Wed, 02 Apr 2014 17:02:40
Message-Id: 1396458099.114014667c0b2368fd217c53ac7013ec65c52495.kensington@gentoo
1 commit: 114014667c0b2368fd217c53ac7013ec65c52495
2 Author: Michael Palimaka <kensington <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 2 17:01:39 2014 +0000
4 Commit: Michael Palimaka <kensington <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 2 17:01:39 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=commit;h=11401466
7
8 [eclass] Add kde5-functions.
9
10 ---
11 eclass/kde5-functions.eclass | 142 +++++++++++++++++++++++++++++++++++++++++++
12 1 file changed, 142 insertions(+)
13
14 diff --git a/eclass/kde5-functions.eclass b/eclass/kde5-functions.eclass
15 new file mode 100644
16 index 0000000..069c033
17 --- /dev/null
18 +++ b/eclass/kde5-functions.eclass
19 @@ -0,0 +1,142 @@
20 +# Copyright 1999-2014 Gentoo Foundation
21 +# Distributed under the terms of the GNU General Public License v2
22 +# $Header: $
23 +
24 +inherit versionator
25 +
26 +# @ECLASS: kde5-functions.eclass
27 +# @MAINTAINER:
28 +# kde@g.o
29 +# @BLURB: Common ebuild functions for KDE 5 packages
30 +# @DESCRIPTION:
31 +# This eclass contains all functions shared by the different eclasses,
32 +# for KDE 5 ebuilds.
33 +
34 +if [[ ${___ECLASS_ONCE_KDE5_FUNCTIONS} != "recur -_+^+_- spank" ]] ; then
35 +___ECLASS_ONCE_KDE5_FUNCTIONS="recur -_+^+_- spank"
36 +
37 +# @ECLASS-VARIABLE: EAPI
38 +# @DESCRIPTION:
39 +# Currently EAPI 5 is supported.
40 +case ${EAPI:-0} in
41 + 5) : ;;
42 + *) die "EAPI=${EAPI} is not supported" ;;
43 +esac
44 +
45 +# @ECLASS-VARIABLE: KDEBASE
46 +# @DESCRIPTION:
47 +# This gets set to a non-zero value when a package is considered a kde or
48 +# kdevelop ebuild.
49 +if [[ ${CATEGORY} = kde-base ]]; then
50 + debug-print "${ECLASS}: KDEBASE ebuild recognized"
51 + KDEBASE=kde-base
52 +elif [[ ${CATEGORY} = kde-frameworks ]]; then
53 + debug-print "${ECLASS}: KDEFRAMEWORKS ebuild recognized"
54 + KDEBASE=kde-frameworks
55 +elif [[ ${KMNAME-${PN}} = kdevelop ]]; then
56 + debug-print "${ECLASS}: KDEVELOP ebuild recognized"
57 + KDEBASE=kdevelop
58 +fi
59 +
60 +# determine the build type
61 +if [[ ${PV} = *9999* ]]; then
62 + KDE_BUILD_TYPE="live"
63 +else
64 + KDE_BUILD_TYPE="release"
65 +fi
66 +export KDE_BUILD_TYPE
67 +
68 +# @FUNCTION: comment_add_subdirectory
69 +# @USAGE: subdirectory
70 +# @DESCRIPTION:
71 +# Comment out an add_subdirectory call in CMakeLists.txt in the current directory
72 +comment_add_subdirectory() {
73 + if [[ -z ${1} ]]; then
74 + die "comment_add_subdirectory must be passed the directory name to comment"
75 + fi
76 +
77 + if [[ -a "CMakeLists.txt" ]]; then
78 + sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${1}[[:space:]]*)/s/^/#DONOTCOMPILE /" \
79 + -i CMakeLists.txt || die "failed to comment add_subdirectory(${1})"
80 + fi
81 +}
82 +
83 +# @FUNCTION: _add_kdecategory_dep
84 +# @INTERNAL
85 +# @DESCRIPTION:
86 +# Implementation of add_kdebase_dep and add_frameworks_dep.
87 +_add_kdecategory_dep() {
88 + debug-print-function ${FUNCNAME} "$@"
89 +
90 + local category=${1}
91 + local package=${2}
92 + local use=${3}
93 + local minversion=${4}
94 + local version
95 +
96 + if [[ -n ${minversion} ]]; then
97 + version=${minversion}
98 + # if building stable-live version depend just on the raw KDE version
99 + # to allow merging packages against more stable basic stuff
100 + elif [[ ${PV} == *.9999 ]]; then
101 + version=$(get_kde_version)
102 + else
103 + version=${PV}
104 + fi
105 +
106 + [[ -z ${1} ]] && die "Missing parameter"
107 +
108 + if [[ -n ${use} ]] ; then
109 + usedep="[${usedep}]"
110 + fi
111 +
112 + echo " >=${category}/${package}-${version}:5${usedep}"
113 +}
114 +
115 +# @FUNCTION: add_frameworks_dep
116 +# @DESCRIPTION:
117 +# Create proper dependency for kde-frameworks/ dependencies.
118 +# This takes 1 to 3 arguments. The first being the package name, the optional
119 +# second is additional USE flags to append, and the optional third is the
120 +# version to use instead of the automatic version (use sparingly).
121 +# The output of this should be added directly to DEPEND/RDEPEND, and may be
122 +# wrapped in a USE conditional (but not an || conditional without an extra set
123 +# of parentheses).
124 +add_frameworks_dep() {
125 + debug-print-function ${FUNCNAME} "$@"
126 +
127 + _add_kdecategory_dep kde-frameworks ${1} ${2} ${3}
128 +}
129 +
130 +# @FUNCTION: add_kdebase_dep
131 +# @DESCRIPTION:
132 +# Create proper dependency for kde-base/ dependencies.
133 +# This takes 1 to 3 arguments. The first being the package name, the optional
134 +# second is additional USE flags to append, and the optional third is the
135 +# version to use instead of the automatic version (use sparingly).
136 +# The output of this should be added directly to DEPEND/RDEPEND, and may be
137 +# wrapped in a USE conditional (but not an || conditional without an extra set
138 +# of parentheses).
139 +add_kdebase_dep() {
140 + debug-print-function ${FUNCNAME} "$@"
141 +
142 + _add_kdecategory_dep kde-base ${1} ${2} ${3}
143 +}
144 +
145 +# @FUNCTION: get_kde_version
146 +# @DESCRIPTION:
147 +# Translates an ebuild version into a major.minor KDE SC
148 +# release version. If no version is specified, ${PV} is used.
149 +get_kde_version() {
150 + local ver=${1:-${PV}}
151 + local major=$(get_major_version ${ver})
152 + local minor=$(get_version_component_range 2 ${ver})
153 + local micro=$(get_version_component_range 3 ${ver})
154 + if [[ ${ver} == 9999 ]]; then
155 + echo live
156 + else
157 + (( micro < 50 )) && echo ${major}.${minor} || echo ${major}.$((minor + 1))
158 + fi
159 +}
160 +
161 +fi