pack.sh
19 KB
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
#!/bin/bash
#
# "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
# (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
# aplicativos mainframe. Registro no INPI sob o nome G3270.
#
# Copyright (C) <2008> <Banco do Brasil S.A.>
#
# Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
# os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
# Free Software Foundation.
#
# Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
# GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
# A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
# obter mais detalhes.
#
# Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
# programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
# St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Contatos:
#
# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
# erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
#
#
PRODUCT_NAME="pw3270"
LIBRARY_NAME="lib3270"
CORE_LIBRARIES="lib3270 libv3270 libipc3270"
PACKAGE_PLUGINS=""
PACKAGE_EXTRAS="libhllapi"
TARGET_ARCHS="x86_64 x86_32"
GIT_URL="https://github.com/PerryWerneck"
BUILD_UNSTABLE=0
MAKE_ZIP=0
PROJECTDIR=$(dirname $(dirname $(readlink -f ${0})))
WORKDIR=$(mktemp -d)
PUBLISH=0
GET_PREREQS=0
CERTS_DIR=${WORKDIR}/certs
PAUSE_ON_ERROR=0
if [ -e /etc/os-release ]; then
. /etc/os-release
fi
if [ -e ~/.config/user-dirs.dirs ]; then
. ~/.config/user-dirs.dirs
fi
#
# Limpa diretório temporário
#
cleanup()
{
rm -fr ${WORKDIR}
}
failed()
{
echo "$@"
if [ "${PAUSE_ON_ERROR}" != "0" ]; then
echo "Type exit to end build script"
/bin/bash
fi
cleanup
exit -1
}
#
# Get Sources from GIT
#
clone()
{
echo -e "\e]2;Cloning ${1}\a"
echo "Cloning ${1}"
mkdir -p ${WORKDIR}/sources
if [ "${BUILD_UNSTABLE}" == "1" ]; then
BRANCH="develop"
else
TEMPVAR=${1}_branch
BRANCH=${!TEMPVAR}
fi
echo "Cloning ${1} ${BRANCH}"
if [ -z ${BRANCH} ]; then
git clone --quiet ${GIT_URL}/${1}.git ${WORKDIR}/sources/${1}
else
echo -e "\e]2;Cloning ${1} ${BRANCH}\a"
git clone --quiet --branch "${BRANCH}" ${GIT_URL}/${1}.git ${WORKDIR}/sources/${1}
fi
if [ "$?" != "0" ]; then
failed "Can't get ${BRANCH} sources for ${1}"
fi
}
prepare()
{
echo -e "\e]2;Preparing ${1}\a"
echo "Preparing ${1}"
if [ -x ${PROJECTDIR}/win/prepare.${1} ]; then
pushd ${WORKDIR}/sources/${1}
${PROJECTDIR}/win/prepare.${1}
if [ "$?" != "0" ]; then
failed "Can't prepare ${1}"
fi
popd
fi
for ARCH in ${TARGET_ARCHS}
do
if [ -d ${WORKDIR}/sources/${1}/win/${ARCH} ]; then
for spec in $(find ${WORKDIR}/sources/${1}/win/${ARCH} -name "*.spec")
do
grep -i buildrequires "${spec}" | grep -v "%" | cut -d: -f2- | tr -d '[:blank:]' >> ${WORKDIR}/sources/pre-reqs
done
fi
done
}
#
# Configure
#
configure()
{
if [ "${GET_PREREQS}" != "0" ]; then
echo -e "\e]2;Installing pre-reqs\a"
echo "Installing pre-reqs"
echo "mingw32-cross-nsis" >> ${WORKDIR}/sources/pre-reqs
cat ${WORKDIR}/sources/pre-reqs \
| grep -v 3270 \
| sort --unique \
| xargs sudo zypper --non-interactive --quiet in
fi
echo -e "\e]2;Creating configuration\a"
echo "Creating configuration"
for DIR in $(find ${WORKDIR}/sources -maxdepth 1 -type d)
do
echo ${DIR}
cd ${DIR}
if [ -x ./autogen.sh ]; then
NOCONFIGURE=1 ./autogen.sh
if [ "$?" != "0" ]; then
failed "Erro em autogen.sh"
fi
fi
done
}
#
# Build library
#
buildLibrary()
{
echo "Building library ${1}"
for ARCH in ${TARGET_ARCHS}
do
echo -e "\e]2;Building ${1} for ${ARCH}\a"
echo "Building ${1} for ${ARCH}"
case ${ARCH} in
x86_32)
host=i686-w64-mingw32
host_cpu=i686
prefix=/usr/i686-w64-mingw32/sys-root/mingw
tools=i686-w64-mingw32
pkg_config=/usr/bin/i686-w64-mingw32-pkg-config
;;
x86_64)
host=x86_64-w64-mingw32
host_cpu=x86_64
prefix=/usr/x86_64-w64-mingw32/sys-root/mingw
tools=x86_64-w64-mingw32
pkg_config=/usr/bin/x86_64-w64-mingw32-pkg-config
;;
*)
failed "Arquitetura desconhecida: ${ARCH}"
esac
# Create install dirs
mkdir -p ${WORKDIR}/build/${ARCH}
mkdir -p ${WORKDIR}/cache/${ARCH}
mkdir -p ${WORKDIR}/build/${ARCH}/locale
mkdir -p ${WORKDIR}/build/${ARCH}/include
export PKG_CONFIG_PATH=${WORKDIR}/build/${ARCH}/lib/pkgconfig
export cache=${WORKDIR}/cache/${ARCH}/${1}.cache
cd ${WORKDIR}/sources/${1}
if [ -x ${PROJECTDIR}/win/configure.${1} ]; then
host="${host}" \
prefix="${prefix}" \
BUILDDIR="${WORKDIR}/build/${ARCH}" \
CFLAGS="-I${WORKDIR}/build/${ARCH}/include" \
CXXFLAGS="-I${WORKDIR}/build/${ARCH}/include" \
LDFLAGS="-L${WORKDIR}/build/${ARCH}" \
${PROJECTDIR}/win/configure.${1}
else
./configure \
CFLAGS="-I${WORKDIR}/build/${ARCH}/include" \
CXXFLAGS="-I${WORKDIR}/build/${ARCH}/include" \
LDFLAGS="-L${WORKDIR}/build/${ARCH}/lib" \
--host=${host} \
--prefix=${prefix} \
--with-product-name="${PRODUCT_NAME}" \
--bindir=${WORKDIR}/build/${ARCH}/bin \
--libdir=${WORKDIR}/build/${ARCH}/lib \
--includedir=${WORKDIR}/build/${ARCH}/include \
--sysconfdir=${WORKDIR}/build/${ARCH}/etc \
--datadir=${WORKDIR}/build/${ARCH}/share \
--datarootdir=${WORKDIR}/build/${ARCH}/share
fi
if [ "$?" != "0" ]; then
failed "Can't configure ${1}"
fi
make all
if [ "$?" != "0" ]; then
failed "Can't buid ${1}"
fi
make install
if [ "$?" != "0" ]; then
failed "Can't install ${1}"
fi
done
}
#
# Build language binding
#
buildExtraPackage()
{
echo "Building ${1}"
for ARCH in ${TARGET_ARCHS}
do
echo -e "\e]2;Building ${1} for ${ARCH}\a"
echo "Building ${1} for ${ARCH}"
case ${ARCH} in
x86_32)
host=i686-w64-mingw32
host_cpu=i686
prefix=/usr/i686-w64-mingw32/sys-root/mingw
tools=i686-w64-mingw32
pkg_config=/usr/bin/i686-w64-mingw32-pkg-config
;;
x86_64)
host=x86_64-w64-mingw32
host_cpu=x86_64
prefix=/usr/x86_64-w64-mingw32/sys-root/mingw
tools=x86_64-w64-mingw32
pkg_config=/usr/bin/x86_64-w64-mingw32-pkg-config
;;
*)
failed "Arquitetura desconhecida: ${ARCH}"
esac
# Required for lib3270 build tools
export HOST_CC=/usr/bin/gcc
# Required for .NET bindings
export GACROOT=${WORKDIR}/build/${ARCH}/mono/gacroot
export GAPIROOT=${WORKDIR}/build/${ARCH}/mono/gapi-2.0
export MONOLIBPATH=${WORKDIR}/build/${ARCH}/mono/lib
# Create install dirs
mkdir -p ${WORKDIR}/build/${ARCH}
mkdir -p ${WORKDIR}/cache/${ARCH}
mkdir -p ${WORKDIR}/build/${ARCH}/locale
mkdir -p ${WORKDIR}/build/${ARCH}/include
export PKG_CONFIG_PATH=${WORKDIR}/build/${ARCH}/lib/pkgconfig
export cache=${WORKDIR}/cache/${ARCH}/${1}.cache
cd ${WORKDIR}/sources/${1}
if [ -x ${PROJECTDIR}/win/configure.${1} ]; then
host="${host}" \
prefix="${prefix}" \
BUILDDIR="${WORKDIR}/build/${ARCH}" \
CFLAGS="-I${WORKDIR}/build/${ARCH}/include" \
CXXFLAGS="-I${WORKDIR}/build/${ARCH}/include" \
LDFLAGS="-static-libgcc -static-libstdc++ -L${WORKDIR}/build/${ARCH}" \
${PROJECTDIR}/win/configure.${1}
else
./configure \
CFLAGS="-I${WORKDIR}/build/${ARCH}/include" \
CXXFLAGS="-I${WORKDIR}/build/${ARCH}/include" \
LDFLAGS="-static-libgcc -static-libstdc++ -L${WORKDIR}/build/${ARCH}/lib" \
--host=${host} \
--prefix=${prefix} \
--with-product-name="${PRODUCT_NAME}" \
--bindir=${WORKDIR}/build/${ARCH}/bin \
--libdir=${WORKDIR}/build/${ARCH}/lib \
--includedir=${WORKDIR}/build/${ARCH}/include \
--sysconfdir=${WORKDIR}/build/${ARCH}/etc \
--datadir=${WORKDIR}/build/${ARCH}/share \
--datarootdir=${WORKDIR}/build/${ARCH}/share
fi
if [ "$?" != "0" ]; then
failed "Can't configure ${1}"
fi
make all
if [ "$?" != "0" ]; then
failed "Can't buid ${1}"
fi
make install
if [ "$?" != "0" ]; then
failed "Can't install ${1}"
fi
done
}
#
# Build main application
#
buildApplication()
{
for ARCH in ${TARGET_ARCHS}
do
echo -e "\e]2;Building ${1} for ${ARCH}\a"
echo "Building ${1} for ${ARCH}"
case ${ARCH} in
x86_32)
host=i686-w64-mingw32
host_cpu=i686
prefix=/usr/i686-w64-mingw32/sys-root/mingw
tools=i686-w64-mingw32
pkg_config=/usr/bin/i686-w64-mingw32-pkg-config
;;
x86_64)
host=x86_64-w64-mingw32
host_cpu=x86_64
prefix=/usr/x86_64-w64-mingw32/sys-root/mingw
tools=x86_64-w64-mingw32
pkg_config=/usr/bin/x86_64-w64-mingw32-pkg-config
;;
*)
failed "Arquitetura desconhecida: ${ARCH}"
esac
mkdir -p ${WORKDIR}/build/${ARCH}
mkdir -p ${WORKDIR}/cache/${ARCH}
mkdir -p ${WORKDIR}/build/${ARCH}/locale
mkdir -p ${WORKDIR}/build/${ARCH}/include
export HOST_CC=/usr/bin/gcc
export PKG_CONFIG_PATH=${WORKDIR}/build/${ARCH}/lib/pkgconfig
export cache=${WORKDIR}/cache/${ARCH}/${1}.cache
cd ${WORKDIR}/sources/${1}
for NSI in $(find ./win -name '*.nsi.in')
do
SRCNAME="${PROJECTDIR}/win/$(basename ${NSI})"
if [ -e "${SRCNAME}" ]; then
cp "${SRCNAME}" "${NSI}"
if [ "$?" != "0" ]; then
failed "Can't copy ${SRCNAME}"
fi
fi
done
if [ -x ${PROJECTDIR}/win/configure.${1} ]; then
host="${host}" \
prefix="${prefix}" \
BUILDDIR="${WORKDIR}/build/${ARCH}" \
CFLAGS="-I${WORKDIR}/build/${ARCH}/include" \
LDFLAGS="-L${WORKDIR}/build/${ARCH}" \
${PROJECTDIR}/win/configure.${1}
else
./configure \
CFLAGS="-I${WORKDIR}/build/${ARCH}/include" \
LDFLAGS="-L${WORKDIR}/build/${ARCH}/lib" \
--host=${host} \
--prefix=${prefix} \
--bindir=${WORKDIR}/build/${ARCH}/bin \
--libdir=${WORKDIR}/build/${ARCH}/lib \
--includedir=${WORKDIR}/build/${ARCH}/include \
--sysconfdir=${WORKDIR}/build/${ARCH}/etc \
--datadir=${WORKDIR}/build/${ARCH}/share \
--datarootdir=${WORKDIR}/build/${ARCH}/share
fi
if [ "$?" != "0" ]; then
failed "Can't configure ${1}"
fi
make all
if [ "$?" != "0" ]; then
failed "Can't buid ${1}"
fi
make install
if [ "$?" != "0" ]; then
failed "Can't install ${1}"
fi
if [ -x ${PROJECTDIR}/win/install.${1} ]; then
pushd "${WORKDIR}/build/${ARCH}"
echo "Executando install.${1} em ${PWD}"
${PROJECTDIR}/win/install.${1}
if [ "$?" != "0" ]; then
failed "Can't install ${1}"
fi
popd
fi
for NSI in $(find ./win -name '*.nsi')
do
cp "${NSI}" "${WORKDIR}/build/${ARCH}"
if [ "$?" != "0" ]; then
failed "Can't copy ${NSI}"
fi
done
if [ -e ./win/makeruntime.sh ]; then
cp "./win/makeruntime.sh" "${WORKDIR}/build/${ARCH}/${1}-makeruntime.sh"
if [ "$?" != "0" ]; then
failed "Can't copy ${1}.makeruntime.sh"
fi
fi
if [ -e branding/${PRODUCT_NAME}.svg ]; then
convert -density 384 -background transparent branding/${PRODUCT_NAME}.svg -define icon:auto-resize -colors 256 ${WORKDIR}/build/${ARCH}/${PRODUCT_NAME}.ico
if [ "$?" != "0" ]; then
cleanup
exit -1
fi
elif [ -e branding/${1}.svg ]; then
convert -density 384 -background transparent branding/${1}.svg -define icon:auto-resize -colors 256 ${WORKDIR}/build/${ARCH}/${PRODUCT_NAME}.ico
if [ "$?" != "0" ]; then
cleanup
exit -1
fi
fi
for doc in LICENSE LICENCA README.md AUTHORS
do
if [ -e ${doc} ]; then
cp ${doc} ${WORKDIR}/build/${ARCH}
if [ "$?" != "0" ]; then
cleanup
exit -1
fi
fi
done
done
}
#
# Make runtime
#
makeRuntime()
{
for ARCH in ${TARGET_ARCHS}
do
echo -e "\e]2;Building runtime for ${ARCH}\a"
echo "Building runtime for ${ARCH}"
rm -fr ${WORKDIR}/build/${ARCH}/runtime
mkdir -p ${WORKDIR}/build/${ARCH}/runtime
for SCRIPT in ${WORKDIR}/build/${ARCH}/*-makeruntime.sh
do
chmod +x ${SCRIPT}
cd ${WORKDIR}/build/${ARCH}
${SCRIPT} --output-dir="${WORKDIR}/build/${ARCH}/runtime" --bindir="${WORKDIR}/build/${ARCH}"
if [ "$?" != "0" ]; then
failed "Error on ${SCRIPT}"
fi
done
done
}
#
# Copy file
#
copy_install_file() {
FILENAME=${PROJECTDIR}/$(basename ${1})
rm -f "${FILENAME}"
cp -v "${1}" "${FILENAME}"
if [ "$?" != "0" ]; then
failed "Can't copy ${1} to ${FILENAME}"
fi
if [ ${BUILD_UNSTABLE} == "1" ]; then
TARGET_PATH="/${PRODUCT_NAME}/unstable/${ARCH}"
else
TARGET_PATH="/${PRODUCT_NAME}/stable/${ARCH}"
fi
if [ -d ~/public_html/win/${PRODUCT_NAME} ]; then
mkdir -p ~/public_html/win/${TARGET_PATH}
ln -f -v "${FILENAME}" ~/public_html/win/${TARGET_PATH}
if [ "$?" != "0" ]; then
failed "Can't link ${1} to ~/public_html/win/${TARGET_PATH}"
fi
fi
if [ ! -z "${XDG_PUBLICSHARE_DIR}" ] && [ -d "${XDG_PUBLICSHARE_DIR}/${PRODUCT_NAME}" ]; then
mkdir -p "${XDG_PUBLICSHARE_DIR}/${TARGET_PATH}"
if [ "$?" != "0" ]; then
failed "Can't create ${XDG_PUBLICSHARE_DIR}/${TARGET_PATH}"
fi
ln -f -v "${FILENAME}" ${XDG_PUBLICSHARE_DIR}/${TARGET_PATH}
if [ "$?" != "0" ]; then
failed "Can't link ${1} to ~/${XDG_PUBLICSHARE_DIR}/${TARGET_PATH}"
fi
fi
if [ "${PUBLISH}" == "1" ] && [ ! -z ${WIN_PACKAGE_SERVER} ]; then
scp "${FILENAME}" ${WIN_PACKAGE_SERVER}/${TARGET_PATH}
if [ "$?" != "0" ]; then
failed "Can't publish ${1} to ${WIN_PACKAGE_SERVER}/${TARGET_PATH}"
fi
fi
}
#
# Make packages
#
makeInstaller()
{
NSIS_ARGS="-DWITHGTK -DWITHIPC -DWITHPLUGINS -DWITHSDK"
if [ -d ${CERTS_DIR} ]; then
NSIS_ARGS="${NSIS_ARGS} -DWITHCERTS"
fi
if [ ! -z "${PACKAGE_EXTRAS}" ]; then
NSIS_ARGS="${NSIS_ARGS} -DWITHEXTRAS"
fi
for ARG in $(echo ${PACKAGE_PLUGINS} | tr "[:lower:]" "[:upper:]") $(echo ${PACKAGE_EXTRAS} | tr "[:lower:]" "[:upper:]")
do
NSIS_ARGS="${NSIS_ARGS} -DWITH${ARG}"
done
for ARCH in ${TARGET_ARCHS}
do
echo -e "\e]2;Creating installers for ${ARCH}\a"
echo "Creating installers for ${ARCH}"
if [ -d ${CERTS_DIR} ]; then
mkdir -p ${WORKDIR}/build/${ARCH}/sslcerts
cp -rv ${CERTS_DIR}/* ${WORKDIR}/build/${ARCH}/sslcerts
if [ "$?" != "0" ]; then
failed "Can't copy certs"
fi
fi
if [ -d ${PROJECTDIR}/ui ]; then
mkdir -p ${WORKDIR}/build/${ARCH}/${PRODUCT_NAME}/ui
cp -rv ${PROJECTDIR}/ui/* ${WORKDIR}/build/${ARCH}/${PRODUCT_NAME}/ui
if [ "$?" != "0" ]; then
failed "Can't copy UI files"
fi
fi
cd ${WORKDIR}/build/${ARCH}
# Remove duplicates
fdupes -q -p -n -H -o name -r . |
while read _file
do
if test -z "$_target" ; then
_target="$_file";
else
if test -z "$_file" ; then
_target="";
continue ;
fi ;
ln -f "$_target" "$_file";
fi ;
done
TARCH=${ARCH}
if [ "${TARCH}" == "x86_32" ]; then
TARCH="i686"
fi
if [ "${MAKE_ZIP}" == "1" ]; then
ZIPNAME="${WORKDIR}/build/${ARCH}/${PRODUCT_NAME}-${ARCH}-bin.zip"
rm -f "${ZIPNAME}"
zip -9 -j "${ZIPNAME}" bin/*
copy_install_file "${ZIPNAME}"
pushd runtime
ZIPNAME="${WORKDIR}/build/${ARCH}/${PRODUCT_NAME}-${ARCH}-runtime.zip"
rm -f "${ZIPNAME}"
zip -9 -r "${ZIPNAME}" *
copy_install_file "${ZIPNAME}"
popd
fi
for NSI in *.nsi
do
makensis ${NSIS_ARGS} ${NSI}
if [ "$?" != "0" ]; then
echo makensis ${NSIS_ARGS} ${NSI}
failed "Error building ${ARCH} ${NSI}"
fi
for FILE in *-[0-9]*-${TARCH}.exe
do
copy_install_file ${FILE}
done
done
done
}
#
# Add repos
#
addRepos() {
for ARCH in ${TARGET_ARCHS}
do
case ${ARCH} in
x86_32)
sudo zypper ar obs://windows:mingw:win32 mingw32
;;
x86_64)
sudo zypper ar obs://windows:mingw:win64 mingw64
;;
*)
failed "Arquitetura desconhecida: ${ARCH}"
esac
done
sudo zypper ar obs://home:PerryWerneck:pw3270 pw3270
sudo zypper ref
}
#
# Check command line parameters
#
until [ -z "$1" ]
do
if [ ${1:0:2} = '--' ]; then
tmp=${1:2}
parameter=${tmp%%=*}
parameter=$(echo $parameter | tr "[:lower:]" "[:upper:]")
value=${tmp##*=}
case "$parameter" in
NO-NOPUBLISH)
PUBLISH=0
;;
PUBLISH)
PUBLISH=1
;;
PRODUCT-NAME)
PRODUCT_NAME=${value}
;;
SOURCES-FROM)
GIT_URL=${value}
;;
CERTS-FROM)
CERTS_DIR=${value}
;;
ADD-REPOS)
addRepos
exit 0
;;
CLEAR)
if [ -d ~/public_html/win/${PRODUCT_NAME} ]; then
rm -fr ~/public_html/win/${PRODUCT_NAME}/{x86_32,x86_64}
fi
if [ ! -z "${XDG_PUBLICSHARE_DIR}" ] && [ -d "${XDG_PUBLICSHARE_DIR}/${PRODUCT_NAME}" ]; then
rm -fr ${XDG_PUBLICSHARE_DIR}/${PRODUCT_NAME}/{x86_32,x86_64}
fi
;;
EXTRA-PACKAGES)
PACKAGE_EXTRAS=$(echo ${value} | sed "s@,@ @g")
;;
TARGET-ARCHS)
TARGET_ARCHS=${value}
;;
NO-PRE-REQS)
GET_PREREQS=0
;;
PRE-REQS)
GET_PREREQS=1
;;
PROJECT-PATH)
PROJECTDIR=$(readlink -f ${value})
;;
UNSTABLE)
BUILD_UNSTABLE=1
;;
DEVELOP)
BUILD_UNSTABLE=1
;;
SHELL-ON-ERROR)
PAUSE_ON_ERROR=1
;;
NO_ZIP)
MAKE_ZIP=0
;;
ZIP)
MAKE_ZIP=1
;;
HELP)
echo "${0} [options]"
echo ""
echo "Options:"
echo ""
echo " --product-name Set the product name (current is ${PRODUCT_NAME})"
echo " --project-path Set the path for the customization data"
echo " --target-archs Set the target architectures (current are ${TARGET_ARCHS})"
echo " --sources-from Base URL of the git server with the sources (current is ${GIT_URL})"
echo " --no-pre-reqs Don't try to install required packages"
echo " --pre-reqs Install required packages"
echo " --shell-on-error Open a shell when the build process failed"
echo " --unstable Build unstable version"
if [ "${MAKE_ZIP}" == "1" ]; then
echo " --no-zip Don't create zip file"
else
echo " --zip Create zip file"
fi
if [ ! -z ${WIN_PACKAGE_SERVER} ]; then
echo " --no-publish Don't publish binaries in ${WIN_PACKAGE_SERVER}/${PRODUCT_NAME}"
echo " --publish Publish binaries in ${WIN_PACKAGE_SERVER}/${PRODUCT_NAME}"
else
if [ -x ~/bin/sync.${PRODUCT_NAME} ]; then
echo " --no-publish Don't call ~/bin/sync.${PRODUCT_NAME}"
echo " --publish Call ~/bin/sync.${PRODUCT_NAME} when build finishes"
fi
fi
if [ -d ~/public_html/win/${PRODUCT_NAME} ]; then
echo " --clear Replace the contents of public folders"
fi
echo ""
exit 0
;;
esac
fi
shift
done
#
# Load customizations
#
if [ -e ${PROJECTDIR}/win/pack.conf ]; then
. ${PROJECTDIR}/win/pack.conf
fi
#
# Download sources
#
for src in ${CORE_LIBRARIES}
do
echo "Core library: ${src}"
clone ${src}
prepare ${src}
done
clone pw3270
prepare pw3270
for src in ${PACKAGE_PLUGINS}
do
echo "Plugin module: ${src}"
clone pw3270-plugin-${src}
prepare pw3270-plugin-${src}
done
for src in ${PACKAGE_EXTRAS}
do
echo "Extra package: ${src}"
clone ${src}
prepare ${src}
done
#
# Build packages
#
configure
for src in ${CORE_LIBRARIES}
do
buildLibrary ${src}
done
buildApplication pw3270
for src in ${PACKAGE_PLUGINS}
do
buildLibrary pw3270-plugin-${src}
done
for src in ${PACKAGE_EXTRAS}
do
buildExtraPackage ${src}
done
#
# Create runtime
#
makeRuntime
makeInstaller
if [ "${PUBLISH}" == "1" ] && [ -x ~/bin/sync.${PRODUCT_NAME} ]; then
echo "Calling sync script..."
~/bin/sync.${PRODUCT_NAME}
if [ "$?" != "0" ]; then
failed "Can't sync folders"
fi
fi
cleanup