summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 88dd2fcf9e3b8a27f0779ea2b3ea299b639a36a7 (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
# Maintainer: Camille 'DrasLorus' Monière <draslorus at draslorus dot fr>
# Contributor: Fredy García <frealgagu at gmail dot com>
# Contributor: Ivelin Velkov <ivelin dot velkov at gmail dot com>

pkgname=teams-for-linux-git
pkgver=1.11.3.r0.gb411431
pkgrel=1
pkgdesc="Unofficial Microsoft Teams client for Linux using system electron (main branch)."
arch=("aarch64" "armv7h" "i686" "x86_64")
url="https://github.com/IsmaelMartinez/${pkgname%-git}"
license=("GPL3")
conflicts=("teams-for-linux")
provides=("teams-for-linux")
depends=("gtk3" "libxss" "nss" "electron")
makedepends=("git" "nodejs>15" "node-gyp" "python3" "yarn")
source=(
  "${pkgname%-git}::git+https://github.com/IsmaelMartinez/${pkgname%-git}#branch=main"
  "${pkgname%-git}.desktop"
  "${pkgname%-git}.sh"
)
sha256sums=('SKIP'
            '9e9ea701b445953383b70133cb52ac6a6ec2872bba419b079a7d0ca13e50dac2'
            '3a34153e962e4478e02deb898577403549268e12eeb058a44303783cf3bcb1b6')

pkgver() {
    cd "$srcdir/${pkgname%-git}"
    git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

# ;s/\"yarn\": \".*\"/\"yarn\": \"$(yarn -v)\"/g"

_electronDist=/usr/lib/electron
_electronVerFun() {
  _completeVer="$(tail /usr/lib/electron/version)"
  while ! curl -sf https://github.com/electron/electron/releases/download/v$_completeVer/electron-v$_completeVer-linux-x64.zip; do
    _baseVer="${_completeVer%.*}"
    _suffix="$((${_completeVer#*.*.} - 1))"
    _completeVer="${_baseVer}.${_suffix}"
  done
  echo "$_completeVer"
}

prepare() {
  _electronVer=$(_electronVerFun) 
  cd "${srcdir}/${pkgname%-git}"
  sed -i "s/\"electron\": \".*\"/\"electron\": \"$_electronVer\"/g;s/\"yarn\": \".*\"/\"yarn\": \"$(yarn -v)\"/g" package.json
}

build() {
  _electronVer=$(_electronVerFun) 
  cd "${srcdir}/${pkgname%-git}"
  ELECTRON_SKIP_BINARY_DOWNLOAD=1 yarn install --non-interactive --pure-lockfile --cache-folder "${srcdir}/yarn-cache"
  if [[ ${CARCH} == "aarch64" ]]; then
    yarn electron-builder build --arm64 -c.electronDist=$_electronDist -c.electronVersion=$_electronVer --linux dir
  elif [[ ${CARCH} == "armv7h" ]]; then
    yarn electron-builder build --armv7l -c.electronDist=$_electronDist -c.electronVersion=$_electronVer --linux dir
  elif [[ ${CARCH} == "i686" ]]; then
    yarn electron-builder build --ia32 -c.electronDist=$_electronDist -c.electronVersion=$_electronVer --linux dir
  elif [[ ${CARCH} == "x86_64" ]]; then
    yarn electron-builder build --x64 -c.electronDist=$_electronDist -c.electronVersion=$_electronVer --linux dir
  fi
}

package() {
  cd "${srcdir}/${pkgname%-git}"
  install -dm755 "${pkgdir}/opt/${pkgname%-git}" "${pkgdir}/usr/bin"

  if [[ ${CARCH} == "aarch64" ]]; then
    _unpacked_dirname="linux-arm64-unpacked"
  elif [[ ${CARCH} == "armv7h" ]]; then
    _unpacked_dirname="linux-armv7l-unpacked"
  elif [[ ${CARCH} == "i686" ]]; then
    _unpacked_dirname="linux-ia32-unpacked"
  elif [[ ${CARCH} == "x86_64" ]]; then
    _unpacked_dirname="linux-unpacked"
  fi

  install -Dm644 "${srcdir}/${pkgname%-git}/dist/${_unpacked_dirname}/resources/app.asar" "${pkgdir}/opt/${pkgname%-git}/app.asar"

  install -Dm644 "${srcdir}/${pkgname%-git}.desktop" "${pkgdir}/usr/share/applications/${pkgname%-git}.desktop"
  for _file in "${srcdir}/${pkgname%-git}/build/icons/"*.png
  do
    _filename="$(basename ${_file})"
    install -Dm644 "${_file}" "${pkgdir}/usr/share/icons/hicolor/${_filename%.png}/apps/${pkgname%-git}.png"
  done

  install -Dm755 "${srcdir}/${pkgname%-git}.sh" "${pkgdir}/opt/${pkgname%-git}/${pkgname%-git}"
  ln -sf "/opt/${pkgname%-git}/${pkgname%-git}" "${pkgdir}/usr/bin/${pkgname%-git}"
}