summaryrefslogtreecommitdiff
path: root/PKGBUILD
blob: 05e5eda5ac5b24200ceef987d877117124a9f12b (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
# Maintainer: jc_gargma <jc_gargma@iserlohn-fortress.net>
# Maintainer (Arch): Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Aqua-sama <aqua@iserlohn-fortress.net>
# Contributor (Arch): Ionut Biru <ibiru@archlinux.org>
# Contributor (Arch): Jakub Schmidtke <sjakub@gmail.com>

# # I maintain this because:
# Arch version uses eme
# Arch version uses git
# Arch version uses python2
# Arch version doesn't use alsa
# Arch version requires signed addons
# Arch version doesn't remove system addons
# Arch version lacks privacy and security by default
# Arch version enables debug symbols

pkgname=firefox
pkgver=65.0.2
bz2ver=$(echo $pkgver | sed 's/\./_/g')
pkgrel=1
pkgdesc="Standalone web browser from mozilla.org"
arch=(x86_64)
license=(MPL GPL LGPL)
url="https://www.mozilla.org/firefox/"
depends=(gtk3 mozilla-common libxt startup-notification mime-types dbus-glib
         ffmpeg nss ttf-font alsa-lib sqlite libvpx icu)
makedepends=(unzip zip diffutils python-setuptools yasm mesa imake inetutils
            xorg-server-xvfb autoconf2.13 rust clang llvm gtk2
            python nodejs python-psutil cbindgen nasm)
optdepends=('networkmanager: Location detection via available WiFi networks'
            'libnotify: Notification integration'
            'speech-dispatcher: Text-to-Speech'
            'hunspell-en_CA: Spell checking, Canadian English')
options=(!emptydirs !makeflags)
source=($pkgname-$pkgver.tar.bz2::https://hg.mozilla.org/releases/mozilla-release/archive/FIREFOX_${bz2ver}_RELEASE.tar.bz2
        $pkgname.desktop $pkgname-symbolic.svg
        vendor.js
        pgo-1.patch
        pgo-2.patch
        moz.configure.diff
        package-manifest.diff)
sha256sums=('e54b21b0faf56650461d39bb27352db2d3a09da5ee0f44d4e9abc8d91f04269b'
            '677e1bde4c6b3cff114345c211805c7c43085038ca0505718a11e96432e9811a'
            '9a1a572dc88014882d54ba2d3079a1cf5b28fa03c5976ed2cb763c93dabbd797'
            'ea197946151c66f5454fa222c94afa222ad9907a1e2918b563e1d5860de88baf'
            'a8c15c9d54ef8b360c0932f4ccf5e74954f14e9a9c2a1ae924b6c392075b2b8c'
            '33a91a7e8ca702ee493f483abe93bf6917881dc4192566587bdfb103da3a2422'
            'ad8a270e1b2affb098440f82517c3952207b28ebf604fef695dad3e29a5ba30e'
            '927e400d6920b98d2fe7db2b6498f195135909a76e0da49441223956364d8227')

prepare() {
#   mkdir mozbuild
  cd mozilla-release-FIREFOX_${bz2ver}_RELEASE

  # Apply pgo patches
  patch -p0 $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/security/sandbox/linux/moz.build $srcdir/pgo-1.patch
  patch -p0 $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/extensions/spellcheck/src/moz.build $srcdir/pgo-2.patch

  cat >$srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/.mozconfig <<END
ac_add_options --enable-application=browser

ac_add_options --prefix=/usr
ac_add_options --enable-release
ac_add_options --enable-hardening
ac_add_options --enable-optimize=-O3
ac_add_options --enable-rust-simd
ac_add_options --enable-lto
ac_add_options --enable-linker=gold
export MOZ_PGO=1
export CC=gcc
export CXX=g++
export AR=gcc-ar
export NM=gcc-nm
export RANLIB=gcc-ranlib

# Branding
ac_add_options --enable-official-branding
ac_add_options --enable-update-channel=release
ac_add_options --with-distribution-id=org.artixlinux

# System libraries
ac_add_options --enable-system-ffi
ac_add_options --enable-system-sqlite
ac_add_options --with-system-bz2
ac_add_options --with-system-icu
ac_add_options --with-system-jpeg
ac_add_options --with-system-libvpx
ac_add_options --with-system-nspr
ac_add_options --with-system-nss
ac_add_options --with-system-zlib

# Features
ac_add_options --enable-alsa
ac_add_options --disable-pulseaudio
ac_add_options --enable-startup-notification
ac_add_options --disable-crashreporter
ac_add_options --disable-debug-symbols
ac_add_options --disable-eme
ac_add_options --disable-gconf
ac_add_options --disable-tests
ac_add_options --disable-updater
ac_add_options --disable-webspeech
ac_add_options --disable-webspeechtestbackend
ac_add_options --disable-webrtc

mk_add_options MOZ_MAKE_FLAGS="-j4"
export MOZ_APP_REMOTINGNAME=$pkgname
export MOZ_ADDON_SIGNING=0
export MOZ_REQUIRE_SIGNING=0

END

# MOZ_TELEMETRY_REPORTING only applied correctly when set in this override file
  cat >$srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/build/mozconfig.common.override <<END
export MOZ_TELEMETRY_REPORTING=0
export MOZ_DATA_REPORTING=0

END

  # Disable various components at the source level
  sed -i 's|[;]1|;0|' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/toolkit/components/telemetry/TelemetryStartup.manifest
#   sed -i 's|[;]1|;0|' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/experiments/Experiments.manifest
#   sed -i '/pocket/d' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/extensions/moz.build
#   sed -i '/activity-stream/d' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/extensions/moz.build
#   sed -i '/aushelper/d' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/extensions/moz.build
#   sed -i '/followonsearch/d' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/extensions/moz.build
#   sed -i '/formautofill/d' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/extensions/moz.build
#   sed -i '/onboarding/d' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/extensions/moz.build
#   sed -i '/screenshots/d' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/extensions/moz.build
#   sed -i '/webcompat/d' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/extensions/moz.build
#   sed -i '/webcompat-reporter/d' $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/extensions/moz.build

#   patch -p0 $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/config/mozconfigs/whitelist $srcdir/whitelist.diff
#   patch -p0 $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/config/mozconfigs/linux64/common-opt $srcdir/common-opt.diff
#   patch -p0 $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/build/mozconfig.common.override $srcdir/mozconfig.common.override.diff

  # Patch out health reporting so that MOZ_DATA_REPORTING=0 can be applied.
  patch -p0 $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/moz.configure $srcdir/moz.configure.diff

  # Remove @RESPATH@/browser/features/* to prevent system addons from being part of the output package.
  patch -p0 $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/browser/installer/package-manifest.in $srcdir/package-manifest.diff

  # Hide mobile promo
  echo ".fxaMobilePromo {  display: none !important; }" >> browser/themes/shared/incontentprefs/preferences.inc.css
  # Hide plugindeprecation-notice
  echo "#plugindeprecation-notice {  display: none !important; }" >> toolkit/mozapps/extensions/content/extensions.css
  # Hide warnings on unsigned extensions
  echo ".warning{display: none!important; } .addon[notification=warning]{background-image: none!important;}" >> toolkit/mozapps/extensions/content/extensions.css


}

build() {
  cd mozilla-release-FIREFOX_${bz2ver}_RELEASE
#   mkdir --parents $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/obj-x86_64-pc-linux-gnu/dist/bin/browser/features
#   mkdir --parents $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/extensions/webcompat-reporter/locales
#   mkdir --parents $srcdir/mozilla-release-FIREFOX_${bz2ver}_RELEASE/obj-x86_64-pc-linux-gnu/services/sync/locales

  export MOZ_NOSPAM=1
  export MOZBUILD_STATE_PATH="$srcdir/mozbuild"
  # LTO needs more open files
  ulimit -n 4096

  xvfb-run -a -n 97 -s "-screen 0 1600x1200x24" ./mach build
  ./mach buildsymbols
}

package() {
  cd mozilla-release-FIREFOX_${bz2ver}_RELEASE
  DESTDIR="$pkgdir" ./mach install

  install -Dm644 "$srcdir/vendor.js" "$pkgdir/usr/lib/$pkgname/browser/defaults/preferences/vendor.js"


  _distini="$pkgdir/usr/lib/$pkgname/distribution/distribution.ini"
  install -Dm644 /dev/stdin "$_distini" <<END
[Global]
id=artixlinux
version=1.0
about=Mozilla Firefox for Artix Linux

[Preferences]
app.distributor=artixlinux
app.distributor.channel=$pkgname
app.partner.artixlinux=artixlinux
END

  for i in 16 22 24 32 48 64 128 256; do
    install -Dm644 browser/branding/official/default$i.png \
      "$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$pkgname.png"
  done
  install -Dm644 browser/branding/official/content/about-logo.png \
    "$pkgdir/usr/share/icons/hicolor/192x192/apps/$pkgname.png"
  install -Dm644 browser/branding/official/content/about-logo@2x.png \
    "$pkgdir/usr/share/icons/hicolor/384x384/apps/$pkgname.png"
  install -Dm644 ../$pkgname-symbolic.svg \
    "$pkgdir/usr/share/icons/hicolor/symbolic/apps/$pkgname-symbolic.svg"

  install -Dm644 ../$pkgname.desktop \
    "$pkgdir/usr/share/applications/$pkgname.desktop"

  # Install a wrapper to avoid confusion about binary path
  install -Dm755 /dev/stdin "$pkgdir/usr/bin/$pkgname" <<END
#!/bin/sh
exec /usr/lib/$pkgname/firefox "\$@"
END

  # Replace duplicate binary with wrapper
  # https://bugzilla.mozilla.org/show_bug.cgi?id=658850
  ln -srf "$pkgdir/usr/bin/$pkgname" \
    "$pkgdir/usr/lib/$pkgname/firefox-bin"
}