summaryrefslogtreecommitdiff
path: root/teams-for-linux/PKGBUILD
blob: fbeb4f996d545116f3fadbe8ca1fd2e55b822504 (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# Maintainer: Erich Eckner <arch at eckner dot net>
# Contributor: Fredy García <frealgagu at gmail dot com>
# Contributor: Ivelin Velkov <ivelin dot velkov at gmail dot com>

pkgname=teams-for-linux
pkgver=1.11.2
pkgrel=1
pkgdesc="Unofficial Microsoft Teams client for Linux using Electron."
arch=("aarch64" "armv7h" "i686" "x86_64")
url="https://github.com/IsmaelMartinez/${pkgname}"
license=("GPL3")
_pinned_dependencies=(
  'gcc-libs=14.2.1+r134+gab884fffe3fc'
  'glibc>=2.35'
  'libatk-1.0.so=0'
  'libatk-bridge-2.0.so=0'
  'libatspi.so=0'
  'libcairo.so=2'
  'libcups=2:2.4.11'
  'libdbus-1.so=3'
  'libdrm=2.4.123'
  'libexpat.so=1'
  'libgdk_pixbuf-2.0.so=0'
  'libgio-2.0.so=0'
  'libglib-2.0.so=0'
  'libgobject-2.0.so=0'
  'libgtk-3.so=0'
  'libpango-1.0.so=0'
  'libx11=1.8.10'
  'libxcb=1.17.0'
  'libxcomposite=0.4.6'
  'libxdamage=1.1.6'
  'libxext=1.3.6'
  'libxfixes=6.0.1'
  'libxkbcommon.so=0'
  'libxrandr=1.5.4'
  'mesa=1:24.2.5'
  'nspr=4.35'
  'nss=3.105'
)
depends=("gtk3" "libxss" "${_pinned_dependencies[@]}")
makedepends=('nodejs-lts-iron' "node-gyp" "python" "yarn")
source=(
  "${pkgname}-${pkgver}.tar.gz::https://github.com/IsmaelMartinez/${pkgname}/archive/v${pkgver}.tar.gz"
  "${pkgname}.desktop"
)
sha512sums=('576788bfcb3533d4f66c9108e3db0665e5dcda2288b470936b1f38e6f3a718d50645b6d38c810d0dfb4b421b9f2d17034026dde8ae29f82f7a0f72624779e52a'
            '3e80d0aaefe42644265bd379f2279912c9358b2ce5c5efcd9aa7c4c67a07841da77c0fabac87eb7837f3cd7f0e620ce322c8791ff61bd3729c343108bd5d5d61')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  yarn install --non-interactive --pure-lockfile --cache-folder "${srcdir}/yarn-cache"
  if [[ ${CARCH} == "aarch64" ]]; then
    yarn electron-builder build --arm64 --linux dir
  elif [[ ${CARCH} == "armv7h" ]]; then
    yarn electron-builder build --armv7l --linux dir
  elif [[ ${CARCH} == "i686" ]]; then
    yarn electron-builder build --ia32 --linux dir
  elif [[ ${CARCH} == "x86_64" ]]; then
    yarn electron-builder build --x64 --linux dir
  fi
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  install -dm755 "${pkgdir}/opt" "${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

  cp -r --preserve=mode "${srcdir}/${pkgname}-${pkgver}/dist/${_unpacked_dirname}" "${pkgdir}/opt/${pkgname}"
  install -Dm644 "${srcdir}/${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
  for _file in "${srcdir}/${pkgname}-${pkgver}/build/icons/"*.png
  do
    _filename="$(basename ${_file})"
    install -Dm644 "${_file}" "${pkgdir}/usr/share/icons/hicolor/${_filename%.png}/apps/${pkgname}.png"
  done
  ln -sf "/opt/${pkgname}/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
_patch_PKGBUILD
}
_patch_PKGBUILD() {
if printf '%s\n' "${arch[@]}" | grep -qvxF any; then
  if [ -d "${pkgdir}/usr/lib" ]; then
    provides=(
      $(
        {
          printf '%s\n' "${provides[@]}"
          find "${pkgdir}/usr/lib" \
            -name '*.so' -printf '%p\n' \
          | while read -r fn; do
            if ! LC_ALL=C readelf -h "$fn" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
              # no shared object
              continue
            fi
            if ! LC_ALL=C readelf -d "$fn" 2>/dev/null | grep -q '.*Library soname: \[.*\].*'; then
              # not versioned
              continue
            fi
            printf '%s\n' "${fn##*/}"
          done
        } \
        | sort -u
      )
    )
  fi
fi
if printf '%s\n' "${arch[@]}" | grep -qvxF any; then
  if ! _errors=$(
    diff <(
      {
        find "${pkgdir}" -type f -exec objdump -x {} \; 2>/dev/null \
        | sed '
          s/^\s*NEEDED\s\+\(\S\+\.so\)\(\.\S\+\)\?\s*$/\1/
          t
          d
        ' \
        | sort -u \
        | while read -r _lib; do
          for _libdir in {${pkgdir},}/usr/lib*; do
            [ -d "${_libdir}" ] || continue
            [ -e "${_libdir}/${_lib}" ] \
            && printf '%s\n' "${_lib}"
          done
        done \
        | sort -u
        for _libdir in "${pkgdir}/usr"/lib*; do
          [ -d "${_libdir}" ] || continue
          find "${_libdir}" -not -type d -name '*.so' -printf '%f\n%f\n'
        done
      } \
      | sort \
      | uniq -u \
      | while read -r _lib; do
        if ! _pkg=$(
          pacman -Qqo "/usr/lib/${_lib}" 2>/dev/null
        ); then
          >&2 printf 'WARNING: noone owns "%s"\n' "${_lib}"
          printf '%s\n' "${_lib}"
          continue
        fi
        if pacman -Qi "${_pkg}" \
        | sed '
          :a
            $! N
            s/\n\s\+/  /
            ta
          P
          D
        ' \
        | sed -n '
          s/^Provides\s*:\s*//
          T
          y/ /\n/
          p
        ' \
        | sed -n '
          /^$/d
          s/=.*$//
          T
          /\.so$/p
        ' \
        | grep -qxF "${_lib}"; then
          printf '%s\n' "${_lib}"
        else
          printf '%s\n' "${_pkg}"
        fi
      done \
      | sed '
        s/[<>]\?=.*$//
        /^python$/d
        /^$/d
      ' \
      | sort -u
    ) <(
      eval 'printf '"'"'%s\n'"'"' "${_pinned_dependencies[@]}" "${_pinned_dependencies_'"${CARCH}"'[@]}" "${_pinned_dependencies_'"${OS}"'[@]}"' \
      | sed '
        s/[<>]\?=.*$//
        /^python$/d
        /^$/d
      ' \
      | sort -u
    )
  ); then
    {
      printf 'There are discrepancies between the _pinned_dependencies and the linked libraries in %s'"'"'s %s():\n' \
        "${pkgbase:-${pkgname}}" \
        "${FUNCNAME[1]}"
      printf '%s\n' "${_errors}" \
      | sed '
        s/^</actual  /
        t
        s/^>/claimed /
        t
        d
      ' \
      | sort -k1,1
    } \
    | tee -a /tmp/pin-dependencies.log
    return 1
  fi
fi
:
}