|
29 | 29 |
|
30 | 30 | (defn- get-rencgs
|
31 | 31 | "Get a value for an re-ncg, potentially looking at multiple ncgs in order
|
32 |
| - until a non-blank value is found. Also trims and lower-cases the value, and |
33 |
| - replaces all whitespace with a single space." |
| 32 | + until a non-blank value is found. Returns `default` when no non-blank value is |
| 33 | + found (and which defaults to `nil` if not provided). Trims and lower-cases the |
| 34 | + value, and replaces all whitespace with a single space." |
34 | 35 | ([m names] (get-rencgs m names nil))
|
35 | 36 | ([m names default]
|
36 | 37 | (loop [f (first names)
|
|
123 | 124 | "netbsd" "NetBSD"
|
124 | 125 | "modification" "Modification"
|
125 | 126 | ("no military license" "no military licence") "No-Military-License"
|
126 |
| - ("no nuclear license" "no nuclear licence") "No-Nuclear-License" |
127 | 127 | ("no nuclear license 2014" "no nuclear licence 2014") "No-Nuclear-License-2014"
|
| 128 | + ("no nuclear license" "no nuclear licence") "No-Nuclear-License" |
128 | 129 | "no nuclear warranty" "No-Nuclear-Warranty"
|
129 | 130 | "open mpi" "Open-MPI"
|
130 | 131 | "shortened" "Shortened"
|
|
186 | 187 | (defn- gpl-id-constructor
|
187 | 188 | "An SPDX id constructor specific to the GNU family of licenses."
|
188 | 189 | [m]
|
189 |
| - (let [variant (cond (contains? m "agpl") "AGPL" |
190 |
| - (contains? m "lgpl") "LGPL" |
191 |
| - (contains? m "gpl") "GPL") |
192 |
| - version (get-rencgs m ["version"] "") |
193 |
| - version (s/replace version #"\p{Punct}+" ".") |
| 190 | + (let [variant (cond (contains? m "agpl") "AGPL" |
| 191 | + (contains? m "lgpl") "LGPL" |
| 192 | + (contains? m "gpl") "GPL") |
| 193 | + version-present? (boolean (get-rencgs m ["version"] false)) |
| 194 | + version (get-rencgs m ["version"] (if (= variant "LGPL") "2.0" "1.0")) |
| 195 | + version (s/replace version #"\p{Punct}+" ".") |
194 | 196 | [confidence confidence-explanations]
|
195 |
| - (if (s/blank? version) |
196 |
| - [:low #{:missing-version}] |
197 |
| - (if (s/includes? version ".") |
198 |
| - [:high] |
199 |
| - [:medium #{:partial-version}])) |
200 |
| - version (if (s/blank? version) |
201 |
| - (:latest-ver m) |
202 |
| - version) |
203 |
| - version (if (s/includes? version ".") |
204 |
| - version |
205 |
| - (str version ".0")) |
206 |
| - suffix (if (contains? m "orLater") |
207 |
| - "or-later" |
208 |
| - "only") ; Note: we (conservatively) default to "only" when we don't have an explicit suffix |
209 |
| - id (str variant "-" version "-" suffix)] |
| 197 | + (if (s/blank? version) |
| 198 | + [:low #{:missing-version}] |
| 199 | + (if (s/includes? version ".") |
| 200 | + [:high] |
| 201 | + [:medium #{:partial-version}])) |
| 202 | + version (if (s/includes? version ".") |
| 203 | + version |
| 204 | + (str version ".0")) |
| 205 | + [suffix confidence-explanations] |
| 206 | + (cond (contains? m "orLater") ["or-later" confidence-explanations] |
| 207 | + (contains? m "only") ["only" confidence-explanations] |
| 208 | + :else [(if version-present? "only" "or-later") ; Note: on the advice of SPDX technical team, default to "or later" variant if version not present |
| 209 | + (set/union #{:missing-version-suffix} confidence-explanations)]) |
| 210 | + id (str variant "-" version "-" suffix)] |
210 | 211 | [(assert-listed-id id) confidence confidence-explanations]))
|
211 | 212 |
|
212 | 213 | (defn- simple-regex-match
|
|
221 | 222 |
|
222 | 223 |
|
223 | 224 | ; The regex for the GNU family is a nightmare, so we build it up (and test it) in pieces
|
224 |
| -(def agpl-re #"(?<agpl>AGPL|Affero)(\s+GNU)?(\s+General)?(\s+Public)?(\s+Licen[cs]e)?(\s+\(?AGPL\)?)?") |
225 |
| -(def lgpl-re #"(?<lgpl>L\s?GPL|GNU\s+(Library|Lesser)|(Library|Lesser)\s+(L?GPL|General\s+Public\s+Licen[cs]e))(\s+or\s+Lesser)?(\s+General)?(\s+Pub?lic)?(\s+Licen[cs]e)?(\s+\(?LGPL\)?)?") |
226 |
| -(def gpl-re #"(?<!(Affero|Lesser|Library)\s+)(?<gpl>GNU(?!\s+Classpath)|(?<!(L|A)\s*)GPL|General\s+Public\s+Licen[cs]e)(?!\s+(Affero|Library|Lesser|General\s+Lesser|General\s+Library|LGPL|AGPL))((\s+General)?(?!\s+(Affero|Lesser|Library))\s+Public\s+Licen[cs]e)?(\s+\(?GPL\)?)?") |
| 225 | +(def agpl-re #"(?<agpl>AGPL|Affero)(\s+GNU)?(\s+Genere?al)?(\s+Pub?lic)?(\s+Licen[cs]e)?(\s+\(?AGPL\)?)?") |
| 226 | +(def lgpl-re #"(?<lgpl>(GNU\s+(Genere?al\s+)?(Library\s+or\s+Lesser|Library|Lesser))|((Library\s+or\s+Lesser|Library|Lesser)\s+(GNU|GPL|Genere?al)|(L(esser\s)?\s*GPL)))(\s+Genere?al)?(\s+Pub?lic)?(\s+Licen[cs]e)?(\s+\(?L\s*GPL\)?)?") |
| 227 | +(def gpl-re #"(?<!(Affero|Lesser|Library)\s+)(?<gpl>GNU(?!\s+Classpath)|(?<!(L|A)\s*)GPL|Genere?al\s+Pub?lic\s+Licen[cs]e)(?!\s+(Affero|Library|Lesser|Genere?al\s+Lesser|Genere?al\s+Library|LGPL|AGPL))((\s+General)?(?!\s+(Affero|Lesser|Library))\s+Pub?lic\s+Licen[cs]e)?(\s+\(?GPL\)?)?") |
227 | 228 | (def version-re #"[\s,-]*(_?V(ersion)?)?[\s\._]*(?<version>\d+([\._]\d+)?)?")
|
228 | 229 | (def only-or-later-re #"[\s,-]*((?<only>\(?only\)?)|(\(?or(\s+\(?at\s+your\s+(option|discretion)\)?)?(\s+any)?)?([\s-]*(?<orLater>lat[eo]r|newer|greater|\+)))?")
|
229 | 230 | (def gnu-re (lciu/re-concat "(?x)(?i)\\b(\n# Alternative 1: AGPL\n"
|
|
0 commit comments