Fix the detection of rpm vs deb systems.
[arvados.git] / build / go-python-package-scripts / postinst
index 6d303f2e3e8cdd00b0d22cd8290d1655643472f2..095872fe247379b18640898e6d1313ca70e52288 100755 (executable)
@@ -3,9 +3,11 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
-set -e
+# Detect rpm-based systems: the exit code of the following command is zero
+# on rpm-based systems
+/usr/bin/rpm -q -f /usr/bin/rpm >/dev/null 2>&1
 
-if [ "%{name}" != "%\{name\}" ]; then
+if [ "$?" = "0" ]; then
     # Red Hat ("%{...}" is interpolated at package build time)
     pkg="%{name}"
     pkgtype=rpm
@@ -18,6 +20,7 @@ else
     prefix=/usr
 fi
 
+set -e
 case "${pkgtype}-${1}" in
     deb-configure | rpm-1)
         dest_dir="/lib/systemd/system"