]>
Commit | Line | Data |
---|---|---|
a98f3ef6 MF |
1 | #!/bin/bash -e |
2 | # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. | |
3 | # Use of this source code is governed by a BSD-style license that can be | |
4 | # found in the LICENSE file. | |
5 | ||
6 | case $1 in | |
7 | -h|--help) | |
8 | echo "Usage: $0 [rev]" | |
9 | exit 0 | |
10 | ;; | |
11 | esac | |
12 | ||
13 | json_value() { | |
14 | local key=$1 | |
cbf343ff MF |
15 | python -c ' |
16 | import json, os, sys | |
17 | path, key = sys.argv[1:] | |
18 | with open(path) as fp: | |
19 | data = json.load(fp) | |
20 | print(data[key]) | |
21 | ' "manifest.json" "${key}" | |
a98f3ef6 MF |
22 | } |
23 | ||
cbf343ff MF |
24 | PN=$(json_value name | sed 's:[[:space:]/]:_:g' | tr '[:upper:]' '[:lower:]') |
25 | if [[ ${PN} == "__msg_name__" ]] ; then | |
26 | PN=$(basename "$(pwd)") | |
27 | fi | |
a98f3ef6 MF |
28 | PV=$(json_value version) |
29 | rev=${1:-0} | |
30 | PVR="${PV}.${rev}" | |
31 | P="${PN}-${PVR}" | |
32 | ||
33 | rm -rf "${P}" | |
34 | mkdir "${P}" | |
35 | ||
36 | while read line ; do | |
37 | [[ ${line} == */* ]] && mkdir -p "${P}/${line%/*}" | |
38 | ln "${line}" "${P}/${line}" | |
39 | done < <(sed 's:#.*::' manifest.files) | |
594d1a6d MF |
40 | cp Makefile manifest.files manifest.json "${P}/" |
41 | ||
9a46592d | 42 | make -C "${P}" -j {css,js}-min |
594d1a6d | 43 | while read line ; do |
cbf343ff MF |
44 | mv "${line}" "${line%.min}" |
45 | done < <(find "${P}" -name '*.min') | |
594d1a6d | 46 | rm "${P}"/{manifest.files,Makefile} |
a98f3ef6 | 47 | |
cbf343ff MF |
48 | python -c ' |
49 | import json, os, sys | |
50 | path, ver = sys.argv[1:] | |
51 | with open(path) as fp: | |
52 | data = json.load(fp) | |
53 | data.pop("key", None) | |
54 | data["version"] = ver | |
55 | with open(path, "w") as fp: | |
56 | json.dump(data, fp, separators=(",", ":")) | |
57 | ' "${P}/manifest.json" "${PVR}" | |
a98f3ef6 MF |
58 | |
59 | zip="${P}.zip" | |
9a46592d | 60 | rm -f "${zip}" |
a98f3ef6 MF |
61 | zip -r "${zip}" "${P}" |
62 | rm -rf "${P}" | |
63 | du -b "${zip}" |