Skip to content

Commit

Permalink
Merge pull request #34 from github/elr/license-updates
Browse files Browse the repository at this point in the history
update license lists from official spdx data
  • Loading branch information
elrayle authored Jan 14, 2023
2 parents a7497e7 + 442905e commit 9edaf20
Show file tree
Hide file tree
Showing 12 changed files with 7,903 additions and 107 deletions.
1 change: 1 addition & 0 deletions cmd/deprecated_license_ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["AGPL-1.0","AGPL-3.0","BSD-2-Clause-FreeBSD","BSD-2-Clause-NetBSD","bzip2-1.0.5","eCos-2.0","GFDL-1.1","GFDL-1.2","GFDL-1.3","GPL-1.0","GPL-1.0+","GPL-2.0","GPL-2.0+","GPL-2.0-with-autoconf-exception","GPL-2.0-with-bison-exception","GPL-2.0-with-classpath-exception","GPL-2.0-with-font-exception","GPL-2.0-with-GCC-exception","GPL-3.0","GPL-3.0+","GPL-3.0-with-autoconf-exception","GPL-3.0-with-GCC-exception","LGPL-2.0","LGPL-2.0+","LGPL-2.1","LGPL-2.1+","LGPL-3.0","LGPL-3.0+","Nunit","StandardML-NJ","wxWindows"]
31 changes: 31 additions & 0 deletions cmd/deprecated_license_ids.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"AGPL-1.0",
"AGPL-3.0",
"BSD-2-Clause-FreeBSD",
"BSD-2-Clause-NetBSD",
"bzip2-1.0.5",
"eCos-2.0",
"GFDL-1.1",
"GFDL-1.2",
"GFDL-1.3",
"GPL-1.0",
"GPL-1.0+",
"GPL-2.0",
"GPL-2.0+",
"GPL-2.0-with-autoconf-exception",
"GPL-2.0-with-bison-exception",
"GPL-2.0-with-classpath-exception",
"GPL-2.0-with-font-exception",
"GPL-2.0-with-GCC-exception",
"GPL-3.0",
"GPL-3.0+",
"GPL-3.0-with-autoconf-exception",
"GPL-3.0-with-GCC-exception",
"LGPL-2.0",
"LGPL-2.0+",
"LGPL-2.1",
"LGPL-2.1+",
"LGPL-3.0",
"LGPL-3.0+",
"Nunit",
"StandardML-NJ",
"wxWindows",
1 change: 1 addition & 0 deletions cmd/exception_ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["389-exception","Autoconf-exception-2.0","Autoconf-exception-3.0","Bison-exception-2.2","Bootloader-exception","Classpath-exception-2.0","CLISP-exception-2.0","DigiRule-FOSS-exception","eCos-exception-2.0","Fawkes-Runtime-exception","FLTK-exception","Font-exception-2.0","freertos-exception-2.0","GCC-exception-2.0","GCC-exception-3.1","gnu-javamail-exception","GPL-3.0-linking-exception","GPL-3.0-linking-source-exception","GPL-CC-1.0","GStreamer-exception-2005","GStreamer-exception-2008","i2p-gpl-java-exception","KiCad-libraries-exception","LGPL-3.0-linking-exception","Libtool-exception","Linux-syscall-note","LLVM-exception","LZMA-exception","mif-exception","OCaml-LGPL-linking-exception","OCCT-exception-1.0","OpenJDK-assembly-exception-1.0","openvpn-openssl-exception","PS-or-PDF-font-exception-20170817","Qt-GPL-exception-1.0","Qt-LGPL-exception-1.1","Qwt-exception-1.0","SHL-2.0","SHL-2.1","Swift-exception","u-boot-exception-2.0","Universal-FOSS-exception-1.0","WxWindows-exception-3.1","x11vnc-openssl-exception"]
44 changes: 44 additions & 0 deletions cmd/exception_ids.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"389-exception",
"Autoconf-exception-2.0",
"Autoconf-exception-3.0",
"Bison-exception-2.2",
"Bootloader-exception",
"Classpath-exception-2.0",
"CLISP-exception-2.0",
"DigiRule-FOSS-exception",
"eCos-exception-2.0",
"Fawkes-Runtime-exception",
"FLTK-exception",
"Font-exception-2.0",
"freertos-exception-2.0",
"GCC-exception-2.0",
"GCC-exception-3.1",
"gnu-javamail-exception",
"GPL-3.0-linking-exception",
"GPL-3.0-linking-source-exception",
"GPL-CC-1.0",
"GStreamer-exception-2005",
"GStreamer-exception-2008",
"i2p-gpl-java-exception",
"KiCad-libraries-exception",
"LGPL-3.0-linking-exception",
"Libtool-exception",
"Linux-syscall-note",
"LLVM-exception",
"LZMA-exception",
"mif-exception",
"OCaml-LGPL-linking-exception",
"OCCT-exception-1.0",
"OpenJDK-assembly-exception-1.0",
"openvpn-openssl-exception",
"PS-or-PDF-font-exception-20170817",
"Qt-GPL-exception-1.0",
"Qt-LGPL-exception-1.1",
"Qwt-exception-1.0",
"SHL-2.0",
"SHL-2.1",
"Swift-exception",
"u-boot-exception-2.0",
"Universal-FOSS-exception-1.0",
"WxWindows-exception-3.1",
"x11vnc-openssl-exception",
75 changes: 75 additions & 0 deletions cmd/exceptions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
)

type ExceptionData struct {
Version string `json:"licenseListVersion"`
Exceptions []Exception `json:"exceptions"`
}

type Exception struct {
Reference string `json:"reference"`
IsDeprecated bool `json:"isDeprecatedLicenseId"`
DetailsURL string `json:"detailsUrl"`
ReferenceNumber int `json:"referenceNumber"`
Name string `json:"name"`
LicenseID string `json:"licenseExceptionId"`
SeeAlso []string `json:"seeAlso"`
IsOsiApproved bool `json:"isOsiApproved"`
}

// extractExceptionLicenseIDs read official exception licenses file copied from spdx/license-list-data
// and write file exception_license_ids.json containing just the non-deprecated exception license IDs.
// NOTE: For now, this function ignores the deprecated exception licenses.
func extractExceptionLicenseIDs() error {
// open file
file, err := os.Open("exceptions.json")
if err != nil {
fmt.Println(err)
return err
}

// read in all licenses marshalled into a slice of exception structs
var exceptionData ExceptionData
err = json.NewDecoder(file).Decode(&exceptionData)
if err != nil {
return err
}

// create slice of exception license IDs that are not deprecated
var nonDeprecatedExceptionLicenseIDs []string
for _, e := range exceptionData.Exceptions {
if !e.IsDeprecated {
nonDeprecatedExceptionLicenseIDs = append(nonDeprecatedExceptionLicenseIDs, e.LicenseID)
}
}

// save non-deprecated license IDs followed by a comma with one per line in file license_ids.txt
nonDeprecatedExceptionLicenseIDsTxt := []byte{}
for _, id := range nonDeprecatedExceptionLicenseIDs {
nonDeprecatedExceptionLicenseIDsTxt = append(nonDeprecatedExceptionLicenseIDsTxt, []byte(" \"")...)
nonDeprecatedExceptionLicenseIDsTxt = append(nonDeprecatedExceptionLicenseIDsTxt, []byte(id)...)
nonDeprecatedExceptionLicenseIDsTxt = append(nonDeprecatedExceptionLicenseIDsTxt, []byte("\",")...)
nonDeprecatedExceptionLicenseIDsTxt = append(nonDeprecatedExceptionLicenseIDsTxt, []byte("\n")...)
}
err = ioutil.WriteFile("exception_ids.txt", nonDeprecatedExceptionLicenseIDsTxt, 0600)
if err != nil {
return err
}

// save non-deprecated license IDs to json array in file exception_ids.json
nonDeprecatedExceptionLicenseIDsJSON, err := json.Marshal(nonDeprecatedExceptionLicenseIDs)
if err != nil {
return err
}
err = ioutil.WriteFile("exception_ids.json", nonDeprecatedExceptionLicenseIDsJSON, 0600)
if err != nil {
return err
}
return nil
}
Loading

0 comments on commit 9edaf20

Please sign in to comment.