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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (show annotations) (download)
Mon Mar 9 19:41:26 2009 UTC (5 years, 6 months ago) by scarabeus
Branch: MAIN
Changes since 1.13: +4 -3 lines
Sync kde4 eclasses with kde-testing (review by scarabeus and jmbsvicetto).

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.12 2009/02/10 20:07:24 scarabeus Exp $
4
5 # @ECLASS: kde4-functions.eclass
6 # @MAINTAINER:
7 # kde@gentoo.org
8 # @BLURB: Common ebuild functions for KDE 4 packages
9 # @DESCRIPTION:
10 # This eclass contains all functions shared by the different eclasses,
11 # for KDE 4 ebuilds.
12
13 # @ECLASS-VARIABLE: EAPI
14 # @DESCRIPTION:
15 # By default kde4 eclasses wants eapi 2 which might be redefinable to newer
16 # versions.
17 case ${EAPI:-0} in
18 2) : ;;
19 *) die "No way! EAPI other than 2 is not supported for now." ;;
20 esac
21
22 # @ECLASS-VARIABLE: KDEBASE
23 # @DESCRIPTION:
24 # This gets set to a non-zero value when a package is considered a kde or
25 # koffice ebuild.
26
27 if [[ $CATEGORY = kde-base ]]; then
28 debug-print "${ECLASS}: KDEBASE ebuild recognized"
29 KDEBASE=kde-base
30 fi
31
32 # is this a koffice ebuild?
33 if [[ $KMNAME = koffice || $PN = koffice ]]; then
34 debug-print "${ECLASS}: KOFFICE ebuild recognized"
35 KDEBASE=koffice
36 fi
37
38 # @ECLASS-VARIABLE: KDE_SLOTS
39 # @DESCRIPTION:
40 # The slots used by all KDE versions later than 4.0. The live-ebuilds use
41 # KDE_LIVE_SLOTS instead.
42 KDE_SLOTS=( kde-4 4.1 4.2 4.3 )
43
44 # @ECLASS-VARIABLE: KDE_LIVE_SLOTS
45 # @DESCRIPTION:
46 # The slots used by all KDE live versions.
47 KDE_LIVE_SLOTS=( live )
48
49 # @FUNCTION: buildsycoca
50 # @DESCRIPTION:
51 # Function to rebuild the KDE System Configuration Cache.
52 # All KDE ebuilds should run this in pkg_postinst and pkg_postrm.
53 #
54 # Note that kde4-base.eclass already does this.
55 buildsycoca() {
56 debug-print-function ${FUNCNAME} "$@"
57
58 if [[ -z ${ROOT%%/} && -x ${KDEDIR}/bin/kbuildsycoca4 ]]; then
59 # Make sure tha cache file exists, or kbuildsycoca4 will fail
60 touch "${KDEDIR}/share/kde4/services/ksycoca4"
61
62 # We have to unset DISPLAY and DBUS_SESSION_BUS_ADDRESS, the ones
63 # in the user's environment (through su [without '-']) may cause
64 # kbuildsycoca4 to hang.
65
66 ebegin "Running kbuildsycoca4 to build global database"
67 # This is needed because we support multiple kde versions installed together.
68 XDG_DATA_DIRS="/usr/share:${KDEDIR}/share:/usr/local/share" \
69 DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \
70 ${KDEDIR}/bin/kbuildsycoca4 --global --noincremental &> /dev/null
71 eend $?
72 fi
73 }
74
75 # @FUNCTION: comment_all_add_subdirectory
76 # @USAGE: [list of directory names]
77 # @DESCRIPTION:
78 # Recursively comment all add_subdirectory instructions in listed directories,
79 # except those in cmake/.
80 comment_all_add_subdirectory() {
81 find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \
82 xargs -0 sed -i -e '/add_subdirectory/s/^/#DONOTCOMPILE /' -e '/ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' || \
83 die "${LINENO}: Initial sed died"
84 }
85
86 # @ECLASS-VARIABLE: KDE_LINGUAS
87 # @DESCRIPTION:
88 # This is a whitespace-separated list of translations this ebuild supports.
89 # These translations are automatically added to IUSE. Therefore ebuilds must set
90 # this variable before inheriting any eclasses. To enable only selected
91 # translations, ebuilds must call enable_selected_linguas(). kde4-base.eclass does
92 # this for you.
93 #
94 # Example: KDE_LINGUAS="en_GB de nl"
95 for _lingua in ${KDE_LINGUAS}; do
96 IUSE="${IUSE} linguas_${_lingua}"
97 done
98
99 # @FUNCTION: enable_selected_linguas
100 # @DESCRIPTION:
101 # Enable translations based on LINGUAS settings and translations supported by
102 # the package (see KDE_LINGUAS). By default, translations are found in "${S}"/po
103 # but this default can be overridden by defining KDE_LINGUAS_DIR.
104 enable_selected_linguas() {
105 local lingua sr_mess wp
106
107 # ebuild overridable linguas directory definition
108 KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:=${S}/po}
109 cd "$KDE_LINGUAS_DIR" || die "wrong linguas dir specified"
110
111 # fix all various crazy sr@Latn variations
112 # this part is only ease for ebuilds, so there wont be any die when this
113 # fail at any point
114 sr_mess="sr@latn sr@latin sr@Latin"
115 for wp in ${sr_mess}; do
116 [[ -e "$wp.po" ]] && mv "$wp.po" "sr@Latn.po"
117 if [[ -d "$wp" ]]; then
118 # move dir and fix cmakelists
119 mv "$wp" "sr@Latn"
120 sed -i \
121 -e "s:$wp:sr@Latin:g" \
122 CMakeLists.txt
123 fi
124 done
125
126 for lingua in ${KDE_LINGUAS}; do
127 if [[ -e "$lingua.po" ]]; then
128 mv "$lingua.po" "$lingua.po.old"
129 fi
130 done
131 comment_all_add_subdirectory "${KDE_LINGUAS_DIR}"
132 for lingua in ${LINGUAS}; do
133 ebegin "Enabling LANGUAGE: ${lingua}"
134 if [[ -d "$lingua" ]]; then
135 sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
136 -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
137 -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed."
138 fi
139 if [[ -e "$lingua.po.old" ]]; then
140 mv "$lingua.po.old" "$lingua.po"
141 fi
142 eend $?
143 done
144 }
145
146 # @FUNCTION: get_build_type
147 # @DESCRIPTION:
148 # Determine whether we are using live ebuild or tbzs.
149 get_build_type() {
150 if [[ $SLOT = live || $PV = 9999* ]]; then
151 BUILD_TYPE="live"
152 else
153 BUILD_TYPE="release"
154 fi
155 export BUILD_TYPE
156 }
157
158 # @FUNCTION: get_latest_kdedir
159 # @DESCRIPTION:
160 # We set up KDEDIR according to the latest KDE version installed; installing our
161 # package for all available installs is just insane.
162 # We can check for kdelibs because it is the most basic package; no KDE package
163 # working without it. This might be changed in future.
164 get_latest_kdedir() {
165 case ${KDE_WANTED} in
166 # note this will need to be updated as stable moves and so on
167 live)
168 _versions="9999 4.2.61 4.2.0 4.1.0"
169 ;;
170 snapshot)
171 _versions="4.2.61 4.2.0 4.1.0 9999"
172 ;;
173 testing)
174 _versions="4.2.0 4.1.0 4.2.61 9999"
175 ;;
176 stable)
177 _versions="4.2.0 4.1.0 4.1.61 9999"
178 ;;
179 *) die "KDE_WANTED=${KDE_WANTED} not supported here." ;;
180 esac
181 # check if exists and fallback as we go
182 for X in ${_versions}; do
183 if has_version ">=kde-base/kdelibs-${X}"; then
184 # figure out which X we are in and set it into _kdedir
185 case ${X} in
186 # also keep track here same for kde_wanted
187 9999)
188 _kdedir="live"
189 break
190 ;;
191 4.3.0 | 4.2.61)
192 _kdedir="4.3"
193 break
194 ;;
195 4.2.0 | 4.1.61)
196 _kdedir="4.2"
197 break
198 ;;
199 4.1.0)
200 _kdedir="4.1"
201 break
202 ;;
203 esac
204 fi
205 done
206
207 debug-print-function ${FUNCNAME} "$@" "KDE_WANTED=${KDE_WANTED} -> _kdedir=${_kdedir}"
208 }
209
210 # @FUNCTION: migrate_store_dir
211 # @DESCRIPTION:
212 # Migrate the remnants of ${ESVN_STORE_DIR}/KDE/ to ${ESVN_STORE_DIR}/.
213 # Perform experimental split of kdebase to kdebase-apps.
214 migrate_store_dir() {
215 local cleandir
216 cleandir="${ESVN_STORE_DIR}/KDE"
217 if [[ -d "${cleandir}" ]]; then
218 ewarn "'${cleandir}' has been found. Moving contents to new location."
219 addwrite "${ESVN_STORE_DIR}"
220 # Split kdebase
221 local module
222 if pushd "${cleandir}"/kdebase/kdebase > /dev/null; then
223 for module in `find . -maxdepth 1 -type d -name [a-z0-9]\*`; do
224 module="${module#./}"
225 mkdir -p "${ESVN_STORE_DIR}/kdebase-${module}" && mv -f "${module}" "${ESVN_STORE_DIR}/kdebase-${module}" || \
226 die "Failed to move to '${ESVN_STORE_DIR}/kdebase-${module}'."
227 done
228 popd > /dev/null
229 rm -fr "${cleandir}/kdebase" || \
230 die "Failed to remove ${cleandir}/kdebase. You need to remove it manually."
231 fi
232 # Move the rest
233 local pkg
234 for pkg in "${cleandir}"/*; do
235 mv -f "${pkg}" "${ESVN_STORE_DIR}"/ || eerror "failed to move ${pkg}"
236 done
237 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."
238 fi
239 }
240
241 # Functions handling KMLOADLIBS and KMSAVELIBS
242
243 # @FUNCTION: save_library_dependencies
244 # @DESCRIPTION:
245 # Add exporting CMake dependencies for current package
246 save_library_dependencies() {
247 local depsfile="${T}/${PN}:${SLOT}"
248
249 ebegin "Saving library dependendencies in ${depsfile##*/}"
250 echo "EXPORT_LIBRARY_DEPENDENCIES(\"${depsfile}\")" >> "${S}/CMakeLists.txt" || \
251 die "Failed to save the library dependencies."
252 eend $?
253 }
254
255 # @FUNCTION: install_library_dependencies
256 # @DESCRIPTION:
257 # Install generated CMake library dependencies to /var/lib/kde
258 install_library_dependencies() {
259 local depsfile="$T/$PN:$SLOT"
260 ebegin "Installing library dependendencies as ${depsfile##*/}"
261 insinto /var/lib/kde
262 doins "${depsfile}" || die "Failed to install library dependencies."
263 eend $?
264 }
265
266 # @FUNCTION: load_library_dependencies
267 # @DESCRIPTION:
268 # Inject specified library dependencies in current package
269 load_library_dependencies() {
270 local pn i depsfile
271 ebegin "Injecting library dependendencies from '${KMLOADLIBS}'"
272
273 i=0
274 for pn in ${KMLOADLIBS} ; do
275 ((i++))
276 depsfile="/var/lib/kde/${pn}:${SLOT}"
277 [[ -r "${depsfile}" ]] || die "Depsfile '${depsfile}' not accessible. You probably need to reinstall ${pn}."
278 sed -i -e "${i}iINCLUDE(\"${depsfile}\")" "${S}/CMakeLists.txt" || \
279 die "Failed to include library dependencies for ${pn}"
280 done
281 eend $?
282 }

  ViewVC Help
Powered by ViewVC 1.1.20