[bash] Simplified lua post script (#740611)
Roman Rakus
rrakus at fedoraproject.org
Mon Nov 7 14:45:06 UTC 2011
commit 1efb46ce7e0e0b2b966526c04946b7ae1d9871e8
Author: Roman Rakus <rrakus at redhat.com>
Date: Mon Nov 7 15:43:34 2011 +0100
Simplified lua post script (#740611)
Code from Sergey Romanov
Signed-off-by: Roman Rakus <rrakus at redhat.com>
bash.spec | 46 ++++++++++++++--------------------------------
1 files changed, 14 insertions(+), 32 deletions(-)
---
diff --git a/bash.spec b/bash.spec
index c26d1ef..0f2282b 100644
--- a/bash.spec
+++ b/bash.spec
@@ -6,7 +6,7 @@
Version: %{baseversion}%{patchleveltag}
Name: bash
Summary: The GNU Bourne Again shell
-Release: 5%{?dist}
+Release: 6%{?dist}
Group: System Environment/Shells
License: GPLv3+
Url: http://www.gnu.org/software/bash
@@ -248,39 +248,18 @@ rm -rf $RPM_BUILD_ROOT
# post is in lua so that we can run it without any external deps. Helps
# for bootstrapping a new install.
# Jesse Keating 2009-01-29 (code from Ignacio Vazquez-Abrams)
+# Roman Rakus 2011-11-07 (code from Sergey Romanov) #740611
%post -p <lua>
-bashfound = false;
-shfound = false;
-
-f = io.open("/etc/shells", "r");
-if f == nil
-then
- f = io.open("/etc/shells", "w");
-else
- repeat
- t = f:read();
- if t == "/bin/bash"
- then
- bashfound = true;
- end
- if t == "/bin/sh"
- then
- shfound = true;
- end
- until t == nil;
+nl = '\n'
+sh = '/bin/sh'..nl
+bash = '/bin/bash'..nl
+f = io.open('/etc/shells', 'a+')
+if f then
+ local shells = nl..f:read('*all')..nl
+ if not shells:find(nl..sh) then f:write(sh) end
+ if not shells:find(nl..bash) then f:write(bash) end
+ f:close()
end
-f:close()
-
-f = io.open("/etc/shells", "a");
-if not bashfound
-then
- f:write("/bin/bash\n")
-end
-if not shfound
-then
- f:write("/bin/sh\n")
-end
-f:close()
%postun -p <lua>
t={}
@@ -317,6 +296,9 @@ end
#%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt
%changelog
+* Mon Nov 07 2011 Roman Rakus <rrakus at redhat.com> - 4.2.10-6
+- Simplified lua post script (#740611)
+
* Fri Jul 29 2011 Roman Rakus <rrakus at redhat.com> - 4.2.10-5
- Clean up unneeded bash-doc files (Ville Skyttä) (#721116)
More information about the scm-commits
mailing list