aboutsummaryrefslogtreecommitdiff
path: root/system/epson-printer-utility/epson-printer-utility.SlackBuild
blob: c8fc095f2dbd3ef764e9fbdeb49d544fcb4d87d0 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#!/bin/bash

# Slackware build script for epson-printer-utility

# Copyright 2020/2022 Tim Dickson
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#thanks to B.Watson for support on this build. :-)

# 20220301 bkw: Modified by SlackBuilds.org, BUILD=4:
# - fix build on 15.0.
# - add qt4 as a dependency, and modify the script to use it.
# - fix weird libtool issue (libcutils.la wasn't being built).
# - stop writing to $CWD. use a top-level build dir instead.
# - fix hardcoded /usr/lib64 in rm command (fix build on 32-bit)!

# 20220522 tim dickson: Build=5: update README.models to include new
# -  models. Also major patching to get working with qt5, removing qt4 dep  

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=epson-printer-utility
VERSION=${VERSION:-1.1.1}
EXTRABIT=1lsb3.2
TARNAM=$PRGNAM-$VERSION.tar.gz
BUILD=${BUILD:-5}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
# the name of the created package would be, and then exit. This information
# could be useful to other scripts.
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  exit 0
fi

TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

set -e

TOPDIR=$TMP/$PRGNAM-$VERSION-build

##this is my attempt to patch the software to work with qt5
#source /etc/profile.d/qt4.sh; export PATH

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $TOPDIR
mkdir -p $TOPDIR
cd $TOPDIR

#lets get the source tarball from the rpm and clean up the bits we don't need
ln -s $CWD/$PRGNAM-$VERSION-$EXTRABIT.src.rpm .
rpm2tgz $PRGNAM-$VERSION-$EXTRABIT.src.rpm
tar xvf $PRGNAM-$VERSION-$EXTRABIT.src.tgz
rm $PRGNAM-$VERSION-$EXTRABIT.src.tgz

tar xvf $TARNAM
#we remove the tarnam as the original is an rpm
#this keeps things tidy.
rm $TARNAM

cd $PRGNAM-$VERSION
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \+ -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+

echo "patch configure.ac"
sed -i 's_/opt/lsb/bin/lsbc++_/usr/bin/c++_g' configure.ac
sed -i '/^AM_INIT_AUTOMAKE/a AM_PROG_AR()' configure.ac
#fix typo in path of udev stuff
sed -i 's_/ect_/etc_g' configure.ac
#fix source code. We shouldn't have to do this, but hey ho!....
mv EPSCommonLib/epsmp/linux/XAsyncSocket.cpp EPSCommonLib/epsmp/linux/XAsyncSocket.c
#patch png files to remove incorrect sRGB profile in all of them.
mogrify -strip PrinterUtility/Images/*.png
#patch the Resources.qrc file to include missing png's
sed -i 'sZInklow.png</file>ZInklow.png</file>\n        <file>Images/Inklow_.png</file>\n        <file>Images/printer_status_OLD.png</file>\n        <file>Images/printer_status_error_laser.png</file>\n        <file>Images/printer_status_warning_laser.png</file>\n        <file>Images/warning.png</file>Zg' PrinterUtility/Resources.qrc
#we need to regenerate qrc_Resources.cpp (which would have been generated by qmake)
#as the one shipped has all the png's with iCCP invalid sRGB profiles.
#echo "create new qrc_resources.cpp file using our patched Resources.qrc file"
#and patch source so it can find class definition for qt5

cd PrinterUtility
sed -i '1i_QT += widgets' PrinterUtility.pro
rm -f qrc_Resources.cpp
rcc -o qrc_Resources.cpp Resources.qrc
sed -i 's_QWidget>_QWidget>\n#include "qboxlayout.h"\n#include "qlabel.h"_g' EPUView.h
sed -i 's_Controller.h"_Controller.h"\n#include "qpushbutton.h"_g' EPUMaintenanceGuideView.h
sed -i 's_QDialog>_QDialog>\n#include "qlistview.h"\n#include "qpushbutton.h"\n#include "qboxlayout.h"\n#include "qapplication.h"_g' EPUPrinterListDialog.h
sed -i 's_QTimer>_QTimer>\n#include "qgroupbox.h"_g' EPUMainView.h
sed -i 's_QTimer>_QTimer>\n#include "qapplication.h"_g' EPUMainController.cpp
sed -i 's_QFont>_QFont>\n#include "qapplication.h"\n#include "qdesktopwidget.h"_g' EPUMainWindow.cpp

cd ..

#echo "now we have a resources file with fixed pngs embeded in it"
#lets run qmake :-) - or lets not. it looks like a bunch of stuff is missing.!
#the list of stuff reported missing by qmake was sent to linux-printer@epson.jp 28/09/2020
#with a request for them to include the missing source code. hopefully they will supply
#the missing code, so we can update this script and remove some of the patches.

#keep next few lines incase we can actually use it in the future.
#cd PrinterUtility
#qmake PrinterUtility.pro
#cd ..

echo "===fix Makefile.am files prior to running autoreconf==="
#fix hardcoded /opt/lsb stuff so that autoreconf generates correct Makefile.in
sed -i 's_/opt/lsb_/usr_g' EPSCommonLib/Makefile.am
sed -i 's_/libQt_/libQt5_g' EPSCommonLib/Makefile.am
sed -i 's_usr/include_usr/include/qt5_g' EPSCommonLib/Makefile.am

sed -i 's_/opt/lsb_/usr_g' PrinterUtility/Makefile.am
sed -i 's_usr/include_usr/include/qt5_g' PrinterUtility/Makefile.am
sed -i 's_qt5/QtNetwork_qt5/QtNetwork \\\n   -I/usr/include/qt5/QtWidgets_g' PrinterUtility/Makefile.am
sed -i 's_libQt_libQt5_g' PrinterUtility/Makefile.am
sed -i 's_libcups.so_libcups.so \\\n   /usr/\$\(LIBARCH\)/libQt5Widgets.so_g' PrinterUtility/Makefile.am

echo "running aclocal"
aclocal
echo "running autoreconf"
autoreconf --install --force

echo "================="
echo "running configure"
echo "================="
#CFLAGS="$SLKCFLAGS -fpermissive -I/usr/include/qt5 -I/usr/include/qt5/QtCore" \
#CXXFLAGS="$SLKCFLAGS -fpermissive -I/usr/include/qt5 -I/usr/include/qt5/QtCore" \


CC=/usr/bin/c++ \
CXX=/usr/bin/c++ \
CFLAGS="$SLKCFLAGS -fpermissive" \
CXXFLAGS="$SLKCFLAGS -fpermissive" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --includedir=/usr/include/qt5 \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --mandir=/usr/man \
  --docdir=/usr/doc/$PRGNAM-$VERSION \
  --datarootdir=/usr/share \
  --disable-static \
  --build=$ARCH-slackware-linux

echo "more patching of source files"
#add missing header for sleep
sed -i "1 i #include <unistd.h>" PrinterUtility/EPUMainController.cpp
sed -i "1 i #include <unistd.h>" PrinterUtility/EPUPrinterListDialog.cpp
#we need to patch the moc files so they work with qt 5.15.3 that ships with slackware 15.0
#when the source is complete and we can run qmake, that should fix this
#for qt 5.15.3 MOC_OUTPUT_REVISION is 67 this number can be found in
#/usr/include/qt5/QtCore/qobjectdefs.h

#fix moc files so version check works with qt5.15.3
#we do this because epson is missing the NozzlecheckResultView.h
#file, so we can't recreate it.
for i in `ls PrinterUtility/moc_*.cpp`; do
  sed -i 's/59/67/g' $i
done
#lets recreate moc files from .h files
cd PrinterUtility
  for i in EPUMainView EPUMainWindow EPUMaintenanceGuideView EPUOperationView EPUPrinterListDialog EPUView ;do
    rm moc_$i.cpp  #remove existing moc file
    moc $i.h >moc_$i.cpp    #create new moc file
  done
  rm moc_EThread.cpp
  moc ../EPUCommon/EThread.h >moc_EThread.cpp
cd ..
#this one is taken from outside the directory

#patch hardcoded path in Main.cpp so it can find language files
sed -i "s_/opt/epson_/usr/share/epson_g" PrinterUtility/Main.cpp
#fix linking to qt5 stuff instead of qt4. should be fixed with .am fix
#sed -i "s_libQt_libQt5_g" EPSCommonLib/Makefile.in
echo "=================="
echo "running make"
echo "============="

make

echo "============"
echo "running make install"

make install DESTDIR=$PKG
#as make install doesn't do much we do it manually
mkdir -p $PKG/usr/bin
cp -a PrinterUtility/epson-printer-utility $PKG/usr/bin/
#udev rule to allow set permissions so any user can monitor the printer.
mkdir -p $PKG/etc/udev/rules.d
cp -a support-tool/79-udev-epson.rules $PKG/etc/udev/rules.d/
mkdir -p $PKG/usr/share/epson-printer-utility/resource/Languages
mv $PKG/usr/resource/Languages/*.qm $PKG/usr/share/epson-printer-utility/resource/Languages/
rm -r $PKG/usr/resource
mkdir -p $PKG/usr/share/pixmaps
cp PrinterUtility/Images/AppIcon.png $PKG/usr/share/pixmaps/epson-printer-utility.png
#+-----------------------------------------------------------+
#| we now have to process the communication daemon           |
#+-----------------------------------------------------------+
echo "qt part of utility done, now for daemon"
cd $TOPDIR
rm -rf epson-backend-$VERSION
tar xvf epson-backend-$VERSION.tar.gz
#we remove the tarnam as the original is an rpm
#this keeps things tidy.
rm epson-backend-$VERSION.tar.gz
cd epson-backend-$VERSION
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \+ -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+

echo "running aclocal"
aclocal
echo "running autoreconf"
autoreconf --install --force

echo "running configure"

CC=/usr/bin/gcc \
CXX=/usr/bin/c++ \
CFLAGS="$SLKCFLAGS -Wno-unused-but-set-variable -Wno-unused-function -Wno-implicit-function-declaration -Wno-pointer-sign -Wno-unused-variable" \
CXXFLAGS="$SLKCFLAGS -fpermissive" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --mandir=/usr/man \
  --docdir=/usr/doc/$PRGNAM-$VERSION \
  --disable-static \
  --build=$ARCH-slackware-linux

echo "patching source for backend daemon. epmnt.c"
sed -i "1 i #include <stdlib.h>\n#include <string.h>" daemon/epmnt.c
echo "running make"
make -C src libcutils.la   # 20220307 bkw: this one wasn't being made
make
echo "running make install"
make install DESTDIR=$PKG

#now lets tidy everything up. after all, we are not debian :-)
#there are three important program files, /usr/bin/epson-printer-utility
#/usr/lib/epson-backend/ecbd the communication daemon, and 
#/usr/lib64/cups/backend/ecblp  the cups backend
#we will trash the contents of /usr/lib64/epson-backend  for now, it looks like it is just debian daemon stuff.
#we need to create our own rc.ecbd file to start/stop/restart the backend
#this should be added into rc.local to make it active at startup
rm -r $PKG/usr/lib$LIBDIRSUFFIX/epson-backend
mkdir -p $PKG/etc/rc.d
cp $CWD/rc.ecbd $PKG/etc/rc.d/rc.ecbd.new
#the utility won't work without the daemon, so reduce steps admin has to do to get
#things working on a clean install.
chmod +x $PKG/etc/rc.d/rc.ecbd.new

mkdir -p $PKG/usr/share/applications
cp $CWD/epson-printer-utility.desktop $PKG/usr/share/applications

find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a AUTHORS COPYING NEWS README $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh >$PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE