blob: 7f410a902f21f76032f9583394fc19d056f918eb (
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
|
# Maintainer: Gergely Meszaros <maetveis@gmail.com>
# Contribute at https://gitlab.com/Maetveis/aur-packages
_name='activitywatch'
pkgname="$_name-git"
pkgver=0.12.3b16.r3.g5b75e58
pkgrel=1
pkgdesc='Log what you do on your computer. Simple, extensible, no third parties.'
arch=('x86_64')
url="https://github.com/ActivityWatch/$_name"
license=('MPL2')
depends=(
'python-click'
'python-deprecation'
'python-flask-cors'
'python-flask-restx' # AUR
'python-flask'
'python-iso8601'
'python-peewee'
'python-persist-queue' # AUR hosted in this repo
'python-platformdirs'
'python-pynput' # AUR
'python-pyqt6'
'python-requests'
'python-setuptools'
'python-tabulate'
'python-timeslot' # AUR
'python-tomlkit'
'python-typing_extensions'
'python-werkzeug'
'python-xlib'
'python'
)
makedepends=(
'cargo'
'desktop-file-utils'
'git'
'imagemagick'
'npm'
'python-installer'
'python-poetry'
)
provides=('activitywatch')
conflicts=('activitywatch')
# Makepkg doesn't do LTO for rust, this causes C/C++ code compiled with LTO to fail to link with
# rust code (without LTO)
options=('!lto')
source=(
"$_name::git+$url"
'aw-core-install-aw-cli.patch'
'aw-core-install-schemas.patch'
'aw-qt-install-logo.patch'
'aw-server-fix-static-install.patch'
)
sha256sums=(
'SKIP'
'1bbff09e15b027b2bca96c0f3233550cf3f3e52210ed07bc0bc3c4e6e90570f0'
'cba81025c0e38fd6022b0926972a839d7e6305830bf0c18e561692bfd2806b35'
'9a8ef6abf6bc05d9c0c3d21fbc69621031f2b817c34ec075fcf2a88dd4415dd6'
'6d608266b03e62a99c8885403c86950e6a2bda43513bc57c681744fec7048612'
)
_aw_core="$_name/aw-core"
_aw_qt="$_name/aw-qt"
_aw_server_rust_dir='aw-server-rust'
_aw_server_rust="$_name/$_aw_server_rust_dir"
_aw_server="$_name/aw-server"
_aw_webui="$_aw_server/aw-webui"
_triple="$CARCH-unknown-linux-gnu"
pkgver() {
cd "$_name" || exit 1
git describe --long --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}
prepare() {
git -C "$srcdir/$_name" clean -dfx
git -C "$srcdir/$_name" submodule foreach --recursive 'git clean -dfx'
git -C "$srcdir/$_name" submodule update --init --recursive
git -C "$srcdir/$_aw_core" apply "$srcdir/aw-core-install-aw-cli.patch"
git -C "$srcdir/$_aw_core" apply "$srcdir/aw-core-install-schemas.patch"
git -C "$srcdir/$_aw_qt" apply "$srcdir/aw-qt-install-logo.patch"
git -C "$srcdir/$_aw_server" apply "$srcdir/aw-server-fix-static-install.patch"
cd "$srcdir/$_aw_server_rust" || exit 1
export RUSTUP_TOOLCHAIN='stable'
cargo fetch --locked --target="$CARCH-unknown-linux-gnu"
}
_find_submodules() {
cd "$srcdir/$_name" || exit 1
IFS=' ' read -r -a submodules \
< <(sed --silent '/^SUBMODULES/{s/^SUBMODULES[[:blank:]]*:=[[:blank:]]*//;p}' Makefile)
IFS=' ' read -r -a python_submodules <<<"${submodules[@]/$_aw_server_rust_dir}"
}
_get_rustflags() {
local _extra_rustflags=("--remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}/$pkgbase")
IFS=$'\x1f' read -r -a _cargo_encoded_rustflags <<<"$CARGO_ENCODED_RUSTFLAGS"
_cargo_encoded_rustflags+=("${_extra_rustflags[@]}")
(
IFS=$'\x1f';
printf '%s' "${_cargo_encoded_rustflags[*]}"
)
}
build() {
# Build aw-webui
make --directory="$srcdir/$_aw_webui" build
# References $srcdir in the output
python - \
"$srcdir/$_aw_webui/dist/service-worker.js.map" \
"$srcdir" \
"${DBGSRCDIR:-/usr/src/debug}/$pkgbase" <<'PYTHON'
import sys
with open(sys.argv[1], 'r+') as f:
text = f.read()
f.seek(0)
f.write(text.replace(sys.argv[2], sys.argv[3]))
PYTHON
# Copy webui into aw-server, will be later included as part of the python module
mkdir --parents "$srcdir/$_aw_server/aw_server/static"
cp --target-directory="$srcdir/$_aw_server/aw_server/static" --recursive "$srcdir/$_aw_webui/dist/."
# Copy logo dir into aw-qt
mkdir --parents "$srcdir/$_aw_qt/aw_qt/media/logo"
cp --target-directory="$srcdir/$_aw_qt/aw_qt/media/logo" "$srcdir/$_aw_qt/media/logo/"*
_find_submodules
# Build python submodules
for submodule in "${python_submodules[@]}"; do
cd "$srcdir/$_name/$submodule" || exit 1
poetry build --format=wheel
done
# Build aw-server-rust
cd "$srcdir/$_aw_server_rust" || exit 1
export RUSTUP_TOOLCHAIN='stable'
export CARGO_ENCODED_RUSTFLAGS="$(_get_rustflags)"
export AW_WEBUI_DIR="$srcdir/$_aw_webui/dist"
cargo build --bins --frozen --release --target-dir='target' --target="$_triple"
}
package() {
_find_submodules
# install python packages
find "${python_submodules[@]}" \
-maxdepth 2 \
-type f \
-path '*/dist/*.whl' \
-exec python -m installer --destdir="$pkgdir" '{}' ';'
# install aw-server-rust
install -D --mode=0755 --no-target-directory \
"$srcdir/$_aw_server_rust/target/$_triple/release/aw-server" \
"$pkgdir/usr/bin/aw-server-rust"
# install other binaries distributed from aw-server-rust
find "$srcdir/$_aw_server_rust/target/$_triple/release" \
-maxdepth 1 \
-type f \
-executable \
! -name "aw-server" \
-exec install -D --mode=0755 --target-directory="$pkgdir/usr/bin" '{}' +
# Install .desktop
desktop-file-install --dir="$pkgdir/usr/share/applications" "$srcdir/$_aw_qt/resources/aw-qt.desktop"
# Install icons
for size in "32x32" "48x48"; do
mkdir -p "$pkgdir/usr/share/icons/hicolor/$size/apps"
convert "$srcdir/$_aw_qt/media/logo/logo.png" -colorspace RGB -resize "$size" \
"$pkgdir/usr/share/icons/hicolor/$size/apps/activitywatch.png"
done
mkdir -p "$pkgdir/usr/share/icons/hicolor/512x512/apps"
cp "$srcdir/$_aw_qt/media/logo/logo.png" "$pkgdir/usr/share/icons/hicolor/512x512/apps/activitywatch.png"
}
|