[Unit]
Description=Workaround waydroid not having the correct label
ConditionPathExists=/usr/lib/waydroid
After=local-fs.target

[Service]
Type=oneshot
# Copy if it doesn't exist
ExecStartPre=/usr/bin/bash -c "[ -d /usr/local/lib/.waydroid ] || /usr/bin/cp -r /usr/lib/waydroid /usr/local/lib/.waydroid"
# This is faster than using .mount unit. Also allows for the previous line/cleanup
ExecStartPre=/usr/bin/mount --bind /usr/local/lib/.waydroid /usr/lib/waydroid
# Fix SELinux label
ExecStart=/usr/sbin/restorecon -R /usr/lib/waydroid
# Clean-up after ourselves
ExecStop=/usr/bin/umount /usr/lib/waydroid
ExecStop=/usr/bin/rm -r /usr/local/lib/.waydroid
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
