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/main_functions~ | 137 ++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 subprojects/freeamo/src/main_functions~ (limited to 'subprojects/freeamo/src/main_functions~') diff --git a/subprojects/freeamo/src/main_functions~ b/subprojects/freeamo/src/main_functions~ new file mode 100644 index 0000000..7aec7e8 --- /dev/null +++ b/subprojects/freeamo/src/main_functions~ @@ -0,0 +1,137 @@ +#!/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 . + +function check_files { + + if [ ! -f "$run_path/FreeAMO-$check_type" ]; then + + echo "$run_path/FreeAMO-$check_type doesn't exist."; + echo "Exiting" && exit + + else + + + # Make sure all links are using SSL + if grep -q "http://addons.mozilla.org/" $run_path/FreeAMO-$check_type; then + + echo "Change http://addons.mozilla.org/ to https://addons.mozilla.org/ (https)." + echo "Exiting" && exit + + fi + + fi + +} + +function line_status { + + + if [ "$file" == "$previous_file" ]; then + + ((++line)) + + else + + line="0"; # Should not be 1 + + fi + +} + +function amo_variables() { + id="$(jq ".results[$entry].id" "$file")"; + average_daily_users="$(jq ".results[$entry].average_daily_users" "$file")"; + has_eula="$(jq ".results[$entry].has_eula" "$file")"; + slug="$(jq ".results[$entry].slug" "$file" | sed "s|^\"||; s|\"$||;")"; + current_version__id=$(jq ".results[$entry].current_version.id" "$file"); + + # Names + name__enUS=$(jq ".results[$entry].name" "$file" | sed "s|-||;" | jq .enUS | sed "s|^\"||; s|\"$||;" ) + name__enGB=$(jq ".results[$entry].name" "$file" | sed "s|-||;" | jq .enGB | sed "s|^\"||; s|\"$||;" ) + if [ "$name__enUS" != "null" ]; then name="$name__enUS"; + elif [ "$name__enGB" != "null" ]; then name="$name__enGB"; + else name=$(jq ".results[$entry].name[]" "$file" | sed "s|-||;" | jq . | sed "s|^\"||; s|\"$||;"); # Use the first avalible name if English is not avaliable + fi + + + if jq .results[$entry].current_version.files[0].permissions "$file" | grep -q "nativeMessaging"; then + + nativeMessaging__pass=false; + + else + + nativeMessaging__pass=true; + + fi + +} + +function amo_variables__licenses { + + license__amo_full_name="$(jq ".license.name" "$run_path/build/json/current_versions/$current_version__id.json" | sed "s|en-US|enUS|;" | jq .enUS | sed "s|^\"||; s|\"$||;")" + +} + +function essential_addon { + + if [ "$has_eula" = false ] && [ "$nativeMessaging__pass" = true ] && [ "$average_daily_users" -ge "$minimum_average_daily_users" ]; then + + essential_addon=true; + + else + + essential_addon=false; + + fi + +} + +#function hard_to_evaluate_addon { + + # curl "https://addons.mozilla.org/api/v3/addons/addon/nemid-nøglefilsprogram/" | jq .current_version.files[0].permissions | grep "nativeMessaging + + + # API data: Add software dependencies - https://github.com/mozilla/addons-server/issues/8668 + # The API should be fixed. there are to many add-ons to keep track on if they have or not have software dependencies. + + # Old solution: + + # 1: Add this to FreeAMO-dependencies: + #belgium-eid eid-mw + + # 2: Uncomment this code: + # depends_on_external_program=false; + # while IFS= read -r dependencies; do + # + # dependency_slug=$(echo $dependencies | awk '{print $1}'); + # dependency=$(echo "$dependencies" | cut -f 2); + # + # if [ "$dependency_slug" == "$slug" ]; then + # + # depends_on_external_program=true; + # + # fi + # + # done < $run_path/FreeAMO-dependencies + +#} + +function progress { + + (>&2 echo -en "\r"; pv --progress --line-mode --size $pv__size --eta --timer) > /dev/null + +} -- cgit v1.2.3