[4.3] qubes-input-proxy: add openrc support #70
4 changed files with 152 additions and 2 deletions
|
@ -3,7 +3,7 @@
|
||||||
pkgname=qubes-input-proxy
|
pkgname=qubes-input-proxy
|
||||||
pkgver=1.0.37
|
pkgver=1.0.37
|
||||||
_gittag=v$pkgver
|
_gittag=v$pkgver
|
||||||
pkgrel=0
|
pkgrel=1
|
||||||
pkgdesc="The Qubes service for proxying input devices"
|
pkgdesc="The Qubes service for proxying input devices"
|
||||||
arch="x86_64"
|
arch="x86_64"
|
||||||
url="http://qubes-os.org/"
|
url="http://qubes-os.org/"
|
||||||
|
@ -13,7 +13,13 @@ depends="
|
||||||
qubes-vm-core
|
qubes-vm-core
|
||||||
"
|
"
|
||||||
makedepends="linux-headers"
|
makedepends="linux-headers"
|
||||||
source="$pkgname-$_gittag.tar.gz::https://github.com/QubesOS/qubes-app-linux-input-proxy/archive/refs/tags/$_gittag.tar.gz"
|
subpackages="$pkgname-openrc"
|
||||||
|
source="
|
||||||
|
$pkgname-$_gittag.tar.gz::https://github.com/QubesOS/qubes-app-linux-input-proxy/archive/refs/tags/$_gittag.tar.gz
|
||||||
|
qubes-input-trigger_use-openrc.patch
|
||||||
|
makefile_skip-systemd.patch
|
||||||
|
qubes-input-sender.openrc
|
||||||
|
"
|
||||||
builddir="$srcdir"/qubes-app-linux-input-proxy-$pkgver
|
builddir="$srcdir"/qubes-app-linux-input-proxy-$pkgver
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
|
@ -35,7 +41,13 @@ package() {
|
||||||
for i in $(grep '/bin/sh' -Rl "$pkgdir"); do
|
for i in $(grep '/bin/sh' -Rl "$pkgdir"); do
|
||||||
sed -i 's|/bin/sh|/bin/bash|' "$i"
|
sed -i 's|/bin/sh|/bin/bash|' "$i"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# move openrc to init.d
|
||||||
|
install -Dm755 "$srcdir"/qubes-input-sender.openrc "$pkgdir"/etc/init.d/qubes-input-sender
|
||||||
}
|
}
|
||||||
sha512sums="
|
sha512sums="
|
||||||
0abe75960531c96f2760a462710de2d5e54d95792d719e42d7ae7e2a22b586e4573835584df74ba288e761ed64149f6a951c19301039cf3293621b4032085292 qubes-input-proxy-v1.0.37.tar.gz
|
0abe75960531c96f2760a462710de2d5e54d95792d719e42d7ae7e2a22b586e4573835584df74ba288e761ed64149f6a951c19301039cf3293621b4032085292 qubes-input-proxy-v1.0.37.tar.gz
|
||||||
|
53f898f4d611e0a9be18127cff90ebc3946dc7e270548a84407067b02cb918546e8425c1722a60efb73b93af05c79889eaa16a4c7d596c948fdb9291d218c803 qubes-input-trigger_use-openrc.patch
|
||||||
|
21e7b95c94ec1a3f3499e79cf8b1931da2c3e33d8f1af2efe6b52b7e2678d4648bb0597b3a4a95cc10d0ca3cb83df93075b99cf1b615d8493a9e2fd21fb7f8f7 makefile_skip-systemd.patch
|
||||||
|
2d5cb4369bc4d4c83403bb3e7cd7bc784769950a8fbf581996074fe53cc65c56fe4039e2689b6fa34e51ce22e552fc145115c12e71601809767962a3682dd299 qubes-input-sender.openrc
|
||||||
"
|
"
|
||||||
|
|
18
qubes-input-proxy/makefile_skip-systemd.patch
Normal file
18
qubes-input-proxy/makefile_skip-systemd.patch
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
diff --git a/qubes-rpc/Makefile.orig b/qubes-rpc/Makefile
|
||||||
|
index 22ec526..bf7e0ea 100644
|
||||||
|
--- a/qubes-rpc/Makefile.orig
|
||||||
|
+++ b/qubes-rpc/Makefile
|
||||||
|
@@ -12,13 +12,6 @@ install-dom0:
|
||||||
|
$(DESTDIR)/etc/qubes-rpc/policy/qubes.InputTablet
|
||||||
|
|
||||||
|
install-vm:
|
||||||
|
- install -d $(DESTDIR)$(USRLIBDIR)/systemd/system
|
||||||
|
- install -m 0644 \
|
||||||
|
- qubes-input-sender-keyboard@.service \
|
||||||
|
- qubes-input-sender-keyboard-mouse@.service \
|
||||||
|
- qubes-input-sender-mouse@.service \
|
||||||
|
- qubes-input-sender-tablet@.service \
|
||||||
|
- $(DESTDIR)$(USRLIBDIR)/systemd/system
|
||||||
|
install -d $(DESTDIR)$(LIBDIR)/udev/rules.d
|
||||||
|
install -m 0644 qubes-input-proxy.rules \
|
||||||
|
$(DESTDIR)$(LIBDIR)/udev/rules.d/90-qubes-input-proxy.rules
|
28
qubes-input-proxy/qubes-input-sender.openrc
Executable file
28
qubes-input-proxy/qubes-input-sender.openrc
Executable file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
|
name=$RC_SVCNAME
|
||||||
|
cfgfile="/etc/qubes/$RC_SVCNAME.conf"
|
||||||
|
input="${RC_SVCNAME/*.}"
|
||||||
|
svcname="${RC_SVCNAME/.*}."
|
||||||
|
type="${RC_SVCNAME%.*}"
|
||||||
|
type="${type/$svcname/}"
|
||||||
|
type="$(echo $type | sed 's/.*/\u&/')"
|
||||||
|
command="/usr/bin/qubes-input-sender"
|
||||||
|
command_args="qubes.Input$type /dev/input/$input dom0"
|
||||||
|
command_user="root"
|
||||||
|
pidfile="/run/qubes/$RC_SVCNAME.pid"
|
||||||
|
start_stop_daemon_args=""
|
||||||
|
command_background="true"
|
||||||
|
output_log="/var/log/qubes/$RC_SVCNAME.log"
|
||||||
|
error_log="/var/log/qubes/$RC_SVCNAME.err"
|
||||||
|
|
||||||
|
start_pre() {
|
||||||
|
checkpath --directory --owner $command_user:qubes --mode 0775 \
|
||||||
|
/run/qubes \
|
||||||
|
/var/log/qubes \
|
||||||
|
/var/run/qubes
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_post() {
|
||||||
|
pkill -f "input-proxy-sender /dev/input/$input" || true
|
||||||
|
}
|
92
qubes-input-proxy/qubes-input-trigger_use-openrc.patch
Normal file
92
qubes-input-proxy/qubes-input-trigger_use-openrc.patch
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
diff --git a/qubes-rpc/qubes-input-trigger.orig b/qubes-rpc/qubes-input-trigger
|
||||||
|
index 5fa0e5a..0dd3773 100755
|
||||||
|
--- a/qubes-rpc/qubes-input-trigger.orig
|
||||||
|
+++ b/qubes-rpc/qubes-input-trigger
|
||||||
|
@@ -42,48 +42,68 @@ def get_service_name(udevreturn, input_dev):
|
||||||
|
('ID_INPUT_TOUCHPAD' in udevreturn) or
|
||||||
|
('QEMU_USB_Tablet' in udevreturn)
|
||||||
|
) and 'ID_INPUT_KEY' not in udevreturn:
|
||||||
|
- service = 'qubes-input-sender-tablet'
|
||||||
|
+ service = 'qubes-input-sender.tablet'
|
||||||
|
# PiKVM "mouse" is special, as it sends absolute events
|
||||||
|
elif 'ID_INPUT_MOUSE' in udevreturn and 'ID_USB_VENDOR=PiKVM' in udevreturn:
|
||||||
|
- service = 'qubes-input-sender-tablet'
|
||||||
|
+ service = 'qubes-input-sender.tablet'
|
||||||
|
elif 'ID_INPUT_MOUSE' in udevreturn and 'ID_INPUT_KEY' not in udevreturn:
|
||||||
|
- service = 'qubes-input-sender-mouse'
|
||||||
|
+ service = 'qubes-input-sender.mouse'
|
||||||
|
elif 'ID_INPUT_KEY' in udevreturn and 'ID_INPUT_MOUSE' not in udevreturn:
|
||||||
|
- service = 'qubes-input-sender-keyboard'
|
||||||
|
+ service = 'qubes-input-sender.keyboard'
|
||||||
|
elif 'ID_INPUT_MOUSE' in udevreturn and 'ID_INPUT_KEY' in udevreturn:
|
||||||
|
- service = 'qubes-input-sender-keyboard-mouse'
|
||||||
|
+ service = 'qubes-input-sender.keyboardmouse'
|
||||||
|
|
||||||
|
if service:
|
||||||
|
- service = '{}@{}.service'.format(service, input_dev)
|
||||||
|
+ service = '{}.{}'.format(service, input_dev)
|
||||||
|
|
||||||
|
return service
|
||||||
|
|
||||||
|
|
||||||
|
def handle_service(service, action):
|
||||||
|
- retcode = subprocess.call(
|
||||||
|
- ["/bin/systemctl", "is-active", "--quiet", "service", service])
|
||||||
|
+ serviceFile = os.path.join("/etc/init.d", service)
|
||||||
|
+
|
||||||
|
+ sudo = []
|
||||||
|
+ if os.getuid() != 0:
|
||||||
|
+ sudo = ["sudo"]
|
||||||
|
+
|
||||||
|
if action == "add":
|
||||||
|
- systemctl_action = "start"
|
||||||
|
+ # create service link is not created
|
||||||
|
+ serviceFile = os.path.join("/etc/init.d", service)
|
||||||
|
+ if not os.path.exists(serviceFile):
|
||||||
|
+ subprocess.call(
|
||||||
|
+ ["/bin/ln", "-s", "/etc/init.d/qubes-input-sender", serviceFile])
|
||||||
|
+
|
||||||
|
# Ignore if service is already started
|
||||||
|
+ retcode = subprocess.call(
|
||||||
|
+ ["/sbin/rc-service","--quiet", service, "status"])
|
||||||
|
if retcode == 0:
|
||||||
|
return
|
||||||
|
+
|
||||||
|
+ subprocess.call(
|
||||||
|
+ sudo + ["/sbin/service", service, "start"])
|
||||||
|
+
|
||||||
|
elif action == "remove":
|
||||||
|
- systemctl_action = "stop"
|
||||||
|
+ # Ignore if service does not exist
|
||||||
|
+ if not os.path.exists(serviceFile):
|
||||||
|
+ return
|
||||||
|
+
|
||||||
|
# Ignore if service is not active
|
||||||
|
- if retcode != 0:
|
||||||
|
+ retcode = subprocess.call(
|
||||||
|
+ ["/sbin/rc-service", "--quiet", service, "status"])
|
||||||
|
+ if retcode == 3:
|
||||||
|
return
|
||||||
|
+
|
||||||
|
+ subprocess.call(
|
||||||
|
+ sudo + ["/sbin/service", service, "stop"])
|
||||||
|
+
|
||||||
|
+ # remove ln once stopped
|
||||||
|
+ if os.path.exists(serviceFile):
|
||||||
|
+ subprocess.call(
|
||||||
|
+ sudo + ["/bin/rm", serviceFile])
|
||||||
|
else:
|
||||||
|
print("Unknown action: %s" % action)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
- sudo = []
|
||||||
|
- if os.getuid() != 0:
|
||||||
|
- sudo = ["sudo"]
|
||||||
|
-
|
||||||
|
- subprocess.call(
|
||||||
|
- sudo + ["/bin/systemctl", "--no-block", systemctl_action, service])
|
||||||
|
-
|
||||||
|
-
|
||||||
|
def handle_event(input_dev, action, dom0):
|
||||||
|
udevreturn = None
|
||||||
|
if 'event' in input_dev: # if filename contains 'event'
|
Loading…
Reference in a new issue