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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.19 - (show annotations) (download)
Thu May 28 09:47:52 2009 UTC (5 years, 5 months ago) by scarabeus
Branch: MAIN
Changes since 1.18: +27 -20 lines
Update kde4 eclasses from kde-testing. Mostly minor sinc. Introduce support for stable koffice2

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 # @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 *) DEPEND="EAPI-TOO-OLD" ;;
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 KDE releases use
41 # KDE_LIVE_SLOTS instead. Values should be ordered.
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 KDE live versions. Values should be ordered.
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 buildsycoca() {
54 debug-print-function ${FUNCNAME} "$@"
55
56 if [[ -z ${ROOT%%/} && -x ${KDEDIR}/bin/kbuildsycoca4 ]]; then
57 # Make sure tha cache file exists, writable by root and readable by
58 # others. Otherwise kbuildsycoca4 will fail.
59 touch "${KDEDIR}/share/kde4/services/ksycoca4"
60 chmod 644 "${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 # Lookup in order - local, KDEDIR, /usr, do not duplicate entries btw.
69 local KDEDIRS="${ROOT}usr/share"
70 [[ ${KDEDIR} != "${ROOT}usr" ]] && KDEDIRS="${KDEDIR}/share:${KDEDIRS}"
71 XDG_DATA_DIRS="${ROOT}usr/local/share:${KDEDIRS}" \
72 DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \
73 ${KDEDIR}/bin/kbuildsycoca4 --global --noincremental &> /dev/null
74 eend $?
75 fi
76
77 # fix permission for some directories
78 for x in share/config share/kde4; do
79 [[ ${KDEDIR} = ${ROOT}usr ]] && DIRS=${ROOT}usr || DIRS="${ROOT}usr ${KDEDIR}"
80 for y in ${DIRS}; do
81 [[ -d "${y}/${x}" ]] || break # nothing to do if directory does not exist
82 if [[ $(stat --format=%a "${y}/${x}") != 755 ]]; then
83 ewarn "QA Notice:"
84 ewarn "Package ${PN} is breaking ${y}/${x} permissions."
85 ewarn "Please report this issue to gentoo bugzilla."
86 einfo "Permissions will get adjusted automatically now."
87 find "${y}/${x}" -type d -print0 | xargs -0 chmod 755
88 fi
89 done
90 done
91 }
92
93 # @FUNCTION: comment_all_add_subdirectory
94 # @USAGE: [list of directory names]
95 # @DESCRIPTION:
96 # Recursively comment all add_subdirectory instructions in listed directories,
97 # except those in cmake/.
98 comment_all_add_subdirectory() {
99 find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \
100 xargs -0 sed -i -e '/add_subdirectory/s/^/#DONOTCOMPILE /' -e '/ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' || \
101 die "${LINENO}: Initial sed died"
102 }
103
104 # @ECLASS-VARIABLE: KDE_LINGUAS
105 # @DESCRIPTION:
106 # This is a whitespace-separated list of translations this ebuild supports.
107 # These translations are automatically added to IUSE. Therefore ebuilds must set
108 # this variable before inheriting any eclasses. To enable only selected
109 # translations, ebuilds must call enable_selected_linguas(). kde4-{base,meta}.eclass does
110 # this for you.
111 #
112 # Example: KDE_LINGUAS="en_GB de nl"
113 for _lingua in ${KDE_LINGUAS}; do
114 IUSE="${IUSE} linguas_${_lingua}"
115 done
116
117 # @FUNCTION: enable_selected_linguas
118 # @DESCRIPTION:
119 # Enable translations based on LINGUAS settings and translations supported by
120 # 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.
122 enable_selected_linguas() {
123 local lingua sr_mess wp
124
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
129 # [[ ! ${LINGUAS+set} = set ]] && LINGUAS="*"
130 # ebuild overridable linguas directory definition
131 KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:="${S}/po"}
132 cd "${KDE_LINGUAS_DIR}" || die "wrong linguas dir specified"
133
134 # fix all various crazy sr@Latn variations
135 # this part is only ease for ebuilds, so there wont be any die when this
136 # fail at any point
137 sr_mess="sr@latn sr@latin sr@Latin"
138 for wp in ${sr_mess}; do
139 [[ -e "${wp}.po" ]] && mv "${wp}.po" "sr@Latn.po"
140 if [[ -d "${wp}" ]]; then
141 # move dir and fix cmakelists
142 mv "${wp}" "sr@Latn"
143 sed -i \
144 -e "s:${wp}:sr@Latin:g" \
145 CMakeLists.txt
146 fi
147 done
148
149 for lingua in ${KDE_LINGUAS}; do
150 if [[ -e "${lingua}.po" ]]; then
151 mv "${lingua}.po" "${lingua}.po.old"
152 fi
153 done
154 comment_all_add_subdirectory "${KDE_LINGUAS_DIR}"
155 for lingua in ${KDE_LINGUAS}; do
156 if use linguas_${lingua} ; then
157 ebegin "Enabling LANGUAGE: ${lingua}"
158 if [[ -d "${lingua}" ]]; then
159 sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
160 -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
161 -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed."
162 fi
163 if [[ -e "${lingua}.po.old" ]]; then
164 mv "${lingua}.po.old" "${lingua}.po"
165 fi
166 eend $?
167 fi
168 done
169 }
170
171 # @FUNCTION: get_build_type
172 # @DESCRIPTION:
173 # Determine whether we are using live ebuild or tbzs.
174 get_build_type() {
175 if [[ ${SLOT} = live || ${PV} = *9999* ]]; then
176 BUILD_TYPE="live"
177 else
178 BUILD_TYPE="release"
179 fi
180 export BUILD_TYPE
181 }
182
183 # @FUNCTION: migrate_store_dir
184 # @DESCRIPTION:
185 # Universal store dir migration
186 # * performs split of kdebase to kdebase-apps when needed
187 # * moves playground/extragear kde4-base-style to toplevel dir
188 migrate_store_dir() {
189 local cleandir="${ESVN_STORE_DIR}/KDE"
190 if [[ -d "${cleandir}" ]]; then
191 ewarn "'${cleandir}' has been found. Moving contents to new location."
192 addwrite "${ESVN_STORE_DIR}"
193 # Split kdebase
194 local module
195 if pushd "${cleandir}"/kdebase/kdebase > /dev/null; then
196 for module in `find . -maxdepth 1 -type d -name [a-z0-9]\*`; do
197 module="${module#./}"
198 mkdir -p "${ESVN_STORE_DIR}/kdebase-${module}" && mv -f "${module}" "${ESVN_STORE_DIR}/kdebase-${module}" || \
199 die "Failed to move to '${ESVN_STORE_DIR}/kdebase-${module}'."
200 done
201 popd > /dev/null
202 rm -fr "${cleandir}/kdebase" || \
203 die "Failed to remove ${cleandir}/kdebase. You need to remove it manually."
204 fi
205 # Move the rest
206 local pkg
207 for pkg in "${cleandir}"/*; do
208 mv -f "${pkg}" "${ESVN_STORE_DIR}"/ || eerror "Failed to move '${pkg}'"
209 done
210 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."
211 fi
212
213 if ! hasq kde4-meta ${INHERITED}; then
214 case ${KMNAME} in
215 extragear*|playground*)
216 local svnlocalpath="${ESVN_STORE_DIR}"/"${KMNAME}"/"${PN}"
217 if [[ -d "${svnlocalpath}" ]]; then
218 local destdir="${ESVN_STORE_DIR}"/"${ESVN_PROJECT}"/"`basename "${ESVN_REPO_URI}"`"
219 ewarn "'${svnlocalpath}' has been found."
220 ewarn "Moving contents to new location: ${destdir}"
221 addwrite "${ESVN_STORE_DIR}"
222 mkdir -p "${ESVN_STORE_DIR}"/"${ESVN_PROJECT}" && mv -f "${svnlocalpath}" "${destdir}" \
223 || die "Failed to move to '${svnlocalpath}'"
224 # Try cleaning empty directories
225 rmdir "`dirname "${svnlocalpath}"`" 2> /dev/null
226 fi
227 ;;
228 esac
229 fi
230 }
231
232 # Functions handling KMLOADLIBS and KMSAVELIBS
233
234 # @FUNCTION: save_library_dependencies
235 # @DESCRIPTION:
236 # Add exporting CMake dependencies for current package
237 save_library_dependencies() {
238 local depsfile="${T}/${PN}:${SLOT}"
239
240 ebegin "Saving library dependencies in ${depsfile##*/}"
241 echo "EXPORT_LIBRARY_DEPENDENCIES(\"${depsfile}\")" >> "${S}/CMakeLists.txt" || \
242 die "Failed to save the library dependencies."
243 eend $?
244 }
245
246 # @FUNCTION: install_library_dependencies
247 # @DESCRIPTION:
248 # Install generated CMake library dependencies to /var/lib/kde
249 install_library_dependencies() {
250 local depsfile="${T}/${PN}:${SLOT}"
251
252 ebegin "Installing library dependencies as ${depsfile##*/}"
253 insinto ${ROOT}var/lib/kde
254 doins "${depsfile}" || die "Failed to install library dependencies."
255 eend $?
256 }
257
258 # @FUNCTION: load_library_dependencies
259 # @DESCRIPTION:
260 # Inject specified library dependencies in current package
261 load_library_dependencies() {
262 local pn i depsfile
263 ebegin "Injecting library dependencies from '${KMLOADLIBS}'"
264
265 i=0
266 for pn in ${KMLOADLIBS} ; do
267 ((i++))
268 depsfile="${ROOT}var/lib/kde/${pn}:${SLOT}"
269 [[ -r "${depsfile}" ]] || die "Depsfile '${depsfile}' not accessible. You probably need to reinstall ${pn}."
270 sed -i -e "${i}iINCLUDE(\"${depsfile}\")" "${S}/CMakeLists.txt" || \
271 die "Failed to include library dependencies for ${pn}"
272 done
273 eend $?
274 }

  ViewVC Help
Powered by ViewVC 1.1.20