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

Contents of /eclass/kde4-meta.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Mon Mar 10 21:43:10 2008 UTC (6 years, 6 months ago) by zlin
Branch: MAIN
Changes since 1.3: +27 -10 lines
Add support for KDE4_STRICTER. Prepare for KDE 4.0.2.

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-meta.eclass,v 1.3 2008/02/24 21:45:39 keytoaster Exp $
4 #
5 # @ECLASS: kde4-meta.eclass
6 # @MAINTAINER:
7 # kde@gentoo.org
8 # @BLURB: Eclass for writing "split" KDE packages.
9 # @DESCRIPTION:
10 # This eclass provides all necessary functions for writing split KDE ebuilds.
11 #
12 # You must define KMNAME to use this eclass, and do so before inheriting it. All other variables are optional.
13 # Do not include the same item in more than one of KMMODULE, KMMEXTRA, KMCOMPILEONLY, KMEXTRACTONLY.
14 #
15 # NOTE: This eclass uses the SLOT dependencies from EAPI="1" or compatible,
16 # hence you must define EAPI="1" in the ebuild, before inheriting any eclasses.
17
18 inherit multilib kde4-functions kde4-base
19
20 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_postinst pkg_postrm
21
22 if [[ -z ${KMNAME} ]]; then
23 die "kde4-meta.eclass inherited but KMNAME not defined - broken ebuild"
24 fi
25
26 case ${KDEBASE} in
27 kde-base) HOMEPAGE="http://www.kde.org/"
28 LICENSE="GPL-2" ;;
29 koffice) HOMEPAGE="http://www.koffice.org/"
30 LICENSE="GPL-2" ;;
31 *) die "KDEBASE=${KDEBASE} is unsupported." ;;
32 esac
33
34 debug-print "${BASH_SOURCE} ${LINENO} ${ECLASS}: DEPEND ${DEPEND} - before blockers"
35 debug-print "${BASH_SOURCE} ${LINENO} ${ECLASS}: RDEPEND ${RDEPEND} - before blockers"
36
37 # Add a blocker on the package we're derived from
38 DEPEND="${DEPEND} !$(get-parent-package ${CATEGORY}/${PN}):${SLOT}"
39 RDEPEND="${RDEPEND} !$(get-parent-package ${CATEGORY}/${PN}):${SLOT}"
40
41 debug-print "line ${LINENO} ${ECLASS}: DEPEND ${DEPEND} - after blockers"
42 debug-print "line ${LINENO} ${ECLASS}: RDEPEND ${RDEPEND} - after blockers"
43
44 # Add dependencies that all packages in a certain module share.
45 case ${KMNAME} in
46 kdebase|kdebase-workspace|kdebase-runtime)
47 DEPEND="${DEPEND} >=kde-base/qimageblitz-0.0.4"
48 RDEPEND="${RDEPEND} >=kde-base/qimageblitz-0.0.4"
49 ;;
50 kdepim)
51 if [[ ${PN} != kode ]]; then
52 DEPEND="${DEPEND} >=kde-base/kode-${PV}:${SLOT}"
53 RDEPEND="${RDEPEND} >=kde-base/kode-${PV}:${SLOT}"
54 fi
55 case ${PN} in
56 akregator|kaddressbook|kmail|kmobiletools|knode|knotes|korganizer|ktimetracker)
57 IUSE="+kontact"
58 DEPEND="${DEPEND} kontact? ( >=kde-base/kontact-${PV}:${SLOT} )"
59 RDEPEND="${RDEPEND} kontact? ( >=kde-base/kontact-${PV}:${SLOT} )"
60 ;;
61 esac
62 ;;
63 kdegames)
64 if [[ ${PN} != "libkdegames" ]]; then
65 DEPEND="${DEPEND} >=kde-base/libkdegames-${PV}:${SLOT}"
66 RDEPEND="${RDEPEND} >=kde-base/libkdegames-${PV}:${SLOT}"
67 fi
68 ;;
69 koffice)
70 case ${PN} in
71 koffice-libs|koffice-data) : ;;
72 *)
73 DEPEND="${DEPEND} >=app-office/koffice-libs-${PV}:${SLOT}"
74 RDEPEND="${RDEPEND} >=app-office/koffice-libs-${PV}:${SLOT}"
75 ;;
76 esac
77 ;;
78 esac
79
80 debug-print "line ${LINENO} ${ECLASS}: DEPEND ${DEPEND} - after metapackage-specific dependencies"
81 debug-print "line ${LINENO} ${ECLASS}: RDEPEND ${RDEPEND} - after metapackage-specific dependencies"
82
83 # @ECLASS-VARIABLE: KMNAME
84 # @DESCRIPTION:
85 # Name of the parent-module (e.g. kdebase, kdepim, ...). You _must_ set it _before_ inheriting this eclass,
86 # (unlike the other parameters), since it's used to set $SRC_URI.
87
88 # @ECLASS-VARIABLE: KMMODULE
89 # @DESCRIPTION:
90 # Specify exactly one subdirectory of $KMNAME here. Defaults to $PN.
91 # The subdirectory listed here is treated exactly like items in $KMEXTRA.
92 #
93 # Example: The ebuild name of "kdebase/l10n" is kde-base/kdebase-l10n, because
94 # just 'l10n' would be too confusing. Hence it sets KMMODULE="l10n".
95
96 # @ECLASS-VARIABLE: KMNOMODULE
97 # @DESCRIPTION:
98 # If set to "true", $KMMODULE doesn't have to be defined.
99 #
100 # Example usage: If you're installing subdirectories of a package, like plugins,
101 # you mark the topsubdirectory (containing the package) as $KMEXTRACTONLY, and set KMNOMODULE="true".
102 if [[ ${KMNOMODULE} != "true" && -z ${KMMODULE} ]]; then
103 KMMODULE=${PN}
104 fi
105
106 # @ECLASS-VARIABLE: KMEXTRA
107 # @DESCRIPTION:
108 # All subdirectories listed here will be extracted, compiled & installed.
109 # $KMMODULE is always added to $KMEXTRA.
110 # If the htmlhandbook USE-flag is set, and if this directory exists,
111 # then "doc/$KMMODULE" is added to $KMEXTRA. In other cases, this should be
112 # handled in the ebuild.
113 # If the documentation is in a different subdirectory, you should add it to KMEXTRA.
114
115 # @ECLASS-VARIABLE: KMCOMPILEONLY
116 # @DESCRIPTION:
117 # All subdirectories listed here will be extracted & compiled, but not installed.
118
119 # @ECLASS-VARIABLE: KMEXTRACTONLY
120 # @DESCRIPTION:
121 # All subdirectories listed here will be extracted, but not compiled nor installed.
122 # This can be used to avoid compilation in a subdirectory of a directory in $KMMODULE or $KMEXTRA
123
124 # @ECLASS-VARIABLE: KMTARPARAMS
125 # @DESCRIPTION:
126 # Specify extra parameters to pass to tar, in kde4-meta_src_extract.
127 # '-xpf -j' are passed to tar by default.
128
129 # @FUNCTION: kde4-meta_pkg_setup
130 # @DESCRIPTION:
131 # Currently just calls its equivalent in kde4-base.eclass(5). Use this in split
132 # ebuilds.
133 kde4-meta_pkg_setup() {
134 kde4-base_pkg_setup
135 }
136
137 # @FUNCTION: kde4-meta_src_unpack
138 # @DESCRIPTION:
139 # This function unpacks the source for split ebuilds. See also
140 # kde4-meta-src_extract.
141 kde4-meta_src_unpack() {
142 debug-print-function ${FUNCNAME} "$@"
143
144 if [[ ${KMNAME} = kdepim ]] && \
145 has kontact ${IUSE//+} && \
146 use kontact; then
147 KMEXTRA="${KMEXTRA} kontact/plugins/${PLUGINNAME:-${PN}}"
148 KMEXTRACTONLY="${KMEXTRACTONLY} kontact/interfaces/"
149 fi
150
151 kde4-meta_src_extract
152 kde4-meta_change_cmakelists
153 }
154
155 # @FUNCTION: kde4-meta_src_extract
156 # @DESCRIPTION:
157 # A function to unpack the source for a split KDE ebuild.
158 # Also see KMMODULE, KMNOMODULE, KMEXTRA, KMCOMPILEONLY, KMEXTRACTONLY and KMTARPARAMS.
159 kde4-meta_src_extract() {
160 local abort tarball tarfile f extractlist
161 tarball="${KMNAME}-${PV}.tar.bz2"
162 tarfile="${DISTDIR}"/${tarball}
163
164 einfo "Unpacking parts of ${tarball} to ${WORKDIR}"
165
166 kde4-meta_create_extractlists
167
168 for f in cmake/ CMakeLists.txt ConfigureChecks.cmake config.h.cmake \
169 AUTHORS COPYING INSTALL README NEWS ChangeLog
170 do
171 extractlist="${extractlist} ${KMNAME}-${PV}/${f}"
172 done
173 extractlist="${extractlist} $(__list_needed_subdirectories)"
174 KMTARPARAMS="${KMTARPARAMS} -j"
175
176 pushd "${WORKDIR}" > /dev/null
177 [[ -n ${KDE4_STRICTER} ]] && echo tar -xpf $tarfile $KMTARPARAMS $extractlist >&2
178 tar -xpf $tarfile $KMTARPARAMS $extractlist 2> /dev/null
179
180 # Default $S is based on $P; rename the extracted directory to match $S
181 mv ${KMNAME}-${PV} ${P} || die "Died while moving \"${KMNAME}-${PV}\" to \"${P}\""
182
183 popd > /dev/null
184
185 if [[ -n ${KDE4_STRICTER} ]]; then
186 for f in $(__list_needed_subdirectories fatal); do
187 if [[ ! -e ${S}/${f#*/} ]]; then
188 eerror "'${f#*/}' is missing"
189 abort=true
190 fi
191 done
192 [[ -n ${abort} ]] && die "There were missing files."
193 fi
194
195 kde4-base_src_unpack
196 }
197
198 # Create lists of files and subdirectories to extract.
199 # Also see the descriptions of KMMODULE, KMNOMODULE, KMEXTRA, KMCOMPILEONLY, KMEXTRACTONLY and KMTARPARAMS.
200 kde4-meta_create_extractlists() {
201 debug-print-function ${FUNCNAME} "$@"
202
203 if has htmlhandbook ${IUSE//+} && use htmlhandbook; then
204 # We use the basename of $KMMODULE because $KMMODULE can contain
205 # the path to the module subdirectory.
206 KMEXTRA_NONFATAL="${KMEXTRA_NONFATAL} doc/${KMMODULE##*/}"
207 fi
208
209 # Add some CMake-files to KMEXTRACTONLY.
210 # Note that this actually doesn't include KMEXTRA handling.
211 # In those cases you should care to add the relevant files to KMEXTRACTONLY
212 case ${KMNAME} in
213 kdebase)
214 KMEXTRACTONLY="${KMEXTRACTONLY}
215 apps/config-apps.h.cmake
216 apps/ConfigureChecks.cmake"
217 ;;
218 kdebase-runtime)
219 KMEXTRACTONLY="${KMEXTRACTONLY}
220 config-runtime.h.cmake"
221 ;;
222 kdebase-workspace)
223 KMEXTRACTONLY="${KMEXTRACTONLY}
224 config-unix.h.cmake
225 ConfigureChecks.cmake
226 config-workspace.h.cmake
227 config-X11.h.cmake
228 startkde.cmake"
229 ;;
230 kdegames)
231 if [[ ${PN} != "libkdegames" ]]; then
232 KMEXTRACTONLY="${KMEXTRACTONLY}
233 libkdegames"
234 fi
235 ;;
236 koffice)
237 KMEXTRACTONLY="${KMEXTRACTONLY}
238 config-endian.h.cmake
239 filters/config-filters.h.cmake
240 config-openexr.h.cmake
241 config-opengl.h.cmake
242 config-prefix.h.cmake"
243 ;;
244 esac
245 # Don't install cmake modules for split ebuilds to avoid collisions.
246 case ${KMNAME} in
247 kdebase-workspace|kdebase-runtime|kdepim|kdegames|kdegraphics)
248 if [[ ${PN} != "libkdegames" ]]; then
249 KMCOMPILEONLY="${KMCOMPILEONLY}
250 cmake/modules/"
251 else
252 KMEXTRA="${KMEXTRA}
253 cmake/modules/"
254 fi
255 ;;
256 esac
257
258 debug-print "line ${LINENO} ${ECLASS} ${FUNCNAME}: KMEXTRACTONLY ${KMEXTRACTONLY}"
259 }
260
261 __list_needed_subdirectories() {
262 local i j kmextra kmextra_expanded kmmodule_expanded kmcompileonly_expanded extractlist topdir
263
264 # We expand KMEXTRA by adding CMakeLists.txt files
265 kmextra="${KMEXTRA}"
266 [[ ${1} != fatal ]] && kmextra="${kmextra} ${KMEXTRA_NONFATAL}"
267 for i in ${kmextra}; do
268 kmextra_expanded="${kmextra_expanded} ${i}"
269 j=$(dirname ${i})
270 while [[ ${j} != "." ]]; do
271 kmextra_expanded="${kmextra_expanded} ${j}/CMakeLists.txt";
272 j=$(dirname ${j})
273 done
274 done
275
276 # Expand KMMODULE
277 if [[ -n ${KMMODULE} ]]; then
278 kmmodule_expanded="${KMMODULE}"
279 j=$(dirname ${KMMODULE})
280 while [[ ${j} != "." ]]; do
281 kmmodule_expanded="${kmmodule_expanded} $j/CMakeLists.txt";
282 j=$(dirname $j)
283 done
284 fi
285
286 # Expand KMCOMPILEONLY
287 for i in ${KMCOMPILEONLY}; do
288 kmcompileonly_expanded="${kmcompileonly_expanded} ${i}"
289 j=$(dirname ${i})
290 while [[ ${j} != "." ]]; do
291 kmcompileonly_expanded="${kmcompileonly_expanded} ${j}/CMakeLists.txt";
292 j=$(dirname ${j})
293 done
294 done
295
296 debug-print "line ${LINENO} ${ECLASS} ${FUNCNAME} - kmextra_expanded: ${kmextra_expanded}"
297 debug-print "line ${LINENO} ${ECLASS} ${FUNCNAME} - kmmodule_expanded: ${kmmodule_expanded}"
298 debug-print "line ${LINENO} ${ECLASS} ${FUNCNAME} - kmcompileonly_expanded: ${kmcompileonly_expanded}"
299
300
301 case ${NEED_KDE} in
302 svn) : ;;
303 *) topdir="${KMNAME}-${PV}/" ;;
304 esac
305
306 # Create final list of stuff to extract
307 for i in ${kmmodule_expanded} ${kmextra_expanded} ${kmcompileonly_expanded} \
308 ${KMEXTRACTONLY}
309 do
310 extractlist="${extractlist} ${topdir}${i}"
311 done
312
313 echo ${extractlist}
314 }
315
316 # @FUNCTION: kde4-meta_src_compile
317 # @DESCRIPTION:
318 # General function for compiling split KDE4 applications.
319 kde4-meta_src_compile() {
320 debug-print-function ${FUNCNAME} "$@"
321
322 kde4-meta_src_configure
323 kde4-meta_src_make
324 }
325
326 _change_cmakelists_parent_dirs() {
327 debug-print-function ${FUNCNAME} "$@"
328
329 local _olddir _dir
330 _dir="${S}"/${1}
331 until [[ ${_dir} == "${S}" ]]; do
332 _olddir=$(basename ${_dir})
333 _dir=$(dirname ${_dir})
334 debug-print "${LINENO}: processing ${_dir} CMakeLists.txt searching for ${_olddir}"
335 if [[ -f ${_dir}/CMakeLists.txt ]]; then
336 sed -i -e "/[[:space:]]*${_olddir}[[:space:]]*/s/^#DONOTCOMPILE //" ${_dir}/CMakeLists.txt || \
337 die "${LINENO}: died in ${FUNCNAME} while processing ${_dir}"
338 fi
339 done
340 }
341
342 kde4-meta_change_cmakelists() {
343 debug-print-function ${FUNCNAME} "$@"
344
345 pushd "${S}" > /dev/null
346
347 comment_all_add_subdirectory ./
348
349 # Restore "add_subdirectory( cmake )" in ${S}/CMakeLists.txt
350 if [[ -f "${S}"/CMakeLists.txt ]]; then
351 sed -i -e '/ *cmake */s/^#DONOTCOMPILE //' "${S}"/CMakeLists.txt || die "${LINENO}: cmake sed died"
352 fi
353
354 if [[ -z ${KMNOMODULE} ]]; then
355 # Restore "add_subdirectory" in $KMMODULE subdirectories
356 find "${S}"/${KMMODULE} -name CMakeLists.txt -print0 | xargs -0 sed -i -e 's/^#DONOTCOMPILE //g' || \
357 die "${LINENO}: died in KMMODULE section"
358 _change_cmakelists_parent_dirs ${KMMODULE}
359 fi
360
361 # KMCOMPILEONLY
362 local i
363 for i in ${KMCOMPILEONLY}; do
364 debug-print "${LINENO}: KMCOMPILEONLY, processing ${i}"
365 # Uncomment "add_subdirectory" instructions inside $KMCOMPILEONLY, then comment "install" instructions.
366 find "${S}"/${i} -name CMakeLists.txt -print0 | \
367 xargs -0 sed -i \
368 -e 's/^#DONOTCOMPILE //g' \
369 -e '/install(.*)/{s/^/#DONOTINSTALL /;}' \
370 -e '/^install(/,/)/{s/^/#DONOTINSTALL /;}' \
371 -e '/kde4_install_icons(.*)/{s/^/#DONOTINSTALL /;}' || \
372 die "${LINENO}: sed died in the KMCOMPILEONLY section while processing ${i}"
373 _change_cmakelists_parent_dirs ${i}
374 done
375
376 # KMEXTRA section
377 for i in ${KMEXTRA}; do
378 debug-print "${LINENO}: KMEXTRA section, processing ${i}"
379 find "${S}"/${i} -name CMakeLists.txt -print0 | \
380 xargs -0 sed -i -e 's/^#DONOTCOMPILE //g' || \
381 die "${LINENO}: sed died uncommenting add_subdirectory instructions in KMEXTRA section while processing ${i}"
382 _change_cmakelists_parent_dirs ${i}
383 done
384 # KMEXTRA_NONFATAL section
385 for i in ${KMEXTRA_NONFATAL}; do
386 if [[ -d "${S}"/${i} ]]; then
387 find "${S}"/${i} -name CMakeLists.txt -print0 | \
388 xargs -0 sed -i -e 's/^#DONOTCOMPILE //g' || \
389 die "${LINENO}: sed died uncommenting add_subdirectory instructions in KMEXTRA section while processing ${i}"
390 _change_cmakelists_parent_dirs ${i}
391 fi
392 done
393
394 # Documentation section
395 if [[ -n ${docs} ]]; then
396 sed -i -e '/ *doc */s/^#DONOTCOMPILE //g' "${S}"/CMakeLists.txt || \
397 die "${LINENO}: sed died while uncommenting doc dir"
398
399 if [[ -f "${S}"/doc/CMakeLists.txt ]]; then
400 sed -i -e "/( *${KMMODULE##*/} *)/s/^#DONOTCOMPILE //g" "${S}"/doc/CMakeLists.txt \
401 || die "${LINENO}: sed died while uncommenting apps documentation in doc subdir "
402 fi
403 fi
404
405 # KMEXTRACTONLY section - Some ebuilds need to comment out some subdirs in KMMODULE and they use KMEXTRACTONLY
406 for i in ${KMEXTRACTONLY}; do
407 if [[ -d "${S}"/${i} && -f "${S}"/${i}/../CMakeLists.txt ]]; then
408 sed -i -e "/( *$(basename $i) *)/s/^/#DONOTCOMPILE /" "${S}"/${i}/../CMakeLists.txt || \
409 die "${LINENO}: sed died while working in the KMEXTRACTONLY section while processing ${i}"
410 fi
411 done
412
413 # COLLISION PROTECT section
414 # Only install the startkde script as part of kde-base/kdebase-startkde,
415 # instead of with every package.
416 case ${KMNAME} in
417 kdebase-workspace)
418 if [[ ${PN} != "kdebase-startkde" && -f "${S}"/CMakeLists.txt ]]; then
419 case ${PV} in
420 *) # The startkde script moved to kdebase-workspace for KDE4 versions > 3.93.0.
421 sed -i -e '/startkde/s/^/#DONOTINSTALL /' "${S}"/CMakeLists.txt || \
422 die "${LINENO}: sed died in the kdebase-startkde collision prevention section"
423 ;;
424 esac
425 fi
426 ;;
427 # This is sort of a hack to avoid patching 16 kdeutils packages with
428 # r775410 from upstream trunk which makes blitz optional so superkaramba
429 # only gets compiled when it is found. Bug #209324. Remove this no later
430 # than 4.1.
431 kdeutils)
432 if [[ ${PN} != superkaramba && ${SLOT} == kde-4 ]]; then
433 sed -i -e '/find_package(Blitz REQUIRED)/d' "${S}"/CMakeLists.txt \
434 || die "${LINENO}: sed to remove dependency on Blitz failed."
435 fi
436 ;;
437 koffice)
438 if [[ ${PN} != koffice-libs ]]; then
439 sed -i -e '/^INSTALL(FILES.*koffice.desktop/ s/^/#DONOTINSTALL /' \
440 doc/CMakeLists.txt || \
441 die "${LINENO}: sed died in the koffice.desktop collision prevention section"
442 fi
443 ;;
444 esac
445
446 popd > /dev/null
447 }
448
449 # @FUNCTION: kde4-meta_src_configure
450 # @DESCRIPTION:
451 # Currently just calls its equivalent in kde4-base.eclass(5). Use this in split
452 # ebuilds.
453 kde4-meta_src_configure() {
454 debug-print-function ${FUNCNAME} "$@"
455
456 kde4-base_src_configure
457 }
458
459 # @FUNCTION: kde4-meta_src_make
460 # @DESCRIPTION:
461 # Currently just calls its equivalent in kde4-base.eclass(5). Use this in split
462 # ebuilds.
463 kde4-meta_src_make() {
464 debug-print-function ${FUNCNAME} "$@"
465
466 kde4-base_src_make
467 }
468
469 # @FUNCTION: kde4-meta_src_test
470 # @DESCRIPTION:
471 # Currently just calls its equivalent in kde4-base.eclass(5). Use this in split
472 # ebuilds.
473 kde4-meta_src_test() {
474 debug-print-function $FUNCNAME "$@"
475
476 kde4-base_src_test
477 }
478
479 # @FUNCTION: kde4-meta_src_install
480 # @DESCRIPTION:
481 # Function for installing KDE4 split applications.
482 kde4-meta_src_install() {
483 debug-print-function $FUNCNAME "$@"
484
485 kde4-meta_src_make_doc
486 cmake-utils_src_install
487 }
488
489 # @FUNCTION: kde4-meta_src_make_doc
490 # @DESCRIPTION:
491 # This function searches under ${S}/${KMMODULE},
492 # and tries to install "AUTHORS ChangeLog* README* NEWS todo" if these files exist.
493 kde4-meta_src_make_doc() {
494 debug-print-function $FUNCNAME "$@"
495
496 local doc
497 for doc in AUTHORS ChangeLog* README* NEWS TODO; do
498 [[ -s ${KMMODULE}/$doc ]] && newdoc "${KMMODULE}/${doc}" "${doc}.${KMMODULE##*/}"
499 done
500
501 kde4-base_src_make_doc
502 }
503
504 # @FUNCTION: kde4-meta_pkg_postinst
505 # @DESCRIPTION:
506 # Currently just calls its equivalent in kde4-base.eclass(5). Use this in split
507 # ebuilds.
508 kde4-meta_pkg_postinst() {
509 kde4-base_pkg_postinst
510 }
511
512 # @FUNCTION: kde4-meta_pkg_postrm
513 # @DESCRIPTION:
514 # Currently just calls its equivalent in kde4-base.eclass(5). Use this in split
515 # ebuilds.
516 kde4-meta_pkg_postrm() {
517 kde4-base_pkg_postrm
518 }

  ViewVC Help
Powered by ViewVC 1.1.20