aboutsummaryrefslogtreecommitdiff
path: root/subprojects/spdx/spdx
blob: 901c6cde54d3702727e8c74f3c78a4da7b84e02b (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
#    This file is part of SPDX-FSD
#    Copyright (C) 2018 David Hedlund
#
#    SPDX-FSD is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    FreeAMO is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

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 show {

    ((entry++)) # Should start with 1 to match "referenceNumber" in the json file
#    referenceNumber=$(jq -r .licenses[$entry].referenceNumber licenses.json)
    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]]
" > "$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]]" > "$run_path/build/wiki/$redirect_full_name"
    
}


######################################################################
# Free licenses


for entry in $(jq -r ".licenses[] | select(.isFsfLibre != null) | .referenceNumber" licenses.json); do
    
    freedom="Free"
    show
    
done

exit

######################################################################
# Nonfree licenses

for entry in $(jq -r ".licenses[] | select(.isFsfLibre = null) | .referenceNumber" licenses.json); do
    
    freedom="Nonfree"
    show
    
done


######################################################################
# Old code that didn't work out

exit

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


    if [ "$(jq -r ".licenses[$i] | select(.isFsfLibre = null) | .isFsfLibre" licenses.json)" == "true" ]; then

        freedom=false
        
    elif [ "$(jq -r ".licenses[$i] | select(.isFsfLibre != null) | .isFsfLibre" licenses.json)" == "true" ]; then

        freedom=free

    fi

done