13 Jul 2006 06:27
Preserving timestamps with patches
Robert Connolly <robert <at> linuxfromscratch.org>
2006-07-13 04:27:41 GMT
2006-07-13 04:27:41 GMT
I've made a little script to get patch(1) to preserve timestamps, so that
autoconf/automake files don't get rebuilt:
# First make sure all the files in the patch exist, otherwise we are probably
# using --help or the wrong patch.
patch --dry-run "$ <at> " | sed -e 's/patching file //' \
-e '/Hunk/d' -e '/Skipping patch/d' \
-e '/saving rejects/d' \
| xargs ls > /dev/null 2>&1 &&
patch --dry-run "$ <at> " | sed -e 's/patching file //' \
-e '/Hunk/d' -e '/Skipping patch/d' \
-e '/saving rejects/d' -e 's/^.*$/& &.timestamp/' \
| xargs touch -r ;
find . -type f -name "*.timestamp" -exec rm -f {} \; &&
patch "$ <at> "
Run this script in place of the patch command and it will patch files and
restore their timestamps to what they were originally. This script returns 0
on success, 1 with an error, 2 with major error (like how patch normally
does). --help still works, and -v. As far as I know its a transparent
replacement for the patch command. This script will be slower than using
patch directly, but its not bad.
robert
-- -- http://linuxfromscratch.org/mailman/listinfo/lfs-chat FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
RSS Feed