summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ad320dcf933a955be89004e864f6f5d9866141a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Maintainer: Daniel Bermond < yahoo-com: danielbermond >

# This package provides pngcrush bundled with libpng and zlib.
# The pngcrush provided in [community] repository uses libpng and zlib from system libraries.
#
# Advantages of having pngcrush bundled with libpng and zlib:
#   - produces slightly smaller PNG files
#   - ability to read erroneous PNG files with "Too many IDAT's"
#   - avoids warnings when pngcrush is not yet rebuild or updated after a libpng/zlib update
#
# Disadvantages of having pngcrush bundled with libpng and zlib:
#   - slightly slower execution
#   - higher pngcrush executable filesize

_srcname=pngcrush
pkgname=pngcrush-bundled
pkgver=1.8.11
pkgrel=1
pkgdesc="A tool for optimizing the compression of PNG files (with bundled libpng and zlib)"
arch=('i686' 'x86_64')
url="http://pmt.sourceforge.net/pngcrush/"
license=('custom')
depends=('glibc')
provides=('pngcrush')
conflicts=('pngcrush')
source=("https://sourceforge.net/projects/pmt/files/pngcrush/${pkgver}/pngcrush-${pkgver}.tar.xz")
sha256sums=('8d530328650ec82f3cbe998729ada8347eb3dbbdf706d9021c5786144d18f5b0')

prepare() {
	cd "$_srcname"-"$pkgver"
	
	sed -r 's|^(CPPFLAGS )=|\1+=|' -i Makefile
	sed -r 's|^(CFLAGS )=|\1+=|'   -i Makefile
	sed -r 's|^(LDFLAGS )=|\1+=|'  -i Makefile
}

build() {
	cd "$_srcname"-"$pkgver"
	
	make
}

package() {
	cd "$_srcname"-"$pkgver"
	
	# Install pngcrush executable
	install -D -m755 pngcrush "${pkgdir}/usr/bin/pngcrush"
	
	# Create a LICENSE file for pngcrush. Note: license is in the file "pngcrush.c".
	sed -n '10,159p' pngcrush.c > LICENSE-pngcrush # create file
	sed -i '1,150s/^.\{,3\}//' LICENSE-pngcrush    # erase C comments
	
	# Modify sections in cexcept, libpng and zlib to reflect the provided LICENSE files:
	sed -i '80s/lines 10/LICENSE-cexcept./' LICENSE-pngcrush
	sed -i -e '81d' LICENSE-pngcrush
	sed -i "84s/If libpng/libpng/" LICENSE-pngcrush
	sed -i "84s/,/ and/" LICENSE-pngcrush
	sed -i "85s/png.h/LICENSE-libpng/" LICENSE-pngcrush
	sed -i "89s/If zlib/zlib/" LICENSE-pngcrush
	sed -i "89s/,/ and/" LICENSE-pngcrush
	sed -i "91s/zlib.h/LICENSE-zlib/" LICENSE-pngcrush
	 
	sed -i '1ipngcrush' LICENSE-pngcrush           # include software name at the top
	sed -i '2i\\' LICENSE-pngcrush                 # insert blank line after
	
	# Create a LICENSE file for cexcept. Note: license is in the file "cexcept.h".
	sed -n '10,17p' cexcept.h > LICENSE-cexcept    # create file
	sed -i '1,8s/^.\{,4\}//' LICENSE-cexcept       # erase leading spaces
	sed -i '1icexcept' LICENSE-cexcept             # include software name at the top
	sed -i '2i\\' LICENSE-cexcept                  # insert blank line after
	
	# Create a LICENSE file for libpng. Note: license is in the file "png.h".
	sed -n '21,109p' png.h > LICENSE-libpng    # create file
	sed -i '1,89s/^.\{,3\}//' LICENSE-libpng   # erase C comments
	sed -i '1ilibpng' LICENSE-libpng           # include software name at the top
	sed -i '2i\\' LICENSE-libpng               # insert blank line after
	
	# Create a LICENSE file for zlib. Note: license is in the file "zlib.h".
	sed -n '4,28p' zlib.h > LICENSE-zlib       # create file
	sed -i '1,25s/^.\{,2\}//' LICENSE-zlib     # erase leading spaces
	sed -i '1izlib' LICENSE-zlib               # include software name at the top
	sed -i '2i\\' LICENSE-zlib                 # insert blank line after
	
	# Install LICENSE files
	install -D -m644 LICENSE-pngcrush "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-pngcrush"
	install -D -m644 LICENSE-cexcept  "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-cexcept"
	install -D -m644 LICENSE-libpng   "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-libpng"
	install -D -m644 LICENSE-zlib     "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-zlib"
}