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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (show annotations) (download)
Fri Apr 17 10:41:29 2009 UTC (5 years, 4 months ago) by scarabeus
Branch: MAIN
Changes since 1.15: +2 -1 lines
Add line noting that the warning is pure QA. Per discussion with yngwin on #g-dev

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

  ViewVC Help
Powered by ViewVC 1.1.20