Makefile: change rsync used in overlays to always transfer files

Submitted by Danomi Manchego on June 8, 2013, 1:43 a.m.

Details

Message ID 1370655822-2668-1-git-send-email-danomimanchego123@gmail.com
State Accepted
Delegated to: Peter Korsgaard
Headers show

Commit Message

Danomi Manchego June 8, 2013, 1:43 a.m.
If two files with the same relative paths exist in multiple overlay
skeletons, and they have the same modification time and size, then rsync
might not copy the later file on top of the earlier file.  This patch fixes
this by adding the -I option to the rsync commands used in the overlay
skeleton file installations.  ("man rsync" indicates that this option turns
off the file-size/mod-date "quick check" behavior, causing all files to be
updated - more like the cp commands that we had originally.)

Signed-off-by: Danomi Manchego <danomimanchego123@gmail.com>

---

Test scenario:  add overlay dirs to configuration, such as:

    BR2_ROOTFS_OVERLAY="$(TOPDIR)/AAA $(TOPDIR)/BBB"

Now make a file in both dirs, one at a time, and make:

    $ mkdir -p AAA/etc BBB/etc
    $ echo AAA > AAA/etc/test.txt
    $ echo BBB > BBB/etc/test.txt
    $ make

The file in target is the file from the last overlay skeleton, as expected:
    $ cat output/target/etc/test.txt
    BBB

Now use touch to make the dates on both files the same, delete the file in
TARGET_DIR, and make again.  The result is that the file from the first skeleton
gets into target, contrary to the expected result:

    $ touch AAA/etc/test.txt BBB/etc/test.txt
    $ rm output/target/etc/test.txt
    $ make
    $ cat output/target/etc/test.txt
    AAA

Adding the -I to the rsync fixes this.
---
 Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Peter Korsgaard Feb. 4, 2014, 4:31 p.m.
On Sat, Jun 8, 2013 at 3:43 AM, Danomi Manchego
<danomimanchego123@gmail.com> wrote:
> If two files with the same relative paths exist in multiple overlay
> skeletons, and they have the same modification time and size, then rsync
> might not copy the later file on top of the earlier file.  This patch fixes
> this by adding the -I option to the rsync commands used in the overlay
> skeleton file installations.  ("man rsync" indicates that this option turns
> off the file-size/mod-date "quick check" behavior, causing all files to be
> updated - more like the cp commands that we had originally.)
>
> Signed-off-by: Danomi Manchego <danomimanchego123@gmail.com>

Committed with -I changed to --ignore-times as it is a bit more
obvious what the option does.
Danomi Manchego Feb. 4, 2014, 4:49 p.m.
Peter,

On Tue, Feb 4, 2014 at 11:31 AM, Peter Korsgaard <jacmet@sunsite.dk> wrote:
> Committed with -I changed to --ignore-times as it is a bit more
> obvious what the option does.

Using "--ignore-times" is fine with me - but the problem still exists.
You added the option to the skeleton install's rsync, but not to the
overlay install's rsync, around line 551 of Makefile.  (So, you can
still demonstrate the issue using the AAA/BBB overlays example that I
mentioned in my original submittal.)  Can you add the --ignore-times
to the second rsync?

Danomi -
Peter Korsgaard Feb. 4, 2014, 4:54 p.m.
>>>>> "Danomi" == Danomi Manchego <danomimanchego123@gmail.com> writes:

 > Peter,
 > On Tue, Feb 4, 2014 at 11:31 AM, Peter Korsgaard <jacmet@sunsite.dk> wrote:
 >> Committed with -I changed to --ignore-times as it is a bit more
 >> obvious what the option does.

 > Using "--ignore-times" is fine with me - but the problem still exists.
 > You added the option to the skeleton install's rsync, but not to the
 > overlay install's rsync, around line 551 of Makefile.  (So, you can
 > still demonstrate the issue using the AAA/BBB overlays example that I
 > mentioned in my original submittal.)  Can you add the --ignore-times
 > to the second rsync?

Argh, crap - I forgot the 2nd instance when I fixed up the merge
conflict. I'll fix it now.

Patch hide | download patch | download mbox

diff --git a/Makefile b/Makefile
index d7437a7..969c0c9 100644
--- a/Makefile
+++ b/Makefile
@@ -431,7 +431,7 @@  endif
 
 $(BUILD_DIR)/.root:
 	mkdir -p $(TARGET_DIR)
-	rsync -a \
+	rsync -a -I \
 		--exclude .empty --exclude .svn --exclude .git \
 		--exclude .hg --exclude=CVS --exclude '*~' \
 		$(TARGET_SKELETON)/ $(TARGET_DIR)/
@@ -507,7 +507,7 @@  endif
 
 	@$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
 		$(call MESSAGE,"Copying overlay $(d)"); \
-		rsync -a \
+		rsync -a -I \
 			--exclude .empty --exclude .svn --exclude .git \
 			--exclude .hg --exclude=CVS --exclude '*~' \
 			$(d)/ $(TARGET_DIR)$(sep))