From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Petazzoni Date: Tue, 17 Nov 2015 22:16:22 +0100 Subject: [Buildroot] [PATCH] pkg-generic: Strip all but leading comments from C files used as license. In-Reply-To: <1447779739-4661-1-git-send-email-peda@lysator.liu.se> References: <1447779739-4661-1-git-send-email-peda@lysator.liu.se> Message-ID: <20151117221622.6443362f@free-electrons.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net Dear Peter Rosin, On Tue, 17 Nov 2015 18:02:19 +0100, Peter Rosin wrote: > From: Peter Rosin > > Signed-off-by: Peter Rosin Thanks for your contribution. Could you explain what is the problem with keeping a complete source file as legal information? > 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) \ We quickly discussed your proposal on the #buildroot IRC, and the conclusion is that we generally don't like this, for at least two reasons: 1/ The sed expression is awfully complicated. 2/ There is absolutely no guarantee that the license part is inside the leading comment and that the complicated sed expression will actually keep the relevant part of the file. We generally try to use a fairly short source code file as the license text, so that keeping the entire file should not be a problem. If it remains a problem, then I would suggest that you work with the upstream project and ask them to include a separate license file that we can use. Another possibility would be to do something like: _LICENSE_FILES = foo.c-23+42 to indicate that the license text is from line 23 to line 42. But it is again not very foolproof, and it doesn't give much benefits. Best regards, Thomas -- Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com