summaryrefslogtreecommitdiff
path: root/skip/thunderbird/thunderbird.xibuild
blob: 05b3f5a1ea10352e1ddfbeb7a210f2b65d921fc7 (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
#!/bin/sh

NAME="thunderbird"
DESC="Thunderbird email client"

MAKEDEPS=" alsa-lib automake botan cargo cbindgen llvm libclang clang dbus-glib gettext gtk3 icu json-c libevent libffi libjpeg-turbo libnotify libogg libtheora libtool libvorbis libvpx libwebp libxcomposite libxt llvm m4 mesa nasm nodejs nspr nss pipewire pulseaudio python sed wireless-tools zip"

PKG_VER=102.6.1
SOURCE="https://ftp.mozilla.org/pub/thunderbird/releases/$PKG_VER/source/thunderbird-$PKG_VER.source.tar.xz"

ADDITIONAL="
allow-custom-rust-vendor.patch
avoid-redefinition.patch
cbindgen-0.24.patch
disable-moz-stackwalk.patch
disable-neon-in-aom.patch
distribution.ini
fix-fortify-system-wrappers.patch
fix-libresolv-path.patch
fix-rust-target.patch
fix-tools.patch
fix-webrtc-glibcisms.patch
mallinfo.patch
metainfo.patch
psutil.patch
sandbox-fork.patch
sandbox-largefile.patch
sandbox-sched_setscheduler.patch
stab.h
thunderbird.desktop
vendor-prefs.js
zstandard.patch
"

mozappdir=/usr/lib/thunderbird

_clear_vendor_checksums() {
	sed -i 's/\("files":{\)[^}]*/\1/' third_party/rust/$1/.cargo-checksum.json
}

export CC="gcc"
export CXX="g++"

export SHELL=/bin/sh
export BUILD_OFFICIAL=1
export MOZILLA_OFFICIAL=1
export USE_SHORT_LIBNAME=1
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none
export MOZBUILD_STATE_PATH="$srcdir"/mozbuild
# disable desktop notifications
export MOZ_NOSPAM=1

# set rpath so linker finds the libs
export LDFLAGS="$LDFLAGS -Wl,-rpath,$_mozappdir"

# let firefox do this itself.
unset CARGO_PROFILE_RELEASE_OPT_LEVEL
unset CARGO_PROFILE_RELEASE_LTO

export CFLAGS="$CFLAGS -O2 -fno-plt"
export CXXFLAGS="$CXXFLAGS -O2 -fno-plt"

prepare() {

    apply_patches

	cp "$BUILD_ROOT"/stab.h toolkit/crashreporter/google-breakpad/src/

	_clear_vendor_checksums audio_thread_priority
	_clear_vendor_checksums packed_simd_2
	_clear_vendor_checksums target-lexicon-0.9.0

	cat > base-mozconfig <<-EOF
	# disable unwanted things
	ac_add_options --disable-bootstrap
	ac_add_options --disable-cargo-incremental
	ac_add_options --disable-crashreporter
	ac_add_options --disable-debug
	ac_add_options --disable-debug-symbols
	ac_add_options --disable-install-strip
	ac_add_options --disable-jemalloc
	ac_add_options --disable-strip
	ac_add_options --disable-tests
	ac_add_options --disable-updater

	# features
	ac_add_options --enable-alsa
	ac_add_options --enable-application=comm/mail
	ac_add_options --enable-dbus
	ac_add_options --enable-default-toolkit=cairo-gtk3-wayland
	ac_add_options --enable-ffmpeg
	ac_add_options --enable-hardening
	ac_add_options --enable-linker=lld
	ac_add_options --enable-necko-wifi
	ac_add_options --enable-official-branding
	ac_add_options --enable-optimize="$CFLAGS"
	ac_add_options --enable-pulseaudio
	ac_add_options --enable-release
	ac_add_options --enable-update-channel=release

	# system libs
	ac_add_options --enable-system-pixman
	ac_add_options --with-system-ffi
	ac_add_options --with-system-icu
	ac_add_options --with-system-jpeg
	ac_add_options --with-system-libevent
	ac_add_options --with-system-libvpx
	ac_add_options --with-system-nspr
	ac_add_options --with-system-nss
	ac_add_options --with-system-png
	ac_add_options --with-system-webp
	ac_add_options --with-system-zlib

	# misc
	ac_add_options --prefix=/usr
	ac_add_options --with-libclang-path=/usr/lib
	ac_add_options --with-unsigned-addon-scopes=app,system
    ac_add_options --without-wasm-sandboxed-libraries

	# objdir
	mk_add_options MOZ_OBJDIR="$BUILD_ROOT/obj"

    ac_add_options --enable-sandbox
    ac_add_options --disable-elf-hack

    mk_add_options AUTOCLOBBER=1
    ac_add_options --host=x86_64-unknown-linux-musl
	EOF
}

build() {
    cat > .mozconfig base-mozconfig

	export MOZ_BUILD_DATE="$(date ${SOURCE_DATE_EPOCH:+ -d@${SOURCE_DATE_EPOCH}} "+%Y%m%d%H%M%S")"

	# for lto
	ulimit -n 4096

	./mach build
}

package() {

	DESTDIR="$PKG_DEST" MOZ_MAKE_FLAGS="$MAKEOPTS" ./mach install

	install -m755 -d "$PKG_DEST"/usr/share/applications
	install -m755 -d "$PKG_DEST"/usr/share/pixmaps

	local _png
	for _png in "$BUILD_ROOT"/comm/mail/branding/thunderbird/default*.png; do
		local i=${_png%.png}
		i=${i##*/default}
		install -D -m644 "$_png" "$PKG_DEST"/usr/share/icons/hicolor/"$i"x"$i"/apps/thunderbird.png
	done

	install -Dm644 "$BUILD_ROOT"/comm/mail/branding/thunderbird/TB-symbolic.svg \
		"$PKG_DEST/usr/share/icons/hicolor/symbolic/apps/thunderbird-symbolic.svg"
	install -Dm644 "$BUILD_ROOT"/comm/mail/branding/thunderbird/default48.png \
		$PKG_DEST/usr/share/pixmaps/thunderbird.png

	install -m644 "$BUILD_ROOT"/thunderbird.desktop "$PKG_DEST"/usr/share/applications/thunderbird.desktop

	# Add StartupWMClass=firefox on the .desktop files so Desktop Environments
	# correctly associate the window with their icon, the correct fix is to have
	# thunderbird sets its own AppID but this will work for the meantime
	# See: https://bugzilla.mozilla.org/show_bug.cgi?id=1607399
	echo "StartupWMClass=thunderbird" >> "$PKG_DEST"/usr/share/applications/thunderbird.desktop

	# install our vendor prefs
	install -d "$PKG_DEST"/$mozappdir/defaults/preferences

	cat >> "$PKG_DEST"/$mozappdir/defaults/preferences/vendor.js <<- EOF
	// Use LANG environment variable to choose locale
	pref("intl.locale.requested", "");

	// Use system-provided dictionaries
	pref("spellchecker.dictionary_path", "/usr/share/hunspell");

	// Disable default mailer checking.
	pref("mail.shell.checkDefaultMail", false);

	// Don't disable our bundled extensions in the application directory
	pref("extensions.autoDisableScopes", 11);
	pref("extensions.shownSelectionUI", true);
	EOF

	install -d "$PKG_DEST"/$mozappdir/distribution

	cat >> "$PKG_DEST"/$mozappdir/distribution/distribution.ini <<- EOF
	[Global]
	id=xilinux
	version=1.0
	about=Mozilla Thunderbird for XiLinux

	[Preferences]
	app.distributor=xilinux
	app.distributor.channel=thunderbird
	EOF

	# Replace duplicate binary with wrapper
	# https://bugzilla.mozilla.org/show_bug.cgi?id=658850
	ln -sf thunderbird "$PKG_DEST/$mozappdir/thunderbird-bin"
}