-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathsignxpi
executable file
·82 lines (68 loc) · 1.41 KB
/
signxpi
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
#!/bin/sh
# functions
usage () {
echo "usage: -s SOURCE-DIRECTORY"
echo " -d DESTINATION-DIRECTORY"
exit 1
}
test_amo_account () {
if [ -e "~/.amo-account.ini" ]; then
echo "signxpi: error: ~/.amo-account.ini not found."
echo "In this file, please describe AMO account information in the following format:"
echo "AMO_API_KEY=<API key of your AMO account>"
echo "AMO_API_SECRET=<Secret key of your AMO account>"
exit 1
fi
}
test_web_ext () {
which web-ext > /dev/null
local s=$?
if [ $s -ne 0 ]; then
echo "signxpi: web-ext not found."
echo "Please install web-ext via npm."
exit 1
fi
}
test_amo_account
test_web_ext
XPI_FILE=wasavi.xpi
AMO_API_KEY=`sed -n -e 's/^\s*AMO_API_KEY\s*=\s*//p' ~/.amo-account.ini`
AMO_API_SECRET=`sed -n -e 's/^\s*AMO_API_SECRET\s*=\s*//p' ~/.amo-account.ini`
# parse arguments
while getopts s:d: OPT
do
case $OPT in
s)
SRC_DIR=$OPTARG ;;
d)
DST_DIR=$OPTARG ;;
*)
usage ;;
esac
done
if [ -z "$SRC_DIR" ]; then
echo "signxpi: error: missing source directory"
usage
fi
if [ -z "$DST_DIR" ]; then
echo "signxpi: error: missing destination directory"
usage
fi
# sign
web-ext sign \
--api-key=${AMO_API_KEY} \
--api-secret=${AMO_API_SECRET} \
--source-dir=${SRC_DIR} \
--artifacts-dir=${DST_DIR}
# rename
(
cd $DST_DIR
for f in *.xpi
do
if [ $f = $XPI_FILE ]; then
continue
fi
mv $f $XPI_FILE
echo "$f renamed to $XPI_FILE"
done
)