All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 5/5] legal-info: properly error out on missing license file
Date: Sat, 14 Jun 2014 17:10:24 +0200	[thread overview]
Message-ID: <8c742a7155e0b24c14ae90f7be00c1043eceb848.1402758331.git.yann.morin.1998@free.fr> (raw)
In-Reply-To: <cover.1402758331.git.yann.morin.1998@free.fr>

From: "Yann E. MORIN" <yann.morin.1998@free.fr>

When saving the license files, if a declared license file is missing,
print a proper error message, instead of the sometime-criptic error
message from 'cp'.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Luca Ceresoli <luca@lucaceresoli.net>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Fabio Porcedda <fabio.porcedda@gmail.com>

---
Note: when I wrote this back in March 2014, I had a concrete example of
a criptic error message (the name of the license did not make it obvious
we were saving a license file?), but today I can't remember what it was
exactly.

Since I believe showing a properly-formatted error message to the user
is anyway a good thing, I kept that patch. Feel free to ditch it if you
don't like it.
---
 package/pkg-utils.mk | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index 471f3ed..c3f9142 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -101,6 +101,10 @@ define legal-warning-pkg # pkg, text
 	echo "WARNING: $(1): $(2)" >>$(LEGAL_WARNINGS)
 endef
 
+define legal-error-pkg # pkg, text
+	echo "ERROR: $(1): $(2)" && false
+endef
+
 define legal-license-nosource # pkg, {local|override}
 	$(call legal-warning-pkg,$(1),sources not saved ($(2) packages not handled))
 endef
@@ -119,9 +123,13 @@ define legal-license-nofiles # pkg, {HOST|TARGET}
 endef
 
 define legal-license-file # pkg, filename, file-fullpath, {HOST|TARGET}
-	$(call legal-license-header,$(1),$(2) file,$(4)) && \
-	cat $(3) >>$(LEGAL_LICENSES_TXT_$(4)) && \
-	echo >>$(LEGAL_LICENSES_TXT_$(4)) && \
-	mkdir -p $(LICENSE_FILES_DIR_$(4))/$(1)/$(dir $(2)) && \
-	cp $(3) $(LICENSE_FILES_DIR_$(4))/$(1)/$(2)
+	if [ -e $(3) ]; then \
+		$(call legal-license-header,$(1),$(2) file,$(4)) && \
+		cat $(3) >>$(LEGAL_LICENSES_TXT_$(4)) && \
+		echo >>$(LEGAL_LICENSES_TXT_$(4)) && \
+		mkdir -p $(LICENSE_FILES_DIR_$(4))/$(1)/$(dir $(2)) && \
+		cp $(3) $(LICENSE_FILES_DIR_$(4))/$(1)/$(2); \
+	else \
+		$(call legal-error-pkg,$(1),license file $(2) not found); \
+	fi
 endef
-- 
1.8.3.2

  parent reply	other threads:[~2014-06-14 15:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-14 15:10 [Buildroot] [PATCH 0/5 v5] legal-info: extract packages to get license files (branch yem/legal) Yann E. MORIN
2014-06-14 15:10 ` [Buildroot] [PATCH 1/5] legal-info: extract even no-redistribute packages Yann E. MORIN
2014-06-18 21:17   ` Luca Ceresoli
2014-06-21 22:08     ` Yann E. MORIN
2014-06-14 15:10 ` [Buildroot] [PATCH 2/5] legal-info: save license files even for local or overriden packages Yann E. MORIN
2014-06-18 21:22   ` Luca Ceresoli
2014-06-14 15:10 ` [Buildroot] [PATCH 3/5] legal-info: add a comment about what packages we save the tarballs of Yann E. MORIN
2014-06-18 21:25   ` Luca Ceresoli
2014-06-14 15:10 ` [Buildroot] [PATCH 4/5] legal-info: rename legal-warning-pkg-savednothing helper Yann E. MORIN
2014-06-18 15:32   ` Luca Ceresoli
2014-06-21 22:17     ` Yann E. MORIN
2014-06-14 15:10 ` Yann E. MORIN [this message]
2014-06-18 21:38   ` [Buildroot] [PATCH 5/5] legal-info: properly error out on missing license file Luca Ceresoli
2014-06-21 22:35     ` Yann E. MORIN
2014-06-15 10:42 ` [Buildroot] [PATCH 0/5 v5] legal-info: extract packages to get license files (branch yem/legal) Yann E. MORIN
2014-06-18 16:00   ` Thomas De Schampheleire

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c742a7155e0b24c14ae90f7be00c1043eceb848.1402758331.git.yann.morin.1998@free.fr \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.