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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (hide annotations) (download)
Sun Mar 1 11:44:09 2009 UTC (5 years, 4 months ago) by scarabeus
Branch: MAIN
Changes since 1.12: +14 -73 lines
Update kde4 eclasses. Was in testing for month now so hope all problems squashed. Resolves some annoying issues and enhance deps.

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

  ViewVC Help
Powered by ViewVC 1.1.20