uzytkownicy i grupy

Andrzej Krzysztofowicz ankry w green.mif.pg.gda.pl
Wto, 10 Sie 2004, 18:45:09 CEST


Oto proponowana implementacjausuwania uzytkownikow/grup na przykladzie
jednego speca.
Jesli nikt nie wskaze bledu / lepszego rozwiazania, to jutro lub pojutrze
zaczynam zmiany w cvs-ie.

--- /usr/lib/rpm/macros.old	2004-08-10 18:41:20.000000000 +0200
+++ /usr/lib/rpm/macros	2004-08-09 06:47:08.000000000 +0200
@@ -1586,3 +1586,11 @@
 %xmms_general_plugindir       %(xmms-config --general-plugin-dir)
 
 %_target_base_arch	%(echo %{_target_cpu} | sed 's/i.86/i386/;s/athlon/i386/;s/pentium./i386/;s/amd64/x86_64/')
+
+# user/group checking macros
+%usercount()	%(echo '`if rpm -q --whatprovides "user(%1)" >/dev/null 2>&1; \
+			then rpm -q --whatprovides "user(%1)" | wc -l; \
+			else echo 0; fi`')
+%groupcount()	%(echo '`if rpm -q --whatprovides "group(%1)" >/dev/null 2>&1; \
+			then rpm -q --whatprovides "group(%1)" | wc -l; \
+			else echo 0; fi`')
Index: tftp-hpa.spec
===================================================================
RCS file: /cvsroot/SPECS/tftp-hpa.spec,v
retrieving revision 1.30
diff -u -r1.30 tftp-hpa.spec
--- tftp-hpa.spec	9 Jul 2004 23:59:45 -0000	1.30
+++ tftp-hpa.spec	10 Aug 2004 16:41:16 -0000
@@ -15,6 +15,8 @@
 Patch0:		%{name}-configure.in.patch
 BuildRequires:	automake
 BuildRequires:	readline-devel
+Provides:	group(tftp)
+Provides:	user(tftp)
 Obsoletes:	tftp
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
@@ -149,12 +151,16 @@
 	/etc/rc.d/init.d/rc-inetd reload
 fi
 if [ "$1" = "0" ]; then
-	echo "Removing user tftp."
-	/usr/sbin/userdel tftp
-	echo "Removing group tftp."
-	/usr/sbin/groupdel tftp
+	if [ "%{usercount tftp}" -lt 2 ]; then
+		echo "Removing user tftp."
+		/usr/sbin/userdel tftp
+	fi
+	if [ "%{groupcount tftp}" -lt 2 ]; then
+		echo "Removing group tftp."
+		/usr/sbin/groupdel tftp
+	fi
 fi

 %files
 %defattr(644,root,root,755)
 %doc README


-- 
=======================================================================
  Andrzej M. Krzysztofowicz               ankry w mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Gdansk University of Technology




Więcej informacji o liście dyskusyjnej pld-devel-pl