Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 1367587

Summary: [PATCH] Adapt post/postun scripts to use atomic file replacement
Product: [Fedora] Fedora Reporter: Colin Walters <walters>
Component: tmuxAssignee: Sven Lankes <sven>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dcantrell, praiskup, rosset.filipe, strobert, sven
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-28 11:39:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1352154    

Description Colin Walters 2016-08-16 21:14:41 UTC
From 1ef0f170653b8eda10cab910c2b5fc5b5f241df0 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters>
Date: Tue, 16 Aug 2016 17:12:58 -0400
Subject: [PATCH] Adapt post/postun scripts to use atomic file replacement

This ensures tmux works with rpm-ostree.  For more information,
see: https://bugzilla.redhat.com/show_bug.cgi?id=1352154
---
 tmux.spec | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/tmux.spec b/tmux.spec
index 449bd64..5dd84c6 100644
--- a/tmux.spec
+++ b/tmux.spec
@@ -1,6 +1,6 @@
 Name:           tmux
 Version:        2.2
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        A terminal multiplexer
 
 Group:          Applications/System
@@ -38,18 +38,20 @@ install -Dpm 644 %{SOURCE1} %{buildroot}%{_datadir}/bash-completion/completions/
 %post
 if [ "$1" = 1 ]; then
   if [ ! -f %{_sysconfdir}/shells ] ; then
-    echo "%{_bindir}/tmux" > %{_sysconfdir}/shells
-    echo "/bin/tmux" >> %{_sysconfdir}/shells
-  else
-    grep -q "^%{_bindir}/tmux$" %{_sysconfdir}/shells || echo "%{_bindir}/tmux" >> %{_sysconfdir}/shells
-    grep -q "^/bin/tmux$" %{_sysconfdir}/shells || echo "/bin/tmux" >> %{_sysconfdir}/shells
+    touch %{_sysconfdir}/shells
   fi
+  for binpath in %{_bindir} /bin; do
+    if ! grep -q "^${binpath}/tmux$" %{_sysconfdir}/shells; then
+       (cat %{_sysconfdir}/shells; echo "$binpath/tmux") > %{_sysconfdir}/shells.new
+       mv %{_sysconfdir}/shells{.new,}
+    fi
+  done
 fi
 
 %postun
 if [ "$1" = 0 ] && [ -f %{_sysconfdir}/shells ] ; then
-  sed -i '\!^%{_bindir}/tmux$!d' %{_sysconfdir}/shells
-  sed -i '\!^/bin/tmux$!d' %{_sysconfdir}/shells
+    sed -e '\!^%{_bindir}/tmux$!d' -e '\!^/bin/tmux$!d' < %{_sysconfdir}/shells > %{_sysconfdir}/shells.new
+    mv %{_sysconfdir}/shells{.new,}
 fi
 
 %files
-- 
2.7.4

Comment 1 Sven Lankes 2016-10-28 11:39:51 UTC
Applied in latest rawhinde build.