Skip to content

Commit 317e047

Browse files
timowerEeems
andauthored
Add support for rm-sync in xochitl package (#718)
* Add support for rm-sync in xochitl package Recent xochitl versions renamed the sync service and binary to rm-sync. This updates the xochitl package to support both. * Use file checks to determine rm-sync vs sync * Update package/xochitl/package Co-authored-by: Nathaniel van Diepen <[email protected]> * Update to use new disable-unit method * Update package * Update package version * Fix unit-exists --------- Co-authored-by: Nathaniel van Diepen <[email protected]>
1 parent aca0538 commit 317e047

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Description=reMarkable Document Sync without the xochitl.service dependency
66
After=dbus.socket
77
StartLimitIntervalSec=60
88
StartLimitBurst=4
9-
Conflicts=sync.service
9+
Conflicts=%i.service
1010

1111
[Service]
1212
# Do NOT make this dbus, systemd will kill the service when it should be
1313
# running otherwise.
1414
Type=simple
1515
BusName=no.remarkable.sync
16-
ExecStart=/usr/bin/sync --service
16+
ExecStart=/usr/bin/%i --service
1717
Restart=on-failure
1818
RestartForceExitStatus=SIGHUP SIGINT SIGTERM SIGPIPE
1919

package/xochitl/package

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
pkgnames=(xochitl)
66
pkgdesc="Read documents and take notes"
77
url=https://remarkable.com
8-
pkgver=0.0.0-17
8+
pkgver=0.0.0-18
99
timestamp=2022-11-07T20:19:57Z
1010
section="readers"
1111
maintainer="Mattéo Delabre <[email protected]>"
@@ -24,7 +24,7 @@ source=(
2424
toltec-after-launcher.conf
2525
toltec-wrapper.conf
2626
env-readme
27-
manual-sync.service
27+
manual-sync@.service
2828
)
2929
sha256sums=(
3030
SKIP
@@ -59,19 +59,30 @@ package() {
5959
install -D -m 644 -t "$pkgdir"/etc/systemd/system/remarkable-reboot.service.d \
6060
"$srcdir"/toltec-after-launcher.conf
6161
install -D -m 644 -t "$pkgdir"/etc/systemd/system \
62-
"$srcdir"/manual-sync.service
62+
"$srcdir"/manual-sync@.service
6363
}
6464

6565
configure() {
6666
systemctl daemon-reload
6767

68-
# sync.service interferes with launchers
69-
# we use manual-sync.service instead
70-
if [[ "x$(systemctl is-enabled sync.service)" != "xmasked" ]]; then
68+
# sync.service and rm-sync.service interfere with launchers
69+
# we use manual-sync@.service instead
70+
if [ -f /usr/bin/sync ] && ! is-masked sync.service; then
7171
systemctl mask sync.service
7272
fi
73-
if ! is-active manual-sync.service; then
74-
systemctl enable --now manual-sync.service
73+
74+
if [ -f /usr/bin/rm-sync ] && ! is-masked rm-sync.service; then
75+
systemctl mask rm-sync.service
76+
fi
77+
78+
# manual-sync.service has been changed to [email protected]
79+
# Make sure to disable and stop the old version
80+
disable-unit manual-sync.service
81+
82+
if [ -f /usr/bin/rm-sync ] && ! is-active [email protected]; then
83+
systemctl enable --now [email protected]
84+
elif [ -f /usr/bin/sync ] && ! is-active [email protected]; then
85+
systemctl enable --now [email protected]
7586
fi
7687

7788
if is-enabled xochitl.service && ! is-enabled launcher.service; then
@@ -83,14 +94,18 @@ configure() {
8394
}
8495

8596
preremove() {
86-
disable-unit manual-sync.service
97+
disable-unit [email protected]
98+
disable-unit [email protected]
8799
}
88100

89101
postremove() {
90102
systemctl daemon-reload
91103

92-
if [[ "x$(systemctl is-enabled sync.service)" == "xmasked" ]]; then
93-
systemctl unmask sync.service 2> /dev/null
104+
if [ -f /usr/bin/sync ] && is-masked sync.service; then
105+
systemctl unmask sync.service
106+
fi
107+
if [ -f /usr/bin/rm-sync ] && is-masked rm-sync.service; then
108+
systemctl unmask rm-sync.service
94109
fi
95110

96111
if is-enabled xochitl.service && is-enabled launcher.service; then

package/xochitl/xochitl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@ for file in /opt/etc/xochitl.env.d/*.env; do
99
source "$file"
1010
fi
1111
done
12+
1213
# If for some reason, sync.service is no longer masked, re-mask it
1314
# The package install should have handled this, but something may
1415
# have changed it.
1516
if [[ "x$(systemctl is-enabled sync.service)" != "xmasked" ]]; then
1617
systemctl mask sync.service
1718
fi
18-
if ! systemctl is-active --quiet manual-sync.service; then
19-
systemctl enable --now manual-sync.service
19+
20+
if [[ "x$(systemctl is-enabled rm-sync.service)" != "xmasked" ]]; then
21+
systemctl mask rm-sync.service
2022
fi
23+
24+
if [ -f /usr/bin/rm-sync ] && ! is-active [email protected]; then
25+
systemctl enable --now [email protected]
26+
elif [ -f /usr/bin/sync ] && ! is-active [email protected]; then
27+
systemctl enable --now [email protected]
28+
fi
29+
2130
exec -a /usr/bin/xochitl /usr/bin/xochitl "$@"

scripts/install-lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ remove-bind-mount() {
189189
#
190190
# $1 - Full name of the systemd unit, e.g. "draft.service"
191191
unit-exists() {
192-
[ "$(systemctl --quiet list-unit-files "${1}" | /bin/grep -c "${1}" 2> /dev/null || echo "0")" -eq 1 ]
192+
[ "$(systemctl --quiet list-unit-files "${1}" | /bin/grep -c "${1}" 2> /dev/null)" -eq 1 ]
193193
}
194194

195195
# Stops and disabled a unit

0 commit comments

Comments
 (0)