summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 32f5a05259687297e43fba55baba8d69f006ac09 (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
# Maintainer: mpsijm
pkgname=browsers-bin
pkgver=0.5.5
pkgrel=1
pkgdesc="Open the right browser at the right time"
arch=("x86_64")
url="https://browsers.software"
license=("Apache" "MIT")
provides=("browsers=$pkgver")
conflicts=("browsers-git")
# Make source file name unique: https://wiki.archlinux.org/title/PKGBUILD#source
source=("browsers_linux-$pkgver.tar.xz::https://github.com/Browsers-software/browsers/releases/download/$pkgver/browsers_linux.tar.xz")
sha256sums=("04c92bac0c1f53b9f16892630f1120f4c2cde8c5d292a8abef9ecb9cdb038ccf")

package() {
  bsdtar -xf "$srcdir/browsers_linux-$pkgver.tar.xz" -C "$srcdir"

  # install.sh assumes it's installing in /usr/local, so replace paths by $pkgdir/usr
  sed -Ei "s|=\"/usr(\/local)?|=\"$pkgdir\/usr|" "$srcdir/install.sh"
  mkdir -p "$pkgdir/usr/share/icons/hicolor"

  # Run install.sh with updated root and --skip-desktop-database.
  # Since install.sh would (by default) update the mime database, this would generate conflicts in mimeinfo.cache,
  # so we move this to the post_install() instead. See https://github.com/Browsers-software/browsers/pull/129#issuecomment-1919579765
  XDG_DATA_DIRS="$pkgdir/usr/share" "$srcdir/install.sh" --system --skip-desktop-database

  # Since we replaced the TARGET_INSTALL_BINARY_PATH in install.sh, we should update any references to it
  sed -Ei "s|$pkgdir||" "$pkgdir/usr/share/applications/software.Browsers.desktop" "$pkgdir/usr/share/xfce4/helpers/software.Browsers.desktop"
  ln -snf /usr/share/software.Browsers/bin/browsers "$pkgdir/usr/bin/browsers"
}

# Thanks to https://bbs.archlinux.org/viewtopic.php?pid=1544072#p1544072
post_install() {
  xdg-icon-resource forceupdate --theme hicolor &>/dev/null
  update-mime-database usr/share/mime &>/dev/null
  update-desktop-database -q
}

post_upgrade() {
  post_install "$1"
}

post_remove() {
  post_install "$1"
}