diff --git a/pkg/debian/salt-common.postinst b/pkg/debian/salt-common.postinst new file mode 100644 index 00000000000..c5a8d969b45 --- /dev/null +++ b/pkg/debian/salt-common.postinst @@ -0,0 +1,4 @@ +#!/bin/sh +set -e + +/opt/saltstack/salt/bin/python3 -m compileall -qq /opt/saltstack/salt/lib diff --git a/pkg/debian/salt-common.prerm b/pkg/debian/salt-common.prerm new file mode 100644 index 00000000000..236c2bd3d12 --- /dev/null +++ b/pkg/debian/salt-common.prerm @@ -0,0 +1,5 @@ +#!/bin/sh +set -e + +dpkg -L salt-common | perl -ne 's,/([^/]*)\.py$,/__pycache__/\1.*, or next; unlink $_ or die $! foreach glob($_)' +find /opt/saltstack/salt -type d -name __pycache__ -empty -print0 | xargs --null --no-run-if-empty rmdir diff --git a/pkg/debian/salt-master.postinst b/pkg/debian/salt-master.postinst index 1c78ee73478..45a759c8bac 100644 --- a/pkg/debian/salt-master.postinst +++ b/pkg/debian/salt-master.postinst @@ -1,6 +1,6 @@ case "$1" in configure) - chown -R salt:salt /etc/salt /var/log/salt /opt/saltstack/salt/ /var/cache/salt/ /var/run/salt + chown -R salt:salt /etc/salt /var/log/salt /var/cache/salt/ /var/run/salt if command -v systemctl; then systemctl enable salt-master; fi ;; esac diff --git a/pkg/rpm/salt.spec b/pkg/rpm/salt.spec index f3cae281605..d157fd540a1 100644 --- a/pkg/rpm/salt.spec +++ b/pkg/rpm/salt.spec @@ -428,6 +428,7 @@ chown -R %{_SALT_USER}:%{_SALT_GROUP} %{_SALT_HOME} chmod u=rwx,g=rwx,o=rx %{_SALT_HOME} ln -s -f /opt/saltstack/salt/spm %{_bindir}/spm ln -s -f /opt/saltstack/salt/salt-pip %{_bindir}/salt-pip +/opt/saltstack/salt/bin/python3 -m compileall -qq /opt/saltstack/salt/lib %post cloud @@ -452,7 +453,7 @@ if [ $1 -lt 2 ]; then /bin/openssl sha256 -r -hmac orboDeJITITejsirpADONivirpUkvarP /opt/saltstack/salt/lib/libcrypto.so.1.1 | cut -d ' ' -f 1 > /opt/saltstack/salt/lib/.libcrypto.so.1.1.hmac || : fi fi -chown -R salt:salt /etc/salt /var/log/salt /opt/saltstack/salt/ /var/cache/salt/ /var/run/salt/ +chown -R salt:salt /etc/salt /var/log/salt /var/cache/salt/ /var/run/salt/ %post syndic %systemd_post salt-syndic.service @@ -480,6 +481,10 @@ ln -s -f /opt/saltstack/salt/salt-ssh %{_bindir}/salt-ssh %systemd_post salt-api.service ln -s -f /opt/saltstack/salt/salt-api %{_bindir}/salt-api +%preun +find /opt/saltstack/salt -type f -name \*\.pyc -print0 | xargs --null --no-run-if-empty rm +find /opt/saltstack/salt -type d -name __pycache__ -empty -print0 | xargs --null --no-run-if-empty rmdir + %postun master %systemd_postun_with_restart salt-master.service if [ $1 -eq 0 ]; then