digitalmars.D - The BSD license problem and a trivial solution
- FeepingCreature (57/57) May 01 2010 Somebody on IRC mentioned that BSD requires including the license with b...
- bearophile (4/5) May 01 2010 Or support for the code licences management can be added to the D syntax...
- FeepingCreature (2/10) May 01 2010 I did mention extending the module syntax to cover this in the proposal....
- Andrej Mitrovic (3/11) May 01 2010 from __future__ import lawsuits
- Bane (1/6) May 01 2010 The horror! The horror!
Somebody on IRC mentioned that BSD requires including the license with binaries. So .. is there any reason this won't work? (Bewarned: code is D1 and not tested) --std/licenses.d-- module std.licenses; // License handling on a per-file basis import std.stdio, std.string; string[string] license_texts; string[] license_order; // Licenses must be added in order from older to newer. void addLicense(string name, string text) { license_texts[name] = text; license_order ~= name; } // If, for instance, this is called with "GPL", it will default to GPLv3; ie. the last version in license_order. string getFullLicenseName(string prefix) { string license_name; foreach (name; license_order) if (name[0 .. min($, prefix.length)].tolower() == prefix.tolower()) license_name = name; return license_name; } string getLicense(string full_name) { return license_texts[full_name]; } static this() { addLicense("GPLv2", import("LICENSE.GPLv2")); addLicense("GPLv3", import("LICENSE.GPLv3")); // etc } string[string] file_licenses; // Refer to licenses by name, not text! void registerFile(string filename, string prefix) { file_licenses[filename] = prefix; } void checkLicenses() { foreach (key, value; file_licenses) if (!getFullLicenseName(value)) throw new Exception(format("License prefix ", value, " not found in ", license_order)); } void printLicenses() { string[][string] files_per_license; // invert file_licenses foreach (key, value; file_licenses) files_per_license[getFullLicenseName(value)] ~= key; // and print foreach (key, value; files_per_license) { writefln("The following files are under ", key, ": ", value); writefln("The full text of these licenses follows. "); foreach (license; files_per_license.keys) { writefln(" === ", license, " === "); writefln(getLicense(license)); } } Then. 1) Add a handler for "--printLicenses" in extern(C) int main. This ensures the text can always be printed. 1.1) Make sure to call checkLicenses beforehand! 2) Public import addLicense and registerFile in object.d 3, optional) Extend the module statement so that `module foo under GPLv2; ` is interpreted as `module foo; static this() { registerFile(__FILE__, "GPLv2"); }` 4, optional) Extend the above system to track what licenses can import what others.
May 01 2010
FeepingCreature:Somebody on IRC mentioned that BSD requires including the license with binaries. So .. is there any reason this won't work?Or support for the code licences management can be added to the D syntax ;-) Bye, bearophile
May 01 2010
On 01.05.2010 14:33, bearophile wrote:FeepingCreature:I did mention extending the module syntax to cover this in the proposal. :)Somebody on IRC mentioned that BSD requires including the license with binaries. So .. is there any reason this won't work?Or support for the code licences management can be added to the D syntax ;-) Bye, bearophile
May 01 2010
bearophile Wrote:FeepingCreature:from __future__ import lawsuits Oops, I'm on the wrong forum. :)Somebody on IRC mentioned that BSD requires including the license with binaries. So .. is there any reason this won't work?Or support for the code licences management can be added to the D syntax ;-) Bye, bearophile
May 01 2010
1) Add a handler for "--printLicenses" in extern(C) int main. This ensures the text can always be printed. 1.1) Make sure to call checkLicenses beforehand! 2) Public import addLicense and registerFile in object.d 3, optional) Extend the module statement so that `module foo under GPLv2; ` is interpreted as `module foo; static this() { registerFile(__FILE__, "GPLv2"); }` 4, optional) Extend the above system to track what licenses can import what others.The horror! The horror!
May 01 2010