summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0c507cb6acbd6a59ea694a839434c5f6d0b553d8 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
# Maintainer: Pavol Hluchy (Lopo) <lopo at losys dot eu>
_model=mg6200
pkgname=scangearmp-${_model}
pkgver=1.80
pkgrel=3
_pkgver=1.80-1
pkgdesc="Canon Scanner Driver (for ${_model} series)"
url="http://support-au.canon.com.au/contents/AU/EN/0100393102.html"
arch=('i686' 'x86_64')
license=('custom')
depends=('sane' 'gtk2' 'libpng>=1.2.8')
makedepends=('findutils' 'grep' 'gawk' 'libusb-compat' 'gimp')
source=("http://gdlp01.c-wss.com/gds/1/0100003931/01/scangearmp-source-${_pkgver}.tar.gz"
	'fix_scanfile.patch'
	'configures.patch')
md5sums=('88e3891918357304a9f527d043b435d2'
	'13df0530aaf3283490e09427070311a8'
	'356b6bfbd8577f3fc19d1044605fdbad')

_getmodelid() {
	echo `grep ^PRINTER_DEPEND_PKG=scangearmp-${_model}- ${srcdir}/scangearmp-source-${_pkgver}/debian/scangearmp-${_model}series.postrm \
		| gawk -F- '{print $3}'`
}

_getlibdir() {
	if [ "$CARCH" == "x86_64" ]; then
		echo libs_bin64
	else
		echo libs_bin32
	fi
}

build() {
	libdir=$(_getlibdir)

	# Apply patch
	cd ${srcdir}/scangearmp-source-${_pkgver}
	patch -p1 -i ${srcdir}/fix_scanfile.patch
	patch -p1 -i ${srcdir}/configures.patch

	cd ${srcdir}/scangearmp-source-${_pkgver}/scangearmp
	./autogen.sh --prefix=/usr LDFLAGS="-L`pwd`/../com/${libdir}" LIBS=-lm
	# Force the use of system's libtool
	rm libtool
	ln -s `which libtool` .
	# Build package
	make clean || return 1
	make || return 1
}

package() {
	_modelid=$(_getmodelid)
	libdir=$(_getlibdir)

	# Install package
	cd ${srcdir}/scangearmp-source-${_pkgver}/scangearmp
	make install DESTDIR=${pkgdir} || return 1

	# Install SANE configuration file
	install -d -m 0755 ${pkgdir}/etc/sane.d/
	install -m 0644 ${srcdir}/scangearmp-source-${_pkgver}/scangearmp/backend/canon_mfp.conf ${pkgdir}/etc/sane.d/canon_mfp.conf

	#Install common libraries
	for _l in cmcm msimg mslld msui net; do
		install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/com/${libdir}/libcncp${_l}.so.*.*.* ${pkgdir}/usr/lib/
	done
	# Install ${_model} series specific libraries
	install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/${_modelid}/${libdir}/libcncpmsimg${_modelid}.so.*.*.* ${pkgdir}/usr/lib/
	install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/${_modelid}/${libdir}/libcncpmslld${_modelid}c.so.*.*.* ${pkgdir}/usr/lib/
	install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/${_modelid}/${libdir}/libcncpmslld${_modelid}.so.*.*.* ${pkgdir}/usr/lib/
	# Create symbolic links
	cd ${pkgdir}/usr/lib/
	for _l in cmcm msimg mslld msui net; do
		ln -s libcncp${_l}.so.*.*.* libcncp${_l}.so
	done
	ln -s libcncpmsimg${_modelid}.so.*.*.* libcncpmsimg${_modelid}.so
	ln -s libcncpmslld${_modelid}c.so.*.*.* libcncpmslld${_modelid}c.so
	ln -s libcncpmslld${_modelid}.so.*.*.* libcncpmslld${_modelid}.so

	# Make scangearmp usable from gimp
	install -d -m 0755 ${pkgdir}/usr/lib/gimp/2.0/plug-ins/
	ln -s /usr/bin/scangearmp ${pkgdir}/usr/lib/gimp/2.0/plug-ins/

	# Install .tbl and .dat files for ${_model} series
	install -d -m 0755 ${pkgdir}/usr/lib/bjlib
	install -D -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/${_modelid}/cnc*.tbl ${pkgdir}/usr/lib/bjlib/
	install -D -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/${_modelid}/CNC*.DAT ${pkgdir}/usr/lib/bjlib/

	# Install udev rules
	install -D -m 0644 ${srcdir}/scangearmp-source-${_pkgver}/scangearmp/etc/80-canon_mfp.rules ${pkgdir}/etc/udev/rules.d/80-canon_mfp.rules

	# Install .ini file
	install -D -m 0666 ${srcdir}/scangearmp-source-${_pkgver}/com/ini/canon_mfp_net.ini ${pkgdir}/usr/lib/bjlib/

	# Install license file
	cd ${srcdir}/scangearmp-source-${_pkgver}
	install -D LICENSE-scangearmp-${pkgver}EN.txt ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-scangearmp-${pkgver}EN.txt

	# Remove unneeded files
	rm ${pkgdir}/usr/lib/libsane-canon_mfp.a
	rm ${pkgdir}/usr/lib/libsane-canon_mfp.la
}