11789: Merge branch 'master' into 11789-arvput-exclude-flag
[arvados.git] / build / go-python-package-scripts / prerm
1 #!/bin/sh
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 set -e
7
8 if [ "%{name}" != "%\{name\}" ]; then
9     # Red Hat ("%{...}" is interpolated at package build time)
10     pkg="%{name}"
11     pkgtype=rpm
12     prefix="${RPM_INSTALL_PREFIX}"
13 else
14     # Debian
15     script="$(basename "${0}")"
16     pkg="${script%.prerm}"
17     pkgtype=deb
18     prefix=/usr
19 fi
20
21 case "${pkgtype}-${1}" in
22     deb-remove | rpm-0)
23         if [ -e /run/systemd/system ]; then
24             systemctl stop "${pkg}" || true
25             systemctl disable "${pkg}" || true
26         fi
27         if [ -e "${prefix}/share/doc/${pkg}/${pkg}.service" ]; then
28             # Unit files from Python packages get installed by
29             # postinst so we have to remove them explicitly here.
30             rm "/lib/systemd/system/${pkg}/${pkg}.service" || true
31         fi
32         ;;
33 esac