]> git.wh0rd.org - chrome-ext/waterfall-buildbot-clicker.git/blame - makedist.sh
initial code
[chrome-ext/waterfall-buildbot-clicker.git] / makedist.sh
CommitLineData
55314fcf
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
6cd "${0%/*}"
7
8case $1 in
9-h|--help)
10 echo "Usage: $0 [rev]"
11 exit 0
12 ;;
13esac
14
15rev=${1:-0}
16if [[ $# -gt 1 || -n ${1//[0-9]} ]] ; then
17 cat <<-EOF
18Usage: makedist.sh <rev>
19
20The ver will be taken from manifest.json.
21
22The rev should be an integer.
23
24Example:
25 ./makedist.sh 1
26This will generate a manifest for version 3.0.1 (when version is '3.0'
27in the manifest.json file)
28EOF
29 exit 0
30fi
31
32json_value() {
33 local key=$1
34 sed -n -r \
35 -e '/^[[:space:]]*"'"${key}"'"/s|.*:[[:space:]]*"([^"]*)",?$|\1|p' \
36 manifest.json
37}
38
39PN=$(json_value name | sed 's:[[:space:]/]:_:g' | tr '[:upper:]' '[:lower:]')
40if [[ ${PN} == "__msg_name__" ]] ; then
41 PN=$(basename "$(pwd)")
42fi
43PV=$(json_value version)
44PVR="${PV}.${rev}"
45P="${PN}-${PVR}"
46
47rm -rf "${P}"
48mkdir "${P}"
49
50while read line ; do
51 [[ ${line} == */* ]] && mkdir -p "${P}/${line%/*}"
52 ln "${line}" "${P}/${line}"
53done < <(sed 's:#.*::' manifest.files)
54cp Makefile manifest.files manifest.json "${P}/"
55
56make -C "${P}" -j min
57while read line ; do
58 mv -v "${line}" "${line%.min}"
59done < <(find "${P}" -name '*.min')
60rm "${P}"/{manifest.files,Makefile}
61
62sed -i \
63 -e '/"version"/s:"[^"]*",:"'${PVR}'",:' \
64 "${P}/manifest.json"
65
66zip="${P}.zip"
67rm -f "${zip}"
68zip -r "${zip}" "${P}"
69rm -rf "${P}"
70du -b "${zip}"