OLD | NEW |
---|---|
(Empty) | |
1 #!/bin/bash | |
2 # Copyright (c) 2010 The Chromium 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 ALL_DIRS=" | |
7 ash/resources | |
8 ui/resources | |
9 chrome/app/theme | |
10 chrome/browser/resources | |
11 chrome/renderer/resources | |
12 webkit/glue/resources | |
13 remoting/resources | |
14 remoting/webapp | |
15 " | |
16 | |
17 function sanitize_file { | |
18 tput el | |
19 echo -ne "$1\r" | |
20 local file=$1 | |
21 local name=$(basename $file) | |
22 pngcrush -d $TMP_DIR -brute -reduce -rem text -rem mkBT \ | |
23 -rem mkTS $file > /dev/null | |
24 mv "$TMP_DIR/$name" "$file" | |
25 } | |
26 | |
27 function sanitize_dir { | |
28 local dir=$1 | |
29 for f in `find $dir -name "*.png"`; do | |
jrbarnette
2013/01/09 20:44:19
This will fail if any of the .png files have a spa
oshima
2013/01/10 05:36:34
Yes, that shouldn't happen.
| |
30 sanitize_file $f | |
31 done | |
32 } | |
33 | |
34 if [ ! -e ../.gclient ]; then | |
35 echo "$0 must be run in src directory" | |
36 exit 1 | |
37 fi | |
38 | |
39 # Make sure we have pngcrush installed. | |
40 dpkg -s pngcrush > /dev/null 2>&1 | |
41 if [ "$?" != "0" ]; then | |
42 read -p "Couldn't fnd pngcrush. Do you want to install? (y/n)" | |
43 [ "$REPLY" == "y" ] && sudo apt-get install pngcrush | |
44 [ "$REPLY" == "y" ] || exit | |
45 fi | |
46 | |
47 # Create tmp directory for crushed png file. | |
48 TMP_DIR=`mktemp -d` | |
jrbarnette
2013/01/09 20:44:19
There's inconsistency here and above regarding whe
oshima
2013/01/10 05:36:34
Done.
| |
49 | |
50 # Make sure we cleanup temp dir | |
51 trap "rm -rf $TMP_DIR; exit 255" SIGINT SIGTERM EXIT | |
jrbarnette
2013/01/09 20:44:19
The 'exit 255' combined with 'trap ... EXIT' means
oshima
2013/01/10 05:36:34
I changed to simply exit for now. Do you have any
jrbarnette
2013/01/10 18:34:33
You could have a global variable that you set with
| |
52 | |
53 # If no arguments passed, sanitize all directories. | |
54 DIRS=$* | |
55 set ${DIRS:=$ALL_DIRS} | |
56 | |
57 for d in $DIRS; do | |
58 echo "Sanitizing png files in $d" | |
59 sanitize_dir $d | |
60 echo | |
61 done | |
62 | |
OLD | NEW |