| 1 | # Copyright 1999-2008 Gentoo Foundation |
1 | # Copyright 1999-2008 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.14 2009/03/09 19:41:26 scarabeus Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.15 2009/04/13 00:02:45 scarabeus Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: kde4-functions.eclass |
5 | # @ECLASS: kde4-functions.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # kde@gentoo.org |
7 | # kde@gentoo.org |
| 8 | # @BLURB: Common ebuild functions for KDE 4 packages |
8 | # @BLURB: Common ebuild functions for KDE 4 packages |
| … | |
… | |
| 22 | # @ECLASS-VARIABLE: KDEBASE |
22 | # @ECLASS-VARIABLE: KDEBASE |
| 23 | # @DESCRIPTION: |
23 | # @DESCRIPTION: |
| 24 | # This gets set to a non-zero value when a package is considered a kde or |
24 | # This gets set to a non-zero value when a package is considered a kde or |
| 25 | # koffice ebuild. |
25 | # koffice ebuild. |
| 26 | |
26 | |
| 27 | if [[ $CATEGORY = kde-base ]]; then |
27 | if [[ ${CATEGORY} = kde-base ]]; then |
| 28 | debug-print "${ECLASS}: KDEBASE ebuild recognized" |
28 | debug-print "${ECLASS}: KDEBASE ebuild recognized" |
| 29 | KDEBASE=kde-base |
29 | KDEBASE=kde-base |
| 30 | fi |
30 | fi |
| 31 | |
31 | |
| 32 | # is this a koffice ebuild? |
32 | # is this a koffice ebuild? |
| 33 | if [[ $KMNAME = koffice || $PN = koffice ]]; then |
33 | if [[ ${KMNAME} = koffice || ${PN} = koffice ]]; then |
| 34 | debug-print "${ECLASS}: KOFFICE ebuild recognized" |
34 | debug-print "${ECLASS}: KOFFICE ebuild recognized" |
| 35 | KDEBASE=koffice |
35 | KDEBASE=koffice |
| 36 | fi |
36 | fi |
| 37 | |
37 | |
| 38 | # @ECLASS-VARIABLE: KDE_SLOTS |
38 | # @ECLASS-VARIABLE: KDE_SLOTS |
| 39 | # @DESCRIPTION: |
39 | # @DESCRIPTION: |
| 40 | # The slots used by all KDE versions later than 4.0. The live-ebuilds use |
40 | # The slots used by all KDE versions later than 4.0. The live KDE releases use |
| 41 | # KDE_LIVE_SLOTS instead. |
41 | # KDE_LIVE_SLOTS instead. Values should be ordered. |
| 42 | KDE_SLOTS=( kde-4 4.1 4.2 4.3 ) |
42 | KDE_SLOTS=( "kde-4" "4.1" "4.2" "4.3" ) |
| 43 | |
43 | |
| 44 | # @ECLASS-VARIABLE: KDE_LIVE_SLOTS |
44 | # @ECLASS-VARIABLE: KDE_LIVE_SLOTS |
| 45 | # @DESCRIPTION: |
45 | # @DESCRIPTION: |
| 46 | # The slots used by all KDE live versions. |
46 | # The slots used by KDE live versions. Values should be ordered. |
| 47 | KDE_LIVE_SLOTS=( live ) |
47 | KDE_LIVE_SLOTS=( "live" ) |
| 48 | |
48 | |
| 49 | # @FUNCTION: buildsycoca |
49 | # @FUNCTION: buildsycoca |
| 50 | # @DESCRIPTION: |
50 | # @DESCRIPTION: |
| 51 | # Function to rebuild the KDE System Configuration Cache. |
51 | # Function to rebuild the KDE System Configuration Cache. |
| 52 | # All KDE ebuilds should run this in pkg_postinst and pkg_postrm. |
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() { |
53 | buildsycoca() { |
| 56 | debug-print-function ${FUNCNAME} "$@" |
54 | debug-print-function ${FUNCNAME} "$@" |
| 57 | |
55 | |
| 58 | if [[ -z ${ROOT%%/} && -x ${KDEDIR}/bin/kbuildsycoca4 ]]; then |
56 | if [[ -z ${ROOT%%/} && -x ${KDEDIR}/bin/kbuildsycoca4 ]]; then |
| 59 | # Make sure tha cache file exists, or kbuildsycoca4 will fail |
57 | # Make sure tha cache file exists, writable by root and readable by |
|
|
58 | # others. Otherwise kbuildsycoca4 will fail. |
| 60 | touch "${KDEDIR}/share/kde4/services/ksycoca4" |
59 | touch "${KDEDIR}/share/kde4/services/ksycoca4" |
|
|
60 | chmod 644 "${KDEDIR}/share/kde4/services/ksycoca4" |
| 61 | |
61 | |
| 62 | # We have to unset DISPLAY and DBUS_SESSION_BUS_ADDRESS, the ones |
62 | # We have to unset DISPLAY and DBUS_SESSION_BUS_ADDRESS, the ones |
| 63 | # in the user's environment (through su [without '-']) may cause |
63 | # in the user's environment (through su [without '-']) may cause |
| 64 | # kbuildsycoca4 to hang. |
64 | # kbuildsycoca4 to hang. |
| 65 | |
65 | |
| 66 | ebegin "Running kbuildsycoca4 to build global database" |
66 | ebegin "Running kbuildsycoca4 to build global database" |
| 67 | # This is needed because we support multiple kde versions installed together. |
67 | # This is needed because we support multiple kde versions installed together. |
| 68 | XDG_DATA_DIRS="/usr/share:${KDEDIR}/share:/usr/local/share" \ |
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}" \ |
| 69 | DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \ |
72 | DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \ |
| 70 | ${KDEDIR}/bin/kbuildsycoca4 --global --noincremental &> /dev/null |
73 | ${KDEDIR}/bin/kbuildsycoca4 --global --noincremental &> /dev/null |
| 71 | eend $? |
74 | eend $? |
| 72 | fi |
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 "Package ${PN} is breaking ${KDEDIR}/${x} permissions." |
|
|
81 | ewarn "Please report this issue to gentoo bugzilla." |
|
|
82 | einfo "Permissions will get adjusted automatically now." |
|
|
83 | find /usr/${x} -type d -print0 | xargs -0 chmod 755 |
|
|
84 | [[ ${KDEDIR} = /usr ]] || find ${KDEDIR}/${x} -type d -print0 | xargs -0 chmod 755 |
|
|
85 | fi |
|
|
86 | done |
| 73 | } |
87 | } |
| 74 | |
88 | |
| 75 | # @FUNCTION: comment_all_add_subdirectory |
89 | # @FUNCTION: comment_all_add_subdirectory |
| 76 | # @USAGE: [list of directory names] |
90 | # @USAGE: [list of directory names] |
| 77 | # @DESCRIPTION: |
91 | # @DESCRIPTION: |
| … | |
… | |
| 103 | # but this default can be overridden by defining KDE_LINGUAS_DIR. |
117 | # but this default can be overridden by defining KDE_LINGUAS_DIR. |
| 104 | enable_selected_linguas() { |
118 | enable_selected_linguas() { |
| 105 | local lingua sr_mess wp |
119 | local lingua sr_mess wp |
| 106 | |
120 | |
| 107 | # ebuild overridable linguas directory definition |
121 | # ebuild overridable linguas directory definition |
| 108 | KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:=${S}/po} |
122 | KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:="${S}/po"} |
| 109 | cd "$KDE_LINGUAS_DIR" || die "wrong linguas dir specified" |
123 | cd "${KDE_LINGUAS_DIR}" || die "wrong linguas dir specified" |
| 110 | |
124 | |
| 111 | # fix all various crazy sr@Latn variations |
125 | # fix all various crazy sr@Latn variations |
| 112 | # this part is only ease for ebuilds, so there wont be any die when this |
126 | # this part is only ease for ebuilds, so there wont be any die when this |
| 113 | # fail at any point |
127 | # fail at any point |
| 114 | sr_mess="sr@latn sr@latin sr@Latin" |
128 | sr_mess="sr@latn sr@latin sr@Latin" |
| 115 | for wp in ${sr_mess}; do |
129 | for wp in ${sr_mess}; do |
| 116 | [[ -e "$wp.po" ]] && mv "$wp.po" "sr@Latn.po" |
130 | [[ -e "${wp}.po" ]] && mv "${wp}.po" "sr@Latn.po" |
| 117 | if [[ -d "$wp" ]]; then |
131 | if [[ -d "${wp}" ]]; then |
| 118 | # move dir and fix cmakelists |
132 | # move dir and fix cmakelists |
| 119 | mv "$wp" "sr@Latn" |
133 | mv "${wp}" "sr@Latn" |
| 120 | sed -i \ |
134 | sed -i \ |
| 121 | -e "s:$wp:sr@Latin:g" \ |
135 | -e "s:${wp}:sr@Latin:g" \ |
| 122 | CMakeLists.txt |
136 | CMakeLists.txt |
| 123 | fi |
137 | fi |
| 124 | done |
138 | done |
| 125 | |
139 | |
| 126 | for lingua in ${KDE_LINGUAS}; do |
140 | for lingua in ${KDE_LINGUAS}; do |
| 127 | if [[ -e "$lingua.po" ]]; then |
141 | if [[ -e "${lingua}.po" ]]; then |
| 128 | mv "$lingua.po" "$lingua.po.old" |
142 | mv "${lingua}.po" "${lingua}.po.old" |
| 129 | fi |
143 | fi |
| 130 | done |
144 | done |
| 131 | comment_all_add_subdirectory "${KDE_LINGUAS_DIR}" |
145 | comment_all_add_subdirectory "${KDE_LINGUAS_DIR}" |
| 132 | for lingua in ${LINGUAS}; do |
146 | for lingua in ${LINGUAS}; do |
| 133 | ebegin "Enabling LANGUAGE: ${lingua}" |
147 | ebegin "Enabling LANGUAGE: ${lingua}" |
| 134 | if [[ -d "$lingua" ]]; then |
148 | if [[ -d "${lingua}" ]]; then |
| 135 | sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \ |
149 | sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \ |
| 136 | -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \ |
150 | -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \ |
| 137 | -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed." |
151 | -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed." |
| 138 | fi |
152 | fi |
| 139 | if [[ -e "$lingua.po.old" ]]; then |
153 | if [[ -e "${lingua}.po.old" ]]; then |
| 140 | mv "$lingua.po.old" "$lingua.po" |
154 | mv "${lingua}.po.old" "${lingua}.po" |
| 141 | fi |
155 | fi |
| 142 | eend $? |
156 | eend $? |
| 143 | done |
157 | done |
| 144 | } |
158 | } |
| 145 | |
159 | |
| 146 | # @FUNCTION: get_build_type |
160 | # @FUNCTION: get_build_type |
| 147 | # @DESCRIPTION: |
161 | # @DESCRIPTION: |
| 148 | # Determine whether we are using live ebuild or tbzs. |
162 | # Determine whether we are using live ebuild or tbzs. |
| 149 | get_build_type() { |
163 | get_build_type() { |
| 150 | if [[ $SLOT = live || $PV = 9999* ]]; then |
164 | if [[ ${SLOT} = live || ${PV} = 9999* ]]; then |
| 151 | BUILD_TYPE="live" |
165 | BUILD_TYPE="live" |
| 152 | else |
166 | else |
| 153 | BUILD_TYPE="release" |
167 | BUILD_TYPE="release" |
| 154 | fi |
168 | fi |
| 155 | export BUILD_TYPE |
169 | export BUILD_TYPE |
| 156 | } |
170 | } |
| 157 | |
171 | |
| 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 |
172 | # @FUNCTION: migrate_store_dir |
| 211 | # @DESCRIPTION: |
173 | # @DESCRIPTION: |
| 212 | # Migrate the remnants of ${ESVN_STORE_DIR}/KDE/ to ${ESVN_STORE_DIR}/. |
174 | # Universal store dir migration |
| 213 | # Perform experimental split of kdebase to kdebase-apps. |
175 | # * performs split of kdebase to kdebase-apps when needed |
|
|
176 | # * moves playground/extragear kde4-base-style to toplevel dir |
| 214 | migrate_store_dir() { |
177 | migrate_store_dir() { |
| 215 | local cleandir |
|
|
| 216 | cleandir="${ESVN_STORE_DIR}/KDE" |
178 | local cleandir="${ESVN_STORE_DIR}/KDE" |
| 217 | if [[ -d "${cleandir}" ]]; then |
179 | if [[ -d "${cleandir}" ]]; then |
| 218 | ewarn "'${cleandir}' has been found. Moving contents to new location." |
180 | ewarn "'${cleandir}' has been found. Moving contents to new location." |
| 219 | addwrite "${ESVN_STORE_DIR}" |
181 | addwrite "${ESVN_STORE_DIR}" |
| 220 | # Split kdebase |
182 | # Split kdebase |
| 221 | local module |
183 | local module |
| … | |
… | |
| 230 | die "Failed to remove ${cleandir}/kdebase. You need to remove it manually." |
192 | die "Failed to remove ${cleandir}/kdebase. You need to remove it manually." |
| 231 | fi |
193 | fi |
| 232 | # Move the rest |
194 | # Move the rest |
| 233 | local pkg |
195 | local pkg |
| 234 | for pkg in "${cleandir}"/*; do |
196 | for pkg in "${cleandir}"/*; do |
| 235 | mv -f "${pkg}" "${ESVN_STORE_DIR}"/ || eerror "failed to move ${pkg}" |
197 | mv -f "${pkg}" "${ESVN_STORE_DIR}"/ || eerror "Failed to move '${pkg}'" |
| 236 | done |
198 | 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." |
199 | 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." |
|
|
200 | fi |
|
|
201 | |
|
|
202 | if ! hasq kde4-meta ${INHERITED}; then |
|
|
203 | case ${KMNAME} in |
|
|
204 | extragear*|playground*) |
|
|
205 | local svnlocalpath="${ESVN_STORE_DIR}"/"${KMNAME}"/"${PN}" |
|
|
206 | if [[ -d "${svnlocalpath}" ]]; then |
|
|
207 | local destdir="${ESVN_STORE_DIR}"/"${ESVN_PROJECT}"/"`basename "${ESVN_REPO_URI}"`" |
|
|
208 | ewarn "'${svnlocalpath}' has been found." |
|
|
209 | ewarn "Moving contents to new location: ${destdir}" |
|
|
210 | addwrite "${ESVN_STORE_DIR}" |
|
|
211 | mkdir -p "${ESVN_STORE_DIR}"/"${ESVN_PROJECT}" && mv -f "${svnlocalpath}" "${destdir}" \ |
|
|
212 | || die "Failed to move to '${svnlocalpath}'" |
|
|
213 | # Try cleaning empty directories |
|
|
214 | rmdir "`dirname "${svnlocalpath}"`" 2> /dev/null |
|
|
215 | fi |
|
|
216 | ;; |
|
|
217 | esac |
| 238 | fi |
218 | fi |
| 239 | } |
219 | } |
| 240 | |
220 | |
| 241 | # Functions handling KMLOADLIBS and KMSAVELIBS |
221 | # Functions handling KMLOADLIBS and KMSAVELIBS |
| 242 | |
222 | |
| … | |
… | |
| 244 | # @DESCRIPTION: |
224 | # @DESCRIPTION: |
| 245 | # Add exporting CMake dependencies for current package |
225 | # Add exporting CMake dependencies for current package |
| 246 | save_library_dependencies() { |
226 | save_library_dependencies() { |
| 247 | local depsfile="${T}/${PN}:${SLOT}" |
227 | local depsfile="${T}/${PN}:${SLOT}" |
| 248 | |
228 | |
| 249 | ebegin "Saving library dependendencies in ${depsfile##*/}" |
229 | ebegin "Saving library dependencies in ${depsfile##*/}" |
| 250 | echo "EXPORT_LIBRARY_DEPENDENCIES(\"${depsfile}\")" >> "${S}/CMakeLists.txt" || \ |
230 | echo "EXPORT_LIBRARY_DEPENDENCIES(\"${depsfile}\")" >> "${S}/CMakeLists.txt" || \ |
| 251 | die "Failed to save the library dependencies." |
231 | die "Failed to save the library dependencies." |
| 252 | eend $? |
232 | eend $? |
| 253 | } |
233 | } |
| 254 | |
234 | |
| 255 | # @FUNCTION: install_library_dependencies |
235 | # @FUNCTION: install_library_dependencies |
| 256 | # @DESCRIPTION: |
236 | # @DESCRIPTION: |
| 257 | # Install generated CMake library dependencies to /var/lib/kde |
237 | # Install generated CMake library dependencies to /var/lib/kde |
| 258 | install_library_dependencies() { |
238 | install_library_dependencies() { |
| 259 | local depsfile="$T/$PN:$SLOT" |
239 | local depsfile="${T}/${PN}:${SLOT}" |
|
|
240 | |
| 260 | ebegin "Installing library dependendencies as ${depsfile##*/}" |
241 | ebegin "Installing library dependencies as ${depsfile##*/}" |
| 261 | insinto /var/lib/kde |
242 | insinto /var/lib/kde |
| 262 | doins "${depsfile}" || die "Failed to install library dependencies." |
243 | doins "${depsfile}" || die "Failed to install library dependencies." |
| 263 | eend $? |
244 | eend $? |
| 264 | } |
245 | } |
| 265 | |
246 | |
| 266 | # @FUNCTION: load_library_dependencies |
247 | # @FUNCTION: load_library_dependencies |
| 267 | # @DESCRIPTION: |
248 | # @DESCRIPTION: |
| 268 | # Inject specified library dependencies in current package |
249 | # Inject specified library dependencies in current package |
| 269 | load_library_dependencies() { |
250 | load_library_dependencies() { |
| 270 | local pn i depsfile |
251 | local pn i depsfile |
| 271 | ebegin "Injecting library dependendencies from '${KMLOADLIBS}'" |
252 | ebegin "Injecting library dependencies from '${KMLOADLIBS}'" |
| 272 | |
253 | |
| 273 | i=0 |
254 | i=0 |
| 274 | for pn in ${KMLOADLIBS} ; do |
255 | for pn in ${KMLOADLIBS} ; do |
| 275 | ((i++)) |
256 | ((i++)) |
| 276 | depsfile="/var/lib/kde/${pn}:${SLOT}" |
257 | depsfile="/var/lib/kde/${pn}:${SLOT}" |