]> git.pld-linux.org Git - packages/rpm.git/commitdiff
- user/group deletion script
authorankry <ankry@pld-linux.org>
Mon, 16 Aug 2004 09:59:13 +0000 (09:59 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    rpm-user_group.sh -> 1.1

rpm-user_group.sh [new file with mode: 0644]

diff --git a/rpm-user_group.sh b/rpm-user_group.sh
new file mode 100644 (file)
index 0000000..921bdc2
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+[ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm
+[ -z "$RPM_SCRIPTVERBOSITY" ] && RPM_SCRIPTVERBOSITY=5
+
+if [ "$1" = user -o "$1" = group ]; then
+       MODE=$1
+else
+       echo ERROR
+       exit 2
+fi
+shift
+
+testrm()
+{
+       [ "$RPM_USERDEL" != yes ] && return 1
+       [ -z "$1" ] && return 2
+       rpm -q --whatprovides "${MODE}($1)" >/dev/null 2>&1
+       # no package Provides it (strange)
+       [ $? -ne 0 ] && return 0
+       # only current package Provides it
+       [ `rpm -q --whatprovides "${MODE}($1)" | wc -l` -lt 2 ] && return 0
+       return 1
+}
+
+if [ "$1" = "testrm" ]; then
+       testrm $2
+       exit $?
+elif [ "$1" = del ]; then
+       if testrm $2; then
+               [ "$RPM_SCRIPTVERBOSITY" -lt 2 ] || echo "Removing $MODE $2"
+               /usr/sbin/${MODE}del $2 || :
+       fi
+else
+       echo ERROR
+       exit 2
+fi
This page took 0.036212 seconds and 4 git commands to generate.