First, note that this is not a plain 'merge two directories', this is a question about how to keep the merge of said directories updated when the sources change.
Let us say that I have two directories a and b and I want to merge them into c with the following rules:
- Entries from
amust always be incregardless of their existence or last modified timestamp. - Fill the gaps with
b.
A simple cp from b to c and overwriting with a where necessary does the job (copies more than necessary, but it is intended to be used only once)
Now, what I want is some way of keeping this updated (as this is intended to be in a Makefile) So, if there is a new file in a, make copies it. If there is a new file in b, make copies it only if it is not already in c. If a file from a is updated, make, updates it in c and if a file from b is updated, it is updated in c only if it came from b but not if it came from a.
I hope I have explained it accurately.
makethe tool you've chosen for this?rmfollowed by two copies. It works, but it needs to copy everything even if just a tiny thing changed.cp -uworks for the copy fromabut only in the cases where the file frombis older than the one inaso it is not fully reliable.makehas been chosen just as a 'wrapper' as this is intended to be used asmake update.