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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (hide annotations) (download)
Mon Apr 13 00:02:45 2009 UTC (5 years, 8 months ago) by scarabeus
Branch: MAIN
Changes since 1.14: +67 -86 lines
Update kde4 eclasses
Add back support for doc handling (now via doc useflag)
Force kdeprefix only for kde-base things (others are going unprefixed to /usr) ->
Note for this: if user find that some application is pulling [-kdeprefix] kde uninstall/install of that app should help.
Rewritten slot handling with simpler code.
Added detection and alert system for finding what aplication break sth for /usr/share/config and /usr/share/kde4 and screw up perms.
Left for next time: "Support for stable live (live packages from stable branch [shiny huh]). :]"

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

  ViewVC Help
Powered by ViewVC 1.1.20