From a9cc841abd7855eb96f09d0f1fd9efad6fd41c7f Mon Sep 17 00:00:00 2001 From: mirkobrombin Date: Thu, 21 Dec 2023 22:17:00 +0100 Subject: [PATCH] feat[close #6] Handle desktop entries exports on apt install/apt remove --- includes.container/etc/apt/apt.conf.d/99-vso-post | 1 + includes.container/etc/apt/apt.conf.d/99-vso-pre | 2 ++ includes.container/usr/share/vso/hooks/apt-post | 11 +++++++++++ includes.container/usr/share/vso/hooks/apt-pre | 6 ++++++ 4 files changed, 20 insertions(+) create mode 100644 includes.container/etc/apt/apt.conf.d/99-vso-post create mode 100644 includes.container/etc/apt/apt.conf.d/99-vso-pre create mode 100644 includes.container/usr/share/vso/hooks/apt-post create mode 100644 includes.container/usr/share/vso/hooks/apt-pre diff --git a/includes.container/etc/apt/apt.conf.d/99-vso-post b/includes.container/etc/apt/apt.conf.d/99-vso-post new file mode 100644 index 0000000..a415b7c --- /dev/null +++ b/includes.container/etc/apt/apt.conf.d/99-vso-post @@ -0,0 +1 @@ +DPkg::Post-Invoke {"/usr/share/vso/hooks/apt-post"} \ No newline at end of file diff --git a/includes.container/etc/apt/apt.conf.d/99-vso-pre b/includes.container/etc/apt/apt.conf.d/99-vso-pre new file mode 100644 index 0000000..a509cda --- /dev/null +++ b/includes.container/etc/apt/apt.conf.d/99-vso-pre @@ -0,0 +1,2 @@ +DPkg::Pre-Install-Pkgs {"/usr/share/vso/hooks/apt-pre"} +Dpkg::Tools::Options::/usr/share/vso/hooks/apt-pre::Version "1"; \ No newline at end of file diff --git a/includes.container/usr/share/vso/hooks/apt-post b/includes.container/usr/share/vso/hooks/apt-post new file mode 100644 index 0000000..3e0633e --- /dev/null +++ b/includes.container/usr/share/vso/hooks/apt-post @@ -0,0 +1,11 @@ +#!/bin/bash + +package="$(cat /tmp/vso-transaction)" + +if [ -n "$SUDO_USER" ]; then + username=$SUDO_USER +else + echo "VSO does not work with root privileges, no programs will be exported. Use 'vso export -a $package' to manually export it." +fi + +su -c "/usr/bin/vso export -a $package" $username \ No newline at end of file diff --git a/includes.container/usr/share/vso/hooks/apt-pre b/includes.container/usr/share/vso/hooks/apt-pre new file mode 100644 index 0000000..1600586 --- /dev/null +++ b/includes.container/usr/share/vso/hooks/apt-pre @@ -0,0 +1,6 @@ +#!/usr/bin/bash +read line +while read pack +do + echo "$pack" > /tmp/vso-transaction +done < <( (echo "$line"; cat ) | xargs -d '\n' dpkg-deb --show --showformat='${Package}\n') \ No newline at end of file