From 1ae516a7bab1d5d9f02ab00c4ac13c219f43c1a1 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 17 Jul 2018 15:52:52 +0200 Subject: Renamed the AMO/FSD project to FreeAMO, and rewrote its architecture. --- subprojects/freeamo/src/get-licenses | 125 +++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 subprojects/freeamo/src/get-licenses (limited to 'subprojects/freeamo/src/get-licenses') diff --git a/subprojects/freeamo/src/get-licenses b/subprojects/freeamo/src/get-licenses new file mode 100644 index 0000000..c7e5559 --- /dev/null +++ b/subprojects/freeamo/src/get-licenses @@ -0,0 +1,125 @@ +#!/usr/bin/env bash +# This file is part of FreeAMO +# Copyright (C) 2018 David Hedlund +# +# FreeAMO 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 . + +# API: Please adopt SPDX - https://github.com/mozilla/addons-server/issues/8706 +# Allow GNU [L]GPL x.x or later - https://github.com/mozilla/addons-server/issues/8707 + +cd "build/json/search-pages" + +function get-licenses--download { + + echo -e "\\nDownloading license pages:" + + + output_file="$output_file_1"; + pv__size="$(wc -l < "$output_file")" + source "$run_path/src/main_functions" + + while IFS= read -r table; do + + ((++line)) + + if [ "$debug" = true ] && [ "$line" -le "3" ] || [ "$debug" = false ] ; then + + file=$(echo $table | awk '{print $1}'); + entry=$(echo $table | awk '{print $2}'); + + source "$run_path/src/main_functions" + amo_variables + + total=$(wc -l < "$output_file_1") + # echo -e "#================== + #Entry $line (of $total): $name\n" + + # Do now download the same license files over and over + wget -nc -q "https://addons.mozilla.org/api/v3/addons/addon/$slug/versions/$current_version__id/" -O "$run_path/build/json/current_versions/$current_version__id.json" + + fi + + + echo "foo" # Must be here to work with pv + done < "$output_file_1" | progress + +} + +function get-licenses--filter { + + echo -e "\\nFilter license pages:" + + output_file="$output_file_1"; + pv__size="$(wc -l < "$output_file")" + source "$run_path/src/main_functions" + rm -f "$run_path/build/index-search-pages--free-licenses.txt" + + + while IFS= read -r table; do + + ((++line)) + + if [ "$debug" = true ] && [ "$line" -le "3" ] || [ "$debug" = false ] ; then + + file=$(echo $table | awk '{print $1}'); + entry=$(echo $table | awk '{print $2}'); + + source "$run_path/src/main_functions" + amo_variables + amo_variables__licenses + + # license="$(jq ".license.name" "$run_path/build/json/current_versions/$current_version__id.json" | sed "s|en-US|enUS|;" | jq .enUS | sed "s|^\"||; s|\"$||;")" + + # echo "$run_path/build/json/current_versions/$(jq ".results[$entry].current_version.id" "$file")" + + # This is the complete list of pre-defined licenses listed on AMO. Apache License 2.0 is not on the list so its not easy to detect because it has to be released under a "Custom License". + # Make a drop-down menu with all SPDX licenses - https://github.com/mozilla/addons-server/issues/8866 + # See https://addons.mozilla.org/en-US/developers/addon//ownership for the current add-on list. Note that not all licenses are added to the list. + # DuckDuckGo Privacy Essentials is distributed under Apache License 2.0. + # Apache License, version 2.0 is not on the add-on license list - https://github.com/mozilla/addons-server/issues/8545 + if + [ "$license__amo_full_name" == "BSD License" ] || + [ "$license__amo_full_name" == "GNU General Public License, version 3.0" ] || + [ "$license__amo_full_name" == "GNU General Public License, version 2.0" ] || + [ "$license__amo_full_name" == "GNU Lesser General Public License, version 3.0" ] || + [ "$license__amo_full_name" == "GNU Lesser General Public License, version 2.1" ] || + [ "$license__amo_full_name" == "MIT/X11 License" ] || + [ "$license__amo_full_name" == "Mozilla Public License, version 2.0" ] || + [ "$license__amo_full_name" == "Mozilla Public License Version 1.1" ] + then + + # The nonfree add-ons should not be removed since the line number must correspond with the entry number in the search result JSON files. + # echo "$name: $license__amo_full_name" + echo "$file $entry" >> "$output_file_2" + + freedom_status="free"; + + elif [ "$license__amo_full_name" == "All Rights Reserved" ]; then + + freedom_status="nonfree"; + + else + + freedom_status="unknown"; + fi + + + + fi + + echo "foo" # Must be here to work with pv + + done < "$output_file_1" | progress + +} -- cgit v1.2.3