On Tuesday 29 April 2008 23:19:15 Quilt newbie. wrote:
> Greetings,
>
> We are trying to use quilt on systems which use AFS (Andrew file system)
> for home directories.  AFS is the chosen file system for our organization
> and thus we cannot change it.  The problem is that quilt uses hard links
> for some operations which fail on AFS when done across directories.  Does
> anyone know if we can modify quilt so that this is no longer a requirement
> to use hard links or explain why hard links are required?

Hardlinks are much more efficient than actual copying. Depending on the size 
of your patches, you may want to move to a local filesystem anyway. With some 
good luck, the attached patch will fix this problem, though -- could you 
please check?

Thanks,
Andreas
 lib/backup-files.c        |   24 +++++++++++++++++-------
 quilt/pop.in              |   14 ++++----------
 quilt/scripts/patchfns.in |   20 +++++---------------
 3 files changed, 26 insertions(+), 32 deletions(-)

--

Index: lib/backup-files.c
===================================================================
--- lib/backup-files.c
+++ lib/backup-files.c
@@ -1,7 +1,7 @@
 /*
   File: backup-files.c
 
-  Copyright (C) 2003, 2004, 2005, 2006
+  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
   Andreas Gruenbacher <[EMAIL PROTECTED]>, SuSE Labs
 
   This program is free software; you can redistribute it and/or
@@ -68,6 +68,7 @@
 const char *opt_prefix="", *opt_suffix="", *opt_file;
 int opt_silent, opt_what=what_noop;
 int opt_nolinks, opt_touch;
+int opt_keep_backup;
 
 #define LINE_LENGTH 1024
 
@@ -75,7 +76,7 @@
 static void
 usage(void)
 {
-	printf("Usage: %s [-B prefix] [-z suffix] [-f {file|-}] [-s] [-b|-r|-x] [-t] [-L] {file|-} ...\n"
+	printf("Usage: %s [-B prefix] [-z suffix] [-f {file|-}] [-sktL] [-b|-r|-x] {file|-} ...\n"
 	       "\n"
 	       "\tCreate hard linked backup copies of a list of files\n"
 	       "\tread from standard input.\n"
@@ -83,6 +84,7 @@
 	       "\t-b\tCreate backup\n"
 	       "\t-r\tRestore the backup\n"
 	       "\t-x\tRemove backup files and empty parent directories\n"
+	       "\t-k\tWhen doing a restore, keep the backup files\n"
 	       "\t-B\tPath name prefix for backup files\n"
 	       "\t-z\tPath name suffix for backup files\n"
 	       "\t-s\tSilent operation; only print error messages\n"
@@ -353,8 +355,10 @@
 				perror(file);
 				goto fail;
 			}
-			unlink(backup);
-			remove_parents(backup);
+			if (!opt_keep_backup) {
+				unlink(backup);
+				remove_parents(backup);
+			}
 		} else {
 			if (!opt_silent)
 				printf("Restoring %s\n", file);
@@ -368,8 +372,10 @@
 				if (opt_nolinks && ensure_nolinks(file))
 					goto fail;
 			}
-			unlink(backup);
-			remove_parents(backup);
+			if (!opt_keep_backup) {
+				unlink(backup);
+				remove_parents(backup);
+			}
 			if (opt_touch)
 				(void) utime(file, NULL);
 			else {
@@ -487,7 +493,7 @@
 
 	progname = argv[0];
 
-	while ((opt = getopt(argc, argv, "brxB:z:f:shLt")) != -1) {
+	while ((opt = getopt(argc, argv, "brkxB:z:f:shLt")) != -1) {
 		switch(opt) {
 			case 'b':
 				opt_what = what_backup;
@@ -497,6 +503,10 @@
 				opt_what = what_restore;
 				break;
 
+			case 'k':
+				opt_keep_backup = 1;
+				break;
+
 			case 'x':
 				opt_what = what_remove;
 				break;
Index: quilt/pop.in
===================================================================
--- quilt/pop.in
+++ quilt/pop.in
@@ -92,21 +92,15 @@
 
 	if [ -d $QUILT_PC/$patch ]
 	then
-		if ! rmdir $workdir ||  # note that this is racey...
-		   ! cp -rl $QUILT_PC/$patch $workdir
+		local prefix=$QUILT_PC/$patch/
+		[ ${prefix:0:1} == / ] || prefix=$PWD/$prefix
+		if ! ( cd $workdir && \
+		       $QUILT_LIB/backup-files -B $prefix -rks - )
 		then
 			printf $"Failed to copy files to temporary directory\n" >&2
 			rm -rf $workdir
 			return 1
 		fi
-
-		# Now we may have some zero-size files that have no
-		# permissions (which represent files that the patch
-		# creates). Those may have been created in the meantime,
-		# but patch would refuse to touch them: We must remove
-		# them here.
-		find $workdir -type f -size 0 -exec rm -f '{}' ';'
-
 	fi
 
 	if [ -s $patch_file ]
Index: quilt/scripts/patchfns.in
===================================================================
--- quilt/scripts/patchfns.in
+++ quilt/scripts/patchfns.in
@@ -874,31 +874,21 @@
 
 apply_patch_temporarily()
 {
-	local workdir=$1 patch=$2 patch_file patch_args files
+	local workdir=$1 patch=$2 patch_file patch_args
 
 	patch_file=$(patch_file_name "$patch")
 	patch_args=$(patch_args "$patch")
 
 	shift 2
-	if [ $# -gt 0 ]
-	then
-		files=( "$@" )
-	else
-		files=( $(files_in_patch "$patch") )
-	fi
 
-	if [ [EMAIL PROTECTED] -gt 0 ] \
-	   && ! ( cd $QUILT_PC/$patch &&
-		  cp -l --parents "[EMAIL PROTECTED]" $workdir/ )
+	local prefix=$QUILT_PC/$patch/
+	[ ${prefix:0:1} == / ] || prefix=$PWD/$prefix
+	if ! ( cd $workdir && \
+	       $QUILT_LIB/backup-files -B $prefix -rks ${@:--} )
 	then
 		printf $"Failed to copy files to temporary directory\n" >&2
 		return 1
 	fi
-	# Now we may have some zero-size files that have no permissions
-	# (which represent files that the patch creates). Those may have
-	# been created in the meantime, but patch would refuse to touch
-	# them: We must remove them here.
-	find $workdir -type f -size 0 -exec rm -f '{}' ';'
 
 	if [ -s $patch_file ]
 	then
_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to