Project

General

Profile

« Previous | Next » 

Revision 098e5e50

Added by koszko over 1 year ago

remove unused shell_utils, update upload_amo.sh to still work

Even though upload_amo.sh scripts for extension signing is included, we're currently unable to use it because Firefox API keys needed for that require execution of nonfree JS and Jahoti's Mozoid tool is no longer working https://hydrillabugs.koszko.org/issues/111

View differences:

shell_utils.sh
1
# This file is part of Haketilo
2
#
3
# Copyright (C) 2021, Wojtek Kosior
4
#
5
# This program is free software: you can redistribute it and/or modify
6
# it under the terms of the CC0 1.0 Universal License as published by
7
# the Creative Commons Corporation.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# CC0 1.0 Universal License for more details.
13

  
14
map_set_instr() {
15
    printf "%s__%s='%s'" "$1" "$2" "$3"
16
}
17

  
18
map_set() {
19
    eval "$(map_set_instr "$@")"
20
}
21

  
22
map_set_export() {
23
    eval "export $(map_set_instr "$@")"
24
}
25

  
26
map_get() {
27
    eval "printf %s \"\$$1__$2\""
28
}
29

  
30
map_del_instr() {
31
    printf 'unset %s__%s' "$1" "$2"
32
}
33

  
34
map_del() {
35
    eval "$(map_del_instr "$@")"
36
}
37

  
38
sanitize() {
39
    printf %s "$1" | tr /.- _
40
}
41

  
42
escape_regex_special() {
43
    printf %s "$1" | sed 's/\([]\.*?{},()[-]\)/\\\1/g'
44
}
45

  
46
# Note: We don't actually parse JSON. We extract needed keys with sed regexes
47
# which does not work in the general case but is sufficient for now.
48
get_json_key() {
49
    local KEY_REG="$(escape_regex_special "$1")"
50
    printf %s "$2" |
51
	sed 's/\(.*"'"$KEY_REG"'"[[:space:]]*:[[:space:]]*"\([^"]*\)"\)\?.*/\2/' |
52
	grep . | head -1
53
}
upload_amo.sh
23 23
SECRET="$3"
24 24
XPI_PATH="$4"
25 25

  
26
escape_regex_special() {
27
    printf %s "$1" | sed 's/\([]\.*[-]\)/\\\1/g'
28
}
29

  
30
# Note: We don't actually parse JSON. We extract needed keys with sed regexes
31
# which does not work in the general case but is sufficient for now.
32
_get_json_key() {
33
    local KEY_REG="$(escape_regex_special "$1")"
34
    printf %s "$2" |
35
	awk '{printf "%s", $0}' |
36
	sed 's/^.*\("'"$KEY_REG"'"[[:space:]]*:[[:space:]]*"\([^"]*\)"\).*$/\2/'
37
}
38

  
39
get_json_key() {
40
    local JSON="$2"
41
    local VALUE="$(_get_json_key "$@")"
42
    if [ "x$VALUE" != "x$JSON" ]; then
43
	printf %s "$VALUE"
44
    fi
45
}
46

  
26 47
base64url() {
27 48
    printf %s "$1" | base64 -w 0 | tr '/+' '_-' | tr -d '='
28 49
}

Also available in: Unified diff