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