13200:test to remove prefix on python
[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 else
13     # Debian
14     script="$(basename "${0}")"
15     pkg="${script%.prerm}"
16     pkgtype=deb
17     prefix=/usr
18 fi
19
20 case "${pkgtype}-${1}" in
21     deb-remove | rpm-0)
22         if [ -e /run/systemd/system ]; then
23             systemctl stop "${pkg}" || true
24             systemctl disable "${pkg}" || true
25         fi
26         if [ -e "${prefix}/share/doc/${pkg}/${pkg}.service" ]; then
27             # Unit files from Python packages get installed by
28             # postinst so we have to remove them explicitly here.
29             rm "/lib/systemd/system/${pkg}/${pkg}.service" || true
30         fi
31         ;;
32 esac