]> git.pld-linux.org Git - packages/rpm.git/commitdiff
- the add %lua_ prefixed /etc/shell edit macros for cleaner specs
authorElan Ruusamäe <glen@pld-linux.org>
Wed, 25 Jun 2008 12:44:18 +0000 (12:44 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    rpm.macros -> 1.462

rpm.macros

index b501361c868847ccc578fbbfaf9aa4e8f91f77a6..6b357744804288876ef66521aea18767c542aa56 100644 (file)
@@ -1426,15 +1426,19 @@ done                                                                                                                            \
 # Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # Usage:
-#   %post      -p %add_etc_shells -p /bin/sh /bin/pdksh
-#   %preun     -p %remove_etc_shells -p /bin/sh /bin/pdksh
+#   %post      -p <lua>
+#   %lua_add_etc_shells /bin/sh /bin/pdksh
 #
-#  -p (optional) -- specifies that result is embeded %post script (prepends <lua> as first line)
+#   %preun     -p <lua>
+#   if arg[2] == 0 then
+#       %lua_remove_etc_shells /bin/bash /bin/rbash
+#   end
 #
 # Requirements:
-# BuildRequires:       rpmbuild(macros) >= 1.429
+# BuildRequires:       rpmbuild(macros) >= 1.462
+#
 
-%add_etc_shells(p) %{-p:<lua>}\
+%lua_add_etc_shells() \
 t = {}\
 f = io.open("/etc/shells", "r")\
 if f then\
@@ -1449,23 +1453,44 @@ for _, s in ipairs({%{expand:%%__lua_split %*}}) do\
 end\
 %{nil}
 
+%lua_remove_etc_shells() \
+t = {}\
+f = io.open("/etc/shells", "r")\
+if f then\
+       for l in f:lines() do t[l]=l; end\
+       f:close()\
+end\
+for _, l in pairs({%{expand:%%__lua_split %*}}) do\
+       print("Removing "..l.." from /etc/shells")\
+       t[l] = nil\
+end\
+s=""\
+for _, l in pairs(t) do\
+       s=s..l.."\\n"\
+end\
+io.open("/etc/shells", "w"):write(s)\
+%{nil}
+
+# Backwards compat. Use of %lua_ prefixed macros is preferred as these are cleaner to read.
+#
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# Usage:
+#   %post      -p %add_etc_shells -p /bin/sh /bin/pdksh
+#   %preun     -p %remove_etc_shells -p /bin/sh /bin/pdksh
+#
+#  -p (optional) -- specifies that result is embeded %post script (prepends <lua> as first line)
+#
+# Requirements:
+# BuildRequires:       rpmbuild(macros) >= 1.429
+#
+%add_etc_shells(p) %{-p:<lua>}\
+%{expand:%%lua_add_etc_shells %*}\
+%{nil}
+
 %remove_etc_shells(p) %{-p:<lua>}\
 %{-p:if arg[2] == 0 then}\
-       t = {}\
-       f = io.open("/etc/shells", "r")\
-       if f then\
-               for l in f:lines() do t[l]=l; end\
-               f:close()\
-       end\
-       for _, l in pairs({%{expand:%%__lua_split %*}}) do\
-               print("Removing "..l.." from /etc/shells")\
-               t[l] = nil\
-       end\
-       s=""\
-       for _, l in pairs(t) do\
-               s=s..l.."\\n"\
-       end\
-       io.open("/etc/shells", "w"):write(s)\
+%{expand:%%lua_remove_etc_shells %*}\
 %{-p:end} \
 %{nil}
 
This page took 0.182744 seconds and 4 git commands to generate.