Merge remote-tracking branch 'qubesos/pr/72'

* qubesos/pr/72:
  Fix UCA mistake and qvm-actions script
  Fix ShellCheck comments
  Add debian package support
  Disable Thunar thumbnails
  Add support for Thunar Qubes VM tools
This commit is contained in:
Marek Marczykowski-Górecki 2017-12-13 19:47:16 +01:00
commit 1651866aa2
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
9 changed files with 301 additions and 0 deletions

View File

@ -233,6 +233,10 @@ install-common: install-doc
install qubes-rpc/qvm-copy-to-vm.gnome $(DESTDIR)$(LIBDIR)/qubes
install qubes-rpc/qvm-move-to-vm.kde $(DESTDIR)$(LIBDIR)/qubes
install qubes-rpc/qvm-move-to-vm.gnome $(DESTDIR)$(LIBDIR)/qubes
install qubes-rpc/qvm-actions.sh $(DESTDIR)$(LIBDIR)/qubes
install -m 0644 misc/uca_qubes.xml $(DESTDIR)$(LIBDIR)/qubes
mkdir -p $(DESTDIR)/etc/xdg/xfce4/xfconf/xfce-perchannel-xml
install -m 0644 misc/thunar.xml $(DESTDIR)/etc/xdg/xfce4/xfconf/xfce-perchannel-xml
install qubes-rpc/xdg-icon $(DESTDIR)$(LIBDIR)/qubes
install qubes-rpc/{vm-file-editor,qfile-agent,qopen-in-vm} $(DESTDIR)$(LIBDIR)/qubes
install qubes-rpc/qubes-open $(DESTDIR)$(BINDIR)

10
debian/control vendored
View File

@ -97,6 +97,16 @@ Breaks: qubes-core-agent (<< 4.0.0-1)
Description: Qubes integration for Nautilus
Nautilus addons for inter-VM file copy/move/open.
Package: qubes-core-agent-thunar
Architecture: any
Depends:
thunar,
qubes-core-agent-qrexec,
Replaces: qubes-core-agent (<< 4.0.0-1)
Breaks: qubes-core-agent (<< 4.0.0-1)
Description: Qubes integration for Thunar
Thunar addons for inter-VM file copy/move/open.
Package: qubes-core-agent-dom0-updates
Architecture: any
Depends:

View File

@ -0,0 +1,3 @@
usr/lib/qubes/qvm-actions.sh
usr/lib/qubes/uca_qubes.xml
etc/xdg/xfce4/xfconf/xfce-perchannel-xml/thunar.xml

58
debian/qubes-core-agent-thunar.postinst vendored Executable file
View File

@ -0,0 +1,58 @@
#!/bin/bash
# postinst script for core-agent-linux
#
# see: dh_installdeb(1)
set -e
# The postinst script may be called in the following ways:
# * <postinst> 'configure' <most-recently-configured-version>
# * <old-postinst> 'abort-upgrade' <new version>
# * <conflictor's-postinst> 'abort-remove' 'in-favour' <package>
# <new-version>
# * <postinst> 'abort-remove'
# * <deconfigured's-postinst> 'abort-deconfigure' 'in-favour'
# <failed-install-package> <version> 'removing'
# <conflicting-package> <version>
#
# For details, see http://www.debian.org/doc/debian-policy/ or
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html or
# the debian-policy package
case "${1}" in
configure)
# There is no system-wide Thunar custom actions. There is only a default
# file and a user file created from the default one. Qubes actions need
# to be placed after all already defined actions and before </actions>
# the end of file.
if [ -f /etc/xdg/Thunar/uca.xml ] ; then
cp -p /etc/xdg/Thunar/uca.xml /etc/xdg/Thunar/uca.xml.bak
#shellcheck disable=SC2016
sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /etc/xdg/Thunar/uca.xml
fi
if [ -f /home/user/.config/Thunar/uca.xml ] ; then
cp -p /home/user/.config/Thunar/uca.xml /home/user/.config/Thunar/uca.xml.bak
#shellcheck disable=SC2016
sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /home/user/.config/Thunar/uca.xml
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 0
;;
*)
echo "postinst called with unknown argument \`${1}'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
# vim: set ts=4 sw=4 sts=4 et :

57
debian/qubes-core-agent-thunar.postrm vendored Executable file
View File

@ -0,0 +1,57 @@
#!/bin/sh
# postrm script for core-agent-linux
#
# see: dh_installdeb(1)
set -e
# The prerm script may be called in the following ways:
# * <postrm> 'remove'
# * <postrm> 'purge'
# * <old-postrm> 'upgrade' <new-version>
# * <disappearer's-postrm> 'disappear' <overwriter> <overwriter-version>
#
# The postrm script is called after the package's files have been removed
# or replaced. The package whose postrm is being called may have previously been
# deconfigured and only be "Unpacked", at which point subsequent package changes
# do not consider its dependencies. Therefore, all postrm actions may only rely
# on essential packages and must gracefully skip any actions that require the
# package's dependencies if those dependencies are unavailable.[48]
#
# * <new-postrm> 'failed-upgrade' <old-version>
#
# Called when the old postrm upgrade action fails. The new package will be
# unpacked, but only essential packages and pre-dependencies can be relied on.
# Pre-dependencies will either be configured or will be "Unpacked" or
# "Half-Configured" but previously had been configured and was never removed.
#
# * <new-postrm> 'abort-install'
# * <new-postrm> 'abort-install' <old-version>
# * <new-postrm> 'abort-upgrade' <old-version>
#
# Called before unpacking the new package as part of the error handling of
# preinst failures. May assume the same state as preinst can assume.
#
# For details, see http://www.debian.org/doc/debian-policy/ or
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html or
# the debian-policy package
if [ "${1}" = "remove" ] ; then
if [ -f /etc/xdg/Thunar/uca.xml ] ; then
mv /etc/xdg/Thunar/uca.xml /etc/xdg/Thunar/uca.xml.uninstall
mv /etc/xdg/Thunar/uca.xml.bak /etc/xdg/Thunar/uca.xml
fi
if [ -f /home/user/.config/Thunar/uca.xml ] ; then
mv /home/user/.config/Thunar/uca.xml /home/user/.config/Thunar/uca.xml.uninstall
mv /home/user/.config/Thunar/uca.xml.bak /home/user/.config/Thunar/uca.xml
fi
fi
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
# vim: set ts=4 sw=4 sts=4 et :

5
misc/thunar.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<channel name="thunar" version="1.0">
<property name="misc-thumbnail-mode" type="string" value="THUNAR_THUMBNAIL_MODE_NEVER"/>
</channel>

72
misc/uca_qubes.xml Normal file
View File

@ -0,0 +1,72 @@
<action>
<icon>folder-copy</icon>
<name>Copy to VM</name>
<unique-id>1507455450991127-4</unique-id>
<command>/usr/lib/qubes/qvm-actions.sh copy %F</command>
<description></description>
<patterns>*</patterns>
<directories/>
<audio-files/>
<image-files/>
<other-files/>
<text-files/>
<video-files/>
</action>
<action>
<icon>folder-move</icon>
<name>Move to VM</name>
<unique-id>1507455437157027-3</unique-id>
<command>/usr/lib/qubes/qvm-actions.sh move %F</command>
<description></description>
<patterns>*</patterns>
<directories/>
<audio-files/>
<image-files/>
<other-files/>
<text-files/>
<video-files/>
</action>
<action>
<icon>document-open</icon>
<name>Open in VM</name>
<unique-id>1507455471075266-5</unique-id>
<command>/usr/lib/qubes/qvm-actions.sh openvm %F</command>
<description></description>
<patterns>*</patterns>
<audio-files/>
<image-files/>
<other-files/>
<text-files/>
<video-files/>
</action>
<action>
<icon>gtk-convert</icon>
<name>Convert in DisposableVM</name>
<unique-id>1507455488971315-6</unique-id>
<command>/usr/lib/qubes/qvm-actions.sh pdf %F</command>
<description></description>
<patterns>*.pdf</patterns>
<other-files/>
</action>
<action>
<icon>gtk-convert</icon>
<name>Convert in DisposableVM</name>
<unique-id>1507455503129941-7</unique-id>
<command>/usr/lib/qubes/qvm-actions.sh img %F</command>
<description></description>
<patterns>*</patterns>
<image-files/>
</action>
<action>
<icon>document-open</icon>
<name>Open in DisposableVM</name>
<unique-id>1507455559234996-8</unique-id>
<command>/usr/lib/qubes/qvm-actions.sh opendvm %F</command>
<description></description>
<patterns>*</patterns>
<audio-files/>
<image-files/>
<other-files/>
<text-files/>
<video-files/>
</action>

52
qubes-rpc/qvm-actions.sh Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash
# Check if at least two arguments are provided: actions + file(s)
if [ "$#" -le 1 ]; then
echo "Not enough arguments provided. Aborting..."
fi
# Action
action="$1"
shift
# copy and move handle a list of files where other actions don't
case "$action" in
copy)
#shellcheck disable=SC2016
qvm-copy-to-vm '$default' "$@" | zenity --notification --text="Copying files..." --timeout 3
;;
move)
#shellcheck disable=SC2016
qvm-move-to-vm '$default' "$@" | zenity --notification --text="Moving files..." --timeout 3
;;
img)
for file in "$@"
do
/usr/lib/qubes/qvm-convert-img.gnome "$file"
done
;;
pdf)
for file in "$@"
do
/usr/lib/qubes/qvm-convert-pdf.gnome "$file"
done
;;
openvm)
for file in "$@"
do
#shellcheck disable=SC2016
qvm-open-in-vm '$default' "$file" | zenity --notification --text "Opening $file in VM..." --timeout 3 &
done
;;
opendvm)
for file in "$@"
do
qvm-open-in-dvm "$file" | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 &
done
;;
*)
echo "Unknown action. Aborting..."
exit 1
;;
esac

View File

@ -269,6 +269,13 @@ switching from user to root. Since all the user data in a VM is accessible
already from normal user account, there is not much more to guard there. Qubes
VM is a single user system.
%package thunar
Summary: Thunar support for Qubes VM tools
Requires: Thunar
%description thunar
Thunar support for Qubes VM tools
%define _builddir %(pwd)
%define kde_service_dir /usr/share/kde4/services
@ -464,6 +471,22 @@ sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf
%post qrexec
%systemd_post qubes-qrexec-agent.service
%post thunar
if [ "$1" = 1 ]; then
# There is no system-wide Thunar custom actions. There is only a default
# file and a user file created from the default one. Qubes actions need
# to be placed after all already defined actions and before </actions>
# the end of file.
if [ -f /etc/xdg/Thunar/uca.xml ] ; then
cp -p /etc/xdg/Thunar/uca.xml{,.bak}
sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /etc/xdg/Thunar/uca.xml
fi
if [ -f /home/user/.config/Thunar/uca.xml ] ; then
cp -p /home/user/.config/Thunar/uca.xml{,.bak}
sed -i '$e cat /usr/lib/qubes/uca_qubes.xml' /home/user/.config/Thunar/uca.xml
fi
fi
%preun
if [ "$1" = 0 ] ; then
# no more packages left
@ -485,6 +508,18 @@ fi
%preun qrexec
%systemd_preun qubes-qrexec-agent.service
%postun thunar
if [ "$1" = 0 ]; then
if [ -f /etc/xdg/Thunar/uca.xml ] ; then
mv /etc/xdg/Thunar/uca.xml{,.uninstall}
mv /etc/xdg/Thunar/uca.xml{.bak,}
fi
if [ -f /home/user/.config/Thunar/uca.xml ] ; then
mv /home/user/.config/Thunar/uca.xml{,.uninstall}
mv /home/user/.config/Thunar/uca.xml{.bak,}
fi
fi
%postun
if [ $1 -eq 0 ] ; then
/usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
@ -675,6 +710,11 @@ rm -f %{name}-%{version}
/usr/share/nautilus-python/extensions/qvm_move_nautilus.py*
/usr/share/nautilus-python/extensions/qvm_dvm_nautilus.py*
%files thunar
/usr/lib/qubes/qvm-actions.sh
/usr/lib/qubes/uca_qubes.xml
/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/thunar.xml
%files dom0-updates
%dir %attr(0775,user,user) /var/lib/qubes/dom0-updates
/usr/lib/qubes/qubes-download-dom0-updates.sh