aboutsummaryrefslogtreecommitdiff
path: root/subprojects/spdx/spdx
blob: eb4c76fe7f909605458a2e93aa390d6cef73f90a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
#    This file is part of SPDX-FSD
#    Copyright (C) 2018 David Hedlund
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

scriptsrc=$(readlink -f -- "${BASH_SOURCE[0]}")
run_path=$(dirname "${scriptsrc}" || echo .)
filename=$(basename "$0");

source "$run_path/err"

rm -fr "$run_path/build"
mkdir -p build/json/licenses build/wiki

cd build/json/ || exit


wget -q --show-progress "https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json" -O licenses.json

function build_wiki {

    license_file="licenses/$(jq -r .licenses[$entry].licenseId licenses.json).json"
    redirect_full_name="$(jq -r .licenses[$entry].name licenses.json | sed "s|w/|with |g; s|/|+|g;").wiki"
    wget -q --show-progress "$(jq -r .licenses[$entry].detailsUrl licenses.json)" -P licenses/

    echo "{{license
|Name=$(jq -r .licenses[$entry].name licenses.json)
|Short name=$(jq -r .licenses[$entry].licenseId licenses.json)
|URL=$(jq -r .licenses[$entry].detailsUrl licenses.json)
|Comment=$(jq -r .licenseComments "$license_file")
|Full text=$(jq -r .licenseText "$license_file")
|See also=$(jq -r .licenses[$entry].seeAlso[] licenses.json)
}}

[[Category:$freedom license]]
[[Category:SPDX short identifier]]
" > "$run_path/build/wiki/$(jq -r .licenses[$entry].licenseId licenses.json).wiki"

    echo "#REDIRECT [[License:$(jq -r .licenses[$entry].licenseId licenses.json)]]

[[Category:$freedom license full name]]
[[Category:SPDX full name]]
" > "$run_path/build/wiki/$redirect_full_name"

}


        ######################################################################
        # Start loop

        # Add false "isFsfLibre" value - https://github.com/spdx/spdx-spec/issues/93
        # I'd like to figure out licenses that are classified as nonfree by the FSF so this issue is still relevant so I can use something like:
        #   if [ "$(jq -r ".licenses[$entry].isFsfLibre" licenses.json)" == "false" ]; then echo "Nonfree"; fi

        for entry in $(jq -r .licenses[].referenceNumber licenses.json); do

            if [ "$(jq -r ".licenses[$entry].isFsfLibre" licenses.json)" == "true" ]; then

                freedom="Free"
                build_wiki

                # Code that will be useful once the "false" values has been added, see above notice:
                #    elif [ "$(jq -r ".licenses[$entry] | select(.isFsfLibre = null) | .isFsfLibre" licenses.json)" == "null" ]; then
                
                #        printf "Unknown: "
                #        jq -r .licenses[$entry].name licenses.json

            fi
            
        done