]> git.wh0rd.org - chrome-ext/wake-on-lan.git/blame - makedist.sh
add port tips to the port field tooltip text
[chrome-ext/wake-on-lan.git] / makedist.sh
CommitLineData
5b4622f6
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
6case $1 in
7-h|--help)
8 echo "Usage: $0 [rev]"
9 exit 0
10 ;;
11esac
12
13json_value() {
14 local key=$1
15 sed -n -r \
16 -e '/^[[:space:]]*"'"${key}"'"/s|.*:[[:space:]]*"([^"]*)",?$|\1|p' \
17 manifest.json
18}
19
20PN=$(json_value name | sed 's:[[:space:]/]:_:g' | tr '[:upper:]' '[:lower:]')
21if [[ ${PN} == "__msg_name__" ]] ; then
22 PN=$(basename "$(pwd)")
23fi
24PV=$(json_value version)
25rev=${1:-0}
26PVR="${PV}.${rev}"
27P="${PN}-${PVR}"
28
29rm -rf "${P}"
30mkdir "${P}"
31
32while read line ; do
33 [[ ${line} == */* ]] && mkdir -p "${P}/${line%/*}"
34 ln "${line}" "${P}/${line}"
35done < <(sed 's:#.*::' manifest.files)
36cp Makefile manifest.files manifest.json "${P}/"
37
38make -C "${P}" -j {css,js}-min
39while read line ; do
40 mv "${line}.min" "${line}"
41done < <(find "${P}" -name '*.js' -o -name '*.css')
42rm "${P}"/{manifest.files,Makefile}
43
44sed -i \
45 -e '/"version"/s:"[^"]*",:"'${PVR}'",:' \
46 "${P}/manifest.json"
47
48zip="${P}.zip"
49rm -f "${zip}"
50zip -r "${zip}" "${P}"
51rm -rf "${P}"
52du -b "${zip}"