aboutsummaryrefslogtreecommitdiff
path: root/subprojects/freeamo/freeamo
blob: dec2d5cad0e75e16748c374ee1b506c1b4c8bf3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/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 <http://www.gnu.org/licenses/>.

source freeamo.conf

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"

# source "$run_path/build/err"

# Evaluate debug mode
if [ "$1" == "--debug" ] || [ "$2" == "--debug" ]; then

    debug=true
    debug_arg="--debug";
    
else
    
    debug=false;
    unset debug_arg;

fi

# 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/<user>/
        $0 --make-collection-list
            Required file: FreeAMO-collections
            File content syntax: https://addons.mozilla.org/en-US/firefox/collections/<user>/<collection name>
        $0 --make-custom-list
            Required file: FreeAMO-custom
            File content syntax: https://addons.mozilla.org/en-US/firefox/addon/<add-on name>/
        $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)

        echo "$notes"
        
        ;;
    
    --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