support/apply-patches: bail-out on duplicate patch basenames
authorYann E. MORIN <yann.morin.1998@free.fr>
Sat, 7 May 2016 16:14:32 +0000 (18:14 +0200)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Fri, 24 Jun 2016 14:04:24 +0000 (16:04 +0200)
commit19241598147e7555dce40b6dd44b28ef22b67ed9
tree4b404bd3f2d03852b0c98d00936a367816cdda51
parenta3165461bb0af6b3fdea436efeb7207779aa8f20
support/apply-patches: bail-out on duplicate patch basenames

Patches we save can come from various locations:
  - bundled with Buildroot
  - downloaded
  - from one or more global-patch-dir

It is possible that two patches lying into different locations have the
same basename, like so (first is bundled, second is from an hypothetical
global-patch-dir):
    package/foo/0001-fix-Makefile.patch
    /path/to/my/patches/foo/0001-fix-Makefile.patch

In that case, when running legal-info, we'd save only the second patch,
overwriting the first. That would be problematic, because:

  - either the second patch depends on the first, and thus would no longer
    apply (this is easy to detect, though),

  - or the second patch does not depend on the first, and the compliance
    delivery will not be complete (this is much harder to detect).

We fix that by checking that no two patches have the same same basename.
If we find that the basename of the patch to be applied collides with
that of a previously applied patch, we error out and report the duplicate.

The unfortunate side-effect is that existing setups will now break in
that situation, but that's a minor, corner-case issue that is easily
fixed.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Luca Ceresoli <luca@lucaceresoli.net>
Cc: Arnout Vandecappelle <arnout@mind.be>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
[Thomas: adjust coding style, fix minor typos in the commit log.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
support/scripts/apply-patches.sh