summaryrefslogtreecommitdiff
blob: 8b40bcc904356d4c01ee0888e60d645a68bdd935 (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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: mozilla-scm.eclass
# @MAINTAINER:
# Sardem FF7 <sardemff7.pub@gmail.com>
# @BLURB: This eclass provides Mozilla SCM support

WANT_AUTOCONF="2.1"
EAPI="3"

inherit base eutils multilib toolchain-funcs autotools python

MAJ_XUL_PV="2.0"

LICENSE="|| ( MPL-1.1 GPL-2 LGPL-2.1 )"
SLOT="0"
SRC_URI=""
S="${WORKDIR}/mozilla-central"

#
# Some per-application stuff
#
IS_LIBXUL=false
MOZLIBDIR="/usr/$(get_libdir)/xulrunner-${MAJ_XUL_PV}"
MOZDEVELDIR="/usr/$(get_libdir)/xulrunner-devel-${MAJ_XUL_PV}"
SDKDIR="${MOZDEVELDIR}/sdk"
MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
case "${PN}" in
	xulrunner)
		IS_LIBXUL=true
		MOZ_APPLICATION=xulrunner
		MOZILLA_FIVE_HOME="${MOZLIBDIR}"
	;;
	firefox)
		MOZ_APPLICATION=browser
	;;
	thunderbird)
		MOZ_APPLICATION=mail
	;;
esac
${IS_LIXBUL} || inherit fdo-mime

EXPORT_FUNCTIONS pkg_setup src_unpack src_configure src_compile src_install pkg_postinst

# @ECLASS-VARIABLE: EHG_REVISION
# @DESCRIPTION:
# Create working directory for specified revision, defaults to tip.
#
# EHG_REVISION is passed as a value for --rev parameter, so it can be more than
# just a revision, please consult `hg help revisions' for more details.
: ${EHG_REVISION:=tip}

# @ECLASS-VARIABLE: EHG_STORE_DIR
# @DESCRIPTION:
# Mercurial sources store directory. Users may override this in /etc/make.conf
: ${EHG_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/hg-src}

# @ECLASS-VARIABLE: EHG_QUIET
# @DESCRIPTION:
# Suppress some extra noise from mercurial, set it to be quiet.

# @ECLASS-VARIABLE: EHG_CLONE_CMD
# @DESCRIPTION:
# Command used to perform initial repository clone.
: ${EHG_CLONE_CMD:=hg clone ${EHG_QUIET:+--quiet} --pull --noupdate}

# @ECLASS-VARIABLE: EHG_PULL_CMD
# @DESCRIPTION:
# Command used to update repository.
: ${EHG_PULL_CMD:=hg pull ${EHG_QUIET:+--quiet}}

# @ECLASS-VARIABLE: EHG_OFFLINE
# @DESCRIPTION:
# Set this variable to a non-empty value to disable the automatic updating of
# a mercurial source tree. This is intended to be set outside the ebuild by
# users.
: ${EHG_OFFLINE:=${ESCM_OFFLINE}}


# @ECLASS-VARIABLE: MOZILLA_BONUS_REPOS_URIS
: ${MOZILLA_BONUS_REPOS_URIS:=}

##
## Base common stuff
##
RDEPEND="
	>=dev-libs/nspr-4.8.7
	"
${IS_LIBXUL} || RDEPEND+="~net-libs/xulrunner-9999[libnotify=,mozdom=,raw=,system-sqlite=,webm=,wifi=]"

DEPEND="${RDEPEND}
	app-arch/zip
	dev-vcs/mercurial
	dev-util/pkgconfig
	"

IUSE=""

function mercurial_fetch {
	debug-print-function ${FUNCNAME} ${*}

	local repo=${1}

	local module="$(basename "${repo}")"

	# Should be set but blank to prevent using $HOME/.hgrc
	export HGRCPATH=

	# Check ${EHG_STORE_DIR} directory:
	addwrite "$(dirname "${EHG_STORE_DIR}")" || die "addwrite failed"
	if [[ ! -d "${EHG_STORE_DIR}" ]]; then
		mkdir -p "${EHG_STORE_DIR}" || die "failed to create ${EHG_STORE_DIR}"
		chmod -f g+rw "${EHG_STORE_DIR}" || \
			die "failed to chown ${EHG_STORE_DIR}"
	fi

	# Create project directory:
	mkdir -p "${EHG_STORE_DIR}/mozilla" || \
		die "failed to create ${EHG_STORE_DIR}/mozilla"
	chmod -f g+rw "${EHG_STORE_DIR}/mozilla" || \
		echo "Warning: failed to chmod g+rw mozilla"
	cd "${EHG_STORE_DIR}/mozilla" || \
		die "failed to cd to ${EHG_STORE_DIR}/mozilla"

	# Clone/update repository:
	if [[ ! -d "${module}" ]]; then
		einfo "Cloning ${repo} to ${EHG_STORE_DIR}/mozilla/${module}"
		${EHG_CLONE_CMD} "${repo}" "${module}" || {
			rm -rf "${module}"
			die "failed to clone ${repo}"
		}
		cd "${module}"
	elif ${IS_LIBXUL} && [[ -z "${EHG_OFFLINE}" ]]; then
		einfo "Updating ${EHG_STORE_DIR}/mozilla/${module} from ${repo}"
		cd "${module}" || die "failed to cd to ${module}"
		${EHG_PULL_CMD} || die "update failed"
	fi

	# Checkout working copy:
	einfo "Creating working directory for ${module} (target revision: ${EHG_REVISION})"
	hg archive \
		${EHG_QUIET_CMD_OPT} \
		--rev="${EHG_REVISION}" \
		-R "${EHG_STORE_DIR}/mozilla/${module}" \
		"${WORKDIR}/${module}" || die "hg clone failed"
	einfo "Work directory: ${WORKDIR}/${module}"
}


##
## eclass exported function
## src_unpack
##
function mozilla-scm_src_unpack {
	mercurial_fetch "http://hg.mozilla.org/mozilla-central/"
	for repo in ${MOZILLA_BONUS_REPOS_URIS}; do
		mercurial_fetch "${repo}"
	done
}

##
## eclass exported function
## pkg_setup
##
function mozilla-scm_pkg_setup {
	# Ensure we always build with C locale.
	export LANG="C"
	export LC_ALL="C"
	export LC_MESSAGES="C"
	export LC_CTYPE="C"

	if ! ${IS_LIBXUL}; then
		elog "You are enabling official branding. You may not redistribute this build"
		elog "to any users on your network or the internet. Doing so puts yourself into"
		elog "a legal problem with Mozilla Foundation"
	fi

	python_set_active_version 2
}

##
## eclass exported function
## src_configure
##
function mozilla-scm_src_configure {
	CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" PYTHON="$(PYTHON)" econf "$@"
}

##
## eclass exported function
## src_install
##
function mozilla-scm_src_install {
	emake DESTDIR="${ED}" install || die "emake install failed"

	if ! ${IS_LIBXUL}; then
		local prefdir="${ED}/${MOZILLA_FIVE_HOME}/defaults/pref"
		[[ -d "${prefdir}erences" ]] && prefdir+="erences"
		cp "${FILESDIR}"/default-prefs.js \
			"${prefdir}/all-gentoo.js" || \
			die "failed to cp -default-prefs.js"
	fi
}

##
## eclass exported function
## pkg_postinst
##
function mozilla-scm_pkg_postinst {
	ewarn "This is experimental DO NOT file a bug report unless you can"
	ewarn "are willing to provide a patch. All bugs that are filled without a patch"
	ewarn "will be closed INVALID!!"

	if ${IS_LIBXUL}; then
		einfo "Don't forget to rebuild firefox/thunderbird to update it to the same changeset"
	else
		ewarn "All the packages built against ${PN} won't compile,"
		ewarn "any package that fails to build warrants a bug report."
		einfo "You should build xulrunner first to update the mercurial repository"

		# Update mimedb for the new .desktop file
		fdo-mime_desktop_database_update
	fi
}