summarylogtreecommitdiffstats
path: root/PKGBUILD.avx
blob: 7b6a0fd9fb8b2d1d51d9aecd01853c65e8f0aeae (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
# Maintainer:

_pkgname="thorium-browser-avx"
: ${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)"

_source_main() {
  _dl_url="$url/releases/download/M${pkgver}"
  _dl_filename="${_pkgname%-avx}_${pkgver}_AVX.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 '\bavx\b' /proc/cpuinfo ; then
  _message=''
  _message+=\$'The fastest browser on Earth.'
else
  _message=''
  _message+=\$'Your processor does not support AVX 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/$_pkgname/thorium-browser \$_USER_FLAGS "\$@"
END
}

package() {
  provides=(
    $(printf '%s\n' "${pkgbase%-bin}" "$_pkgname" | sort -u)
  )
  conflicts=(
    $(printf '%s\n' "${pkgbase%-bin}" "$_pkgname" | sort -u)
  )

  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"

  mv "$pkgdir/usr/bin/thorium-shell" "$pkgdir/usr/bin/thorium-shell-${_pkgname: -4}"

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

  mv "$pkgdir/usr/share/gnome-control-center/default-apps/thorium-browser.xml" "$pkgdir/usr/share/gnome-control-center/default-apps/$_pkgname.xml"

  # thorium-browser.appdata.xml
  sed -E \
    -e "s@thorium-browser@$_pkgname@" \
    -i "$pkgdir/usr/share/appdata/thorium-browser.appdata.xml"

  mv "$pkgdir/usr/share/appdata/thorium-browser.appdata.xml" "$pkgdir/usr/share/appdata/$_pkgname.appdata.xml"

  # thorium-browser.desktop
  sed -E \
    -e "s@thorium-browser@$_pkgname@" \
    -e "s@thorium-shell@thorium-shell-${_pkgname: -4}@" \
    -e "s@^(Name\S*=.*)\$@\1 AVX@" \
    -e "s@^(GenericName\S*=.*)\$@\1 AVX@" \
    -i "$pkgdir/usr/share/applications/thorium-browser.desktop"

  mv "$pkgdir/usr/share/applications/thorium-browser.desktop" "$pkgdir/usr/share/applications/$_pkgname.desktop"

  # thorium-shell.desktop
  sed -E \
    -e "s@^Icon=.*\$@Icon=thorium-shell-${_pkgname: -4}@" \
    -e "s@thorium-shell@thorium-shell-${_pkgname: -4}@" \
    -e "s@thorium_shell@thorium_shell_${_pkgname: -4}@" \
    -e "s@^(Name\S*=.*)\$@\1 AVX@" \
    -e "s@^(GenericName\S*=.*)\$@\1 AVX@" \
    -i "$pkgdir/usr/share/applications/thorium-shell.desktop"

  mv "$pkgdir/usr/share/applications/thorium-shell.desktop" "$pkgdir/usr/share/applications/thorium-shell-${_pkgname: -4}.desktop"

  # man page
  mv "$pkgdir/usr/share/man/man1/thorium-browser.1.gz" "$pkgdir/usr/share/man/man1/$_pkgname.1.gz"

  # 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-${_pkgname: -4}.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