tag 606756 + patch
thanks

Hi,

I've uploaded Jonathan's patch for this bug, using the .dsc provided
earlier in the log.  For completeness, the patch for the NMU is
attached.

Regards,

Adam
diff -u dash-0.5.5.1/debian/dash.postinst dash-0.5.5.1/debian/dash.postinst
--- dash-0.5.5.1/debian/dash.postinst
+++ dash-0.5.5.1/debian/dash.postinst
@@ -1,6 +1,25 @@
 #!/bin/sh
 set -e
 
+# $1: dfile, $2: link target, $3: distrib
+replace_with_link() {
+	dfile=$1; ltarget=$2; distrib=$3
+	temp=$dfile.tmp
+	# Safely create a symlink to $ltarget at $dfile, first
+	# making a backup of $dfile (the file being diverted)
+	# in $distrib.
+	#
+	# The cp / ln -s / mv dance avoids having to live without
+	# $dfile (think: /bin/sh) for even a moment, so applications
+	# running in parallel can continue without trouble.
+	# See dash.preinst for details.
+	if [ -e "$dfile" ]; then
+		cp -dp "$dfile" "$distrib"
+	fi
+	ln -sf "$ltarget" "$temp"
+	mv -f "$temp" "$dfile"
+}
+
 # $1: case, $2: dfile, $3: ltarget [, $4: distrib]
 check_divert() {
 	dfile=$2; ltarget=$3
@@ -28,10 +47,7 @@
 			if [ -n "$truename" ]; then
 			       rm -f "$truename"
 			fi
-			# Safely create a slink to $ltarget at $dfile
-			# by first making a copy of $dfile at $distrib
-			cp -dp $dfile $distrib
-			ln -sf $ltarget $dfile
+			replace_with_link $dfile $ltarget $distrib
 		fi
 		;;
 	false)
@@ -48,8 +64,7 @@
 				rm -f "$truename"
 			fi
 			# Point everything back to bash
-			cp -dp $dfile $distrib
-			ln -sf $bash $dfile
+			replace_with_link $dfile $bash $distrib
 		fi
 		;;
 	ash)
@@ -75,7 +90,8 @@
 			if [ "$dst" != $distrib ] && [ -e "$dst" ]; then
 				mv "$dst" $distrib
 			fi
-			ln -sf $3 $2
+			ln -sf $3 $2.tmp
+			mv -f $2.tmp $2
 			;;
 		*)
 			d=${2%/*}
@@ -83,7 +99,8 @@
 				[ -h $2 ] && [ -f $2 ] && [ -f $d/$5 ] &&
 				cmp $2 $d/$5
 			then
-				ln -sf $3 $2
+				ln -sf $3 $2.tmp
+				mv -f $2.tmp $2
 			fi
 			;;
 		esac
diff -u dash-0.5.5.1/debian/dash.preinst dash-0.5.5.1/debian/dash.preinst
--- dash-0.5.5.1/debian/dash.preinst
+++ dash-0.5.5.1/debian/dash.preinst
@@ -15,7 +15,9 @@
 		# intermediate temporary file as ln -sf is not atomic.
 		# dpkg-divert's --rename direct equivalent would be:
 		# mv $dfile $distrib -- but we could end up without a symlink
-		cp -dp $dfile $distrib
+		if [ -e $dfile ]; then
+			cp -dp $dfile $distrib
+		fi
 		ln -sf $ltarget $temp
 		mv -f $temp $dfile
 		dpkg-divert --package dash --divert $distrib --add $dfile
diff -u dash-0.5.5.1/debian/changelog dash-0.5.5.1/debian/changelog
--- dash-0.5.5.1/debian/changelog
+++ dash-0.5.5.1/debian/changelog
@@ -1,3 +1,14 @@
+dash (0.5.5.1-7.4) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * dash.preinst: Do not error out if /bin/sh or its manpage is
+    not already present (thx Brian Potkin; closes: #606756).
+  * dash.postinst: Cope with missing files.  Atomically replace
+    /bin/sh and its manpage rather than removing and re-creating them
+    (thx Adam D. Barratt).
+
+ -- Jonathan Nieder <jrnie...@gmail.com>  Tue, 14 Dec 2010 01:33:42 -0600
+
 dash (0.5.5.1-7.3) unstable; urgency=medium
 
   * Non-maintainer upload.

Reply via email to