#!/usr/bin/env bash
# This file is part of FreeAMO
# Copyright (C) 2017, 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 .
if [ "$1" == "--debug" ] || [ "$2" == "--debug" ]; then
debug=true
debug_arg="--debug";
else
debug=false;
unset debug_arg;
fi
scriptsrc=$(readlink -f -- "${BASH_SOURCE[0]}")
run_path=$(dirname "${scriptsrc}" || echo .)
filename=$(basename "$0");
output_file_1="$run_path/build/index-search-pages.txt";
output_file_2="$run_path/build/index-search-pages--free-licenses.txt"
latest_trisquel_icecat_version="$(wget -qO- "http://archive.trisquel.info/trisquel/pool/main/i/icecat/?C=N;O=D" | grep icecat_ | head -n 1 | sed "s|\"|\\n|g; s|-|\\n|g" | grep icecat_ | sed "s|icecat_||" | head -n 1)"
minimum_average_daily_users="10000"
# source "$run_path/build/err"
# Delete empty files to re-generate them -- Typical case scenario: 1) wget tried to download a file 2) The script is interupted 3) The script is run again
if [ -d "$run_path/build" ]; then
find "$run_path/build" -type f -empty -delete
fi
export -p debug
if [ ! -f /usr/bin/jq ]; then echo "/usr/bin/jq not found!"; exit=true; fi
if [ ! -f /usr/bin/wget ]; then echo "/usr/bin/wget not found!"; exit=true; fi
if [[ $exit == true ]]; then exit 1; fi
case "$1" in
""|--debug)
$0 --disclaimer "$debug_arg"
$0 --remove-build "$debug_arg"
$0 --search-pages "$debug_arg"
$0 --get-licenses "$debug_arg"
$0 --make-directory.fsf.org-wiki "$debug_arg"
;;
-help)
[ "$1" = "" ] && echo "Usage: $filename [--option] [--debug]
OPTIONS
$0 --disclaimer
Display which icecat version the add-on will be compatible with.
$0 --remove-build
Remove the build directory if it exists.
$0 --search-pages
Downloads the most popular WebExtensions from https://addons.mozilla.org/en-US/firefox/search/...
$0 --get-licenses
The licenses are not added to the general JSON file. This option will download the neccesary license JSON files for all add-ons.
$0 --make-directory.fsf.org-wiki
Generates .wiki files specifically for https://directory.fsf.org/wiki/
Disabled options due to limited development time
$0 --make-repository-list
Required file: FreeAMO-collections
File content syntax: https://addons.mozilla.org/en-US/firefox/collections//
$0 --make-collection-list
Required file: FreeAMO-collections
File content syntax: https://addons.mozilla.org/en-US/firefox/collections//
$0 --make-custom-list
Required file: FreeAMO-custom
File content syntax: https://addons.mozilla.org/en-US/firefox/addon//
$0 --download-licenses-json
$0 --download-free-webextensions
Downloads the latest version of the free WebExtensions.
$0 --verify-license-copy
Search for license files in the root directory in the downloaded WebExtensions (.xpi files)
" && exit 1
;;
--disclaimer)
bold=$(tput bold)
normal=$(tput sgr0)
echo "${bold}icecat-$latest_trisquel_icecat_version${normal} is the latest package version for Trisquel GNU/Linux.
This program will download meta-data that is compatible with that version."
;;
--remove-build)
rm -fr "$run_path/build"
;;
--search-pages)
# This option is named after named after https://addons.mozilla.org/en-US/firefox/search/
$0 --search-pages--download "$debug_arg"
$0 --search-pages--filter "$debug_arg"
;;
--search-pages--download)
mkdir -p "$run_path/build/json/search-pages"
source src/search-pages
search-pages--download
;;
--search-pages--filter)
mkdir -p "$run_path/build/json/search-pages"
source src/search-pages
search-pages--filter
;;
--get-licenses)
$0 --get-licenses--download "$debug_arg"
$0 --get-licenses--filter "$debug_arg"
;;
--get-licenses--download)
mkdir -p "$run_path/build/json/current_versions";
source src/get-licenses
get-licenses--download
;;
--get-licenses--filter)
source src/get-licenses
get-licenses--filter
;;
--make-directory.fsf.org-wiki)
mkdir -p "$run_path/build/wiki";
source src/make-wiki
;;
esac