forked from Juris-M/zotero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·157 lines (129 loc) · 4 KB
/
build.sh
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
#!/bin/bash
set -e
# Release-dance code goes here.
# Constants
PRODUCT="Juris-M: reference manager with legal and multilingual support"
IS_BETA="false"
FORK="zotero"
BRANCH="jurism-5.0"
CLIENT="jurism"
VERSION_ROOT="5.0m"
SIGNED_STUB="juris_m-"
set +e
gfind --version > /dev/null 2<&1
if [ $? -gt 0 ]; then
FIND=find
else
FIND=gfind
fi
gsed --version > /dev/null 2<&1
if [ $? -gt 0 ]; then
SED=sed
else
SED=gsed
fi
set -e
function xx-remove-and-replace-old-build-dir () {
rm -fR build
for i in build build/styles build/translators; do
mkdir $i
done
}
function xx-save-aside-deleted-translators-list () {
#if [ ${RELEASE} -gt 1 ]; then
cp translators/deleted.txt .
#fi
}
function xx-copy-files-into-xpi () {
VALUE=$(cat cl-key.txt)
cat resource/config.js | $SED -e "s/%%VALUE%%/$VALUE/" > resource/config.js.NEW
mv resource/config.js.NEW resource/config.js
for i in chrome components defaults resource translators styles; do
$FIND $i -path "*/\.git" -prune -o -name "*~" -prune -o -print | zip "${XPI_FILE}" -@ >> "${LOG_FILE}"
done
for i in chrome.manifest COPYING deleted.txt install.rdf; do
if [ -f "$i" ]; then
echo $i | zip "${XPI_FILE}" -@ >> "${LOG_FILE}"
else
echo "Warning: file \"$i\" not found, unable to add to XPI" >> "${LOG_FILE}"
fi
done
for i in $($FIND resource -type f); do
echo $i | zip "${XPI_FILE}" -@ >> "${LOG_FILE}"
done
git checkout resource/config.js
}
function xx-zip-up-styles () {
cp styles/* build/styles
cd build/styles
zip styles *.csl >> "${LOG_FILE}"
cd ../..
mv build/styles/styles.zip .
}
function xx-zip-up-translators () {
if [ -f translators.index ]; then
rm translators.index
fi
touch translators.index
if [ -d translators_actual ]; then
rm -fR translators_actual
fi
mkdir translators_actual
cd translators_actual
if [ ${RELEASE} -eq 1 ]; then
echo "Using local translator source"
cp ../translators/*.js .
elif [ ${RELEASE} -gt 1 ]; then
echo "Downloading translator source from remote"
wget -O translators_actual.zip http://citationstylist.org/translators/translators.zip
unzip translators_actual.zip >> "${LOG_FILE}"
fi
cd ..
COUNT=0
for i in translators_actual/*.js; do
#FILENAME=$(echo ${COUNT}.js)
FILENAME=$(basename "${i}")
KEY=$(grep -m 1 translatorID "$i"| sed -e "s/.*translatorID\" *: *\"\([^\"]\+\)\".*/\\1/")
NAME=$(grep -m 1 label "$i"| sed -e "s/.*label\" *: *\"\([^\"]\+\)\".*/\\1/")
DATE=$(grep -m 1 lastUpdated "$i"| sed -e "s/.*lastUpdated\" *: *\"\([^\"]\+\)\".*/\\1/")
if [ "${KEY}" != "" ]; then
echo "\"${FILENAME}\",\"${KEY}\",\"${NAME}\",\"${DATE}\"" >> translators.index
cp "$i" build/translators/"${FILENAME}"
echo -n "${FILENAME} "
echo $((COUNT++)) > /dev/null
fi
done
./tools/makeTranslatorJSON.py
#cd build/translators
#zip translators *.js >> "${LOG_FILE}"
#cd ../..
#cp build/translators/translators.zip .
}
function xx-add-styles-and-translators-to-zip () {
#echo styles.zip | zip "${XPI_FILE}" -@ >> "${LOG_FILE}"
echo translators.json | zip "${XPI_FILE}" -@ >> "${LOG_FILE}"
#echo translators.index | zip "${XPI_FILE}" -@ >> "${LOG_FILE}"
#echo translators.zip | zip "${XPI_FILE}" -@ >> "${LOG_FILE}"
}
function xx-cleanup () {
rm styles.zip
}
function xx-patch-sources-before-build () {
"${SCRIPT_DIR}/tools/patch-chrome.sh"
}
function xx-unpatch-sources-after-build () {
"${SCRIPT_DIR}/tools/unpatch-chrome.sh"
}
function build-the-plugin () {
#xx-patch-sources-before-build
set-install-version
xx-remove-and-replace-old-build-dir
xx-save-aside-deleted-translators-list
xx-copy-files-into-xpi
xx-zip-up-styles
xx-zip-up-translators
xx-add-styles-and-translators-to-zip
xx-cleanup
#xx-unpatch-sources-after-build
}
. jm-sh/frontend.sh