7
quilt/scripts/backup-files.in | 269 ++++++++++++++++++++++++++++++++++++++++++
9
7 files changed, 281 insertions(+), 31 deletions(-)
11
--- quilt-0.45.orig/Makefile.in
12
+++ quilt-0.45/Makefile.in
15
exec_prefix := @exec_prefix@
20
mandir := $(datadir)/man
25
-LIBOBJS := $(filter $(patsubst lib/%.c,lib/%.o,$(wildcard lib/*.c)), $(patsubst %,lib/%,@LIBOBJS@))
30
COMPAT_SYMLINKS := @COMPAT_SYMLINKS@
31
COMPAT_PROGRAMS := @COMPAT_PROGRAMS@
34
DIRT += $(QUILT_IN:%=quilt/%)
36
SCRIPTS_IN := patchfns parse-patch inspect dependency-graph edmail \
38
+ remove-trailing-ws backup-files
40
SCRIPTS_SRC := $(SCRIPTS_IN:%=%.in)
41
SCRIPTS := $(SCRIPTS_IN)
43
SRC += $(wildcard compat/*.in) $(wildcard compat/*.sh)
44
DIRT += $(patsubst %.in,%,$(wildcard compat/*.in)) $(COMPAT_SYMLINKS:%=compat/%)
46
-LIB_SRC := backup-files.c
47
-LIB := backup-files$(EXEEXT)
48
-SRC += $(LIB_SRC:%=lib/%)
49
-DIRT += lib/backup-files$(EXEEXT) $(LIB_SRC:%.c=lib/%.o)
52
DOC_SRC := $(DOC_IN:%=doc/%.in)
55
# Settings for running the uninstalled version of quilt in the source tree:
56
PATH := $(CURDIR)/bin:$(CURDIR)/compat:$(PATH)
57
QUILT_DIR := $(CURDIR)/quilt
58
-QUILT_LIB := $(CURDIR)/lib
59
QUILTRC := $(CURDIR)/test/test.quiltrc
60
-export QUILT_DIR QUILT_LIB QUILTRC
61
+export QUILT_DIR QUILTRC
63
#-----------------------------------------------------------------------
65
all : configure scripts compat $(DOC:%=doc/%) $(MAN1) mofiles
67
-$(LIB:%=lib/%) :: $(LIBOBJS)
70
mofiles : $(LINGUAS:%=po/%.mo)
73
$(MSGMERGE) -o $@ $@ $^
75
scripts : $(BIN:%=bin/%) $(QUILT:%=quilt/%) \
76
- $(SCRIPTS:%=quilt/scripts/%) $(LIB:%=lib/%) \
77
+ $(SCRIPTS:%=quilt/scripts/%) \
78
$(if $(PATCH_WRAPPER),bin/patch-wrapper)
80
dist : clean $(PACKAGE)-$(VERSION).tar.gz
82
$(patsubst %.in,%,$(wildcard bin/*.in quilt/*.in quilt/scripts/*.in)) :: Makefile
85
- @$(SED) -e 's:@QUILT_LIB''@:$(libdir)/$(PACKAGE):g' \
86
- -e 's:@QUILT_DIR''@:$(datadir)/$(PACKAGE):g' \
87
+ @$(SED) -e 's:@QUILT_DIR''@:$(datadir)/$(PACKAGE):g' \
88
-e 's:@PERL''@:$(PERL):g' \
89
-e 's:@BASH''@:$(BASH):g' \
90
-e 's:@PATCH''@:$(PATCH):g' \
93
@$(if $(filter-out $<,$(NON_EXEC_IN)),chmod +x $@)
95
-lib/backup-files.o :: Makefile
96
+#lib/backup-files.o :: Makefile
98
configure : configure.ac aclocal.m4
101
$(BUILD_ROOT)$(datadir)/$(PACKAGE)/wrapper/patch
104
- $(INSTALL) -d $(BUILD_ROOT)$(libdir)/$(PACKAGE)
105
- $(INSTALL) -m 755 $(LIB:%=lib/%) $(BUILD_ROOT)$(libdir)/$(PACKAGE)/
107
$(INSTALL) -d $(BUILD_ROOT)$(docdir)/$(PACKAGE)-$(VERSION)/
108
$(INSTALL) -m 644 doc/README \
109
$(BUILD_ROOT)$(docdir)/$(PACKAGE)-$(VERSION)/
113
rm -rf $(BIN:%=$(BUILD_ROOT)$(bindir)/%) \
114
- $(BUILD_ROOT)$(libdir)/$(PACKAGE) \
115
$(BUILD_ROOT)$(datadir)/$(PACKAGE) \
116
$(patsubst %,$(BUILD_ROOT)$(mandir)/man1/%, \
120
# Include a run-time generated list of dependencies for each test case
121
test/.depend : Makefile $(TESTS)
122
- @( printf "%s : bin/quilt quilt/scripts/patchfns $(LIB:%=lib/%) $(COMPAT)\n" $(TESTS); \
123
+ @( printf "%s : bin/quilt quilt/scripts/patchfns $(COMPAT)\n" $(TESTS); \
124
$(AWK) 'sub(/.*\$$ *quilt /, "") \
125
{ print FILENAME, ":", "quilt/"$$1}' $(TESTS); \
126
$(AWK) 'sub(/.*\<quilt_command /, "") && ($$1 !~ /[^a-z]/) \
127
--- quilt-0.45.orig/quilt/add.in
128
+++ quilt-0.45/quilt/add.in
133
- if ! $QUILT_LIB/backup-files -b -s -L -B $QUILT_PC/$patch/ $SUBDIR$file
134
+ if ! $QUILT_DIR/scripts/backup-files -b -s -L -B $QUILT_PC/$patch/ $SUBDIR$file
136
printf $"Failed to back up file %s\n" "$SUBDIR$file" >&2
138
--- quilt-0.45.orig/quilt/pop.in
139
+++ quilt-0.45/quilt/pop.in
143
printf $"Removing patch %s\n" "$(print_patch $patch)"
144
- $QUILT_LIB/backup-files $silent -r -t -B $QUILT_PC/$patch/ -
145
+ $QUILT_DIR/scripts/backup-files $silent -r -t -B $QUILT_PC/$patch/ -
148
remove_from_db $patch
150
# of one: This will automatically be the case in the usual
151
# situations, but we don't want to risk file corruption in weird
152
# corner cases such as files added to a patch but not modified.
153
- $QUILT_LIB/backup-files -L -s -B $QUILT_PC/$patch/ -
154
+ $QUILT_DIR/scripts/backup-files -L -s -B $QUILT_PC/$patch/ -
155
printf $"Now at patch %s\n" "$(print_patch $patch)"
158
--- quilt-0.45.orig/quilt/push.in
159
+++ quilt-0.45/quilt/push.in
164
- $QUILT_LIB/backup-files $silent_unless_verbose -r -B $QUILT_PC/$patch/ -
165
+ $QUILT_DIR/scripts/backup-files $silent_unless_verbose -r -B $QUILT_PC/$patch/ -
168
cleanup_patch_output() {
169
--- quilt-0.45.orig/quilt/remove.in
170
+++ quilt-0.45/quilt/remove.in
174
# Restore file from backup
175
- if ! $QUILT_LIB/backup-files -r -t -s -B $QUILT_PC/$patch/ $SUBDIR$file
176
+ if ! $QUILT_DIR/scripts/backup-files -r -t -s -B $QUILT_PC/$patch/ $SUBDIR$file
178
printf $"Failed to remove file %s from patch %s\n" \
179
"$SUBDIR$file" "$(print_patch $patch)" >&2
181
+++ quilt-0.45/quilt/scripts/backup-files.in
187
+# File: backup-files.sh
189
+# Copyright (C) 2006 Steve Langasek <vorlon@debian.org>
190
+# portions Copyright (C) 2003, 2004, 2005, 2006 Andreas Gruenbacher
191
+# <agruen@suse.de>, SuSE Labs
193
+# This program is free software; you can redistribute it and/or modify
194
+# it under the terms of the GNU General Public License as published by
195
+# the Free Software Foundation; version 2 dated June, 1991.
197
+# This program is distributed in the hope that it will be useful, but
198
+# WITHOUT ANY WARRANTY; without even the implied warranty of
199
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
200
+# General Public License for more details.
202
+# You should have received a copy of the GNU General Public License
203
+# along with this program; if not, write to the Free Software
204
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
205
+# MA 02110-1301, USA.
208
+# Create backup files of a list of files similar to GNU patch. A path
209
+# name prefix and suffix for the backup file can be specified with the
210
+# -B and -z options.
214
+ printf "Usage: %s [-B prefix] [-z suffix] [-f {file|-}] [-s] [-b|-r|-x] [-t] [-L] {file|-} ...\n"\
216
+ "\tCreate hard linked backup copies of a list of files\n"\
217
+ "\tread from standard input.\n"\
219
+ "\t-b\tCreate backup\n"\
220
+ "\t-r\tRestore the backup\n"\
221
+ "\t-x\tRemove backup files and empty parent directories\n"\
222
+ "\t-B\tPath name prefix for backup files\n"\
223
+ "\t-z\tPath name suffix for backup files\n"\
224
+ "\t-s\tSilent operation; only print error messages\n"\
225
+ "\t-f\tRead the filenames to process from file (- = standard input)\n"\
226
+ "\t-t\tTouch original files after restore (update their mtimes)\n\n"\
227
+ "\t-L\tEnsure that when finished, the source file has a link count of 1\n\n", \
231
+link_or_copy_file() {
234
+ if ! ln "$from" "$to" || [ -d "$to" ]; then
235
+ cp -dp --remove-destination "$from" "$to"
242
+ link_count=$(stat -c '%h' "$filename")
243
+ if [ -z "$link_count" ] || [ "$link_count" -gt 1 ]; then
244
+ dirname=$(dirname "$filename")
245
+ basename=$(basename "$filename")
246
+ # Temp file name is "path/to/.file.XXXXXX"
247
+ tmpname=$(mktemp "${dirname}/.${basename}.XXXXXX")
248
+ cp -dp "$filename" "$tmpname"
249
+ mv "$tmpname" "$filename"
255
+ backup="${OPT_PREFIX}${file}${OPT_SUFFIX}"
257
+ if [ "$OPT_WHAT" == "backup" ]; then
258
+ if [ -e "$backup" ]; then
261
+ mkdir -p "$(dirname "$backup")"
263
+ if [ ! -e "$file" ]; then
264
+ $ECHO "New file $file"
266
+ chmod 000 "$backup"
268
+ $ECHO "Copying $file"
269
+ link_or_copy_file "$file" "$backup"
270
+ if [ -n "$OPT_NOLINKS" ]; then
271
+ ensure_nolinks "$file"
273
+ if [ -n "OPT_TOUCH" ]; then
277
+ elif [ "$OPT_WHAT" == "restore" ]; then
278
+ mkdir -p "$(dirname "$file")"
280
+ if [ ! -e "$backup" ]; then
283
+ if [ ! -s "$backup" ]; then
284
+ if [ -e "$file" ]; then
287
+ $ECHO "Removing $file"
289
+ while [ -d "${backup%/*}" ] && ! [ -L "${backup%/*}" ]
291
+ backup="${backup%/*}"
292
+ rmdir --ignore-fail-on-non-empty "$backup" 2>/dev/null
293
+ if [ -d "$backup" ]; then
298
+ $ECHO "Restoring $file"
299
+ if [ -e "$file" ]; then
302
+ link_or_copy_file "$backup" "$file"
304
+ while [ -d "${backup%/*}" ] && ! [ -L "${backup%/*}" ]
306
+ backup="${backup%/*}"
307
+ rmdir --ignore-fail-on-non-empty "$backup" 2>/dev/null
308
+ if [ -d "$backup" ]; then
312
+ if [ -n "$OPT_NOLINKS" ]; then
313
+ ensure_nolinks "$file"
315
+ if [ -n "$OPT_TOUCH" ]; then
319
+ elif [ "$OPT_WHAT" == "remove" ]; then
320
+ if [ -e "$backup" ]; then
323
+ while [ -d "${backup%/*}" ] && ! [ -L "${backup%/*}" ]
325
+ backup="${backup%/*}"
326
+ rmdir --ignore-fail-on-non-empty "$backup" 2>/dev/null
327
+ if [ -d "$backup" ]; then
331
+ elif [ "$OPT_WHAT" == "noop" ]; then
332
+ if [ -e "$file" ] && [ -n "$OPT_NOLINKS" ]; then
333
+ ensure_nolinks "$file"
342
+ if [ ! -f "$path" ]; then
346
+ if [ "${path#$OPT_PREFIX}" == "$path" ]
348
+ # prefix does not match
351
+ path="${path#$OPT_PREFIX}"
353
+ if [ -n "$OPT_SUFFIX" ] && [ "${path%$OPT_SUFFIX}" == "$path" ]
355
+ # suffix does not match
358
+ path="${path%$OPT_SUFFIX}"
360
+ process_file "$path"
367
+while [ $# -gt 0 ]; do
369
+ -b) OPT_WHAT=backup
371
+ -r) OPT_WHAT=restore
373
+ -x) OPT_WHAT=remove
390
+ -?*) usage "$progname"
400
+if [ -z "${OPT_PREFIX}${OPT_SUFFIX}" ]; then
404
+if [ ${#FILELIST[@]} == 0 ] && [ -z "$OPT_FILE" ]; then
409
+if [ -n "$OPT_FILE" ]; then
411
+ | while read nextfile; do
412
+ process_file "$nextfile"
417
+while [ $I -lt ${#FILELIST[@]} ]; do
419
+ case "${FILELIST[$I]}" in
421
+ path="${OPT_PREFIX%/*}"
422
+ if ! [ -n "$path" ] && [ -d "$path" ] ; then
427
+ find "$path" -mindepth 1 \( -type f -o -type d \) -print 2>/dev/null \
432
+ if ! [ -r "$REPLY" ] || ! [ -x "$REPLY" ]
434
+ echo "$REPLY: Permission denied"
441
+ if [ $? != 0 ]; then
446
+ process_file "${FILELIST[$I]}"
452
--- quilt-0.45.orig/quilt/snapshot.in
453
+++ quilt-0.45/quilt/snapshot.in
458
-| $QUILT_LIB/backup-files -b -s -L -f - -B "$QUILT_PC/$snap_subdir/"
459
+| $QUILT_DIR/scripts/backup-files -b -s -L -f - -B "$QUILT_PC/$snap_subdir/"
462
### mode: shell-script