Skip to content

Commit

Permalink
Add support for rm-sync in xochitl package
Browse files Browse the repository at this point in the history
Recent xochitl versions renamed the sync service and binary to rm-sync.
This updates the xochitl package to support both.
  • Loading branch information
timower committed Aug 14, 2023
1 parent 715ca4b commit e3ae2fd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Description=reMarkable Document Sync without the xochitl.service dependency
After=dbus.socket
StartLimitIntervalSec=60
StartLimitBurst=4
Conflicts=sync.service
Conflicts=%i.service

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

Expand Down
40 changes: 30 additions & 10 deletions package/xochitl/package
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pkgnames=(xochitl)
pkgdesc="Read documents and take notes"
url=https://remarkable.com
pkgver=0.0.0-14
pkgver=0.0.0-15
timestamp=2022-11-07T20:19:57Z
section="readers"
maintainer="Mattéo Delabre <spam@delab.re>"
Expand All @@ -24,7 +24,7 @@ source=(
toltec-after-launcher.conf
toltec-wrapper.conf
env-readme
manual-sync.service
manual-sync@.service
)
sha256sums=(
SKIP
Expand Down Expand Up @@ -59,19 +59,26 @@ package() {
install -D -m 644 -t "$pkgdir"/etc/systemd/system/remarkable-reboot.service.d \
"$srcdir"/toltec-after-launcher.conf
install -D -m 644 -t "$pkgdir"/etc/systemd/system \
"$srcdir"/manual-sync.service
"$srcdir"/manual-sync@.service
}

configure() {
systemctl daemon-reload

# sync.service interferes with launchers
# we use manual-sync.service instead
if [[ "x$(systemctl is-enabled sync.service)" != "xmasked" ]]; then
systemctl mask sync.service
if ! is-masked sync.service; then
systemctl mask sync.service 2> /dev/null
fi
if ! is-active manual-sync.service; then
systemctl enable --now manual-sync.service

if ! is-masked rm-sync.service; then
systemctl mask rm-sync.service 2> /dev/null
fi

if [ -f /usr/bin/rm-sync ] && ! is-active manual-sync@rm-sync.service; then
systemctl enable --now manual-sync@rm-sync.service
elif [ -f /usr/bin/sync ] && ! is-active manual-sync@sync.service; then
systemctl enable --now manual-sync@sync.service
fi

if is-enabled xochitl.service && ! is-enabled launcher.service; then
Expand All @@ -83,17 +90,24 @@ configure() {
}

preremove() {
if is-active manual-sync.service; then
systemctl disable --now manual-sync.service
if is-active manual-sync@rm-sync.service; then
systemctl disable --now manual-sync@rm-sync.service
fi

if is-active manual-sync@sync.service; then
systemctl disable --now manual-sync@sync.service
fi
}

postremove() {
systemctl daemon-reload

if [[ "x$(systemctl is-enabled sync.service)" == "xmasked" ]]; then
if is-masked sync.service; then
systemctl unmask sync.service 2> /dev/null
fi
if is-masked rm-sync.service; then
systemctl unmask rm-sync.service 2> /dev/null
fi

if is-enabled xochitl.service && is-enabled launcher.service; then
# If xochitl is currently the active launcher, make sure the
Expand All @@ -102,3 +116,9 @@ postremove() {
systemctl enable xochitl.service 2> /dev/null
fi
}

preupgrade() {
if is-enabled manual-sync.service; then
systemctl disable manual-sync.service
fi
}
13 changes: 11 additions & 2 deletions package/xochitl/xochitl
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ for file in /opt/etc/xochitl.env.d/*.env; do
source "$file"
fi
done

# If for some reason, sync.service is no longer masked, re-mask it
# The package install should have handled this, but something may
# have changed it.
if [[ "x$(systemctl is-enabled sync.service)" != "xmasked" ]]; then
systemctl mask sync.service
fi
if ! systemctl is-active --quiet manual-sync.service; then
systemctl enable --now manual-sync.service

if [[ "x$(systemctl is-enabled rm-sync.service)" != "xmasked" ]]; then
systemctl mask rm-sync.service
fi

if [ -f /usr/bin/rm-sync ] && ! is-active manual-sync@rm-sync.service; then
systemctl enable --now manual-sync@rm-sync.service
elif [ -f /usr/bin/sync ] && ! is-active manual-sync@sync.service; then
systemctl enable --now manual-sync@sync.service
fi

exec /usr/bin/xochitl "$@"

0 comments on commit e3ae2fd

Please sign in to comment.