]> git.wh0rd.org Git - chrome-ext/clearhistory-advance-fork.git/commitdiff
update dist helpers
authorMike Frysinger <vapier@gentoo.org>
Sat, 29 Mar 2014 06:02:13 +0000 (02:02 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 29 Mar 2014 06:02:23 +0000 (02:02 -0400)
Makefile
dist/makedist.sh [new file with mode: 0755]
dist/pngcrush.sh [new file with mode: 0755]
makedist.sh [deleted file]

index 5e8804718f2a4b3f8c0a036ace8699620c29083e..47d1a38d18ba7c2dbdc2af0fb0f792a2d017a777 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,6 @@ css-min: $(CSS_FILES:=.min)
 check: css-min js-min
 
 dist:
-       ./makedist.sh
+       ./dist/makedist.sh
 
 .PHONY: all clean check css-min dist js-min
diff --git a/dist/makedist.sh b/dist/makedist.sh
new file mode 100755 (executable)
index 0000000..fc99c19
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash -e
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+case $1 in
+-h|--help)
+  echo "Usage: $0 [rev]"
+  exit 0
+  ;;
+esac
+
+json_value() {
+  local key=$1
+  sed -n -r \
+    -e '/^[[:space:]]*"'"${key}"'"/s|.*:[[:space:]]*"([^"]*)",?$|\1|p' \
+    manifest.json
+}
+
+PN=$(json_value name | sed 's:[[:space:]/]:_:g' | tr '[:upper:]' '[:lower:]')
+if [[ ${PN} == "__msg_name__" ]] ; then
+  PN=$(basename "$(pwd)")
+fi
+PV=$(json_value version)
+rev=${1:-0}
+PVR="${PV}.${rev}"
+P="${PN}-${PVR}"
+
+rm -rf "${P}"
+mkdir "${P}"
+
+while read line ; do
+  [[ ${line} == */* ]] && mkdir -p "${P}/${line%/*}"
+  ln "${line}" "${P}/${line}"
+done < <(sed 's:#.*::' manifest.files)
+cp Makefile manifest.files manifest.json "${P}/"
+
+make -C "${P}" -j {css,js}-min
+while read line ; do
+  mv "${line}.min" "${line}"
+done < <(find "${P}" -name '*.js' -o -name '*.css')
+rm "${P}"/{manifest.files,Makefile}
+
+sed -i \
+  -e '/"version"/s:"[^"]*",:"'${PVR}'",:' \
+  "${P}/manifest.json"
+
+zip="${P}.zip"
+rm -f "${zip}"
+zip -r "${zip}" "${P}"
+rm -rf "${P}"
+du -b "${zip}"
diff --git a/dist/pngcrush.sh b/dist/pngcrush.sh
new file mode 100755 (executable)
index 0000000..f302a2e
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash -xe
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+size()
+{
+  stat -c %s "$@"
+}
+
+do_apngopt()
+{
+  local png new
+
+  for png in "$@"; do
+    new="${png}.new"
+    apngopt "${png}" "${new}"
+    if [[ $(size "${png}") -gt $(size "${new}") ]]; then
+      mv "${new}" "${png}"
+    else
+      rm "${new}"
+    fi
+  done
+}
+
+do_pngcrush()
+{
+  local png new
+
+  pngcrush -e .png.new "$@"
+  for png in "$@"; do
+    new="${png}.new"
+    mv "${new}" "${png}"
+  done
+}
+
+main()
+{
+  if [ $# -eq 0 ]; then
+    set -- $(find -name '*.png')
+  fi
+
+  if type -P apngopt >/dev/null; then
+    # apngopt likes to corrupt images.
+    : do_apngopt "$@"
+  elif type -P pngcrush >/dev/null; then
+    do_pngcrush "$@"
+  else
+    echo "error: could not find apngopt or pngcrush"
+    exit 1
+  fi
+}
+main "$@"
diff --git a/makedist.sh b/makedist.sh
deleted file mode 100755 (executable)
index 1b66c57..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash -e
-# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-case $1 in
--h|--help)
-  echo "Usage: $0 [rev]"
-  exit 0
-  ;;
-esac
-
-json_value() {
-  local key=$1
-  sed -n -r \
-    -e '/^[[:space:]]*"'"${key}"'"/s|.*:[[:space:]]*"([^"]*)",?$|\1|p' \
-    manifest.json
-}
-
-PN=$(json_value name | sed 's:[[:space:]]:_:g' | tr '[:upper:]' '[:lower:]')
-if [[ ${PN} == "__msg_name__" ]] ; then
-       PN=$(basename "$(pwd)")
-fi
-PV=$(json_value version)
-rev=${1:-0}
-PVR="${PV}.${rev}"
-P="${PN}-${PVR}"
-
-rm -rf "${P}"
-mkdir "${P}"
-
-while read line ; do
-  [[ ${line} == */* ]] && mkdir -p "${P}/${line%/*}"
-  ln "${line}" "${P}/${line}"
-done < <(sed 's:#.*::' manifest.files)
-cp Makefile manifest.files manifest.json "${P}/"
-
-make -C "${P}" -j {css,js}-min
-while read line ; do
-       mv "${line}.min" "${line}"
-done < <(find "${P}" -name '*.js' -o -name '*.css')
-rm "${P}"/{manifest.files,Makefile}
-
-sed -i \
-  -e '/"version"/s:"[^"]*",:"'${PVR}'",:' \
-  "${P}/manifest.json"
-
-zip="${P}.zip"
-rm -f "${zip}"
-zip -r "${zip}" "${P}"
-rm -rf "${P}"
-du -b "${zip}"