/[gentoo-x86]/eclass/kde4-functions.eclass
Gentoo

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (show annotations) (download)
Tue Sep 1 09:32:08 2009 UTC (4 years, 10 months ago) by scarabeus
Branch: MAIN
Changes since 1.23: +13 -5 lines
Sync kde4 eclasses with overlay ones in preparation for 4.3.1.
One thing differ from overlay ones. KDE_MINIMAL sets still 4.2 instead of 4.3 because some archies did not keyword all kde-base YET!

1 # Copyright 1999-2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.18 2009/05/09 13:23:15 scarabeus Exp $
4
5 # Prefix compat:
6 : ${EROOT:=${ROOT}}
7 # Append missing trailing slash character
8 [[ ${EROOT} = */ ]] || EROOT+="/"
9
10 # @ECLASS: kde4-functions.eclass
11 # @MAINTAINER:
12 # kde@gentoo.org
13 # @BLURB: Common ebuild functions for KDE 4 packages
14 # @DESCRIPTION:
15 # This eclass contains all functions shared by the different eclasses,
16 # for KDE 4 ebuilds.
17
18 # @ECLASS-VARIABLE: EAPI
19 # @DESCRIPTION:
20 # By default kde4 eclasses want EAPI 2 which might be redefinable to newer
21 # versions.
22 case ${EAPI:-0} in
23 2) : ;;
24 *) DEPEND="EAPI-TOO-OLD" ;;
25 esac
26
27 # @ECLASS-VARIABLE: KDEBASE
28 # @DESCRIPTION:
29 # This gets set to a non-zero value when a package is considered a kde or
30 # koffice ebuild.
31
32 if [[ ${CATEGORY} = kde-base ]]; then
33 debug-print "${ECLASS}: KDEBASE ebuild recognized"
34 KDEBASE=kde-base
35 fi
36
37 # is this a koffice ebuild?
38 if [[ ${KMNAME} = koffice || ${PN} = koffice ]]; then
39 debug-print "${ECLASS}: KOFFICE ebuild recognized"
40 KDEBASE=koffice
41 fi
42
43 # @ECLASS-VARIABLE: KDE_SLOTS
44 # @DESCRIPTION:
45 # The slots used by all KDE versions later than 4.0. The live KDE releases use
46 # KDE_LIVE_SLOTS instead. Values should be ordered.
47 KDE_SLOTS=( "4.1" "4.2" "4.3" "4.4" )
48
49 # @ECLASS-VARIABLE: KDE_LIVE_SLOTS
50 # @DESCRIPTION:
51 # The slots used by KDE live versions. Values should be ordered.
52 KDE_LIVE_SLOTS=( "live" )
53
54 # @FUNCTION: slot_is_at_least
55 # @USAGE: <want> <have>
56 # @DESCRIPTION:
57 # Version aware slot comparator.
58 # Current implementation relies on the fact, that slots can be compared like
59 # string literals (and let's keep it this way).
60 slot_is_at_least() {
61 [[ "${2}" > "${1}" || "${2}" = "${1}" ]]
62 }
63
64 # @FUNCTION: buildsycoca
65 # @DESCRIPTION:
66 # Function to rebuild the KDE System Configuration Cache.
67 # All KDE ebuilds should run this in pkg_postinst and pkg_postrm.
68 buildsycoca() {
69 debug-print-function ${FUNCNAME} "$@"
70
71 local KDE3DIR="${EROOT}usr/kde/3.5"
72 if [[ -z ${EROOT%%/} && -x "${KDE3DIR}"/bin/kbuildsycoca ]]; then
73 # Since KDE3 is aware of shortcuts in /usr, rebuild database
74 # for KDE3 as well.
75 touch "${KDE3DIR}"/share/services/ksycoca
76 chmod 644 "${KDE3DIR}"/share/services/ksycoca
77
78 ebegin "Running kbuildsycoca to build global database"
79 XDG_DATA_DIRS="${EROOT}usr/local/share:${KDE3DIR}/share:${EROOT}usr/share" \
80 DISPLAY="" \
81 "${KDE3DIR}"/bin/kbuildsycoca --global --noincremental &> /dev/null
82 eend $?
83 fi
84
85 if [[ -z ${EROOT%%/} && -x "${KDEDIR}"/bin/kbuildsycoca4 ]]; then
86 # Make sure tha cache file exists, writable by root and readable by
87 # others. Otherwise kbuildsycoca4 will fail.
88 touch "${KDEDIR}/share/kde4/services/ksycoca4"
89 chmod 644 "${KDEDIR}/share/kde4/services/ksycoca4"
90
91 # We have to unset DISPLAY and DBUS_SESSION_BUS_ADDRESS, the ones
92 # in the user's environment (through su [without '-']) may cause
93 # kbuildsycoca4 to hang.
94
95 ebegin "Running kbuildsycoca4 to build global database"
96 # This is needed because we support multiple kde versions installed together.
97 # Lookup in order - local, KDEDIR, /usr, do not duplicate entries btw.
98 local KDEDIRS="${EROOT}usr/share"
99 [[ ${KDEDIR} != "${EROOT}usr" ]] && KDEDIRS="${KDEDIR}/share:${KDEDIRS}"
100 XDG_DATA_DIRS="${EROOT}usr/local/share:${KDEDIRS}" \
101 DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \
102 "${KDEDIR}"/bin/kbuildsycoca4 --global --noincremental &> /dev/null
103 eend $?
104 fi
105
106 # fix permission for some directories
107 for x in share/{config,kde4}; do
108 [[ ${KDEDIR} = ${EROOT}usr ]] && DIRS=${EROOT}usr || DIRS="${EROOT}usr ${KDEDIR}"
109 for y in ${DIRS}; do
110 [[ -d "${y}/${x}" ]] || break # nothing to do if directory does not exist
111 if [[ $(stat --format=%a "${y}/${x}") != 755 ]]; then
112 ewarn "QA Notice:"
113 ewarn "Package ${PN} is breaking ${y}/${x} permissions."
114 ewarn "Please report this issue to gentoo bugzilla."
115 einfo "Permissions will get adjusted automatically now."
116 find "${y}/${x}" -type d -print0 | xargs -0 chmod 755
117 fi
118 done
119 done
120 }
121
122 # @FUNCTION: comment_all_add_subdirectory
123 # @USAGE: [list of directory names]
124 # @DESCRIPTION:
125 # Recursively comment all add_subdirectory instructions in listed directories,
126 # except those in cmake/.
127 comment_all_add_subdirectory() {
128 find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \
129 xargs -0 sed -i \
130 -e '/^[[:space:]]*add_subdirectory/s/^/#DONOTCOMPILE /' \
131 -e '/^[[:space:]]*ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' \
132 -e '/^[[:space:]]*macro_optional_add_subdirectory/s/^/#DONOTCOMPILE /' \
133 -e '/^[[:space:]]*MACRO_OPTIONAL_ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' \
134 || die "${LINENO}: Initial sed died"
135 }
136
137 # @ECLASS-VARIABLE: KDE_LINGUAS
138 # @DESCRIPTION:
139 # This is a whitespace-separated list of translations this ebuild supports.
140 # These translations are automatically added to IUSE. Therefore ebuilds must set
141 # this variable before inheriting any eclasses. To enable only selected
142 # translations, ebuilds must call enable_selected_linguas(). kde4-{base,meta}.eclass does
143 # this for you.
144 #
145 # Example: KDE_LINGUAS="en_GB de nl"
146 for _lingua in ${KDE_LINGUAS}; do
147 IUSE="${IUSE} linguas_${_lingua}"
148 done
149
150 # @FUNCTION: enable_selected_linguas
151 # @DESCRIPTION:
152 # Enable translations based on LINGUAS settings and translations supported by
153 # the package (see KDE_LINGUAS). By default, translations are found in "${S}"/po
154 # but this default can be overridden by defining KDE_LINGUAS_DIR.
155 enable_selected_linguas() {
156 debug-print-function ${FUNCNAME} "$@"
157
158 local lingua linguas sr_mess wp
159
160 # if there is no linguas defined we enable everything
161 if ! $(env | grep -q "^LINGUAS="); then
162 return 0
163 fi
164
165 # @ECLASS-VARIABLE: KDE_LINGUAS_DIR
166 # @DESCRIPTION:
167 # Specified folder where application translations are located.
168 KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:="po"}
169 [[ -d "${KDE_LINGUAS_DIR}" ]] || die "wrong linguas dir specified"
170 comment_all_add_subdirectory "${KDE_LINGUAS_DIR}"
171 pushd "${KDE_LINGUAS_DIR}" > /dev/null
172
173 # fix all various crazy sr@Latn variations
174 # this part is only ease for ebuilds, so there wont be any die when this
175 # fail at any point
176 sr_mess="sr@latn sr@latin sr@Latin"
177 for wp in ${sr_mess}; do
178 [[ -e "${wp}.po" ]] && mv "${wp}.po" "sr@Latn.po"
179 if [[ -d "${wp}" ]]; then
180 # move dir and fix cmakelists
181 mv "${wp}" "sr@Latn"
182 sed -i \
183 -e "s:${wp}:sr@Latin:g" \
184 CMakeLists.txt
185 fi
186 done
187
188 for lingua in ${KDE_LINGUAS}; do
189 if [[ -e "${lingua}.po" ]]; then
190 mv "${lingua}.po" "${lingua}.po.old"
191 fi
192 done
193
194 for lingua in ${KDE_LINGUAS}; do
195 if use linguas_${lingua} ; then
196 if [[ -d "${lingua}" ]]; then
197 linguas="${linguas} ${lingua}"
198 sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
199 -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
200 -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed."
201 fi
202 if [[ -e "${lingua}.po.old" ]]; then
203 linguas="${linguas} ${lingua}"
204 mv "${lingua}.po.old" "${lingua}.po"
205 fi
206 fi
207 done
208 [[ -n "${linguas}" ]] && einfo "Enabling languages: ${linguas}"
209
210 popd > /dev/null
211 }
212
213 # @FUNCTION: enable_selected_doc_linguas
214 # @DESCRIPTION:
215 # Enable only selected linguas enabled doc folders.
216 enable_selected_doc_linguas() {
217 debug-print-function ${FUNCNAME} "$@"
218
219 # if there is no linguas defined we enable everything
220 if ! $(env | grep -q "^LINGUAS="); then
221 return 0
222 fi
223
224 # @ECLASS-VARIABLE: KDE_DOC_DIRS
225 # @DESCRIPTION:
226 # Variable specifying whitespace separated patterns for documentation locations.
227 # Default is "doc/%lingua"
228 KDE_DOC_DIRS=${KDE_DOC_DIRS:='doc/%lingua'}
229 local linguas
230 for pattern in ${KDE_DOC_DIRS}; do
231
232 local handbookdir=`dirname ${pattern}`
233 local translationdir=`basename ${pattern}`
234 # Do filename pattern supplied, treat as directory
235 [[ "${handbookdir}" = '.' ]] && handbookdir=${translationdir} && translationdir=
236 [[ -d "${handbookdir}" ]] || die 'wrong doc dir specified'
237
238 if ! use handbook; then
239 # Disable whole directory
240 sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${handbookdir}[[:space:]]*)/s/^/#DONOTCOMPILE /" \
241 -e "/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${handbookdir}[[:space:]]*)/s/^/#DONOTCOMPILE /" \
242 -i CMakeLists.txt || die 'failed to comment out all handbooks'
243 else
244 # Disable subdirectories recursively
245 comment_all_add_subdirectory "${handbookdir}"
246 # Add requested translations
247 local lingua
248 for lingua in en ${KDE_LINGUAS}; do
249 if [[ ${lingua} = 'en' ]] || use linguas_${lingua}; then
250 if [[ -d "${handbookdir}/${translationdir//%lingua/${lingua}}" ]]; then
251 sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${translationdir//%lingua/${lingua}}/s/^#DONOTCOMPILE //" \
252 -e "/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${translationdir//%lingua/${lingua}}/s/^#DONOTCOMPILE //" \
253 -i "${handbookdir}"/CMakeLists.txt && ! has ${lingua} ${linguas} && linguas="${linguas} ${lingua}"
254 fi
255 fi
256 done
257 fi
258
259 done
260 [[ -n "${linguas}" ]] && einfo "Enabling handbook translations:${linguas}"
261 }
262
263 # @FUNCTION: get_build_type
264 # @DESCRIPTION:
265 # Determine whether we are using live ebuild or tbzs.
266 get_build_type() {
267 if [[ ${SLOT} = live || ${PV} = *9999* ]]; then
268 BUILD_TYPE="live"
269 else
270 BUILD_TYPE="release"
271 fi
272 export BUILD_TYPE
273 }
274
275 # @FUNCTION: migrate_store_dir
276 # @DESCRIPTION:
277 # Universal store dir migration
278 # * performs split of kdebase to kdebase-apps when needed
279 # * moves playground/extragear kde4-base-style to toplevel dir
280 migrate_store_dir() {
281 local cleandir="${ESVN_STORE_DIR}/KDE"
282 if [[ -d "${cleandir}" ]]; then
283 ewarn "'${cleandir}' has been found. Moving contents to new location."
284 addwrite "${ESVN_STORE_DIR}"
285 # Split kdebase
286 local module
287 if pushd "${cleandir}"/kdebase/kdebase > /dev/null; then
288 for module in `find . -maxdepth 1 -type d -name [a-z0-9]\*`; do
289 module="${module#./}"
290 mkdir -p "${ESVN_STORE_DIR}/kdebase-${module}" && mv -f "${module}" "${ESVN_STORE_DIR}/kdebase-${module}" || \
291 die "Failed to move to '${ESVN_STORE_DIR}/kdebase-${module}'."
292 done
293 popd > /dev/null
294 rm -fr "${cleandir}/kdebase" || \
295 die "Failed to remove ${cleandir}/kdebase. You need to remove it manually."
296 fi
297 # Move the rest
298 local pkg
299 for pkg in "${cleandir}"/*; do
300 mv -f "${pkg}" "${ESVN_STORE_DIR}"/ || eerror "Failed to move '${pkg}'"
301 done
302 rmdir "${cleandir}" || die "Could not move obsolete KDE store dir. Please move '${cleandir}' contents to appropriate location (possibly ${ESVN_STORE_DIR}) and manually remove '${cleandir}' in order to continue."
303 fi
304
305 if ! hasq kde4-meta ${INHERITED}; then
306 case ${KMNAME} in
307 extragear*|playground*)
308 local svnlocalpath="${ESVN_STORE_DIR}"/"${KMNAME}"/"${PN}"
309 if [[ -d "${svnlocalpath}" ]]; then
310 local destdir="${ESVN_STORE_DIR}"/"${ESVN_PROJECT}"/"`basename "${ESVN_REPO_URI}"`"
311 ewarn "'${svnlocalpath}' has been found."
312 ewarn "Moving contents to new location: ${destdir}"
313 addwrite "${ESVN_STORE_DIR}"
314 mkdir -p "${ESVN_STORE_DIR}"/"${ESVN_PROJECT}" && mv -f "${svnlocalpath}" "${destdir}" \
315 || die "Failed to move to '${svnlocalpath}'"
316 # Try cleaning empty directories
317 rmdir "`dirname "${svnlocalpath}"`" 2> /dev/null
318 fi
319 ;;
320 esac
321 fi
322 }
323
324 # Functions handling KMLOADLIBS and KMSAVELIBS
325
326 # @FUNCTION: save_library_dependencies
327 # @DESCRIPTION:
328 # Add exporting CMake dependencies for current package
329 save_library_dependencies() {
330 local depsfile="${T}/${PN}:${SLOT}"
331
332 ebegin "Saving library dependencies in ${depsfile##*/}"
333 echo "EXPORT_LIBRARY_DEPENDENCIES(\"${depsfile}\")" >> "${S}/CMakeLists.txt" || \
334 die "Failed to save the library dependencies."
335 eend $?
336 }
337
338 # @FUNCTION: install_library_dependencies
339 # @DESCRIPTION:
340 # Install generated CMake library dependencies to /var/lib/kde
341 install_library_dependencies() {
342 local depsfile="${T}/${PN}:${SLOT}"
343
344 ebegin "Installing library dependencies as ${depsfile##*/}"
345 insinto ${EROOT}var/lib/kde
346 doins "${depsfile}" || die "Failed to install library dependencies."
347 eend $?
348 }
349
350 # @FUNCTION: load_library_dependencies
351 # @DESCRIPTION:
352 # Inject specified library dependencies in current package
353 load_library_dependencies() {
354 local pn i depsfile
355 ebegin "Injecting library dependencies from '${KMLOADLIBS}'"
356
357 i=0
358 for pn in ${KMLOADLIBS} ; do
359 ((i++))
360 depsfile="${EROOT}var/lib/kde/${pn}:${SLOT}"
361 [[ -r "${depsfile}" ]] || die "Depsfile '${depsfile}' not accessible. You probably need to reinstall ${pn}."
362 sed -i -e "${i}iINCLUDE(\"${depsfile}\")" "${S}/CMakeLists.txt" || \
363 die "Failed to include library dependencies for ${pn}"
364 done
365 eend $?
366 }
367
368 # @FUNCTION: block_other_slots
369 # @DESCRIPTION:
370 # Create blocks for the current package in other slots when
371 # installed with USE=-kdeprefix
372 block_other_slots() {
373 debug-print-function ${FUNCNAME} "$@"
374
375 local slot
376 for slot in ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do
377 # Block non kdeprefix ${PN} on other slots
378 if [[ ${SLOT} != ${slot} ]]; then
379 echo "!kdeprefix? ( !kde-base/${PN}:${slot}[-kdeprefix] )"
380 fi
381 done
382 }
383
384 # @FUNCTION: add_blocker
385 # @DESCRIPTION:
386 # Create correct RDEPEND value for blocking correct package.
387 # Usefull for file-collision blocks.
388 # Parameters are package and version to block.
389 # add_blocker kde-base/kdelibs 4.2.4
390 add_blocker() {
391 debug-print-function ${FUNCNAME} "$@"
392
393 [[ ${1} = "" || ${2} = "" ]] && die "Missing parameter"
394 local slot
395 for slot in ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do
396 # on -kdeprefix we block every slot
397 RDEPEND+=" !kdeprefix? ( !<=${1}-${2}:${slot}[-kdeprefix] )"
398 done
399 # on kdeprefix we block only our slot
400 RDEPEND+=" kdeprefix? ( !<=${1}-${2}:${SLOT}[kdeprefix] )"
401 }

  ViewVC Help
Powered by ViewVC 1.1.20