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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.75 - (hide annotations) (download)
Wed Feb 11 04:29:06 2015 UTC (3 weeks, 3 days ago) by patrick
Branch: MAIN
CVS Tags: HEAD
Changes since 1.74: +2 -2 lines
Fix kde4-functions more better: comparison breaks because 4.4 > 4.14

1 johu 1.72 # Copyright 1999-2015 Gentoo Foundation
2 ingmar 1.1 # Distributed under the terms of the GNU General Public License v2
3 patrick 1.75 # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.74 2015/02/11 03:25:52 patrick Exp $
4 ingmar 1.1
5     # @ECLASS: kde4-functions.eclass
6     # @MAINTAINER:
7     # kde@gentoo.org
8 scarabeus 1.10 # @BLURB: Common ebuild functions for KDE 4 packages
9 ingmar 1.1 # @DESCRIPTION:
10     # This eclass contains all functions shared by the different eclasses,
11 scarabeus 1.10 # for KDE 4 ebuilds.
12    
13 ulm 1.70 if [[ -z ${_KDE4_FUNCTIONS_ECLASS} ]]; then
14     _KDE4_FUNCTIONS_ECLASS=1
15 kensington 1.64
16 johu 1.72 inherit versionator
17    
18 scarabeus 1.10 # @ECLASS-VARIABLE: EAPI
19     # @DESCRIPTION:
20 kensington 1.65 # Currently kde4 eclasses support EAPI 4 and 5.
21 johu 1.72 case ${EAPI} in
22 kensington 1.65 4|5) : ;;
23 johu 1.72 *) die "EAPI=${EAPI:-0} is not supported" ;;
24 scarabeus 1.10 esac
25 ingmar 1.1
26 scarabeus 1.45 # @ECLASS-VARIABLE: KDE_OVERRIDE_MINIMAL
27     # @DESCRIPTION:
28     # For use only in very few well-defined cases; normally it should be unset.
29     # If this variable is set, all calls to add_kdebase_dep return a dependency on
30     # at least this version, independent of the version of the package itself.
31     # If you know exactly that one specific NEW KDE component builds and runs fine
32     # with all the rest of KDE at an OLDER version, you can set this old version here.
33     # Warning- may lead to general instability and kill your pet targh.
34    
35 ingmar 1.1 # @ECLASS-VARIABLE: KDEBASE
36     # @DESCRIPTION:
37     # This gets set to a non-zero value when a package is considered a kde or
38 johu 1.61 # kdevelop ebuild.
39 johu 1.72 if [[ ${CATEGORY} = kde-base || ${CATEGORY} = kde-apps ]]; then
40 ingmar 1.1 debug-print "${ECLASS}: KDEBASE ebuild recognized"
41 scarabeus 1.10 KDEBASE=kde-base
42 scarabeus 1.45 elif [[ ${KMNAME-${PN}} = kdevelop ]]; then
43     KDEBASE=kdevelop
44 ingmar 1.1 fi
45    
46 johu 1.72 debug-print "${ECLASS}: ${KDEBASE} ebuild recognized"
47    
48 scarabeus 1.45 # determine the build type
49 abcd 1.51 if [[ ${PV} = *9999* ]]; then
50 johu 1.60 KDE_BUILD_TYPE="live"
51 scarabeus 1.45 else
52 johu 1.60 KDE_BUILD_TYPE="release"
53 scarabeus 1.45 fi
54 johu 1.60 export KDE_BUILD_TYPE
55 scarabeus 1.45
56 johu 1.60 # Set reponame and SCM for modules that have fully migrated to git
57 scarabeus 1.45 # (hack - it's here because it needs to be before SCM inherits from kde4-base)
58 johu 1.60 if [[ ${KDE_BUILD_TYPE} == live ]]; then
59 scarabeus 1.45 case "${KMNAME}" in
60     kdebase-workspace)
61     EGIT_REPONAME=${EGIT_REPONAME:=kde-workspace}
62     ;;
63     kdebase-runtime)
64     EGIT_REPONAME=${EGIT_REPONAME:=kde-runtime}
65     ;;
66     esac
67     fi
68    
69     # @ECLASS-VARIABLE: KDE_SCM
70     # @DESCRIPTION:
71     # If this is a live package which scm does it use
72 alexxy 1.63 # Everything else uses git by default
73     KDE_SCM="${KDE_SCM:-git}"
74 scarabeus 1.45 case ${KDE_SCM} in
75     svn|git) ;;
76     *) die "KDE_SCM: ${KDE_SCM} is not supported" ;;
77     esac
78    
79     # @ECLASS-VARIABLE: KDE_LINGUAS
80     # @DESCRIPTION:
81     # This is a whitespace-separated list of translations this ebuild supports.
82     # These translations are automatically added to IUSE. Therefore ebuilds must set
83     # this variable before inheriting any eclasses. To enable only selected
84     # translations, ebuilds must call enable_selected_linguas(). kde4-{base,meta}.eclass does
85     # this for you.
86     #
87 johu 1.61 # Example: KDE_LINGUAS="de en_GB nl"
88 johu 1.60 if [[ ${KDE_BUILD_TYPE} != live || -n ${KDE_LINGUAS_LIVE_OVERRIDE} ]]; then
89 scarabeus 1.45 for _lingua in ${KDE_LINGUAS}; do
90     IUSE="${IUSE} linguas_${_lingua}"
91     done
92     fi
93    
94 ingmar 1.1 # @FUNCTION: buildsycoca
95     # @DESCRIPTION:
96     # Function to rebuild the KDE System Configuration Cache.
97     # All KDE ebuilds should run this in pkg_postinst and pkg_postrm.
98     buildsycoca() {
99     debug-print-function ${FUNCNAME} "$@"
100 scarabeus 1.19
101 alexxy 1.25 # We no longer need to run kbuildsycoca4, as kded does that automatically, as needed
102 scarabeus 1.15
103     # fix permission for some directories
104 abcd 1.52 for x in usr/share/{config,kde4}; do
105     DIRS=${EROOT}usr
106     [[ -d "${EROOT}${x}" ]] || break # nothing to do if directory does not exist
107     # fixes Bug 318237
108     if use userland_BSD ; then
109     [[ $(stat -f %p "${EROOT}${x}") != 40755 ]]
110     local stat_rtn="$?"
111     else
112     [[ $(stat --format=%a "${EROOT}${x}") != 755 ]]
113     local stat_rtn=$?
114     fi
115     if [[ $stat_rtn != 1 ]] ; then
116     ewarn "QA Notice:"
117     ewarn "Package ${PN} is breaking ${EROOT}${x} permissions."
118     ewarn "Please report this issue to gentoo bugzilla."
119     einfo "Permissions will get adjusted automatically now."
120     find "${EROOT}${x}" -type d -print0 | xargs -0 chmod 755
121     fi
122 scarabeus 1.15 done
123 ingmar 1.1 }
124    
125     # @FUNCTION: comment_all_add_subdirectory
126     # @USAGE: [list of directory names]
127     # @DESCRIPTION:
128 scarabeus 1.10 # Recursively comment all add_subdirectory instructions in listed directories,
129     # except those in cmake/.
130 ingmar 1.1 comment_all_add_subdirectory() {
131     find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \
132 wired 1.22 xargs -0 sed -i \
133     -e '/^[[:space:]]*add_subdirectory/s/^/#DONOTCOMPILE /' \
134     -e '/^[[:space:]]*ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' \
135     -e '/^[[:space:]]*macro_optional_add_subdirectory/s/^/#DONOTCOMPILE /' \
136     -e '/^[[:space:]]*MACRO_OPTIONAL_ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' \
137     || die "${LINENO}: Initial sed died"
138 ingmar 1.1 }
139    
140 zlin 1.5 # @FUNCTION: enable_selected_linguas
141     # @DESCRIPTION:
142 scarabeus 1.10 # Enable translations based on LINGUAS settings and translations supported by
143     # the package (see KDE_LINGUAS). By default, translations are found in "${S}"/po
144 zlin 1.5 # but this default can be overridden by defining KDE_LINGUAS_DIR.
145     enable_selected_linguas() {
146 wired 1.22 debug-print-function ${FUNCNAME} "$@"
147    
148 alexxy 1.37 local x
149 scarabeus 1.10
150 scarabeus 1.19 # if there is no linguas defined we enable everything
151 scarabeus 1.20 if ! $(env | grep -q "^LINGUAS="); then
152     return 0
153     fi
154 wired 1.22
155     # @ECLASS-VARIABLE: KDE_LINGUAS_DIR
156     # @DESCRIPTION:
157     # Specified folder where application translations are located.
158 alexxy 1.37 # Can be defined as array of folders where translations are located.
159     # Note that space separated list of dirs is not supported.
160     # Default value is set to "po".
161     if [[ "$(declare -p KDE_LINGUAS_DIR 2>/dev/null 2>&1)" == "declare -a"* ]]; then
162     debug-print "$FUNCNAME: we have these subfolders defined: ${KDE_LINGUAS_DIR}"
163 scarabeus 1.45 for x in ${KDE_LINGUAS_DIR[@]}; do
164 alexxy 1.37 _enable_selected_linguas_dir ${x}
165     done
166     else
167     KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:="po"}
168     _enable_selected_linguas_dir ${KDE_LINGUAS_DIR}
169     fi
170 wired 1.22 }
171    
172     # @FUNCTION: enable_selected_doc_linguas
173     # @DESCRIPTION:
174     # Enable only selected linguas enabled doc folders.
175     enable_selected_doc_linguas() {
176     debug-print-function ${FUNCNAME} "$@"
177    
178     # @ECLASS-VARIABLE: KDE_DOC_DIRS
179     # @DESCRIPTION:
180     # Variable specifying whitespace separated patterns for documentation locations.
181     # Default is "doc/%lingua"
182     KDE_DOC_DIRS=${KDE_DOC_DIRS:='doc/%lingua'}
183     local linguas
184     for pattern in ${KDE_DOC_DIRS}; do
185    
186     local handbookdir=`dirname ${pattern}`
187     local translationdir=`basename ${pattern}`
188     # Do filename pattern supplied, treat as directory
189 scarabeus 1.45 [[ ${handbookdir} = '.' ]] && handbookdir=${translationdir} && translationdir=
190     [[ -d ${handbookdir} ]] || die 'wrong doc dir specified'
191 wired 1.22
192     if ! use handbook; then
193     # Disable whole directory
194     sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${handbookdir}[[:space:]]*)/s/^/#DONOTCOMPILE /" \
195     -e "/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${handbookdir}[[:space:]]*)/s/^/#DONOTCOMPILE /" \
196     -i CMakeLists.txt || die 'failed to comment out all handbooks'
197     else
198 dilfridge 1.59 # if there is no linguas defined we enable everything (i.e. comment out nothing)
199     if ! $(env | grep -q "^LINGUAS="); then
200     return 0
201     fi
202    
203 wired 1.22 # Disable subdirectories recursively
204     comment_all_add_subdirectory "${handbookdir}"
205 kensington 1.71
206     # In certain packages, the default handbook is en_US instead of the usual en. Since there is no en_US 'translation',
207     # it makes no sense to add to KDE_LINGUAS which causes this type of handbook to not be installed.
208     if [[ -d "${handbookdir}/en_US" && ! -d "${handbookdir}/en" ]]; then
209     mv "${handbookdir}/en_US" "${handbookdir}/en" || die
210     sed -e "s/en_US/en/" -i "${handbookdir}/CMakeLists.txt"
211     fi
212    
213 wired 1.22 # Add requested translations
214     local lingua
215     for lingua in en ${KDE_LINGUAS}; do
216 scarabeus 1.45 if [[ ${lingua} = en ]] || use linguas_${lingua}; then
217     if [[ -d ${handbookdir}/${translationdir//%lingua/${lingua}} ]]; then
218 wired 1.22 sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${translationdir//%lingua/${lingua}}/s/^#DONOTCOMPILE //" \
219     -e "/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${translationdir//%lingua/${lingua}}/s/^#DONOTCOMPILE //" \
220     -i "${handbookdir}"/CMakeLists.txt && ! has ${lingua} ${linguas} && linguas="${linguas} ${lingua}"
221     fi
222     fi
223     done
224     fi
225    
226     done
227     [[ -n "${linguas}" ]] && einfo "Enabling handbook translations:${linguas}"
228 zlin 1.5 }
229    
230 scarabeus 1.10 # Functions handling KMLOADLIBS and KMSAVELIBS
231 ingmar 1.1
232 scarabeus 1.10 # @FUNCTION: save_library_dependencies
233     # @DESCRIPTION:
234     # Add exporting CMake dependencies for current package
235     save_library_dependencies() {
236 abcd 1.51 local depsfile="${T}/${PN}"
237 scarabeus 1.10
238 scarabeus 1.15 ebegin "Saving library dependencies in ${depsfile##*/}"
239 scarabeus 1.10 echo "EXPORT_LIBRARY_DEPENDENCIES(\"${depsfile}\")" >> "${S}/CMakeLists.txt" || \
240     die "Failed to save the library dependencies."
241     eend $?
242 ingmar 1.1 }
243    
244 scarabeus 1.10 # @FUNCTION: install_library_dependencies
245 ingmar 1.1 # @DESCRIPTION:
246 scarabeus 1.10 # Install generated CMake library dependencies to /var/lib/kde
247     install_library_dependencies() {
248 abcd 1.51 local depsfile="${T}/${PN}"
249 scarabeus 1.15
250     ebegin "Installing library dependencies as ${depsfile##*/}"
251 abcd 1.28 insinto /var/lib/kde
252 scarabeus 1.10 doins "${depsfile}" || die "Failed to install library dependencies."
253     eend $?
254     }
255 ingmar 1.1
256 scarabeus 1.10 # @FUNCTION: load_library_dependencies
257     # @DESCRIPTION:
258     # Inject specified library dependencies in current package
259     load_library_dependencies() {
260     local pn i depsfile
261 scarabeus 1.15 ebegin "Injecting library dependencies from '${KMLOADLIBS}'"
262 scarabeus 1.10
263     i=0
264     for pn in ${KMLOADLIBS} ; do
265     ((i++))
266 abcd 1.51 depsfile="${EPREFIX}/var/lib/kde/${pn}"
267     [[ -r ${depsfile} ]] || depsfile="${EPREFIX}/var/lib/kde/${pn}:$(get_kde_version)"
268 scarabeus 1.45 [[ -r ${depsfile} ]] || die "Depsfile '${depsfile}' not accessible. You probably need to reinstall ${pn}."
269 scarabeus 1.10 sed -i -e "${i}iINCLUDE(\"${depsfile}\")" "${S}/CMakeLists.txt" || \
270     die "Failed to include library dependencies for ${pn}"
271     done
272     eend $?
273 ingmar 1.1 }
274 scarabeus 1.23
275 johu 1.72 # @FUNCTION: add_kdeapps_dep
276 alexxy 1.37 # @DESCRIPTION:
277 johu 1.72 # Create proper dependency for kde-apps/ dependencies.
278 scarabeus 1.45 # This takes 1 to 3 arguments. The first being the package name, the optional
279     # second is additional USE flags to append, and the optional third is the
280     # version to use instead of the automatic version (use sparingly).
281     # The output of this should be added directly to DEPEND/RDEPEND, and may be
282     # wrapped in a USE conditional (but not an || conditional without an extra set
283     # of parentheses).
284 johu 1.72 add_kdeapps_dep() {
285 alexxy 1.37 debug-print-function ${FUNCNAME} "$@"
286    
287 scarabeus 1.45 local ver
288    
289     if [[ -n ${3} ]]; then
290     ver=${3}
291     elif [[ -n ${KDE_OVERRIDE_MINIMAL} ]]; then
292     ver=${KDE_OVERRIDE_MINIMAL}
293     elif [[ ${KDEBASE} != kde-base ]]; then
294     ver=${KDE_MINIMAL}
295 abcd 1.54 # if building stable-live version depend just on the raw KDE version
296 scarabeus 1.45 # to allow merging packages against more stable basic stuff
297     elif [[ ${PV} == *.9999 ]]; then
298 abcd 1.51 ver=$(get_kde_version)
299 scarabeus 1.45 else
300     ver=${PV}
301     fi
302    
303 alexxy 1.37 [[ -z ${1} ]] && die "Missing parameter"
304    
305 johu 1.72 #FIXME
306     # Drop aqua= from kf5 packages
307     echo " >=kde-apps/${1}-${ver}:4[aqua=${2:+,${2}}]"
308     }
309    
310     # @FUNCTION: add_kdebase_dep
311     # @DESCRIPTION:
312     # Create proper dependency for kde-base/ dependencies.
313     # This takes 1 to 3 arguments. The first being the package name, the optional
314     # second is additional USE flags to append, and the optional third is the
315     # version to use instead of the automatic version (use sparingly).
316     # The output of this should be added directly to DEPEND/RDEPEND, and may be
317     # wrapped in a USE conditional (but not an || conditional without an extra set
318     # of parentheses).
319     add_kdebase_dep() {
320     debug-print-function ${FUNCNAME} "$@"
321    
322     local ver
323    
324     if [[ -n ${3} ]]; then
325     ver=${3}
326     elif [[ -n ${KDE_OVERRIDE_MINIMAL} ]]; then
327     ver=${KDE_OVERRIDE_MINIMAL}
328 patrick 1.74 elif [[ -n ${KDE_MINIMAL} ]]; then
329 johu 1.72 ver=${KDE_MINIMAL}
330     # if building live version depend on the final release since there will
331     # not be any more major development. this solves dep errors as not all
332     # packages have kde-base live versions now
333    
334     # depend on the last sane released version where the normal >=${PV} dep
335     # is not possible
336 patrick 1.75 elif [[ ${CATEGORY} == kde-apps || ${PV} == *9999 ]]; then
337 johu 1.72 ver=4.14.3
338     else
339     ver=${PV}
340     fi
341    
342     [[ -z ${1} ]] && die "Missing parameter"
343    
344 abcd 1.54 echo " >=kde-base/${1}-${ver}:4[aqua=${2:+,${2}}]"
345 alexxy 1.25 }
346    
347 alexxy 1.37 # local function to enable specified translations for specified directory
348     # used from kde4-functions_enable_selected_linguas function
349     _enable_selected_linguas_dir() {
350     local lingua linguas sr_mess wp
351     local dir=${1}
352 alexxy 1.25
353 scarabeus 1.45 [[ -d ${dir} ]] || die "linguas dir \"${dir}\" does not exist"
354 alexxy 1.37 comment_all_add_subdirectory "${dir}"
355     pushd "${dir}" > /dev/null
356 alexxy 1.25
357 alexxy 1.37 # fix all various crazy sr@Latn variations
358     # this part is only ease for ebuilds, so there wont be any die when this
359     # fail at any point
360     sr_mess="sr@latn sr@latin sr@Latin"
361     for wp in ${sr_mess}; do
362 scarabeus 1.45 [[ -e ${wp}.po ]] && mv "${wp}.po" "sr@Latn.po"
363     if [[ -d ${wp} ]]; then
364 alexxy 1.37 # move dir and fix cmakelists
365     mv "${wp}" "sr@Latn"
366     sed -i \
367 scarabeus 1.45 -e "s:${wp}:sr@Latn:g" \
368 alexxy 1.37 CMakeLists.txt
369     fi
370     done
371 alexxy 1.25
372 alexxy 1.37 for lingua in ${KDE_LINGUAS}; do
373 scarabeus 1.45 if [[ -e ${lingua}.po ]]; then
374 alexxy 1.37 mv "${lingua}.po" "${lingua}.po.old"
375 reavertm 1.35 fi
376 alexxy 1.37 done
377    
378     for lingua in ${KDE_LINGUAS}; do
379     if use linguas_${lingua} ; then
380 scarabeus 1.45 if [[ -d ${lingua} ]]; then
381 alexxy 1.37 linguas="${linguas} ${lingua}"
382     sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
383     -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
384     -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed."
385     fi
386 scarabeus 1.45 if [[ -e ${lingua}.po.old ]]; then
387 alexxy 1.37 linguas="${linguas} ${lingua}"
388     mv "${lingua}.po.old" "${lingua}.po"
389     fi
390 reavertm 1.34 fi
391 alexxy 1.37 done
392 scarabeus 1.45 [[ -n ${linguas} ]] && echo ">>> Enabling languages: ${linguas}"
393 alexxy 1.37
394     popd > /dev/null
395 scarabeus 1.23 }
396 scarabeus 1.45
397 abcd 1.51 # @FUNCTION: get_kde_version
398 vapier 1.56 # @DESCRIPTION:
399 abcd 1.51 # Translates an ebuild version into a major.minor KDE SC
400     # release version. If no version is specified, ${PV} is used.
401     get_kde_version() {
402 scarabeus 1.45 local ver=${1:-${PV}}
403     local major=$(get_major_version ${ver})
404     local minor=$(get_version_component_range 2 ${ver})
405     local micro=$(get_version_component_range 3 ${ver})
406 abcd 1.52 if [[ ${ver} == 9999 ]]; then
407     echo live
408     else
409 scarabeus 1.45 (( micro < 50 )) && echo ${major}.${minor} || echo ${major}.$((minor + 1))
410     fi
411     }
412 kensington 1.64
413     fi

  ViewVC Help
Powered by ViewVC 1.1.20