diff options
Diffstat (limited to 'subprojects/spdx/spdx')
-rwxr-xr-x | subprojects/spdx/spdx | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/subprojects/spdx/spdx b/subprojects/spdx/spdx new file mode 100755 index 0000000..901c6cd --- /dev/null +++ b/subprojects/spdx/spdx @@ -0,0 +1,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 |