forked from vapier/chrome-ext-wake-on-lan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakedist.sh
executable file
·52 lines (44 loc) · 1.13 KB
/
makedist.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
#!/bin/bash -e
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
case $1 in
-h|--help)
echo "Usage: $0 [rev]"
exit 0
;;
esac
json_value() {
local key=$1
sed -n -r \
-e '/^[[:space:]]*"'"${key}"'"/s|.*:[[:space:]]*"([^"]*)",?$|\1|p' \
manifest.json
}
PN=$(json_value name | sed 's:[[:space:]/]:_:g' | tr '[:upper:]' '[:lower:]')
if [[ ${PN} == "__msg_name__" ]] ; then
PN=$(basename "$(pwd)")
fi
PV=$(json_value version)
rev=${1:-0}
PVR="${PV}.${rev}"
P="${PN}-${PVR}"
rm -rf "${P}"
mkdir "${P}"
while read line ; do
[[ ${line} == */* ]] && mkdir -p "${P}/${line%/*}"
ln "${line}" "${P}/${line}"
done < <(sed 's:#.*::' manifest.files)
cp Makefile manifest.files manifest.json "${P}/"
make -C "${P}" -j {css,js}-min
while read line ; do
mv "${line}.min" "${line}"
done < <(find "${P}" -name '*.js' -o -name '*.css')
rm "${P}"/{manifest.files,Makefile}
sed -i \
-e '/"version"/s:"[^"]*",:"'${PVR}'",:' \
"${P}/manifest.json"
zip="${P}.zip"
rm -f "${zip}"
zip -r "${zip}" "${P}"
rm -rf "${P}"
du -b "${zip}"