Index: build/sanitize-png-files.sh |
diff --git a/build/sanitize-png-files.sh b/build/sanitize-png-files.sh |
new file mode 100755 |
index 0000000000000000000000000000000000000000..489e65a21c3211fd0b97b20fad210a248ec2a239 |
--- /dev/null |
+++ b/build/sanitize-png-files.sh |
@@ -0,0 +1,62 @@ |
+#!/bin/bash |
+# Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+ALL_DIRS=" |
+ash/resources |
+ui/resources |
+chrome/app/theme |
+chrome/browser/resources |
+chrome/renderer/resources |
+webkit/glue/resources |
+remoting/resources |
+remoting/webapp |
+" |
+ |
+function sanitize_file { |
+ tput el |
+ echo -ne "$1\r" |
+ local file=$1 |
+ local name=$(basename $file) |
+ pngcrush -d $TMP_DIR -brute -reduce -rem text -rem mkBT \ |
+ -rem mkTS $file > /dev/null |
+ mv "$TMP_DIR/$name" "$file" |
+} |
+ |
+function sanitize_dir { |
+ local dir=$1 |
+ 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.
|
+ sanitize_file $f |
+ done |
+} |
+ |
+if [ ! -e ../.gclient ]; then |
+ echo "$0 must be run in src directory" |
+ exit 1 |
+fi |
+ |
+# Make sure we have pngcrush installed. |
+dpkg -s pngcrush > /dev/null 2>&1 |
+if [ "$?" != "0" ]; then |
+ read -p "Couldn't fnd pngcrush. Do you want to install? (y/n)" |
+ [ "$REPLY" == "y" ] && sudo apt-get install pngcrush |
+ [ "$REPLY" == "y" ] || exit |
+fi |
+ |
+# Create tmp directory for crushed png file. |
+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.
|
+ |
+# Make sure we cleanup temp dir |
+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
|
+ |
+# If no arguments passed, sanitize all directories. |
+DIRS=$* |
+set ${DIRS:=$ALL_DIRS} |
+ |
+for d in $DIRS; do |
+ echo "Sanitizing png files in $d" |
+ sanitize_dir $d |
+ echo |
+done |
+ |