summaryrefslogtreecommitdiff
blob: 6718cff13d058c72a086a89c8750fafa23d4423e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/gnome2.eclass,v 1.61 2005/08/23 03:51:03 leonardop Exp $
#
# Authors:
# Bruce A. Locke <blocke@shivan.org>
# Spidler <spider@gentoo.org>

inherit libtool gnome.org debug fdo-mime

# Gnome 2 ECLASS

# extra configure opts passed to econf
[ -z "$G2CONF" ] && G2CONF=""

# extra options passed to elibtoolize
[ -z "$ELTCONF" ] && ELTCONF=""

# whether to run scrollkeeper for this package
[ -z "$SCROLLKEEPER_UPDATE" ] && SCROLLKEEPER_UPDATE="1"

# use make DESTDIR=${D} install rather than einstall
[ -z "$USE_DESTDIR" ] && USE_DESTDIR=""


IUSE="debug"


DEPEND=">=sys-apps/sed-4"

gnome2_src_configure() {

	# [ -n "${ELTCONF}" ] && elibtoolize ${ELTCONF}
	elibtoolize ${ELTCONF}

	use debug && G2CONF="${G2CONF} --enable-debug=yes"

	# doc keyword for gtk-doc
	G2CONF="${G2CONF} $(use_enable doc gtk-doc)"

	econf "$@" ${G2CONF} || die "./configure failure"

}

gnome2_src_compile() {

	gnome2_src_configure "$@"
	emake || die "compile failure"

}

gnome2_src_install() {

	# if this is not present, scrollkeeper-update may segfault and
	# create bogus directories in /var/lib/
	dodir /var/lib/scrollkeeper

	# we must delay gconf schema installation due to sandbox
	export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL="1"

	if [ -z "${USE_DESTDIR}" -o "${USE_DESTDIR}" = "0" ]; then
		einstall "scrollkeeper_localstate_dir=${D}/var/lib/scrollkeeper/" "$@" || die "einstall failed"
	else
		make DESTDIR=${D} \
		   	"$@" install || die "make DESTDIR install failed"
	fi

	unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL

	# manual document installation
	[ -n "${DOCS}" ] && dodoc ${DOCS}

	# do not keep /var/lib/scrollkeeper because:
	# 1. scrollkeeper will get regenerated at pkg_postinst()
	# 2. ${D}/var/lib/scrollkeeper contains only indexes for the current pkg
	#    thus it makes no sense if pkg_postinst ISN'T run for some reason.

	if [ -z "`find ${D} -name '*.omf'`" ]; then
		export SCROLLKEEPER_UPDATE="0"
	fi

	# regenerate these in pkg_postinst()
	rm -rf ${D}/var/lib/scrollkeeper
	# make sure this one doesn't get in the portage db
	rm -fr ${D}/usr/share/applications/mimeinfo.cache

}


gnome2_gconf_install() {

	if [ -x ${ROOT}/usr/bin/gconftool-2 ]
	then
		unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
		export GCONF_CONFIG_SOURCE=`${ROOT}/usr/bin/gconftool-2 --get-default-source`
		einfo "Installing GNOME 2 GConf schemas"
		grep "obj /etc/gconf/schemas" ${ROOT}/var/db/pkg/*/${PF}/CONTENTS | sed 's:obj \([^ ]*\) .*:\1:' | while read F; do
			if [ -e "${F}" ]; then
				# echo "DEBUG::gconf install  ${F}"
				${ROOT}/usr/bin/gconftool-2  --makefile-install-rule ${F} 1>/dev/null
			fi
		done
	fi

}

gnome2_gconf_uninstall() {

	if [ -x ${ROOT}/usr/bin/gconftool-2 ]
	then
		unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
		export GCONF_CONFIG_SOURCE=`${ROOT}/usr/bin/gconftool-2 --get-default-source`
		einfo "Uninstalling GNOME 2 GConf schemas"
		cat ${ROOT}/var/db/pkg/*/${PN}-${PVR}/CONTENTS | grep "obj /etc/gconf/schemas" | sed 's:obj \([^ ]*\) .*:\1:' |while read F; do
			# echo "DEBUG::gconf install  ${F}"
			${ROOT}/usr/bin/gconftool-2  --makefile-uninstall-rule ${F} 1>/dev/null
		done
	fi

}

gnome2_icon_cache_update() {
	local updater=`which gtk-update-icon-cache`
	if ! grep -q "obj /usr/share/icons" ${ROOT}/var/db/pkg/*/${PF}/CONTENTS \
	|| [ ! -x "$updater" ]; then
		# Nothing to update
		return
	fi

	ebegin "Updating icons cache"

	local retval=0
	for dir in \
	$(find ${ROOT}/usr/share/icons -maxdepth 1 -mindepth 1 -type d); do
		$updater -qf $dir || retval=$?
	done

	eend $retval
}

gnome2_omf_fix() {

	# workaround/patch against omf.make or omf-install/Makefile.in
	# in order to remove redundant scrollkeeper-updates.
	# - <liquidx@gentoo.org>

	local omf_makefiles

	omf_makefiles="$@"

	[ -f ${S}/omf-install/Makefile.in ] \
		&& omf_makefiles="${omf_makefiles} ${S}/omf-install/Makefile.in"

	# FIXME: does this really work? because omf.make only gets included
	#        when autoconf/automake is run. You should directly patch
	#        the Makefile.in's

	[ -f ${S}/omf.make ] \
		&& omf_makefiles="${omf_makefiles} ${S}/omf.make"

	ebegin "Fixing OMF Makefiles"
	local retval=0
	for omf in ${omf_makefiles}; do
		sed -i -e 's:scrollkeeper-update:true:' ${omf} || retval=$?
	done
	eend $retval

}

gnome2_scrollkeeper_update() {

	if [ -x ${ROOT}/usr/bin/scrollkeeper-update ] && [ "${SCROLLKEEPER_UPDATE}" = "1" ]
	then
		einfo "Updating scrollkeeper database ..."
		scrollkeeper-update -q -p ${ROOT}/var/lib/scrollkeeper
	fi

}

gnome2_pkg_postinst() {

	gnome2_gconf_install
	gnome2_scrollkeeper_update
	fdo-mime_desktop_database_update
	fdo-mime_mime_database_update
	gnome2_icon_cache_update

}

#gnome2_pkg_prerm() {

#	gnome2_gconf_uninstall

#}

gnome2_pkg_postrm() {

	gnome2_scrollkeeper_update
	fdo-mime_desktop_database_update
	fdo-mime_mime_database_update
	gnome2_icon_cache_update

}

#EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_prerm  pkg_postrm
EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm