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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (hide annotations) (download)
Thu Jun 4 09:29:54 2009 UTC (5 years, 1 month ago) by scarabeus
Branch: MAIN
Changes since 1.20: +0 -0 lines
Adjust eclasses to support new handbook useflag, also keep backcompat with old doc handling (will be dropped). Depend on qt4.5 and add variable allowing to override this. Linugas handling update.

1 ingmar 1.1 # Copyright 1999-2008 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 scarabeus 1.19 # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.18 2009/05/09 13:23:15 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.19 *) DEPEND="EAPI-TOO-OLD" ;;
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.15 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.15 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.15 # 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 jmbsvicetto 1.8
44     # @ECLASS-VARIABLE: KDE_LIVE_SLOTS
45     # @DESCRIPTION:
46 scarabeus 1.15 # The slots used by KDE live versions. Values should be ordered.
47     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     buildsycoca() {
54     debug-print-function ${FUNCNAME} "$@"
55 scarabeus 1.19
56 scarabeus 1.10 if [[ -z ${ROOT%%/} && -x ${KDEDIR}/bin/kbuildsycoca4 ]]; then
57 scarabeus 1.15 # Make sure tha cache file exists, writable by root and readable by
58     # others. Otherwise kbuildsycoca4 will fail.
59 jmbsvicetto 1.8 touch "${KDEDIR}/share/kde4/services/ksycoca4"
60 scarabeus 1.15 chmod 644 "${KDEDIR}/share/kde4/services/ksycoca4"
61 jmbsvicetto 1.8
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.15 # Lookup in order - local, KDEDIR, /usr, do not duplicate entries btw.
69 scarabeus 1.19 local KDEDIRS="${ROOT}usr/share"
70     [[ ${KDEDIR} != "${ROOT}usr" ]] && KDEDIRS="${KDEDIR}/share:${KDEDIRS}"
71     XDG_DATA_DIRS="${ROOT}usr/local/share:${KDEDIRS}" \
72 jmbsvicetto 1.8 DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \
73     ${KDEDIR}/bin/kbuildsycoca4 --global --noincremental &> /dev/null
74 ingmar 1.1 eend $?
75     fi
76 scarabeus 1.15
77     # fix permission for some directories
78     for x in share/config share/kde4; do
79 scarabeus 1.19 [[ ${KDEDIR} = ${ROOT}usr ]] && DIRS=${ROOT}usr || DIRS="${ROOT}usr ${KDEDIR}"
80 scarabeus 1.17 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 scarabeus 1.15 done
91 ingmar 1.1 }
92    
93     # @FUNCTION: comment_all_add_subdirectory
94     # @USAGE: [list of directory names]
95     # @DESCRIPTION:
96 scarabeus 1.10 # Recursively comment all add_subdirectory instructions in listed directories,
97     # except those in cmake/.
98 ingmar 1.1 comment_all_add_subdirectory() {
99     find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \
100 ingmar 1.6 xargs -0 sed -i -e '/add_subdirectory/s/^/#DONOTCOMPILE /' -e '/ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' || \
101 ingmar 1.1 die "${LINENO}: Initial sed died"
102     }
103    
104 zlin 1.5 # @ECLASS-VARIABLE: KDE_LINGUAS
105     # @DESCRIPTION:
106 scarabeus 1.10 # 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 scarabeus 1.19 # translations, ebuilds must call enable_selected_linguas(). kde4-{base,meta}.eclass does
110 zlin 1.5 # 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 scarabeus 1.10 # 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 zlin 1.5 # but this default can be overridden by defining KDE_LINGUAS_DIR.
122     enable_selected_linguas() {
123 scarabeus 1.10 local lingua sr_mess wp
124    
125 scarabeus 1.19 ## 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 scarabeus 1.20 if ! $(env | grep -q "^LINGUAS="); then
130     return 0
131     fi
132 scarabeus 1.19 # [[ ! ${LINGUAS+set} = set ]] && LINGUAS="*"
133 scarabeus 1.10 # ebuild overridable linguas directory definition
134 scarabeus 1.15 KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:="${S}/po"}
135     cd "${KDE_LINGUAS_DIR}" || die "wrong linguas dir specified"
136 scarabeus 1.10
137     # fix all various crazy sr@Latn variations
138     # this part is only ease for ebuilds, so there wont be any die when this
139     # fail at any point
140     sr_mess="sr@latn sr@latin sr@Latin"
141     for wp in ${sr_mess}; do
142 scarabeus 1.15 [[ -e "${wp}.po" ]] && mv "${wp}.po" "sr@Latn.po"
143     if [[ -d "${wp}" ]]; then
144 scarabeus 1.10 # move dir and fix cmakelists
145 scarabeus 1.15 mv "${wp}" "sr@Latn"
146 scarabeus 1.10 sed -i \
147 scarabeus 1.15 -e "s:${wp}:sr@Latin:g" \
148 scarabeus 1.10 CMakeLists.txt
149     fi
150     done
151 jmbsvicetto 1.8
152     for lingua in ${KDE_LINGUAS}; do
153 scarabeus 1.15 if [[ -e "${lingua}.po" ]]; then
154     mv "${lingua}.po" "${lingua}.po.old"
155 jmbsvicetto 1.8 fi
156     done
157 scarabeus 1.10 comment_all_add_subdirectory "${KDE_LINGUAS_DIR}"
158 scarabeus 1.19 for lingua in ${KDE_LINGUAS}; do
159     if use linguas_${lingua} ; then
160     ebegin "Enabling LANGUAGE: ${lingua}"
161     if [[ -d "${lingua}" ]]; then
162     sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
163     -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
164     -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed."
165     fi
166     if [[ -e "${lingua}.po.old" ]]; then
167     mv "${lingua}.po.old" "${lingua}.po"
168     fi
169     eend $?
170 jmbsvicetto 1.8 fi
171 zlin 1.5 done
172     }
173    
174 scarabeus 1.10 # @FUNCTION: get_build_type
175 ingmar 1.1 # @DESCRIPTION:
176 scarabeus 1.10 # Determine whether we are using live ebuild or tbzs.
177     get_build_type() {
178 scarabeus 1.18 if [[ ${SLOT} = live || ${PV} = *9999* ]]; then
179 scarabeus 1.10 BUILD_TYPE="live"
180     else
181     BUILD_TYPE="release"
182     fi
183     export BUILD_TYPE
184     }
185 ingmar 1.1
186 scarabeus 1.11 # @FUNCTION: migrate_store_dir
187     # @DESCRIPTION:
188 scarabeus 1.15 # Universal store dir migration
189     # * performs split of kdebase to kdebase-apps when needed
190     # * moves playground/extragear kde4-base-style to toplevel dir
191 scarabeus 1.11 migrate_store_dir() {
192 scarabeus 1.15 local cleandir="${ESVN_STORE_DIR}/KDE"
193 scarabeus 1.11 if [[ -d "${cleandir}" ]]; then
194     ewarn "'${cleandir}' has been found. Moving contents to new location."
195     addwrite "${ESVN_STORE_DIR}"
196     # Split kdebase
197     local module
198     if pushd "${cleandir}"/kdebase/kdebase > /dev/null; then
199     for module in `find . -maxdepth 1 -type d -name [a-z0-9]\*`; do
200     module="${module#./}"
201     mkdir -p "${ESVN_STORE_DIR}/kdebase-${module}" && mv -f "${module}" "${ESVN_STORE_DIR}/kdebase-${module}" || \
202     die "Failed to move to '${ESVN_STORE_DIR}/kdebase-${module}'."
203     done
204     popd > /dev/null
205     rm -fr "${cleandir}/kdebase" || \
206     die "Failed to remove ${cleandir}/kdebase. You need to remove it manually."
207     fi
208     # Move the rest
209     local pkg
210     for pkg in "${cleandir}"/*; do
211 scarabeus 1.15 mv -f "${pkg}" "${ESVN_STORE_DIR}"/ || eerror "Failed to move '${pkg}'"
212 scarabeus 1.11 done
213     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."
214     fi
215 scarabeus 1.15
216     if ! hasq kde4-meta ${INHERITED}; then
217     case ${KMNAME} in
218     extragear*|playground*)
219     local svnlocalpath="${ESVN_STORE_DIR}"/"${KMNAME}"/"${PN}"
220     if [[ -d "${svnlocalpath}" ]]; then
221     local destdir="${ESVN_STORE_DIR}"/"${ESVN_PROJECT}"/"`basename "${ESVN_REPO_URI}"`"
222     ewarn "'${svnlocalpath}' has been found."
223     ewarn "Moving contents to new location: ${destdir}"
224     addwrite "${ESVN_STORE_DIR}"
225     mkdir -p "${ESVN_STORE_DIR}"/"${ESVN_PROJECT}" && mv -f "${svnlocalpath}" "${destdir}" \
226     || die "Failed to move to '${svnlocalpath}'"
227     # Try cleaning empty directories
228     rmdir "`dirname "${svnlocalpath}"`" 2> /dev/null
229     fi
230     ;;
231     esac
232     fi
233 scarabeus 1.11 }
234    
235 scarabeus 1.10 # Functions handling KMLOADLIBS and KMSAVELIBS
236 ingmar 1.1
237 scarabeus 1.10 # @FUNCTION: save_library_dependencies
238     # @DESCRIPTION:
239     # Add exporting CMake dependencies for current package
240     save_library_dependencies() {
241     local depsfile="${T}/${PN}:${SLOT}"
242    
243 scarabeus 1.15 ebegin "Saving library dependencies in ${depsfile##*/}"
244 scarabeus 1.10 echo "EXPORT_LIBRARY_DEPENDENCIES(\"${depsfile}\")" >> "${S}/CMakeLists.txt" || \
245     die "Failed to save the library dependencies."
246     eend $?
247 ingmar 1.1 }
248    
249 scarabeus 1.10 # @FUNCTION: install_library_dependencies
250 ingmar 1.1 # @DESCRIPTION:
251 scarabeus 1.10 # Install generated CMake library dependencies to /var/lib/kde
252     install_library_dependencies() {
253 scarabeus 1.15 local depsfile="${T}/${PN}:${SLOT}"
254    
255     ebegin "Installing library dependencies as ${depsfile##*/}"
256 scarabeus 1.19 insinto ${ROOT}var/lib/kde
257 scarabeus 1.10 doins "${depsfile}" || die "Failed to install library dependencies."
258     eend $?
259     }
260 ingmar 1.1
261 scarabeus 1.10 # @FUNCTION: load_library_dependencies
262     # @DESCRIPTION:
263     # Inject specified library dependencies in current package
264     load_library_dependencies() {
265     local pn i depsfile
266 scarabeus 1.15 ebegin "Injecting library dependencies from '${KMLOADLIBS}'"
267 scarabeus 1.10
268     i=0
269     for pn in ${KMLOADLIBS} ; do
270     ((i++))
271 scarabeus 1.19 depsfile="${ROOT}var/lib/kde/${pn}:${SLOT}"
272 scarabeus 1.10 [[ -r "${depsfile}" ]] || die "Depsfile '${depsfile}' not accessible. You probably need to reinstall ${pn}."
273     sed -i -e "${i}iINCLUDE(\"${depsfile}\")" "${S}/CMakeLists.txt" || \
274     die "Failed to include library dependencies for ${pn}"
275     done
276     eend $?
277 ingmar 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20