summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorQue Quotion2016-03-21 15:21:15 +0900
committerQue Quotion2016-03-21 15:21:15 +0900
commit4c9fc7af6158f92b2c1d3924d37c98fc10f2d377 (patch)
tree5162d296bfeb0ddf8df128093d589a370f5c632b
parent309160005a8c30d1f8d520e1236611224f433294 (diff)
downloadaur-4c9fc7af6158f92b2c1d3924d37c98fc10f2d377.tar.gz
SVGO - svg optimization with nodejs-svgo
-rw-r--r--.SRCINFO7
-rw-r--r--05.svgo.patch16
-rw-r--r--PKGBUILD10
-rw-r--r--svgo.sh44
4 files changed, 73 insertions, 4 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 99c322cb22c..ef5edb26441 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,5 +1,5 @@
# Generated by mksrcinfo v8
-# Sun Mar 20 22:07:54 UTC 2016
+# Mon Mar 21 06:21:04 UTC 2016
pkgbase = makepkg-optimize
pkgdesc = Additional package optimization routines for makepkg
pkgver = 1
@@ -11,13 +11,16 @@ pkgbase = makepkg-optimize
depends = pacman
depends = upx
depends = optipng
+ depends = nodejs-svgo
source = 00.optipng.patch
source = 01.upx.patch
source = 02.lto.patch
source = 03.pgo.patch
source = 04.graphite.patch
+ source = 05.svgo.patch
source = upx.sh
source = optipng.sh
+ source = svgo.sh
source = opticonf.patch
source = conf.buildopts.patch
source = conf.pkgopts.patch
@@ -28,8 +31,10 @@ pkgbase = makepkg-optimize
sha512sums = bbd4bf3ddbda97008764c1a619aee4f2e3d3476c8affaac75ffee328db452f587454f16158942ec666e2357474a052019e5641ce6d432c43593b3612bdc40af2
sha512sums = 5a8083ea14a6a414051602740d1cabf80e77119570b8555194bd921c46a4fce5a7e6611d04a778bfe688e30b0de5ccd6c458299d279476e4ffcc01577959d949
sha512sums = 3520817c16ea83a4bed28f153138608456267eac0caed250f8d951c54cf6a07d07e5b13768c5165a8e31a56e76919b3c9b84ad3b2905489ce65e625fa067f9b0
+ sha512sums = c2f74ab15214ccac6ae570fa4a4ebfdf35690be60851be9eb8ab65c1ce4ebed0f0d3cb98947fd4a586d19cb399d312390ebbc68f4de86f607adef2a2d590798e
sha512sums = db55e9d4302035447854ec34d44d454a1a68882437129c00de388f56413cff71e133848df5a09962c40f2bd0203f5e5c692af4e100e67072da4b504ef4752ca4
sha512sums = 60ca209609ddbf617e63c7103d675da17671efc91db066a1e11dd1df78f9c8abf267f1cd417ff3b5db59411cf6e7df134e6bd8b06c73442410f14c13b1f5dd53
+ sha512sums = 9fab754ef2ffb2587d2d9f4669ad12b98393d5df6aff65fb15ff93e0dbb4912a65c0f76e26ef1a4a36e55f4e74a02367a7795812353b8c85ad1099cd333c86a7
sha512sums = 16c2b0e666234f1a493e7456f4c387fbabd24b10514c93fa4338520e8f537e9a12de0d833a6148fe871452d87f6e1b3454b2bde332b9ba4c4e7680616b7eeede
sha512sums = dd609146c46b36bf3b9d7ed81935b64708cc5a37210f39e54162c603f1cae2bc9d8110dec92d61939c63245549b0a4548b17a15f9746abdd64faa65421288a2e
sha512sums = cef2f8f3e82fa668c490f305bb01a344391958ca3f0be95da09e6008b30ecf996803dfda863a73e340c71937c7691d115bfe7e109c71d71eb65b5052bb179504
diff --git a/05.svgo.patch b/05.svgo.patch
new file mode 100644
index 00000000000..f3330f981cf
--- /dev/null
+++ b/05.svgo.patch
@@ -0,0 +1,16 @@
+--- makepkg-optimize 2016-03-21 08:09:30.386922025 +0900
++++ makepkg-optimize+svgo 2016-03-21 15:18:36.410371191 +0900
+@@ -1603,6 +1603,13 @@
+ fi
+ fi
+
++ # svgo - svg image optimization
++ if check_option "svgo" "y"; then
++ if ! type -p svgo >/dev/null; then
++ error "$(gettext "Cannot find the %s binary required for optimizing SVG images.")" "svgo"
++ ret=1
++ fi
++ fi
+ # distcc - compilation with distcc
+ if check_buildoption "distcc" "y"; then
+ if ! type -p distcc >/dev/null; then
diff --git a/PKGBUILD b/PKGBUILD
index 860adad66db..576f230fdea 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -7,10 +7,10 @@ pkgdesc='Additional package optimization routines for makepkg'
arch=('x86_64')
license=('GPL')
url='https://projects.archlinux.org/pacman.git/'
-depends=('pacman' 'upx' 'optipng')
+depends=('pacman' 'upx' 'optipng' 'nodejs-svgo')
makedepends=('pacman')
-source=('00.optipng.patch' '01.upx.patch' '02.lto.patch' '03.pgo.patch' '04.graphite.patch'
- 'upx.sh' 'optipng.sh'
+source=('00.optipng.patch' '01.upx.patch' '02.lto.patch' '03.pgo.patch' '04.graphite.patch' '05.svgo.patch'
+ 'upx.sh' 'optipng.sh' 'svgo.sh'
'opticonf.patch' 'conf.buildopts.patch' 'conf.pkgopts.patch'
'makepkg' 'makepkg.conf')
sha512sums=('67fb9359cd5dc52413ad2ca7e91b445826d7cf6b7ad3db0d2b3845310ab0bdfc41c2e70cec564e26269521ac313f7202c44996a24266380e48e88927bd1012e2'
@@ -18,8 +18,10 @@ sha512sums=('67fb9359cd5dc52413ad2ca7e91b445826d7cf6b7ad3db0d2b3845310ab0bdfc41c
'bbd4bf3ddbda97008764c1a619aee4f2e3d3476c8affaac75ffee328db452f587454f16158942ec666e2357474a052019e5641ce6d432c43593b3612bdc40af2'
'5a8083ea14a6a414051602740d1cabf80e77119570b8555194bd921c46a4fce5a7e6611d04a778bfe688e30b0de5ccd6c458299d279476e4ffcc01577959d949'
'3520817c16ea83a4bed28f153138608456267eac0caed250f8d951c54cf6a07d07e5b13768c5165a8e31a56e76919b3c9b84ad3b2905489ce65e625fa067f9b0'
+ 'c2f74ab15214ccac6ae570fa4a4ebfdf35690be60851be9eb8ab65c1ce4ebed0f0d3cb98947fd4a586d19cb399d312390ebbc68f4de86f607adef2a2d590798e'
'db55e9d4302035447854ec34d44d454a1a68882437129c00de388f56413cff71e133848df5a09962c40f2bd0203f5e5c692af4e100e67072da4b504ef4752ca4'
'60ca209609ddbf617e63c7103d675da17671efc91db066a1e11dd1df78f9c8abf267f1cd417ff3b5db59411cf6e7df134e6bd8b06c73442410f14c13b1f5dd53'
+ '9fab754ef2ffb2587d2d9f4669ad12b98393d5df6aff65fb15ff93e0dbb4912a65c0f76e26ef1a4a36e55f4e74a02367a7795812353b8c85ad1099cd333c86a7'
'16c2b0e666234f1a493e7456f4c387fbabd24b10514c93fa4338520e8f537e9a12de0d833a6148fe871452d87f6e1b3454b2bde332b9ba4c4e7680616b7eeede'
'dd609146c46b36bf3b9d7ed81935b64708cc5a37210f39e54162c603f1cae2bc9d8110dec92d61939c63245549b0a4548b17a15f9746abdd64faa65421288a2e'
'cef2f8f3e82fa668c490f305bb01a344391958ca3f0be95da09e6008b30ecf996803dfda863a73e340c71937c7691d115bfe7e109c71d71eb65b5052bb179504'
@@ -48,6 +50,7 @@ prepare() {
patch -Np0 < ../02.lto.patch
patch -Np0 < ../03.pgo.patch
patch -Np0 < ../04.graphite.patch
+ patch -Np0 < ../05.svgo.patch
}
package() {
@@ -57,6 +60,7 @@ package() {
#Uncomment once dropped from pacman.
#install -m755 ../optipng.sh $pkgdir/usr/share/makepkg/tidy/optipng.sh
#install -m755 ../upx.sh $pkgdir/usr/share/makepkg/tidy/upx.sh
+ #install -m755 ../upx.sh $pkgdir/usr/share/makepkg/tidy/svgo.sh
mkdir -p $pkgdir/etc/
install -m644 makepkg-optimize.conf $pkgdir/etc/
}
diff --git a/svgo.sh b/svgo.sh
new file mode 100644
index 00000000000..9873325a22d
--- /dev/null
+++ b/svgo.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/bash
+#
+# svgo.sh - Compress SVG files using optsvg
+#
+# Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_TIDY_SVGO_SH" ]] && return
+LIBMAKEPKG_TIDY_SVGO_SH=1
+
+LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+
+packaging_options+=('svgo')
+tidy_modify+=('tidy_svgo')
+
+tidy_svgo() {
+ if check_option "svgo" "y"; then
+ msg2 "$(gettext "Optimizing SVG images...")"
+ local svg
+ find . -type f -iname "*.svg" 2>/dev/null | while read -r svg ; do
+ if [[ $(file --brief --mime-type "$svg") = 'image/svg' ]]; then
+ svgo "${SVGOFLAGS[@]}" "$svg" &>/dev/null ||
+ warning "$(gettext "Could not optimize SVG image : %s")" "${svg/$pkgdir\//}"
+ fi
+ done
+ fi
+}