summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b2c1036ecfb748a89f55c6f695fc387bc95f61b4 (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
# Maintainer: txtsd <aur.archlinux@ihavea.quest>
# Contributor: Sefa Eyeoglu <contact@scrumplex.net>

pkgbase=espanso-git
pkgname=(espanso-x11-git espanso-wayland-git)
_pkgbase="${pkgbase%-git}"
_branch=dev
pkgver=2.2.2.r0.g42a6c95a
pkgrel=1
pkgdesc='Cross-platform Text Expander written in Rust'
arch=(x86_64)
url='https://espanso.org'
license=('GPL-3.0-or-later')
makedepends=(
  bzip2
  cargo
  dbus
  gcc-libs
  git
  glibc
  libx11
  libxcb
  libxkbcommon
  libxtst
  openssl
  wl-clipboard
  wxwidgets-common
  wxwidgets-gtk3
  xclip
  xdotool
)
source=("git+https://github.com/espanso/espanso.git#branch=${_branch}")
sha256sums=('SKIP')
options=(!lto)

prepare() {
  cd "${_pkgbase}"

  export RUSTUP_TOOLCHAIN=stable
  cargo fetch --target "$(rustc -vV | sed -n 's/host: //p')"

  # Don't change the original service file, as it will be embedded in the
  # binary
  sed 's|{{{espanso_path}}}|/usr/bin/espanso|g' espanso/src/res/linux/systemd.service \
    > espanso.service

  # Icon name
  sed 's/Icon=icon/Icon=espanso/g' espanso/src/res/linux/espanso.desktop \
    > espanso.desktop
}

pkgver() {
  cd "${_pkgbase}"

  git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd "${_pkgbase}"

  export RUSTUP_TOOLCHAIN=stable

  export CARGO_TARGET_DIR=target-x11
  cargo build --frozen --release \
    --manifest-path Cargo.toml \
    --package espanso

  export CARGO_TARGET_DIR=target-wayland
  cargo build --frozen --release \
    --features wayland \
    --manifest-path Cargo.toml \
    --package espanso
}

check() {
  cd "${_pkgbase}"

  # Skip failing tests - unsure why they fail
  export RUSTUP_TOOLCHAIN=stable
  cargo test --frozen --all-features -- \
    --skip tests::ipc_multiple_clients \
    --skip tests::test_migration
}

package_espanso-x11-git() {
  pkgdesc+=" (built for X11)"
  depends=(
    bzip2
    dbus
    gcc-libs
    glibc
    libx11
    libxcb
    libxkbcommon
    libxtst
    openssl
    wxwidgets-common
    wxwidgets-gtk3
    xclip
    xdotool
  )
  provides=("${_pkgbase}")
  conflicts=("${_pkgbase}")

  cd "${_pkgbase}"

  install -Dm755 -t "${pkgdir}/usr/bin" target-x11/release/espanso
  install -Dm644 -t "${pkgdir}/usr/lib/systemd/user" espanso.service
  install -Dm644 -t "${pkgdir}/usr/share/applications" espanso.desktop
  install -Dm644 -t "${pkgdir}/usr/share/doc/espanso" ./*.md
  install -Dm644 espanso/src/res/linux/icon.png \
    "${pkgdir}/usr/share/pixmaps/espanso.png"
}

package_espanso-wayland-git() {
  pkgdesc+=" (built for Wayland)"
  depends=(
    bzip2
    dbus
    gcc-libs
    glibc
    libxkbcommon
    openssl
    wl-clipboard
    wxwidgets-common
    wxwidgets-gtk3
  )
  provides=("${_pkgbase}")
  conflicts=("${_pkgbase}")
  install=espanso-wayland.install

  cd "${_pkgbase}"

  install -Dm755 -t "${pkgdir}/usr/bin" target-wayland/release/espanso
  install -Dm644 -t "${pkgdir}/usr/lib/systemd/user" espanso.service
  install -Dm644 -t "${pkgdir}/usr/share/applications" espanso.desktop
  install -Dm644 -t "${pkgdir}/usr/share/doc/espanso" ./*.md
  install -Dm644 espanso/src/res/linux/icon.png "${pkgdir}/usr/share/pixmaps/espanso.png"
}