[buildd-tools-devel] Bug#559019: Bug#559019: schroot: copyfiles doesn't support device files

Roger Leigh rleigh at codelibre.net
Sun Dec 13 17:37:56 UTC 2009


tags 559019 + patch fixed-upstream pending
thanks

On Tue, Dec 01, 2009 at 09:39:05AM +0100, Raphaël Hertzog wrote:
> I run virtualbox-ose in a 64 bit chroot managed by schroot because I run
> a 64 bit kernel and want to run 64 bit virtual machine but my machine is
> setup as i386. For virtualbox to work properly I need /dev/vboxdrv and
> /dev/vboxnetctl in the chroot and it needs to be in sync with the host
> (a one-time copy is not enough due to dynamic allocation of device numbers
> by the kernel).
> 
> So I wanted to put /dev/vboxdrv and /dev/vboxnetctl in
> /etc/schroot/copyfiles-defaults but it leads to error message like:
> /usr/bin/md5sum: /dev/vboxdrv: Invalid argument
> /usr/bin/md5sum: /var/lib/schroot/mount/sid-amd64-7deb8402-75d4-4a90-9f24-c38159f6f9b9/dev/vboxdrv: Invalid argument
> 
> when the file already exists and to failures when it doesn't exist:
> $ LANG=C schroot -c sid-amd64 -p
> /usr/bin/md5sum: /dev/vboxdrv: Invalid argument
> cp: reading `/dev/vboxdrv': Invalid argument
> E: sid-amd64-ee46539c-eb7a-4cef-944f-dbd372b93442: Chroot setup failed: stage=setup-start
> 
> You want to compute md5sum only for real files (or symlinks to real files), and
> use "cp -a" on other kinds of files.

This has been fixed in the git repository using the patch below.  I've
also attached the entire updated script in case you'd like to test it
or review it.  This should continue to copy regular files (and
symlinks to regular files) as before, but will additionally copy non-
regular files using "cp -a" as requested.


Regards,
Roger


diff --git a/etc/setup.d/20copyfiles b/etc/setup.d/20copyfiles
index cd7df77..f55a273 100755
--- a/etc/setup.d/20copyfiles
+++ b/etc/setup.d/20copyfiles
@@ -35,33 +35,47 @@ fi
 # $2: destination file
 copy_file()
 {
-    if [ -r "$1" ]; then
-	if [ -r "$2" ]; then
+    if [ -e "$1" ]; then
+
+	COPY="true"
+
+	if [ -e "$2" ]; then
 
             # Device and inode
 	    da=$(/usr/bin/stat --format="%d %i" "$1")
 	    db=$(/usr/bin/stat --format="%d %i" "$2")
 
-            # Content
-	    ca=$(/usr/bin/md5sum "$1" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/')
-	    cb=$(/usr/bin/md5sum "$2" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/')
-
-	    # Copy if files are different
-	    if [ "$da" != "$db" ]; then
-		if [ "$ca" != "$cb" ]; then
-		    cp $VERBOSE "$1" "$2"
+	    if [ "$da" = "$db" ]; then
+		COPY="false"
+	    elif [ -L "$2" ]; then
+		# Copy if destination is a symlink
+		:
+	    elif [ -f "$1" ] && [ -f "$2" ]; then
+                # Content
+		ca=$(/usr/bin/md5sum "$1" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/')
+		cb=$(/usr/bin/md5sum "$2" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/')
+	        # Copy only if file contents differ
+		if [ "$ca" = "$cb" ]; then
+		    COPY="false"
 		fi
 	    fi
+	fi
 
-	else
-
-	    # Copy if destination file does not exist
-	    cp $VERBOSE "$1" "$2"
+echo "$1 $2 COPY=$COPY"
 
+	# Copy only if files are different
+	if [ "$COPY" = "true" ]; then
+	    if [ -f "$1" ]; then
+		cp --preserve=all $VERBOSE "$1" "$2"
+	    else
+	        # Copy non-regular file directly
+		cp -a $VERBOSE "$1" "$2"
+	    fi
 	fi
 
     else
 	echo "Not copying nonexistent file: $file"
+	exit 1
     fi
 }
 

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20091213/266afb6b/attachment.pgp>


More information about the Buildd-tools-devel mailing list