Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] pkg-generic: Strip all but leading comments from C files used as license.
@ 2015-11-17 17:02 Peter Rosin
  2015-11-17 21:16 ` Thomas Petazzoni
  2015-11-17 21:21 ` Peter Korsgaard
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Rosin @ 2015-11-17 17:02 UTC (permalink / raw)
  To: buildroot

From: Peter Rosin <peda@axentia.se>

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 package/pkg-utils.mk |   28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index 44bd2c9..1497eb2 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -145,8 +145,30 @@ 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)
+	case $(3) in \
+	*.c|*.h) \
+	  sed -e '\
+x;\
+/^$$/{\
+  x;\
+  /^[ \t]*$$/b;\
+  /^[ \t]*\/\//b;\
+  /^[ \t]*\/\*.*\*\//b;\
+  /^[ \t]*\/\*/h;\
+  //b;\
+  s/.*//;\
+  q\
+};\
+x;\
+/\*\//{\
+  x;\
+  s/.*//;\
+  x\
+}' < $(3) > $(LICENSE_FILES_DIR_$(4))/$(1)/$(2) \
+	;; \
+	*) cp $(3) $(LICENSE_FILES_DIR_$(4))/$(1)/$(2);; \
+	esac && \
+	cat $(LICENSE_FILES_DIR_$(4))/$(1)/$(2) >>$(LEGAL_LICENSES_TXT_$(4)) && \
+	echo >>$(LEGAL_LICENSES_TXT_$(4))
 endef
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-17 21:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-17 17:02 [Buildroot] [PATCH] pkg-generic: Strip all but leading comments from C files used as license Peter Rosin
2015-11-17 21:16 ` Thomas Petazzoni
2015-11-17 21:36   ` Peter Rosin
2015-11-17 21:21 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox