Package: quilt / 0.65-3

push_timeskew Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
Description: ensure that all mtime of modified files are equal when pushing
 This is intended to avoid time skew in build systems in some cases.
 .
 See the discussion
 https://lists.debian.org/debian-policy/2008/02/msg00030.html for more
 context information.
Bug-Debian: https://bugs.debian.org/466360
Upstream-status: to be submitted 

---
 quilt/push.in                 |   22 ++++++++--
 quilt/scripts/backup-files.in |    3 -
 test/push_timeskew.test       |   86 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+), 6 deletions(-)

--- a/quilt/push.in
+++ b/quilt/push.in
@@ -30,7 +30,8 @@
 specified number of patches.  When a patch name is specified, apply
 all patches up to and including the specified patch.  Patch names may
 include the patches/ prefix, which means that filename completion can
-be used.
+be used. The mtime of all touched files will be exactly the same to
+prevent time skews.
 
 -a	Apply all patches in the series file.
 
@@ -212,18 +213,29 @@
 			touch "$QUILT_PC/$patch~refresh"
 		fi
 
-		if [ -e "$QUILT_PC/$patch" ]
+		if ! [ -e "$QUILT_PC/$patch" ]
 		then
-			touch "$QUILT_PC/$patch/.timestamp"
-		else
 			mkdir "$QUILT_PC/$patch"
 		fi
+		touch "$QUILT_PC/$patch/.timestamp"
+
+		# Store the list of files to process
+		NONEMPTY_FILES=$(gen_tempfile)
+		trap "rm -f \"$NONEMPTY_FILES\"" EXIT
+		find "$QUILT_PC/$patch" -type f \
+		      -a ! -path "$QUILT_PC/$patch/.timestamp" -size +0 -print0 > "$NONEMPTY_FILES"
+
+		if [ -s "$NONEMPTY_FILES" ]; then
+			xargs -0 touch -c -r "$QUILT_PC/$patch/.timestamp" < "$NONEMPTY_FILES"
+		fi
+
+		rm -f $NONEMPTY_FILES
 
 		if ! [ -e "$patch_file" ]
 		then
 			printf $"Patch %s does not exist; applied empty patch\n" \
 			       "$(print_patch "$patch")"
-		elif [ -z "$(shopt -s nullglob ; echo "$QUILT_PC/$patch/"*)" ]
+		elif [ "$(shopt -s nullglob ; echo "$QUILT_PC/$patch/"*)" = "$QUILT_PC/$patch/.timestamp" ]
 		then
 			printf $"Patch %s appears to be empty; applied\n" \
 			       "$(print_patch "$patch")"
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -184,8 +184,9 @@
 			done < "$NONEMPTY_FILES"
 		fi
 
+		modif_time=`date +%m%d%H%M.%S`
 		if [ -n "$OPT_TOUCH" ]; then
-			xargs -0 touch -c < "$NONEMPTY_FILES"
+			xargs -0 touch -t $modif_time -c < "$NONEMPTY_FILES"
 		fi
 	fi
 
--- /dev/null
+++ b/test/push_timeskew.test
@@ -0,0 +1,86 @@
+This test enforces that files touched by a patch have the exact same
+mtime when pushing and poping the patch.
+(To run, type `./run push_timeskew.test' in this directory.)
+
+	$ mkdir patches d
+
+	$ quilt new patch1
+	> Patch %{P}patch1 is now on top
+
+	$ cd d
+	$ mkdir dir
+	$ echo "This is file one." > dir/file1
+	$ quilt add dir/file1
+	> File d/dir/file1 added to patch %{_P}patch1
+
+	$ echo "This is file two." > dir/file2
+	$ quilt add dir/file2
+	> File d/dir/file2 added to patch %{_P}patch1
+
+	$ echo "More content to file one." >> dir/file1
+	$ echo "More content to file two." >> dir/file2
+	$ quilt refresh
+	> Refreshed patch %{_P}patch1
+
+	$ quilt pop -q
+	> Removing patch %{_P}patch1
+	> No patches applied
+
+	$ test dir/file1 -nt dir/file2 && echo "timeskew!"
+	$ test dir/file2 -nt dir/file1 && echo "timeskew!"
+
+	$ quilt push -q
+	> Applying patch %{_P}patch1
+	> Now at patch %{_P}patch1
+
+	$ test dir/file1 -nt dir/file2 && echo "timeskew!"
+	$ test dir/file2 -nt dir/file1 && echo "timeskew!"
+
+
+
+	# And now, enforces that this timestamp fixup don't create unwanted files
+	$ quilt new patch2.diff
+	> Patch %{_P}patch2.diff is now on top
+
+	$ echo "some content" > dir/file_removed
+	$ quilt add dir/file_removed
+	> File d/dir/file_removed added to patch %{_P}patch2.diff
+
+	$ quilt add dir/file_created
+	> File d/dir/file_created added to patch %{_P}patch2.diff
+
+	$ rm dir/file_removed
+	$ echo "some content" > dir/file_created
+	$ quilt refresh
+	> Refreshed patch %{_P}patch2.diff
+
+	$ quilt diff --no-timestamps --no-index -p ab
+	> --- /dev/null
+	> +++ b/d/dir/file_created
+	> @@ -0,0 +1 @@
+	> +some content
+	> --- a/d/dir/file_removed
+	> +++ /dev/null
+	> @@ -1 +0,0 @@
+	> -some content
+
+	$ quilt pop
+	> Removing patch %{_P}patch2.diff
+	> Removing d/dir/file_created
+	> Restoring d/dir/file_removed
+	>
+	> Now at patch %{_P}patch1
+
+	$ test   -e dir/file_created && echo "Created file should not exist when patch is poped!"
+	$ test ! -e dir/file_removed && echo "Deleted file should exist when patch is poped!"
+
+	$ quilt push
+	> Applying patch %{_P}patch2.diff
+	> patching file d/dir/file_created
+	> patching file d/dir/file_removed
+	>
+	> Now at patch %{_P}patch2.diff
+
+	$ test ! -e dir/file_created && echo "Created file should exist when patch is pushed!"
+	$ test   -e dir/file_removed && echo "Deleted file should not exist when patch is pushed!"
+