aboutsummaryrefslogblamecommitdiff
path: root/subprojects/spdx/spdx
blob: e8a8208fd46c1a6671c290736fdb668266b07fdb (plain) (tree)
1
2
3
4



                                     










                                                                          




                                               
                       





                                       
 

                                                                                                                             
                     
 


















                                                                                                          
 
 
 
 

                                                                              
 


                                                                                                                                                
 
                                                                           
 
                                                                                          
 

                              
 




                                                                                                                                     
 


              
#!/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]]
" > "$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"

}


        ######################################################################
        # 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