On Fri, Dec 28, 2012 at 06:35:12PM +0100, Raphael Hertzog wrote:
> On Fri, 28 Dec 2012, Martin Quinson wrote:
> > -           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"
> 
> Right, I forgot that we always want to update the timestamp...

It was not necessary before, but our change makes it mandatory.

> > +           files_in_patch "$patch" |
> > +           grep -v '^$' |
> > +           while read file
> > +           do
> > +                   touch -r "$QUILT_PC/$patch/.timestamp" "$file"
> > +           done
> 
> I was more thinking about using “… | xargs -d '\n' touch -r
> "$QUILT_PC/$patch/.timestamp"” for this task. 

Ok, here is a third attempt, sorry for being so bad at bash scripting.
I know why I'm always reluctant to hack on quilt itself.

> It should call it
> once only except when too many files are listed and when the list
> must be split.

I'm not sure I got this part, unfortunately.

> > -           elif [ -z "$(shopt -s nullglob ; echo "$QUILT_PC/$patch/"*)" ]
> > +           elif [ "$(shopt -s nullglob ; echo "$QUILT_PC/$patch/"*)" == 
> > "$QUILT_PC/$patch/.timestamp" ]
> 
> This is a pre-existing bug, right? It should probably go in a different
> commit when submitted upstream.

Nope, it worked well before (it's even tested throughfully), as the
directory was empty the first time that we created the directory and
always remained so for empty patches. That chunk is only mandated by
the unconditional touch of "$QUILT_PC/$patch/.timestamp" introduced
above.

Bye, Mt.

-- 
Autrefois, c'était l'excellence qui faisait la notoriété.
Maintenant, c'est la notoriété qui fait l'excellence.
          --- Alain Finkielkraut
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
 http://lists.debian.org/debian-policy/2008/02/msg00030.html for more
 context information.
Bug-Debian: http://bugs.debian.org/466360
Upstream-status: to be submitted 

Index: quilt.git/quilt/push.in
===================================================================
--- quilt.git.orig/quilt/push.in        2012-12-28 21:16:25.000000000 +0100
+++ quilt.git/quilt/push.in     2012-12-28 21:17:05.763646798 +0100
@@ -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.
 
@@ -208,18 +209,24 @@
                        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"
+
+               # xargs executes the command once even if there is no input 
(--no-run-if-empty is GNU specific)
+               # so only launch it if we know that there is a file to handle
+               if [ "$(shopt -s nullglob ; echo "$QUILT_PC/$patch/"*)" != 
"$QUILT_PC/$patch/.timestamp" ]
+               then
+                       files_in_patch "$patch" | xargs -d '\n' touch -r 
"$QUILT_PC/$patch/.timestamp"
+               fi
 
                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)"

Reply via email to