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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download)
Mon Mar 9 19:41:26 2009 UTC (5 years, 5 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 ingmar 1.1 # Copyright 1999-2008 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 scarabeus 1.13 # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.12 2009/02/10 20:07:24 scarabeus 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     # @ECLASS-VARIABLE: EAPI
14     # @DESCRIPTION:
15 scarabeus 1.14 # By default kde4 eclasses wants eapi 2 which might be redefinable to newer
16     # versions.
17     case ${EAPI:-0} in
18 scarabeus 1.10 2) : ;;
19 scarabeus 1.14 *) die "No way! EAPI other than 2 is not supported for now." ;;
20 scarabeus 1.10 esac
21 ingmar 1.1
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 scarabeus 1.10 if [[ $CATEGORY = kde-base ]]; then
28 ingmar 1.1 debug-print "${ECLASS}: KDEBASE ebuild recognized"
29 scarabeus 1.10 KDEBASE=kde-base
30 ingmar 1.1 fi
31    
32     # is this a koffice ebuild?
33 scarabeus 1.10 if [[ $KMNAME = koffice || $PN = koffice ]]; then
34 ingmar 1.1 debug-print "${ECLASS}: KOFFICE ebuild recognized"
35 scarabeus 1.10 KDEBASE=koffice
36 ingmar 1.1 fi
37    
38 jmbsvicetto 1.8 # @ECLASS-VARIABLE: KDE_SLOTS
39     # @DESCRIPTION:
40 scarabeus 1.10 # The slots used by all KDE versions later than 4.0. The live-ebuilds use
41     # KDE_LIVE_SLOTS instead.
42 scarabeus 1.13 KDE_SLOTS=( kde-4 4.1 4.2 4.3 )
43 jmbsvicetto 1.8
44     # @ECLASS-VARIABLE: KDE_LIVE_SLOTS
45     # @DESCRIPTION:
46     # The slots used by all KDE live versions.
47 scarabeus 1.10 KDE_LIVE_SLOTS=( live )
48 ingmar 1.1
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 scarabeus 1.10 if [[ -z ${ROOT%%/} && -x ${KDEDIR}/bin/kbuildsycoca4 ]]; then
59 jmbsvicetto 1.8 # 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 ingmar 1.1
66     ebegin "Running kbuildsycoca4 to build global database"
67     # This is needed because we support multiple kde versions installed together.
68 scarabeus 1.13 XDG_DATA_DIRS="/usr/share:${KDEDIR}/share:/usr/local/share" \
69 jmbsvicetto 1.8 DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \
70     ${KDEDIR}/bin/kbuildsycoca4 --global --noincremental &> /dev/null
71 ingmar 1.1 eend $?
72     fi
73     }
74    
75     # @FUNCTION: comment_all_add_subdirectory
76     # @USAGE: [list of directory names]
77     # @DESCRIPTION:
78 scarabeus 1.10 # Recursively comment all add_subdirectory instructions in listed directories,
79     # except those in cmake/.
80 ingmar 1.1 comment_all_add_subdirectory() {
81     find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \
82 ingmar 1.6 xargs -0 sed -i -e '/add_subdirectory/s/^/#DONOTCOMPILE /' -e '/ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' || \
83 ingmar 1.1 die "${LINENO}: Initial sed died"
84     }
85    
86 zlin 1.5 # @ECLASS-VARIABLE: KDE_LINGUAS
87     # @DESCRIPTION:
88 scarabeus 1.10 # 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 zlin 1.5 # 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 scarabeus 1.10 # 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 zlin 1.5 # but this default can be overridden by defining KDE_LINGUAS_DIR.
104     enable_selected_linguas() {
105 scarabeus 1.10 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 jmbsvicetto 1.8
126     for lingua in ${KDE_LINGUAS}; do
127 scarabeus 1.10 if [[ -e "$lingua.po" ]]; then
128     mv "$lingua.po" "$lingua.po.old"
129 jmbsvicetto 1.8 fi
130     done
131 scarabeus 1.10 comment_all_add_subdirectory "${KDE_LINGUAS_DIR}"
132 jmbsvicetto 1.8 for lingua in ${LINGUAS}; do
133 scarabeus 1.10 ebegin "Enabling LANGUAGE: ${lingua}"
134     if [[ -d "$lingua" ]]; then
135 ingmar 1.6 sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
136     -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
137 scarabeus 1.10 -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed."
138 zlin 1.5 fi
139 scarabeus 1.10 if [[ -e "$lingua.po.old" ]]; then
140     mv "$lingua.po.old" "$lingua.po"
141 jmbsvicetto 1.8 fi
142 scarabeus 1.10 eend $?
143 zlin 1.5 done
144     }
145    
146 scarabeus 1.10 # @FUNCTION: get_build_type
147 ingmar 1.1 # @DESCRIPTION:
148 scarabeus 1.10 # 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 ingmar 1.1
158 scarabeus 1.10 # @FUNCTION: get_latest_kdedir
159 ingmar 1.1 # @DESCRIPTION:
160 scarabeus 1.10 # 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 scarabeus 1.12 case ${KDE_WANTED} in
166     # note this will need to be updated as stable moves and so on
167     live)
168 scarabeus 1.13 _versions="9999 4.2.61 4.2.0 4.1.0"
169 scarabeus 1.12 ;;
170     snapshot)
171 scarabeus 1.13 _versions="4.2.61 4.2.0 4.1.0 9999"
172 scarabeus 1.12 ;;
173     testing)
174 scarabeus 1.13 _versions="4.2.0 4.1.0 4.2.61 9999"
175 scarabeus 1.12 ;;
176     stable)
177 scarabeus 1.13 _versions="4.2.0 4.1.0 4.1.61 9999"
178 scarabeus 1.12 ;;
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 scarabeus 1.10 ;;
191 scarabeus 1.13 4.3.0 | 4.2.61)
192     _kdedir="4.3"
193     break
194     ;;
195     4.2.0 | 4.1.61)
196 scarabeus 1.12 _kdedir="4.2"
197     break
198 scarabeus 1.10 ;;
199 scarabeus 1.12 4.1.0)
200     _kdedir="4.1"
201     break
202 scarabeus 1.10 ;;
203 scarabeus 1.12 esac
204     fi
205     done
206 scarabeus 1.13
207     debug-print-function ${FUNCNAME} "$@" "KDE_WANTED=${KDE_WANTED} -> _kdedir=${_kdedir}"
208 scarabeus 1.10 }
209 ingmar 1.1
210 scarabeus 1.11 # @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 scarabeus 1.10 # Functions handling KMLOADLIBS and KMSAVELIBS
242 ingmar 1.1
243 scarabeus 1.10 # @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 ingmar 1.1 }
254    
255 scarabeus 1.10 # @FUNCTION: install_library_dependencies
256 ingmar 1.1 # @DESCRIPTION:
257 scarabeus 1.10 # 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 ingmar 1.1
266 scarabeus 1.10 # @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 ingmar 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20