[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#486926: Installed system does not have correct permissions on directories



Chris Lamb wrote:
> That fixes that problem, but now the read command started by "db_progress
> STEP 1" is reading a filename instead of the the STEP value, resulting in
> "Invalid value: ./bin/", and the installation failing.
> 
> I tried a few fd/fifo redirection tricks, but couldn't get the right
> combination..any ideas?

I still haven't been able to fully test this, sorry, but I think this
should work. stdin (debconf) is redirected to fd 4 and sent into the
dh_progress command, then restored at the end.

> I also benchmarked this tar method and it seems to be about three or four
> times faster than my C version, putting it approximately 10 (!) times faster
> than the current shell version. (I agree with Daniel's remark regarding not
> depending on 'tar' though -- perhaps live-installer itself could embed or
> depend on a functioning tar binary?)

Or we could take the small size hit and turn on tar creation in busybox
tar.

However, if this patch fixes the immediate problem, I'd be inclined to
look at supporting target systems that don't have a working tar as a
wishlist feature that could be implemented later. d-i requires a great
deal from the target system after it's unpacked, including a fully working
apt, which implies a working dpkg, which implies a working tar..

-- 
see shy jo
From bf5104387f5a22c3119bd9d9dcc0d1adf0762f03 Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kodama.kitenet.net>
Date: Wed, 18 Jun 2008 22:16:50 -0400
Subject: [PATCH] Copy files using tar, avoids permissions problems and other nonsense

I suggest getting rid of this mkdir/rm/cp nonsense and just pipe tar to
tar. d-i busybox tar cannot create tar archives, but that's ok, we have
a live filesystem with a fullfledged tar on it available to use.

There is some FD trickery needed by the progress update loop since it is
piped filenames on stdin. Real stdin (debconf) is redirected to fd 4
and sent into the dh_progress command, then restored at the end. fd 4 should
be safe with both cdebconf and debconf as they use 3 and 5, respectively.

This patch has not yet been tested. (take 3)
---
 packages/live-installer/debian/changelog |    7 +++++
 packages/live-installer/debian/postinst  |   43 ++++++++++++++++--------------
 2 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/packages/live-installer/debian/changelog b/packages/live-installer/debian/changelog
index 2ad2913..9b03bc0 100644
--- a/packages/live-installer/debian/changelog
+++ b/packages/live-installer/debian/changelog
@@ -1,3 +1,10 @@
+live-installer (6) UNRELEASED; urgency=low
+
+  * Copy files using tar, avoids permissions problems and other nonsense.
+    Closes: #486926
+
+ -- Joey Hess <joeyh@debian.org>  Wed, 18 Jun 2008 21:23:06 -0400
+
 live-installer (5) unstable; urgency=low
 
   [ Updated translations ]
diff --git a/packages/live-installer/debian/postinst b/packages/live-installer/debian/postinst
index cd3313d..5bd585e 100755
--- a/packages/live-installer/debian/postinst
+++ b/packages/live-installer/debian/postinst
@@ -36,26 +36,29 @@ install_live_system () {
 
 		COUNT=0
 		OLD_IFS=$IFS
-		IFS=$NEWLINE
-		for item in `find .`; do
-			# We need to be ensure it's not a symbolic link otherwise
-			# it breaks links for directories.
-			if [ -d "$item" ] && [ ! -h "$item" ]; then
-				mkdir -p /target/"$item"
-			else
-				mkdir -p /target/"$(dirname $item)"
-				rm -f /target/"$item"
-				cp -a "$item" /target/"$item"
-			fi
-
-			COUNT=$(($COUNT + 1))
-			CURRENT=$(($COUNT * 100 / $STEPS))
-
-			[ x$CURRENT = x$LAST_UPDATE ] && continue
-
-			LAST_UPDATE=$CURRENT
-			db_progress STEP 1
-		done
+		mkdir -p /target
+		# use tar from inside the live filesystem to create
+		# the tarball, because busybox tar in d-i does not 
+		# support creating tarballs.
+		# 
+		# The --exclude is a paranoia measure, in case this program
+		# is running from the toplevel of a live filesystem,
+		# which is not normally the case.
+		exec 4>&0
+		chroot . tar c . --exclude=target | \
+		(chdir /target && tar xv) | \
+		(
+			while read line; do
+				COUNT=$(($COUNT + 1))
+				CURRENT=$(($COUNT * 100 / $STEPS))
+
+				[ x$CURRENT = x$LAST_UPDATE ] && continue
+
+				LAST_UPDATE=$CURRENT
+				db_progress STEP 1 <&4
+			done
+		)
+		exec 0>&4
 		IFS=$OLD_IFS
 	done
 
-- 
1.5.5.4

Attachment: signature.asc
Description: Digital signature


Reply to: