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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (show annotations) (download)
Mon Aug 3 21:59:53 2009 UTC (5 years, 3 months ago) by wired
Branch: MAIN
Changes since 1.21: +101 -24 lines
synced kde4 eclasses with new ones from kde-testing overlay

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

  ViewVC Help
Powered by ViewVC 1.1.20