[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:
> Just tried it here. Whilst the files are copied with the correct permissions
> (yay), something seems to block the filename output from tar, causing the
> progress bar to sit at 2% until very near the end - it then shoots up quite
> quickly.

Right, I guess I'd need to use a read loop to get the lines one at a
time rather than having it buffer. Updated patch attached.

> As a bonus, before reading your reply I had re-implemented this
> functionality in C which sped it up by a factor of 4 - using tar seems to
> have the same effect.

Using C is an interesting idea..

-- 
see shy jo
From 0b30e08a28fb8bceed82bf01c8c2f18eedf30687 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.

This patch has not yet been tested. (take 2)
---
 packages/live-installer/debian/changelog     |    7 ++
 packages/live-installer/debian/postinst      |   43 +++++-----
 packages/live-installer/debian/postinst.orig |  123 ++++++++++++++++++++++++++
 3 files changed, 152 insertions(+), 21 deletions(-)
 create mode 100755 packages/live-installer/debian/postinst.orig

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..5dc222b 100755
--- a/packages/live-installer/debian/postinst
+++ b/packages/live-installer/debian/postinst
@@ -36,27 +36,28 @@ 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
-		IFS=$OLD_IFS
+		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.
+		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		
+			done
+			IFS=$OLD_IFS
+		)
 	done
 
 	# if we're dumping it, we need to set boot=live
diff --git a/packages/live-installer/debian/postinst.orig b/packages/live-installer/debian/postinst.orig
new file mode 100755
index 0000000..e1e331b
--- /dev/null
+++ b/packages/live-installer/debian/postinst.orig
@@ -0,0 +1,123 @@
+#! /bin/sh
+set -e
+
+. /usr/share/debconf/confmodule
+db_capb backup
+
+. /usr/lib/base-installer/library.sh
+
+NEWLINE="
+"
+
+db_input low live-installer/mode || true
+db_go || exit 10 # back to menu
+db_get live-installer/mode
+mode="$RET"
+
+install_live_system () {
+	# Look at
+	PLACES=""
+
+	# Load filesystem support
+	for script in $(ls /lib/live-installer/*); do
+		. $script
+	done
+
+	for place in $PLACES; do
+		[ ! -e $place ] && continue
+
+		SUPPORT=$(echo $place | sed 's,.*\.\(.*\)$,\1,g')
+		info "Using $SUPPORT support for $place"
+
+		eval ${SUPPORT}_prepare
+		STEPS=$(eval ${SUPPORT}_count)
+
+		db_progress INFO live-installer/progress/copying
+
+		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
+		IFS=$OLD_IFS
+	done
+
+	# if we're dumping it, we need to set boot=live
+	if [ "$mode" = live ]; then
+		# set the init script to use
+		if [ -d /cdrom/casper ]; then
+			db_set debian-installer/add-kernel-opts "boot=casper"
+		else
+			db_set debian-installer/add-kernel-opts "boot=live"
+		fi
+
+		# skip the hooks
+		return
+	fi
+
+	# run the scripts found in hook directory after copying the system
+	partsdir="/usr/lib/live-installer.d"
+	if [ -d "$partsdir" ]; then
+		for script in $(ls "$partsdir"/*); do
+			base=$(basename $script | sed 's/[0-9]*//')
+			if ! db_progress INFO live-installer/progress/$base; then
+				db_subst live-installer/progress/fallback SCRIPT "$base"
+				db_progress INFO live-installer/progress/fallback
+			fi
+
+			if [ -x "$script" ] ; then
+				# be careful to preserve exit code
+				if log-output -t live-installer "$script"; then
+					:
+				else
+					warning "$script returned error code $?"
+				fi
+			else
+				error "Unable to execute $script"
+			fi
+		done
+	fi
+}
+
+waypoint 1	check_target
+waypoint 1	get_mirror_info
+waypoint 100	install_live_system
+waypoint 1	pre_install_hooks
+#waypoint 1	setup_dev
+waypoint 1	configure_apt_preferences
+waypoint 1	configure_apt
+waypoint 3	apt_update
+#waypoint 2	install_filesystems
+waypoint 5	post_install_hooks
+#waypoint 1	pick_kernel
+#waypoint 20	install_linux
+#waypoint 10	install_extra
+waypoint 0	cleanup
+
+run_waypoints live-installer/progress/installing
+
+# mount /dev and /proc on target otherwise grub-installer will fail
+mount -o bind /dev /target/dev
+
+if [ ! -e /target/proc/version ]; then
+	mount -o bind /proc /target/proc
+fi
+
+exit 0
-- 
1.5.5.4

Attachment: signature.asc
Description: Digital signature


Reply to: