Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Rosin <peda@lysator.liu.se>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] pkg-generic: Strip all but leading comments from C files used as license.
Date: Tue, 17 Nov 2015 22:36:03 +0100	[thread overview]
Message-ID: <564B9DC3.8070703@lysator.liu.se> (raw)
In-Reply-To: <20151117221622.6443362f@free-electrons.com>


On 2015-11-17 22:16, Thomas Petazzoni wrote:
> Dear Peter Rosin,
>
> On Tue, 17 Nov 2015 18:02:19 +0100, Peter Rosin wrote:
>> From: Peter Rosin <peda@axentia.se>
>>
>> Signed-off-by: Peter Rosin <peda@axentia.se>
> Thanks for your contribution. Could you explain what is the problem
> with keeping a complete source file as legal information?

It's not a big deal, but source code certainly looked out of place
when I first scanned through licenses.txt. I guess you old-timers
have just gotten used to having it there...

>> 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.

I wouldn't call it a sed expression, it's a sed program really, but it's not very
complicated once you get through the sed syntax. But I see your points. I
just had a bit of fun writing it, no big deal if it gets thrown away here. I'll just
run the same thing locally instead...

> Another possibility would be to do something like:
>
> <pkg>_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.
>
Right, and that approach would require more care on version bumps...

Cheers,
Peter

  reply	other threads:[~2015-11-17 21:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2015-11-17 21:21 ` Peter Korsgaard

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=564B9DC3.8070703@lysator.liu.se \
    --to=peda@lysator.liu.se \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox