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

Diff of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.21 Revision 1.22
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2008 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.21 2009/06/04 09:29:54 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.22 2009/08/03 21:59:53 wired Exp $
4
5# Prefix compat:
6: ${EROOT:=${ROOT}}
4 7
5# @ECLASS: kde4-functions.eclass 8# @ECLASS: kde4-functions.eclass
6# @MAINTAINER: 9# @MAINTAINER:
7# kde@gentoo.org 10# kde@gentoo.org
8# @BLURB: Common ebuild functions for KDE 4 packages 11# @BLURB: Common ebuild functions for KDE 4 packages
10# This eclass contains all functions shared by the different eclasses, 13# This eclass contains all functions shared by the different eclasses,
11# for KDE 4 ebuilds. 14# for KDE 4 ebuilds.
12 15
13# @ECLASS-VARIABLE: EAPI 16# @ECLASS-VARIABLE: EAPI
14# @DESCRIPTION: 17# @DESCRIPTION:
15# By default kde4 eclasses wants eapi 2 which might be redefinable to newer 18# By default kde4 eclasses want EAPI 2 which might be redefinable to newer
16# versions. 19# versions.
17case ${EAPI:-0} in 20case ${EAPI:-0} in
18 2) : ;; 21 2) : ;;
19 *) DEPEND="EAPI-TOO-OLD" ;; 22 *) DEPEND="EAPI-TOO-OLD" ;;
20esac 23esac
37 40
38# @ECLASS-VARIABLE: KDE_SLOTS 41# @ECLASS-VARIABLE: KDE_SLOTS
39# @DESCRIPTION: 42# @DESCRIPTION:
40# The slots used by all KDE versions later than 4.0. The live KDE releases use 43# The slots used by all KDE versions later than 4.0. The live KDE releases use
41# KDE_LIVE_SLOTS instead. Values should be ordered. 44# KDE_LIVE_SLOTS instead. Values should be ordered.
42KDE_SLOTS=( "kde-4" "4.1" "4.2" "4.3" ) 45KDE_SLOTS=( "kde-4" "4.1" "4.2" "4.3" "4.4" )
43 46
44# @ECLASS-VARIABLE: KDE_LIVE_SLOTS 47# @ECLASS-VARIABLE: KDE_LIVE_SLOTS
45# @DESCRIPTION: 48# @DESCRIPTION:
46# The slots used by KDE live versions. Values should be ordered. 49# The slots used by KDE live versions. Values should be ordered.
47KDE_LIVE_SLOTS=( "live" ) 50KDE_LIVE_SLOTS=( "live" )
51# Function to rebuild the KDE System Configuration Cache. 54# Function to rebuild the KDE System Configuration Cache.
52# All KDE ebuilds should run this in pkg_postinst and pkg_postrm. 55# All KDE ebuilds should run this in pkg_postinst and pkg_postrm.
53buildsycoca() { 56buildsycoca() {
54 debug-print-function ${FUNCNAME} "$@" 57 debug-print-function ${FUNCNAME} "$@"
55 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
56 if [[ -z ${ROOT%%/} && -x ${KDEDIR}/bin/kbuildsycoca4 ]]; then 73 if [[ -z ${EROOT%%/} && -x "${KDEDIR}"/bin/kbuildsycoca4 ]]; then
57 # Make sure tha cache file exists, writable by root and readable by 74 # Make sure tha cache file exists, writable by root and readable by
58 # others. Otherwise kbuildsycoca4 will fail. 75 # others. Otherwise kbuildsycoca4 will fail.
59 touch "${KDEDIR}/share/kde4/services/ksycoca4" 76 touch "${KDEDIR}/share/kde4/services/ksycoca4"
60 chmod 644 "${KDEDIR}/share/kde4/services/ksycoca4" 77 chmod 644 "${KDEDIR}/share/kde4/services/ksycoca4"
61 78
64 # kbuildsycoca4 to hang. 81 # kbuildsycoca4 to hang.
65 82
66 ebegin "Running kbuildsycoca4 to build global database" 83 ebegin "Running kbuildsycoca4 to build global database"
67 # This is needed because we support multiple kde versions installed together. 84 # This is needed because we support multiple kde versions installed together.
68 # Lookup in order - local, KDEDIR, /usr, do not duplicate entries btw. 85 # Lookup in order - local, KDEDIR, /usr, do not duplicate entries btw.
69 local KDEDIRS="${ROOT}usr/share" 86 local KDEDIRS="${EROOT}usr/share"
70 [[ ${KDEDIR} != "${ROOT}usr" ]] && KDEDIRS="${KDEDIR}/share:${KDEDIRS}" 87 [[ ${KDEDIR} != "${EROOT}usr" ]] && KDEDIRS="${KDEDIR}/share:${KDEDIRS}"
71 XDG_DATA_DIRS="${ROOT}usr/local/share:${KDEDIRS}" \ 88 XDG_DATA_DIRS="${EROOT}usr/local/share:${KDEDIRS}" \
72 DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \ 89 DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \
73 ${KDEDIR}/bin/kbuildsycoca4 --global --noincremental &> /dev/null 90 "${KDEDIR}"/bin/kbuildsycoca4 --global --noincremental &> /dev/null
74 eend $? 91 eend $?
75 fi 92 fi
76 93
77 # fix permission for some directories 94 # fix permission for some directories
78 for x in share/config share/kde4; do 95 for x in share/{config,kde4}; do
79 [[ ${KDEDIR} = ${ROOT}usr ]] && DIRS=${ROOT}usr || DIRS="${ROOT}usr ${KDEDIR}" 96 [[ ${KDEDIR} = ${EROOT}usr ]] && DIRS=${EROOT}usr || DIRS="${EROOT}usr ${KDEDIR}"
80 for y in ${DIRS}; do 97 for y in ${DIRS}; do
81 [[ -d "${y}/${x}" ]] || break # nothing to do if directory does not exist 98 [[ -d "${y}/${x}" ]] || break # nothing to do if directory does not exist
82 if [[ $(stat --format=%a "${y}/${x}") != 755 ]]; then 99 if [[ $(stat --format=%a "${y}/${x}") != 755 ]]; then
83 ewarn "QA Notice:" 100 ewarn "QA Notice:"
84 ewarn "Package ${PN} is breaking ${y}/${x} permissions." 101 ewarn "Package ${PN} is breaking ${y}/${x} permissions."
95# @DESCRIPTION: 112# @DESCRIPTION:
96# Recursively comment all add_subdirectory instructions in listed directories, 113# Recursively comment all add_subdirectory instructions in listed directories,
97# except those in cmake/. 114# except those in cmake/.
98comment_all_add_subdirectory() { 115comment_all_add_subdirectory() {
99 find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \ 116 find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \
100 xargs -0 sed -i -e '/add_subdirectory/s/^/#DONOTCOMPILE /' -e '/ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' || \ 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 /' \
101 die "${LINENO}: Initial sed died" 122 || die "${LINENO}: Initial sed died"
102} 123}
103 124
104# @ECLASS-VARIABLE: KDE_LINGUAS 125# @ECLASS-VARIABLE: KDE_LINGUAS
105# @DESCRIPTION: 126# @DESCRIPTION:
106# This is a whitespace-separated list of translations this ebuild supports. 127# This is a whitespace-separated list of translations this ebuild supports.
118# @DESCRIPTION: 139# @DESCRIPTION:
119# Enable translations based on LINGUAS settings and translations supported by 140# Enable translations based on LINGUAS settings and translations supported by
120# the package (see KDE_LINGUAS). By default, translations are found in "${S}"/po 141# the package (see KDE_LINGUAS). By default, translations are found in "${S}"/po
121# but this default can be overridden by defining KDE_LINGUAS_DIR. 142# but this default can be overridden by defining KDE_LINGUAS_DIR.
122enable_selected_linguas() { 143enable_selected_linguas() {
144 debug-print-function ${FUNCNAME} "$@"
145
123 local lingua sr_mess wp 146 local lingua linguas sr_mess wp
124 147
125 ## This isn't working because it seems portage sets LINGUAS
126 ## even if you don't have it in make.conf
127 ## Im leaving the command that *should* work if LINGUAS was unset commented
128 # if there is no linguas defined we enable everything 148 # if there is no linguas defined we enable everything
129 if ! $(env | grep -q "^LINGUAS="); then 149 if ! $(env | grep -q "^LINGUAS="); then
130 return 0 150 return 0
131 fi 151 fi
132 # [[ ! ${LINGUAS+set} = set ]] && LINGUAS="*" 152
133 # ebuild overridable linguas directory definition 153 # @ECLASS-VARIABLE: KDE_LINGUAS_DIR
154 # @DESCRIPTION:
155 # Specified folder where application translations are located.
134 KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:="${S}/po"} 156 KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:="po"}
135 cd "${KDE_LINGUAS_DIR}" || die "wrong linguas dir specified" 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
136 160
137 # fix all various crazy sr@Latn variations 161 # fix all various crazy sr@Latn variations
138 # this part is only ease for ebuilds, so there wont be any die when this 162 # this part is only ease for ebuilds, so there wont be any die when this
139 # fail at any point 163 # fail at any point
140 sr_mess="sr@latn sr@latin sr@Latin" 164 sr_mess="sr@latn sr@latin sr@Latin"
152 for lingua in ${KDE_LINGUAS}; do 176 for lingua in ${KDE_LINGUAS}; do
153 if [[ -e "${lingua}.po" ]]; then 177 if [[ -e "${lingua}.po" ]]; then
154 mv "${lingua}.po" "${lingua}.po.old" 178 mv "${lingua}.po" "${lingua}.po.old"
155 fi 179 fi
156 done 180 done
157 comment_all_add_subdirectory "${KDE_LINGUAS_DIR}" 181
158 for lingua in ${KDE_LINGUAS}; do 182 for lingua in ${KDE_LINGUAS}; do
159 if use linguas_${lingua} ; then 183 if use linguas_${lingua} ; then
160 ebegin "Enabling LANGUAGE: ${lingua}"
161 if [[ -d "${lingua}" ]]; then 184 if [[ -d "${lingua}" ]]; then
185 linguas="${linguas} ${lingua}"
162 sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \ 186 sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
163 -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \ 187 -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
164 -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed." 188 -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed."
165 fi 189 fi
166 if [[ -e "${lingua}.po.old" ]]; then 190 if [[ -e "${lingua}.po.old" ]]; then
191 linguas="${linguas} ${lingua}"
167 mv "${lingua}.po.old" "${lingua}.po" 192 mv "${lingua}.po.old" "${lingua}.po"
168 fi 193 fi
169 eend $? 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.
204enable_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
170 fi 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
171 done 244 done
245 fi
246
247 done
248 [[ -n "${linguas}" ]] && einfo "Enabling handbook translations:${linguas}"
172} 249}
173 250
174# @FUNCTION: get_build_type 251# @FUNCTION: get_build_type
175# @DESCRIPTION: 252# @DESCRIPTION:
176# Determine whether we are using live ebuild or tbzs. 253# Determine whether we are using live ebuild or tbzs.
251# Install generated CMake library dependencies to /var/lib/kde 328# Install generated CMake library dependencies to /var/lib/kde
252install_library_dependencies() { 329install_library_dependencies() {
253 local depsfile="${T}/${PN}:${SLOT}" 330 local depsfile="${T}/${PN}:${SLOT}"
254 331
255 ebegin "Installing library dependencies as ${depsfile##*/}" 332 ebegin "Installing library dependencies as ${depsfile##*/}"
256 insinto ${ROOT}var/lib/kde 333 insinto ${EROOT}var/lib/kde
257 doins "${depsfile}" || die "Failed to install library dependencies." 334 doins "${depsfile}" || die "Failed to install library dependencies."
258 eend $? 335 eend $?
259} 336}
260 337
261# @FUNCTION: load_library_dependencies 338# @FUNCTION: load_library_dependencies
266 ebegin "Injecting library dependencies from '${KMLOADLIBS}'" 343 ebegin "Injecting library dependencies from '${KMLOADLIBS}'"
267 344
268 i=0 345 i=0
269 for pn in ${KMLOADLIBS} ; do 346 for pn in ${KMLOADLIBS} ; do
270 ((i++)) 347 ((i++))
271 depsfile="${ROOT}var/lib/kde/${pn}:${SLOT}" 348 depsfile="${EROOT}var/lib/kde/${pn}:${SLOT}"
272 [[ -r "${depsfile}" ]] || die "Depsfile '${depsfile}' not accessible. You probably need to reinstall ${pn}." 349 [[ -r "${depsfile}" ]] || die "Depsfile '${depsfile}' not accessible. You probably need to reinstall ${pn}."
273 sed -i -e "${i}iINCLUDE(\"${depsfile}\")" "${S}/CMakeLists.txt" || \ 350 sed -i -e "${i}iINCLUDE(\"${depsfile}\")" "${S}/CMakeLists.txt" || \
274 die "Failed to include library dependencies for ${pn}" 351 die "Failed to include library dependencies for ${pn}"
275 done 352 done
276 eend $? 353 eend $?

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.20