summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 926c7de6a882af0dd166922cbf0ef2df4968cddc (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
# Maintainer:
# Contributor: The one with the braid <info@braid.business>

## links
# https://fluffychat.im/
# https://github.com/krille-chan/fluffychat

: ${_fvm_version=}

: ${FVM_CACHE_PATH:=$SRCDEST/fvm-cache}
: ${RUSTUP_TOOLCHAIN:=nightly}
export FVM_CACHE_PATH RUSTUP_TOOLCHAIN

_pkgname="fluffychat"
pkgname="$_pkgname"
pkgver=2.0.0
pkgrel=1
pkgdesc="The cutest instant messenger in the [matrix]"
url="https://github.com/krille-chan/fluffychat"
license=('AGPL-3.0-only')
arch=('x86_64' 'aarch64')

depends=(
  'gtk3'
  'libsecret'     # flutter_secure_storage
  'xdg-user-dirs' # path_provider
  'libolm'        # for e2ee
  'openssl'       # sqlite encryption
)
makedepends=(
  'clang'
  'cmake'
  'fvm' # AUR
  'git'
  'lld'
  'llvm'
  'ninja'
  'patchelf'
  'rustup'
)
optdepends=(
  'zenity: for flutter_file_picker'
  'kdialog: for flutter_file_picker'
)

options=('!lto' '!strip' '!debug')

_pkgsrc="$_pkgname-$pkgver"
_pkgext="tar.gz"
source=(
  "$_pkgsrc.$_pkgext"::"$url/archive/refs/tags/v$pkgver.$_pkgext"
  '0000-fix-wayland-gtk-csd.patch'
)
sha256sums=(
  'f49e212844f2b983a104510fb370fbb1fafccda39457bb62b62c3bad76136fca'
  '0699d9eca413975cf8c99fcc906092cb4f546c9be139b6fcb3995e607eac1763'
)

prepare() {
  cd "$_pkgsrc"
  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    src="${src%.zst}"
    if [[ $src == *.patch ]]; then
      printf '\n\nApplying patch: %s\n' "$src"
      patch -Np1 -F100 -i "${srcdir:?}/$src"
    fi
  done
}

build() {
  # fix incompatible C(XX)FLAGS on Arch Linux on ARM
  if [ "${CARCH::1}" != "x" ]; then
    local i _cflags _cxxflags _unwanted
    _cflags=(${CFLAGS})
    _cxxflags=(${CXXFLAGS})

    _unwanted=(
      -fstack-protector-strong
      -fstack-clash-protection
    )

    for i in ${_unwanted[@]}; do
      _cflags=(${_cflags[@]//$i/})
      _cxxflags=(${_cxxflags[@]//$i/})
    done

    CFLAGS="${_cflags[@]}"
    CXXFLAGS="${_cxxflags[@]}"
  fi

  : ${_fvm_version:=$(grep -Pom1 '(?<=FLUTTER_VERSION=)[0-9\.]+' "$_pkgsrc/.github/workflows/versions.env")}

  cd "$_pkgsrc"
  fvm install $_fvm_version
  fvm global $_fvm_version

  fvm flutter --disable-analytics
  #fvm flutter pub upgrade --major-versions
  fvm flutter pub get
  fvm flutter build linux --no-pub --release
}

package() {
  pushd "$_pkgsrc"/build/linux/*/release
  cmake -DCMAKE_INSTALL_PREFIX="/usr/lib/$_pkgname" .
  DESTDIR="$pkgdir" cmake -P cmake_install.cmake
  popd

  # reset rpath
  patchelf --set-rpath '$ORIGIN' "$pkgdir/usr/lib/$_pkgname/lib"/*.so

  # symlink
  install -dm755 "$pkgdir/usr/bin"
  ln -s "/usr/lib/$_pkgname/$_pkgname" "$pkgdir/usr/bin/$_pkgname"

  # license
  install -Dm644 "$_pkgsrc/LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"

  # icon
  install -Dm644 "$_pkgsrc/assets/favicon.png" "$pkgdir/usr/share/pixmaps/$_pkgname.png"

  # launcher
  install -Dm644 /dev/stdin "$pkgdir/usr/share/applications/$_pkgname.desktop" << END
[Desktop Entry]
Type=Application
Name=FluffyChat
Comment=$pkgdesc
Exec=$_pkgname
Icon=$_pkgname
SingleMainWindow=true
StartupWMClass=chat.fluffy.fluffychat
Terminal=false
StartupNotify=false
Categories=Network;InstantMessaging;Chat;MatrixClient
X-Purism-FormFactor=Workstation;Mobile;
END
}