summarylogtreecommitdiffstats
path: root/PKGBUILD.base
blob: 9d4205f98c68721f8496e9ade27c4809f2ae6bf6 (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
# Maintainer:

_pkgname="thorium-browser"
: ${pkgname:=$_pkgname-bin}

: ${pkgver:=$(grep -Pom1 '^pkgver=\K\S+' "$startdir"/PKGBUILD)}
: ${pkgrel:=$(grep -Pom1 '^pkgrel=\K.*' "$startdir"/PKGBUILD)}
: ${_hash:=SKIP}

eval "$(grep -Pom1 '^pkgdesc=.*' "$startdir"/PKGBUILD)"
eval "$(grep -Pom1 '^url=.*' "$startdir"/PKGBUILD)"
eval "$(grep -Pom1 '^license=.*' "$startdir"/PKGBUILD)"

eval "$(grep -Pom1 '^arch=.*' "$startdir"/PKGBUILD)"

install="$_pkgname.install"

_source_main() {
  _dl_url="$url/releases/download/M${pkgver}"
  _dl_filename="${_pkgname}_${pkgver}_SSE3.deb"
  noextract+=("$_dl_filename")

  source=("$_dl_url/$_dl_filename")
  sha256sums=("$_hash")
}

prepare() {
  install -Dvm644 /dev/stdin "$_pkgname.sh" << END
#!/usr/bin/env bash

# check microprocessor architecture level
if grep -qsE '\bpni\b' /proc/cpuinfo ; then
  _message=''
  _message+=\$'The fastest browser on Earth.'
else
  _message=''
  _message+=\$'Your processor does not support SSE3 instructions.\n'
  _message+=\$'thorium-browser may not work on your computer.'
fi

# Allow users to override command-line options
XDG_CONFIG_HOME=\${XDG_CONFIG_HOME:-~/.config}
_FLAGS_FILE="\$XDG_CONFIG_HOME/thorium-flags.conf"

if [[ -f "\$_FLAGS_FILE" ]]; then
  _USER_FLAGS="\$(cat "\$_FLAGS_FILE")"
fi

# display processor support message
if tty -s ; then
  echo "\$_message"
else
  [ ! -e "\$XDG_CONFIG_HOME/thorium" ] && notify-send -a "thorium-browser" -t 7500 "\$_message"
fi

# Launch
exec /opt/thorium-browser/thorium-browser \$_USER_FLAGS "\$@"
END
}

package() {
  provides=("$_pkgname")
  conflicts=("$_pkgname")

  depends+=(
    'alsa-lib'
    'at-spi2-core'
    'cairo'
    'dbus'
    'libcups'
    'libnotify' # notify-send
    'libxcomposite'
    'libxkbcommon'
    'libxrandr'
    'mesa'
    'nspr'
    'nss'
    'pango'

    ## implicit
    #expat
    #glib2
    #libdrm
    #libx11
    #libxcb
    #libxdamage
    #libxext
    #libxfixes
  )

  echo "  -> Extracting the archive..."
  bsdtar -xf "$_dl_filename" data.tar.xz
  bsdtar -xf data.tar.xz -C "$pkgdir/"
  rm data.tar.xz

  echo "  -> Moving files in place..."
  mv "$pkgdir/opt/chromium.org/thorium" "$pkgdir/opt/$_pkgname"
  unlink "$pkgdir/usr/bin/thorium-browser"
  unlink "$pkgdir/usr/bin/pak"

  # thorium-browser
  install -Dm755 "$_pkgname.sh" "$pkgdir/usr/bin/$_pkgname"
  chmod 4755 "$pkgdir/opt/$_pkgname/chrome-sandbox"

  # thorium-shell
  sed -E \
    -e "s@/opt/chromium.org/thorium/@/opt/$_pkgname/@" \
    -i "$pkgdir/usr/bin/thorium-shell"

  # thorium-browser.xml
  sed -E \
    -e "s@/opt/chromium.org/thorium/@/opt/$_pkgname/@" \
    -i "$pkgdir/usr/share/gnome-control-center/default-apps/thorium-browser.xml"

  # Icons
  for i in 16 24 32 48 64 128 256; do
    install -Dm644 "$pkgdir/opt/$_pkgname/product_logo_${i}.png" \
      "$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$_pkgname.png"
  done

  install -Dm644 "$pkgdir/opt/$_pkgname/thorium_shell.png" \
    "$pkgdir/usr/share/icons/hicolor/256x256/apps/thorium-shell.png"

  # clean-up
  echo "  -> Removing Debian Cron job, duplicate product logos and menu directory..."
  rm -r -- \
    "$pkgdir/opt/chromium.org" \
    "$pkgdir/etc/cron.daily/" \
    "$pkgdir/usr/share/doc/" \
    "$pkgdir/opt/$_pkgname/cron/" \
    "$pkgdir/opt/$_pkgname"/product_logo_*.{png,xpm} \
    "$pkgdir/usr/share/menu/"
}

_source_main