SPECS: pdksh.spec - use lua in POSTIN

areq areq at pld-linux.org
Sat Sep 29 15:27:02 CEST 2007


Author: areq                         Date: Sat Sep 29 13:27:02 2007 GMT
Module: SPECS                         Tag: HEAD
---- Log message:
- use lua in POSTIN 

---- Files affected:
SPECS:
   pdksh.spec (1.112 -> 1.113) 

---- Diffs:

================================================================
Index: SPECS/pdksh.spec
diff -u SPECS/pdksh.spec:1.112 SPECS/pdksh.spec:1.113
--- SPECS/pdksh.spec:1.112	Sun Sep  2 14:54:54 2007
+++ SPECS/pdksh.spec	Sat Sep 29 15:26:57 2007
@@ -14,7 +14,7 @@
 Summary(uk.UTF-8):	Вілбна реалізація командного процесора Korn shell (ksh)
 Name:		pdksh
 Version:	5.2.14
-Release:	46
+Release:	47
 License:	Mostly Public Domain with Free & GPL additions
 Group:		Applications/Shells
 Source0:	ftp://ftp.cs.mun.ca/pub/pdksh/%{name}-%{version}.tar.gz
@@ -155,22 +155,18 @@
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%post
-if [ ! -f /etc/shells ]; then
-	umask 022
-	echo "/bin/ksh" > /etc/shells
-	echo "/bin/sh" >> /etc/shells
-else
-	while read SHNAME; do
-		if [ "$SHNAME" = "/bin/ksh" ]; then
-			HAS_KSH=1
-		elif [ "$SHNAME" = "/bin/sh" ]; then
-			HAS_SH=1
-		fi
-	done < /etc/shells
-	[ -n "$HAS_KSH" ] || echo "/bin/ksh" >> /etc/shells
-	[ -n "$HAS_SH" ] || echo "/bin/sh" >> /etc/shells
-fi
+%post -p <lua>
+t = {}
+f = io.open("/etc/shells", "r")
+if f then
+   for l in f:lines() do t[l]=l; end
+   f:close()
+end
+for _, s in ipairs({"/bin/ksh", "/bin/sh"}) do
+   if not t[s] then
+      f = io.open("/etc/shells", "a"); f:write(s.."\n"); f:close()
+   end
+end
 
 %preun
 if [ "$1" = "0" ]; then
@@ -180,18 +176,16 @@
 	' /etc/shells
 fi
 
-%post static
-if [ ! -f /etc/shells ]; then
-	umask 022
-	echo "/bin/ksh.static" > /etc/shells
-else
-	while read SHNAME; do
-	if [ "$SHNAME" = "/bin/ksh.static" ]; then
-		HAS_KSH_STATIC=1
-	fi
-	done < /etc/shells
-	[ -n "$HAS_KSH_STATIC" ] || echo "/bin/ksh.static" >> /etc/shells
-fi
+%post static -p <lua>
+t = {}
+f = io.open("/etc/shells", "r")
+if f then
+   for l in f:lines() do t[l]=l; end
+   f:close()
+end
+if not t["/bin/ksh.static"] then
+   f = io.open("/etc/shells", "a"); f:write("/bin/ksh.static\n"); f:close()
+end
 
 %preun static
 if [ "$1" = "0" ]; then
@@ -221,6 +215,9 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.113  2007/09/29 13:26:57  areq
+- use lua in POSTIN
+
 Revision 1.112  2007/09/02 12:54:54  arekm
 - rel 46; unset shouldn't fail if variable wasn't set
 
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/pdksh.spec?r1=1.112&r2=1.113&f=u



More information about the pld-cvs-commit mailing list