PKGBUILD 8.92 KB
Newer Older
1 2 3 4 5 6 7 8 9
# Contributions from Arch:
# Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
# Contributor: Pierre Schmitz <pierre@archlinux.de>
# Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

# Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
# Keys are the names in the above script; values are the dependencies in Chakra
declare -rgA _system_libs=(
Jeff Huang's avatar
Jeff Huang committed
10
  #[ffmpeg]=ffmpeg     # https://crbug.com/731766
11
  [flac]=flac
12
  #[fontconfig]=fontconfig # Enable for M65
Xuetian Weng's avatar
Xuetian Weng committed
13
  #[freetype]=freetype2      # https://crbug.com/pdfium/733
14 15
  #[harfbuzz-ng]=harfbuzz-icu # https://crbug.com/768938
  #[icu]=icu                 # https://crbug.com/772655
Xuetian Weng's avatar
Xuetian Weng committed
16
  [libdrm]=
17
  [libjpeg]=libjpeg
Jeff Huang's avatar
Jeff Huang committed
18
  #[libpng]=libpng           # https://crbug.com/752403#c10
Xuetian Weng's avatar
Xuetian Weng committed
19
  #[libvpx]=libvpx           # https://bugs.gentoo.org/611394
20
  [libwebp]=libwebp
21
  #[libxml]=libxml2          # https://crbug.com/736026
22
  [libxslt]=libxslt
Xuetian Weng's avatar
Xuetian Weng committed
23
  [opus]=opus
Xuetian Weng's avatar
Xuetian Weng committed
24
  [re2]=re2
25 26
  [snappy]=snappy
  [yasm]=
Xuetian Weng's avatar
Xuetian Weng committed
27
  [zlib]=minizip
28 29
)

Luca Giambonini's avatar
Luca Giambonini committed
30
pkgname=chromium
31
pkgver=64.0.3282.119
Xuetian Weng's avatar
Xuetian Weng committed
32
pkgrel=1
Xuetian Weng's avatar
Xuetian Weng committed
33
_launcher_ver=5
Jeff Huang's avatar
Jeff Huang committed
34
pkgdesc="A web browser built for speed, simplicity, and security"
Luca Giambonini's avatar
Luca Giambonini committed
35
arch=('x86_64')
36
url="https://www.chromium.org/Home"
Luca Giambonini's avatar
Luca Giambonini committed
37
license=('BSD')
Xuetian Weng's avatar
Xuetian Weng committed
38 39 40
depends=('gtk3' 'nss' 'alsa-lib' 'xdg-utils' 'libxss' 'libcups' 'libgcrypt'
         'ttf-font' 'systemd' 'dbus' 'libpulse' 'pciutils' 'json-glib'
         'desktop-file-utils' 'hicolor-icon-theme')
41
depends+=(${_system_libs[@]})
42
makedepends=('python2' 'gperf' 'yasm' 'mesa' 'ninja' 'nodejs' 'git' 'clang')
Jeff Huang's avatar
Jeff Huang committed
43
optdepends=('kwallet: for storing passwords in KWallet'
44
            'kdialog: needed for file dialogs in KDE')
Xuetian Weng's avatar
Xuetian Weng committed
45
install=chromium.install
46
source=(https://commondatastorage.googleapis.com/chromium-browser-official/$pkgname-$pkgver.tar.xz
Xuetian Weng's avatar
Xuetian Weng committed
47
        chromium-launcher-$_launcher_ver.tar.gz::https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver.tar.gz
48
        chromium-$pkgver.txt::https://chromium.googlesource.com/chromium/src.git/+/$pkgver?format=TEXT
49
        chromium-use-fromUTF8-for-UnicodeString-construction.patch
50
        chromium-omnibox-unescape-fragment.patch
51
        chromium-exclude_unwind_tables.patch
52 53
        chromium-memcpy-r0.patch
        chromium-clang-r2.patch
Xuetian Weng's avatar
Xuetian Weng committed
54
        chromium-widevine.patch)
55
sha256sums=('342ea80a925d85f5155b2b423a0d3cbcf2ee5729bf107c601d7d902315d03127'
Xuetian Weng's avatar
Xuetian Weng committed
56
            '4dc3428f2c927955d9ae117f2fb24d098cc6dd67adb760ac9c82b522ec8b0587'
57 58
            'a86a8ec67aed5a94557257b9826c5b8fe37005e8376e75986fee77acd066539a'
            'c82c830bac7ab328a76d85fb141e150a17d02d97138a6daa4720a8a8c371a402'
59
            '814eb2cecb10cb697e24036b08aac41e88d0e38971741f9e946200764e2401ae'
60
            '9478f1ec1a3c53425306cf41c2d0555c215a4f106955d9d6adfff38044530ce8'
61 62
            '455f0029987d9f0532bd9a5250669af5146a9c2b65b776d4a6e2499e8aca7bb4'
            '4495e8b29dae242c79ffe4beefc5171eb3c7aacb7e9aebfd2d4d69b9d8c958d3'
Xuetian Weng's avatar
Xuetian Weng committed
63
            'd6fdcb922e5a7fbe15759d39ccc8ea4225821c44d98054ce0f23f9d1f00c9808')
Luca Giambonini's avatar
Luca Giambonini committed
64

65 66 67 68 69 70 71
# Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
# Note: These are for Chakra Linux use ONLY. For your own distribution, please
# get your own set of keys.
_google_api_key=AIzaSyA33sdKPff0x3KBByOhpzc1i7RS2A1mEpY
_google_default_client_id=3502044743.apps.googleusercontent.com
_google_default_client_secret=TPvjII_2SwZn_9Ic0kRKqjtG

72
prepare() {
73
  cd "$srcdir/$pkgname-$pkgver"
Luca Giambonini's avatar
Luca Giambonini committed
74

Jeff Huang's avatar
Jeff Huang committed
75
  # https://crbug.com/710701
76 77
  local _chrome_build_hash=$(base64 -d ../chromium-$pkgver.txt |
    grep -Po '^parent \K[0-9a-f]{40}$')
Jeff Huang's avatar
Jeff Huang committed
78 79 80 81 82 83
  if [[ -z $_chrome_build_hash ]]; then
    error "Unable to fetch Chrome build hash."
    return 1
  fi
  echo "LASTCHANGE=$_chrome_build_hash-" >build/util/LASTCHANGE

84 85 86 87 88 89
  # Enable support for the Widevine CDM plugin
  # libwidevinecdm.so is not included, but can be copied over from Chrome
  # (Version string doesn't seem to matter so let's go with "Pinkie Pie")
  sed "s/@WIDEVINE_VERSION@/Pinkie Pie/" ../chromium-widevine.patch |
    patch -Np1

90 91
  # https://chromium-review.googlesource.com/c/chromium/src/+/712575
  patch -Np1 -i ../chromium-exclude_unwind_tables.patch
Jeff Huang's avatar
Jeff Huang committed
92

93 94 95
  # https://crbug.com/772655
  patch -Np1 -i ../chromium-use-fromUTF8-for-UnicodeString-construction.patch

96 97 98
  # https://crbug.com/789163
  patch -Np1 -i ../chromium-omnibox-unescape-fragment.patch

Xuetian Weng's avatar
Xuetian Weng committed
99
  # Fixes from Gentoo
100 101
  patch -Np1 -i ../chromium-memcpy-r0.patch
  patch -Np1 -i ../chromium-clang-r2.patch
102 103 104 105 106 107

  # Remove compiler flags not supported by our system clang
  sed -i \
    -e '/"-Wno-enum-compare-switch"/d' \
    -e '/"-Wno-null-pointer-arithmetic"/d' \
    -e '/"-Wno-tautological-unsigned-zero-compare"/d' \
108
    -e '/"-Wno-tautological-constant-compare"/d' \
109
    build/config/compiler/BUILD.gn
110 111 112 113 114

  # Use Python 2
  find . -name '*.py' -exec sed -i -r 's|/usr/bin/python$|&2|g' {} +

  # There are still a lot of relative calls which need a workaround
Jeff Huang's avatar
Jeff Huang committed
115 116
  mkdir "$srcdir/python2-path"
  ln -s /usr/bin/python2 "$srcdir/python2-path/python"
117

Jeff Huang's avatar
Jeff Huang committed
118 119 120
  mkdir -p third_party/node/linux/node-linux-x64/bin
  ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/

121 122 123 124 125 126 127 128
  # Remove bundled libraries for which we will use the system copies; this
  # *should* do what the remove_bundled_libraries.py script does, with the
  # added benefit of not having to list all the remaining libraries
  local _lib
  for _lib in ${!_system_libs[@]} ${_system_libs[libjpeg]+libjpeg_turbo}; do
    find -type f -path "*third_party/$_lib/*" \
      \! -path "*third_party/$_lib/chromium/*" \
      \! -path "*third_party/$_lib/google/*" \
Xuetian Weng's avatar
Xuetian Weng committed
129
      \! -path "*base/third_party/icu/*" \
130 131 132 133 134 135
      \! -regex '.*\.\(gn\|gni\|isolate\|py\)' \
      -delete
  done

  python2 build/linux/unbundle/replace_gn_files.py \
    --system-libraries "${!_system_libs[@]}"
136 137 138
}

build() {
Xuetian Weng's avatar
Xuetian Weng committed
139
  make -C chromium-launcher-$_launcher_ver
Xuetian Weng's avatar
Xuetian Weng committed
140

141
  cd "$srcdir/$pkgname-$pkgver"
Luca Giambonini's avatar
Luca Giambonini committed
142

143 144 145 146 147
  if check_buildoption ccache y; then
    # Avoid falling back to preprocessor mode when sources contain time macros
    export CCACHE_SLOPPINESS=time_macros
  fi

148 149 150 151
  export PATH="$srcdir/python2-path:$PATH"
  export TMPDIR="$srcdir/temp"
  mkdir -p "$TMPDIR"

152 153 154 155 156
  export CC=clang
  export CXX=clang++
  export AR=ar
  export NM=nm

157
  local _flags=(
158 159 160
    'custom_toolchain="//build/toolchain/linux/unbundle:default"'
    'host_toolchain="//build/toolchain/linux/unbundle:default"'
    'is_clang=true'
161
    'clang_use_chrome_plugins=false'
Chaoting Liu's avatar
Chaoting Liu committed
162
    'is_debug=false'
163 164 165 166 167 168 169
    'fatal_linker_warnings=false'
    'treat_warnings_as_errors=false'
    'fieldtrial_testing_like_official_build=true'
    'remove_webcore_debug_symbols=true'
    'ffmpeg_branding="Chrome"'
    'proprietary_codecs=true'
    'link_pulseaudio=true'
170
    'use_gtk3=true'
171 172 173
    'use_gconf=false'
    'use_gnome_keyring=false'
    'use_gold=false'
Jeff Huang's avatar
Jeff Huang committed
174
    'use_lld=false'
175
    'use_sysroot=false'
Jeff Huang's avatar
Jeff Huang committed
176 177
    'linux_use_bundled_binutils=false'
    'use_custom_libcxx=false'
178 179 180
    'enable_hangout_services_extension=true'
    'enable_widevine=true'
    'enable_nacl=false'
181
    'enable_swiftshader=false'
182 183 184 185 186 187 188 189 190
    "google_api_key=\"${_google_api_key}\""
    "google_default_client_id=\"${_google_default_client_id}\""
    "google_default_client_secret=\"${_google_default_client_secret}\""
  )

  python2 tools/gn/bootstrap/bootstrap.py --gn-gen-args "${_flags[*]}"
  out/Release/gn gen out/Release --args="${_flags[*]}" \
    --script-executable=/usr/bin/python2

191
  ninja -C out/Release chrome chrome_sandbox chromedriver widevinecdmadapter
Luca Giambonini's avatar
Luca Giambonini committed
192 193 194
}

package() {
Xuetian Weng's avatar
Xuetian Weng committed
195
  cd chromium-launcher-$_launcher_ver
Jeff Huang's avatar
Jeff Huang committed
196
  make PREFIX=/usr DESTDIR="$pkgdir" install
Xuetian Weng's avatar
Xuetian Weng committed
197 198 199
  install -Dm644 LICENSE \
    "$pkgdir/usr/share/licenses/chromium/LICENSE.launcher"

200
  cd "$srcdir/$pkgname-$pkgver"
Luca Giambonini's avatar
Luca Giambonini committed
201

202
  install -D out/Release/chrome "$pkgdir/usr/lib/chromium/chromium"
203 204
  install -Dm4755 out/Release/chrome_sandbox "$pkgdir/usr/lib/chromium/chrome-sandbox"
  ln -s /usr/lib/chromium/chromedriver "$pkgdir/usr/bin/chromedriver"
Luca Giambonini's avatar
Luca Giambonini committed
205

206 207 208 209 210 211 212 213 214 215 216 217
  install -Dm644 chrome/installer/linux/common/desktop.template \
    "$pkgdir/usr/share/applications/chromium.desktop"
  install -Dm644 chrome/app/resources/manpage.1.in \
    "$pkgdir/usr/share/man/man1/chromium.1"
  sed -i \
    -e "s/@@MENUNAME@@/Chromium/g" \
    -e "s/@@PACKAGE@@/chromium/g" \
    -e "s/@@USR_BIN_SYMLINK_NAME@@/chromium/g" \
    "$pkgdir/usr/share/applications/chromium.desktop" \
    "$pkgdir/usr/share/man/man1/chromium.1"

  cp \
Jeff Huang's avatar
Jeff Huang committed
218 219
    out/Release/{chrome_{100,200}_percent,resources}.pak \
    out/Release/{*.bin,chromedriver,libwidevinecdmadapter.so} \
Jeff Huang's avatar
Jeff Huang committed
220
    "$pkgdir/usr/lib/chromium/"
221
  install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Release/locales/*.pak
Luca Giambonini's avatar
Luca Giambonini committed
222

Jeff Huang's avatar
Jeff Huang committed
223 224 225 226
  if [[ -z ${_system_libs[icu]+set} ]]; then
    cp out/Release/icudtl.dat "$pkgdir/usr/lib/chromium/"
  fi

Luca Giambonini's avatar
Luca Giambonini committed
227 228
  for size in 22 24 48 64 128 256; do
    install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
229
      "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
Luca Giambonini's avatar
Luca Giambonini committed
230
  done
231

232 233
  for size in 16 32; do
    install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
234
      "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
235
  done
Luca Giambonini's avatar
Luca Giambonini committed
236

237
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
Luca Giambonini's avatar
Luca Giambonini committed
238
}
Xuetian Weng's avatar
Xuetian Weng committed
239

240

Xuetian Weng's avatar
Xuetian Weng committed
241
# vim:set ts=2 sw=2 et: