summaryrefslogtreecommitdiff
path: root/libre-testing/iceweasel-libre/PKGBUILD
blob: 2998ebae94ede98f96d46abdf63d7f5b94dba2ee (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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# Maintainer: Márcio Silva <coadde@lavabit.com>
# Contributor (Parabola): Luke Shumaker <lukeshu@sbcglobal.net>
# Contributor (Parabola): fauno <fauno@kiwwwi.com.ar>
# Contributor (Parabola): vando <facundo@esdebian.org>
# Contributor (Parabola): André Silva <emulatorman@lavabit.com>

# Maintainer (ConnochaetOS): Henry Jensen <hjensen@connochaetos.org>

# Maintainer (Arch) : Ionut Biru <ibiru@archlinux.org>
# Contributor (Arch): Jakub Schmidtke <sjakub@gmail.com>

# Contributor: Figue <ffigue at gmail>
# Thank you very much to the older contributors:
# Contributor: evr <evanroman at gmail>
# Contributor: Muhammad 'MJ' Jassim <UnbreakableMJ@gmail.com>

lowercase() { tr A-Z a-z <<<"$*"; }

# Version Configuration ##############################################

_pgo=false

_debname=iceweasel
_debver=18.0
_debrel=1
_debrepo=http://ftp.debian.org/debian/pool/main

# locales can be easily generated by running
# $ sed -rn 's/.*-l10n-([^.]*)\..*/\1/p' src/*.dsc | sort -u
_locales=(ach af ak ar as ast be bg bn-BD bn-IN br bs ca cs csb cy da de el en-GB en-ZA eo es-AR es-CL es-ES es-MX et eu fa ff fi fr fy-NL ga-IE gd gl gu-IN he hi-IN hr hu hy-AM id is it ja kk km kn ko ku lg lij lt lv mai mk ml mr nb-NO nl nn-NO nso or pa-IN pl pt-BR pt-PT rm ro ru si sk sl son sq sr sv-SE ta-LK ta te th tr uk vi zh-CN zh-TW zu)

pkgbase=iceweasel
pkgname=(iceweasel-libre)
for locale in "${_locales[@]}"; do
	pkgname+=("iceweasel-libre-l10n-$(lowercase ${locale})")
done
pkgver=${_debver}.${_debrel}
pkgrel=3

######################################################################

debfile() { echo "${_debrepo}/${1:0:1}/${1%_*}/${1}"; }

if [[ -z $pkgbase ]]; then pkgbase=$pkgname; fi
if $_pgo; then pkgname+='-pgo'; fi
if [ "$pkgbase" != "$pkgname" ]; then
  provides+=("$pkgbase=$pkgver")
  conflicts+=("$pkgbase")
fi

pkgdesc="A libre version of Debian Iceweasel, the web browser based on Mozilla Firefox."
arch=(
  'i686'
  'mips64el'
  'x86_64'
)
license=(
  'GPL2'
  'LGPL'
  'MPL'
)
depends=(
  'alsa-lib'
  'dbus-glib'
  'desktop-file-utils'
  'gtk2'
  'hicolor-icon-theme'
  'hunspell'
  'libevent'
  'libnotify'
  'libvpx'
  'libxt'
  'mime-types'
  'mozilla-common'
  'mozilla-searchplugins'
  'nss>=3.14.1'
  'sqlite'
  'startup-notification'
)
makedepends=(
  'autoconf2.13'
  'diffutils'
  'dpkg-devtools'
  'imagemagick'
  'imake'
  'libidl2'
  'librsvg'
  'libxslt'
  'mesa'
  'python2'
  'unzip'
  'zip'
)
[[ $CARCH != mips64el ]] && makedepends+=('yasm')
if $_pgo; then
  makedepends+=('xorg-server-xvfb')
  options+=(!ccache)
fi
optdepends=('networkmanager: Location detection via available WiFi networks')
url="http://packages.debian.org/source/experimental/$_debname"
install=firefox.install
options=(!emptydirs)
source=($(debfile ${_debname}_${_debver}-${_debrel}.dsc)
        $(debfile ${_debname}_${_debver}-${_debrel}.debian.tar.gz)
        $(debfile ${_debname}_${_debver}.orig.tar.bz2)
        $(debfile ${_debname}_${_debver}.orig-compare-locales.tar.bz2)
        $(for locale in "${_locales[@]}"; do debfile ${_debname}_${_debver}.orig-l10n-${locale}.tar.bz2; done)
        replace-urls.txt libre.patch mozconfig.pgo
        mozconfig $pkgbase.desktop iceweasel-install-dir.patch vendor.js shared-libs.patch
        bug677092.patch)
# use dpkg-source to extract everything
noextract=(); for file in "${source[@]}"; do noextract+=("${file##*/}"); done

# This is a bug, we should fix it.
mips64el-prepare() {
  # Fix MIPS N32 support.
  sed -i 's/defined(_ABIO32)/(defined(_ABIO32) || defined(_ABIN32))/' \
    js/src/assembler/wtf/Platform.h
  # Disable JIT.
  sed -ri 's/#define ENABLE_(JIT|ASSEMBLER) 1/#define ENABLE_\1 0/' \
    js/src/assembler/wtf/Platform.h
  sed -ri 's/ENABLE_(JIT|ASSEMBLER)=1/ENABLE_\1=0/' js/src/Makefile.in
}
misp64el-configure() {
  echo 'ac_add_options --disable-methodjit' >> .mozconfig
  echo 'ac_add_options --disable-tracejit' >> .mozconfig
  echo 'ac_add_options --disable-jemalloc' >> .mozconfig
}

prepare() {
  if [[ -d "/usr/lib/$pkgbase" ]]; then
    error "Because of how rpath is set, this package cannot be installed during build"
    return 1
  fi
  dpkg-source -x ${_debname}_${_debver}-${_debrel}.dsc mozilla-release
  cd mozilla-release

  patch -Np1 -i ../iceweasel-install-dir.patch
  patch -Np1 -i ../shared-libs.patch

  # Back out https://bugzilla.mozilla.org/show_bug.cgi?id=677092
  # in order to fix https://bugzilla.mozilla.org/show_bug.cgi?id=818468
  patch -Rp1 -i ../bug677092.patch

  # Replace common URLs
  sed '/^#/d' ../replace-urls.txt | while read -r moz_url gnu_url; do
    if [[ -n $moz_url ]]; then
      printf 'liberating: %s -> %s\n' "$moz_url" "$gnu_url"
      grep -Erl "${moz_url}" \
        --exclude='*.'{patch,orig,rej} \
        --exclude-dir={.pc,test,tests,testing} \
        | xargs -d '\n' --no-run-if-empty sed -ri "s<${moz_url}<${gnu_url}<g"
    fi
  done

  # Liberate the locales
  printf '%s\n' l10n-*/*/searchplugins/*.xml \
    | grep -Ev 'creativecommons|wikipedia|wikipediaro|wiktionary' \
    | xargs -d '\n' rm -f
  for dir in l10n-*/*/searchplugins; do
    pushd "$dir"
    ls | sed -n 's/\.xml$//p' > list.txt
    popd
  done
  find l10n-* -name 'region.properties' -delete

  # Patch anything that's left
  patch -Np1 -i ../libre.patch

  # Fix PRE_RELEASE_SUFFIX
  sed -i '/^PRE_RELEASE_SUFFIX := ""/s/ ""//' \
    browser/base/Makefile.in

  if [[ $CARCH  == mips64el ]]; then mips64el-prepare; fi

  touch "$srcdir/.makepkg-prepare"
}

build() {
  [[ -f "$srcdir/.makepkg-prepare" ]] || { prepare || return $?; cd "$srcdir"; }
  cd "$srcdir"
  build_browser
  for locale in "${_locales[@]}"; do
    cd "$srcdir"
    build_locale "${locale}"
  done
}

build_browser() {
  cd mozilla-release

  cp ../mozconfig .mozconfig
  if $_pgo; then cat ../mozconfig.pgo >> .mozconfig; fi
  if [[ $CARCH  == mips64el ]]; then mips64el-configure; fi

  # WebRTC build tries to execute "python" and expects Python 2
  # Workaround taken from chromium PKGBUILD
  mkdir "$srcdir/python2-path"
  ln -s /usr/bin/python2 "$srcdir/python2-path/python"
  export PATH="$srcdir/python2-path:$PATH"

  export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/lib/$pkgbase"
  export PYTHON="/usr/bin/python2"
  export MOZ_MAKE_FLAGS="$MAKEFLAGS"
  unset MAKEFLAGS

  if $_pgo; then
    export MOZ_PGO=1
    export DISPLAY=:99
    Xvfb -nolisten tcp -extension GLX -screen 0 1280x1024x24 $DISPLAY &
  fi

  _fail=0
  make -f client.mk build || _fail=1

  if $_pgo; then
    kill $! || true
  fi
  return $_fail
}

build_locale() {
  locale=$1
  cd mozilla-release

  export PYTHON="/usr/bin/python2"
  export PRODUCT='browser'

  # This is an adaptation of the "$(L10N_BUILD_STAMPS)" rule from debian/rules
  [[ -e l10n ]] || mkdir -p l10n
  [[ -e l10n/$locale ]] || ln -sf ../l10n-$locale l10n/$locale
  ${PYTHON} config/pythonpath.py -I$(pwd)/compare-locales/lib \
    $(pwd)/compare-locales/scripts/compare-locales \
    -m $(pwd)/moz-objdir/l10n-$locale ${PRODUCT}/locales/l10n.ini $(pwd)/l10n $locale
  make -C moz-objdir/${PRODUCT}/locales langpack-$locale \
    L10NBASEDIR=$(pwd)/l10n MOZ_CHROME_FILE_FORMAT=flat \
    MOZ_LANGPACK_EID=langpack-${locale}@${pkgbase}.mozilla.org \
    PKG_LANGPACK_BASENAME='$(MOZ_LANGPACK_EID)' PKG_LANGPACK_PATH=xpi/ \
    LOCALE_MERGEDIR=$(pwd)/moz-objdir/l10n-$locale
}

install-icon() {
  local brandingdir=$1 prog=$2 size=$3
  local sizedir=${size}x${size} ext=png
  [[ $size == scalable ]] && { sizedir=$size; ext=svg; size=''; }

  dirs=({moz-objdir/,}"$brandingdir")
  files=({default,mozicon,${prog}{,_icon}}${size}.${ext})

  for dir in "${dirs[@]}"; do
    for files in "${files[@]}"; do
      if [[ -e "$dir/$file" ]]; then
	install -Dm644 "$dir/$file" \
	  "$pkgdir/usr/share/icons/hicolor/$sizedir/apps/$prog.png"
	return 0
      fi
    done
  done
  #return 1
}

package_iceweasel-libre() {
  cd mozilla-release
  make -j1 -f client.mk DESTDIR="$pkgdir" install

  install -Dm644 ../vendor.js "$pkgdir/usr/lib/$pkgbase/defaults/preferences/vendor.js"

  for size in 16 32 48 64 128 scalable; do
    install-icon debian/branding $pkgbase $size
  done

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

  # Use system-provided dictionaries
  rm -rf "$pkgdir"/usr/lib/$pkgbase/{dictionaries,hyphenation}
  ln -s /usr/share/hunspell "$pkgdir/usr/lib/$pkgbase/dictionaries"
  ln -s /usr/share/hyphen "$pkgdir/usr/lib/$pkgbase/hyphenation"
  # use mozilla-searchplugins
  rm -rf "$pkgdir"/usr/lib/$pkgbase/searchplugins
  ln -s /usr/lib/mozilla/searchplugins "$pkgdir/usr/lib/$pkgbase/searchplugins"

  # We don't want the development stuff
  rm -r "$pkgdir"/usr/{include,lib/$pkgbase-devel,share/idl}

  #workaround for now
  #https://bugzilla.mozilla.org/show_bug.cgi?id=658850
  ln -sf $pkgbase "$pkgdir/usr/lib/$pkgbase/$pkgbase-bin"
}

package_locale() {
  locale=$1
  cd mozilla-release
  lang=$(sed -n "/^%define L10N_LANG ${locale}/,+1p" debian/l10n/browser-l10n.control|sed -n 's/%define L10N_LANGUAGE\s\s*//p')

  pkgdesc="${lang} language package for Iceweasel-libre"
  depends=("iceweasel-libre=${pkgver}")

  replaces=(iceweasel-i18n-$(lowercase "${locale}"))
  conflicts=(iceweasel-i18n-$(lowercase "${locale}"))

  extdir="$pkgdir"/usr/lib/iceweasel/extensions/
  install -d "${extdir}"
  install -m644 moz-objdir/dist/xpi/langpack-${locale}@${pkgbase}.mozilla.org.xpi "${extdir}"
}
for locale in "${_locales[@]}"; do
  eval "package_iceweasel-libre-l10n-$(lowercase ${locale})() { package_locale ${locale}; }"
done

md5sums=('263569a577f72314694a711cc6a0d96f'
         '6a571d3a3b355c331f67d57702f4fccf'
         '366e1e4847d7e00eba77ee5a4be0d3db'
         '80dd4a702302fb36719c67445b487895'
         'c99d7605c0e0bb0d77e71cd54f305a9a'
         '1f4aeabf6c28fcf6539d13f65f8b366b'
         'cb9cc5f721d81442f1a93d134054f23c'
         'c69e0fa169bf6c49b1f83afd2383b628'
         '09f4376791d17a772c60a0308095211d'
         'a16081e4da9daf6df5f6fcce2000cec1'
         '88dd4c5837485acea83e97f3cb4f1e31'
         '8751f0a634656ba973c53f96d1fa34e1'
         'f4531f867e6e75501bac3d7ed5f09045'
         '740667ba651f0562b45bbfe63b8ec84e'
         'a1f3637341457fb8272d126f1aa70e4b'
         '3d00ad2734c890930441d6cd919f11c8'
         '84b7a2bf7f1458b60e9552d04c7e84b2'
         '30ce51ca764b091c59df5c08e35e8a7f'
         '1291e5976c83a8cda1903e4443d44c8e'
         '1eacf81985d9993b2b94f98fd4c453e0'
         '07b91907c98155c1b95e5d7f47367fde'
         'cd4042405f6eaa2931021f745f49d91f'
         '24f8a5d05d0d2485c30b46e6d6835330'
         '1b95f32637229a86e4633994350cf76f'
         'ae6007384d85dbd14fbe6496e0b9e47b'
         'a8ef67c04d3dc263f0f58e877b13cd71'
         'b5c3b2e366aa776e574d0972df72a423'
         '200f856b50a7485a1d5447cbf8dee77c'
         '1767400f27cf010572308f949e56176e'
         'c6dde21438789ccf4c666afc22ee713c'
         'd202408658b9e7e7a2656dd874ac0712'
         '1c463a18e2a395314f7d0ad72282d5aa'
         'ec222722f432e8a94f993c1c32cd9757'
         'cf44fd1d567a7638fc0b5b80bb0398f7'
         '13151197d7ef349699e55c760c74af16'
         '32c185ef506e439bb63f572906a9bf66'
         '2e6b90b3c6cad17753ec1aecaf61073c'
         'dbf451ef9ecf1816973ac4dffe7e2b8e'
         '85c0900fb798fb64a8883dba06deccc0'
         '0efff47ab838fd320c710ffd46ee3a57'
         '28e5d445e7a91ddd64d50478b05edb51'
         '770dcdf1a8d6d2db64dadb6e4f6149fb'
         '7732b021cdf73ace33cb41609b327f3d'
         '3a195266b43e9f477619aac9c326a26b'
         'a55e22c7ab045826b331efd7c0f036ef'
         '2edcd565c19828e3d4a2da19f8529edd'
         '531c54a91d509e768b55bfd88a96a527'
         'ddf2182b6e33795450bf41f46e7be521'
         '8bf4edabc95abbaf274ddd5e5c5db562'
         '63a227dbab0e66b6a0d4804c419049e2'
         '3c9bab1f629c0b079345a186c0f22afc'
         '786a62179094cda5f5e831232f4f94ce'
         '535f68d0cfa4dee9df0cddbee42a4c94'
         'ffc4c457dfa697162e4198e61ae19e3b'
         '4476b94e676b3cfb309f972f7c42da1b'
         '792700b40ba53de7de5b48187b604b29'
         '7f71fa7bed8488226168406ac022d2fd'
         'fdd9a144cd2a630d1b7ab6b73315c548'
         '88d668eccb111a9e4f5fde58e000a5aa'
         '46509bb591bf54b6fed025814bfc11bf'
         '715a3f8c2fcdab17b24ce61f55c49183'
         '658226211d66a724d0335a173ef8512f'
         'ecb41c7536c95cf2ca118d7ab6b7d357'
         'b813931cfba36f3b00826ba2d36e648f'
         '2a926d37294ab24a7d7dc879339ae736'
         'fba979124cd393f1164a59e3b9183ccc'
         'e8597a5af1643b9c9a0b02a3756e0a86'
         '665140babab027228eb195b6c0e83d4e'
         'e71a740bfc52d25968f8e2c4c1896897'
         '47bd00559728578bfc257b80c72ce393'
         '3a3d846613363e6d4dd99326cd07417d'
         '80daf692c2fa80ef7f528df2a6aed42e'
         '25c03afb8f5086a07eb0e26c94bcbc01'
         '481db49b914f33d6c594ecebbc291e4c'
         '742d2af843536fc1cdc8560b5aa0620f'
         '9ee935f09dc89b42db9ad8db3473717d'
         'cf3e65e4db50dfa467defb4f820cd378'
         '3e0c8ea5b69c4363e40c21dda5230850'
         '32b73226e95ae47dc11a554a7208d960'
         '437602c23394eb02ae5fe03ca4fd29bc'
         'f7a347a3d5679d82340d227474de938f'
         '1a898825183ed67ea72b67a2c3486dd4'
         '73bead055152cd4885b9834691c9066a'
         '722a0d2212060e2044cbac859db3e063'
         'fba01f51ac90dec18758a7468fb509e1'
         '03c2a59eab8ef4ad3687b91c07f96165'
         'd502ec35e4ec26d7f538f4b96402fe9c'
         'b75b729e9ab3ff9a908115ab520339a9'
         'cd696e70fdb4f5ab9d50040abea46b82'
         '1b9df937ef08b6a72ca7d659f91df099'
         '17bbe91d26b302aa36391ed57199006d'
         'de6037c0a65e7b86e0929637156ba587'
         'a8fc4658d45b6bf9350023e5c3f34e56'
         '25861e760dc41b518cbee9c9194b2b19'
         'e4cd438a0b2a42dfb14bc7716e901e5f'
         '5bfaf77580b6d3ce185b4c3ad4fa30ca'
         '39d8b9249c5effe5fe24d2e9f80a9a94'
         '2baf8cffccd50c568ad153a709cb3136'
         'e9b4ec9a34bdab1854255aaa05e7cedd'
         '52e52f840a49eb1d14be1c0065b03a93'
         '23520aca140fb0dd3e1b6f21b21f591f')