-
Notifications
You must be signed in to change notification settings - Fork 3
/
create-standalone.sh
978 lines (818 loc) · 31.1 KB
/
create-standalone.sh
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
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
#!/bin/bash
#
# This script creates a Mac OS X NorduGrid ARC standalone package.
# The following environment variables are used to control the outcome:
# ARC_BUILD_CHANNEL (nightlies, releases, testing, experimental)
# ARC_BUILD_VERSION (e.g. 1970-01-01, 1.0.0...)
# ARC_BUILD_ARCHITECTURE (x86_64, i386)
# ARC_BUILD_MAKECHECK (no, yes)
# ARC_BUILD_GLOBUS (yes, no)
# ARC_BUILD_INTERACTIVE (no, yes)
# ARC_BUILD_DEBUG (no, yes)
#
# TODO:
# * Upload package to download.nordugrid.org
# * Add a 'Finish Up' entry in the installer
test "x${ARC_BUILD_DEBUG}" == "xyes" && set -x
## DEFAULT VALUES.
# Install package to the specified location. Note that the specified location should be a path used exclusively for the standalone.
location=/opt/local/nordugrid
name=nordugrid-arc-standalone
arcglobusmoduledir=globus-plugins
# The metapackage should contain the following packages (order matters!):
#deppackages=(zlib libiconv libxml2 gettext libsigcxx2 glib2 glibmm libtool)
deppackages=(libiconv gettext libtool libsigcxx2 glib2 glibmm)
# The following globus packages are needed for a working ARC0 middleware module. Order matters.
globuspkgs=(libtool common callout openssl gsi-openssl-error gsi-proxy-ssl openssl-module \
gsi-cert-utils gsi-sysconfig gsi-callback gsi-credential gsi-proxy-core \
gssapi-gsi gss-assist gssapi-error xio xio-gsi-driver io xio-popen-driver \
ftp-control ftp-client rls-client)
###
function initialise() {
basedir=`pwd`
workdir=`mktemp -d /tmp/arcstandalone-workdir-XXXXXX`
cd ${workdir}
rm -rf ${location}/*
mkdir ${HOME}/.macports
mkdir -p macports/{registry,logs,software,build}
ln -s /opt/local/var/macports/sources macports/sources
cp -p /opt/local/var/macports/registry/registry.db macports/registry/.
touch macports/variants.conf
return 0
}
function toggleownmacportconf() {
if test "${1}" = "on"; then
if test -L ${HOME}/.macports/macports.conf; then
if test "`readlink ${HOME}/.macports/macports.conf`" = "${workdir}/macports.conf"; then
return
else
rm ${HOME}/.macports/macports.conf
fi
fi
if test -f ${HOME}/.macports/macports.conf; then
mv ${HOME}/.macports/macports.conf ${workdir}/macports.conf.orig
fi
cat << EOF > ${workdir}/macports.conf
# Set the directory in which to install ports. Must match where MacPorts itself is installed.
prefix /opt/local
# Where to store MacPorts working data
portdbpath ${workdir}/macports
applications_dir /Applications/MacPorts
frameworks_dir /opt/local/Library/Frameworks
sources_conf /opt/local/etc/macports/sources.conf
variants_conf ${workdir}/macports/variants.conf
binpath ${location}/bin:/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
universal_archs x86_64 i386
EOF
ln -s ${workdir}/macports.conf ${HOME}/.macports/macports.conf
elif test "${1}" = "off"; then
if test -L ${HOME}/.macports/macports.conf && test "`readlink ${HOME}/.macports/macports.conf`" = "${workdir}/macports.conf"; then
rm ${HOME}/.macports/macports.conf
if test -f ${workdir}/macports.conf.orig; then
mv ${workdir}/macports.conf.orig ${HOME}/.macports/macports.conf
fi
fi
fi
}
function requiredpackagescheck() {
toggleownmacportconf on
# The following packages are required to be installed to build the stand-alone package.
requiredpkgs=(gsed gperf autoconf automake wget doxygen p5-archive-tar perl5)
pkgsneeded=
installedports=`port installed`
toggleownmacportconf off
for package in ${requiredpkgs[@]}
do
[[ `echo $installedports | grep -c $package` -eq 0 ]] && pkgsneeded="$pkgsneeded $package"
done
if test "x${pkgsneeded}x" != "xx"
then
echo "The following packages are required to build the stand-alone:"
echo $pkgsneeded
echo "Please install them."
return 1
fi
return 0
}
function fetchsource() {
# Source need to be downloaded to be able to calculate checksums. Remove old source first.
rm -rf ${workdir}/${name}/files
mkdir -p ${workdir}/${name}/files
if test ${type} == "nightlies"
then
if test "x${version}" == "x"; then
version=`date +%F`
fi
source=`wget -O - -q http://download.nordugrid.org/nightlies/nordugrid-arc/trunk/${version}/src | grep -o "nordugrid-arc-[0-9]\+.tar.gz" | head -1`
if test "x${source}" == "x"; then
echo "Unable to locate source."
return 1
fi
wget -q http://download.nordugrid.org/nightlies/nordugrid-arc/trunk/${version}/src/${source} -O ${workdir}/${name}/files/${source}
else
source=nordugrid-arc-${version}.tar.gz
wget -q http://download.nordugrid.org/software/nordugrid-arc/${type}/${version}/src/${source} -O ${workdir}/${name}/files/${source}
fi
if [[ $? != 0 ]]
then
echo "Unable to fetch source."
return 1
fi
return 0
}
function createportfile() {
if test ! -f ${workdir}/${name}/files/${source}; then
echo "Unable to create Portfile. Source ${workdir}/${name}/files/${source} does not exist."
return 1
fi
# Calculate and insert checksums and insert version.
md5=`md5 ${workdir}/${name}/files/${source} | awk '{ print $NF }'`
sha1=`openssl sha1 ${workdir}/${name}/files/${source} | awk '{ print $NF }'`
rmd160=`openssl rmd160 ${workdir}/${name}/files/${source} | awk '{ print $NF }'`
cat << EOF > ${workdir}/${name}/Portfile
set sourcename nordugrid-arc
PortSystem 1.0
name \${sourcename}-standalone
version ${version}
categories grid
maintainers NorduGrid
description \${version} release of the Advanced Resource Connector (ARC)
long_description \\
The Advanced Resource Connector (ARC) middleware, introduced by \\
NorduGrid (www.nordugrid.org), is an open source software solution \\
enabling production quality computational and data Grids since May \\
2002.
homepage http://www.nordugrid.org
platforms darwin
distfiles ${source}
checksums md5 ${md5} \\
sha1 ${sha1} \\
rmd160 ${rmd160}
worksrcdir ${source//.tar.gz}
pre-configure {
reinplace "s/@MSGMERGE@ --update/@MSGMERGE@ --update --backup=off/" \${worksrcpath}/po/Makefile.in.in
reinplace "s/\\\/opt\\\/local/${location//\//\\\/}/g" \${worksrcpath}/Makefile.in
}
configure.env PKG_CONFIG_LIBDIR=\${prefix}/lib/pkgconfig:/usr/lib/pkgconfig
configure.args-append --disable-xmlsec1 --disable-all --enable-hed --enable-arclib-client --enable-credentials-client --enable-data-client --enable-srm-client --enable-doc --enable-cppunit
test.run yes
test.target check
post-destroot {
system "rm -rf \${destroot}/\${prefix}/share/arc/examples/config"
system "rm -rf \${destroot}/\${prefix}/share/arc/examples/echo"
system "rm -rf \${destroot}/\${prefix}/share/arc/profiles"
system "rm -rf \${destroot}/\${prefix}/share/arc/schema"
system "rm -rf \${destroot}/\${prefix}/share/doc"
system "rm -rf \${destroot}/\${prefix}/share/man/man8"
system "rm -rf \${destroot}/\${prefix}/sbin"
system "rm -rf \${destroot}/\${prefix}/libexec"
system "rm -rf \${destroot}/Library"
}
destroot.violate_mtree yes
EOF
return 0
}
function installpkgconfig() {
rm -rf ${workdir}/pkgconfig
mkdir ${workdir}/pkgconfig
port cat pkgconfig | sed -e :a -e '$!N;s/[[:space:]]*\\\n[[:space:]]*/ /;ta' \
| sed -e "s/\${name}/pkgconfig/g" \
| sed -e "s/\(name[[:space:]]*pkgconfig\)/\1-arcstandalone/" \
| sed -e "/^archcheck.files/d" \
| sed -e "s/^\(master_sites[[:space:]]*gnu\)/\1:pkgconfig/" > ${workdir}/pkgconfig/Portfile
gsed -i "/checksums/i \\
destroot.violate_mtree yes\\
" ${workdir}/pkgconfig/Portfile
gsed -i "
/^[[:space:]]*version[[:space:]]/a \\
distname pkgconfig-\${version}\\
" ${workdir}/pkgconfig/Portfile
# Make link to patch files.
[[ -d `port dir pkgconfig`/files ]] && ln -s `port dir pkgconfig`/files ${workdir}/pkgconfig/files
sleep 1
toggleownmacportconf on
port install -D pkgconfig prefix=${location} build_arch=${architecture}
if [[ $? -ne 0 ]]
then
echo "Unable to install pkgconfig"
toggleownmacportconf off
return 1
fi
toggleownmacportconf off
return 0
}
function insertpackage() {
pkgname=${1}
pkgversion=${2}
pkgdir=${name}-${version}.mpkg/Contents/
[[ "x${4}x" != "xx" ]] && pkgdir=${pkgdir}/Packages/${4}/Contents/
rm -rf ${pkgdir}/Packages/${pkgname}-arcstandalone-${pkgversion}.pkg
mv -f ${pkgname}/${pkgname}-arcstandalone-${pkgversion}.pkg ${pkgdir}/Packages/.
if [[ $? != 0 ]]; then
echo "Unable to locate package ${pkgname}/${pkgname}-arcstandalone-${pkgversion}.pkg"
return 1
fi
gsed -i "/<\/array>/i \\
\ <dict>\\
\ <key>IFPkgFlagPackageLocation</key>\\
\ <string>${pkgname}-arcstandalone-${pkgversion}.pkg</string>\\
\ <key>IFPkgFlagPackageSelection</key>\\
\ <string>${3}</string>\\
\ </dict>
" ${pkgdir}/Info.plist
return 0
}
function makedeppackage() {
pkgname=${1}
rm -rf ${pkgname}
mkdir ${pkgname}
# Modify Portfile to our purpose.
port cat ${pkgname} | sed -e :a -e '$!N;s/[[:space:]]*\\\n[[:space:]]*/ /;ta' \
| sed -e "s/\${name}/${pkgname}/g" \
| sed -e "s/\(name[[:space:]]*${pkgname}\)/\1-arcstandalone/" \
| sed -e "/^depends_lib/d" \
| sed -e "/^depends_build/d" \
| sed -e "/^archcheck.files/d" \
| sed -e "s/^\(master_sites[[:space:]]*gnu\)/\1:${pkgname}/" > ${pkgname}/Portfile
gsed -i "/checksums/i \\
destroot.violate_mtree yes\\
" ${pkgname}/Portfile
if test "x${pkgname}" = "xglibmm"; then
gsed -i -e "
/^checksums/a \\
\\
configure.env PKG_CONFIG_LIBDIR=${location}/lib/pkgconfig
" ${pkgname}/Portfile
fi
# Set distname so source can be fetched.
gsed -i "
/^[[:space:]]*version[[:space:]]/a \\
distname ${pkgname}-\${version}\\
" ${pkgname}/Portfile
# Make link to patch files.
[[ -d `port dir ${pkgname}`/files ]] && ln -s `port dir ${pkgname}`/files ${pkgname}/files
# Wait 1 second before creating package to avoid MacPorts complaining about files in future.
sleep 1
# Make a package.
toggleownmacportconf on
port pkg -D ${pkgname} prefix=${location} build_arch=${architecture}
if [[ $? -ne 0 ]]
then
echo "Unable to make package ${pkgname}"
toggleownmacportconf off
return 1
fi
workpath=`port work -D ${pkgname}`
toggleownmacportconf off
# Move package, so it is not deleted.
pkgversion=`port info --version -D ${pkgname} | awk '{ print $2 }'`
mv -f ${workpath}/${pkgname}-arcstandalone-${pkgversion}.pkg ${pkgname}/.
mv -f ${pkgname}/${pkgname}-arcstandalone-${pkgversion}.pkg/Contents/Resources/English.lproj/Description.plist \
${pkgname}/${pkgname}-arcstandalone-${pkgversion}.pkg/Contents/Resources/.
rm -rf ${pkgname}/${pkgname}-arcstandalone-${pkgversion}.pkg/Contents/Resources/English.lproj
description=`port info --long_description -D ${pkgname} | sed "s/^long_description: //"`
description=${description//\//\\\/}
gsed -i "s/<string><\/string>/<string>${description}<\/string>/" \
${pkgname}/${pkgname}-arcstandalone-${pkgversion}.pkg/Contents/Resources/Description.plist
toggleownmacportconf on
# Install package since other packages might depend on it.
port install -D ${pkgname} prefix=${location} build_arch=${architecture}
if test $? != 0; then
echo "Unable to install package ${pkgname}"
return 1
fi
# Sanity check. Check if libraries are linked properly.
depslibs=`port contents -D ${pkgname} | grep ${location} | grep dylib`
toggleownmacportconf off
if [[ -n ${depslibs} ]] && [[ `otool -L ${depslibs} | grep -v ${location} |\
grep -v /usr/lib |\
grep -c -v /System/Library` -ne 0 ]]
then
echo "The ${pkgname} package libraries are linked inconsistently."
otool -L ${depslibs} | grep -v ${location} | grep -v /usr/lib | grep -v /System/Library
return 1
fi
return 0
}
function makedependencypackages() {
for package in ${deppackages[@]}
do
makedeppackage $package || return 1
done
return 0
}
function makeglobuspackage() {
pkgname=${1}
export PERL5LIB="${location}/lib/perl5/vendor_perl"
if [[ "${pkgname}" != "grid-packaging-tools" ]]; then
pkgname=globus-${pkgname}
fi
rm -rf ${pkgname}
mkdir ${pkgname}
# Modify Portfile to our purpose.
port cat ${pkgname} \
| sed -e :a -e '$!N;s/[[:space:]]*\\\n[[:space:]]*/ /;ta' \
| sed -e "s/\${name}/${pkgname}/g" \
| sed -e "s/\$name/${pkgname}/g" \
| sed -e "s/\(name[[:space:]]*${pkgname}\)/\1-arcstandalone/" \
| sed -e "/^depends/d" \
| sed -e "s@\${prefix}/share/libtool@/opt/local/share/libtool@g" \
| sed -e "s@\${perl_vendor_lib}@${PERL5LIB}@" \
| sed -e "/^archcheck.files/d" > ${pkgname}/Portfile
gsed -i "/checksums/i \\
destroot.violate_mtree yes\\
" ${pkgname}/Portfile
if test "x${pkgname}" == "xglobus-openssl"; then
gsed -i "/configure {/a \\
set env(PKG_CONFIG_LIBDIR) ${location}:/usr/lib/pkgconfig\\
" ${pkgname}/Portfile
fi
# Make link to patch files.
[[ -d `port dir ${pkgname}`/files ]] && ln -s `port dir ${pkgname}`/files ${pkgname}/files
# Wait 1 second before creating package to avoid MacPorts complaining about files in future.
sleep 1
if [[ "${pkgname}" == "grid-packaging-tools" ]] || [[ "${pkgname}" == "globus-core" ]];
then
toggleownmacportconf on
port install -D ${pkgname} prefix=${location} build_arch=${architecture}
if [[ $? -ne 0 ]]
then
toggleownmacportconf off
echo "Unable to make package ${pkgname}"
return 1
fi
toggleownmacportconf off
return 0
fi
toggleownmacportconf on
# Make a package.
port pkg -D ${pkgname} prefix=${location} build_arch=${architecture}
if [[ $? -ne 0 ]]
then
toggleownmacportconf off
echo "Unable to make package ${pkgname}"
return 1
fi
workpath=`port work -D ${pkgname}`
toggleownmacportconf off
# Move package, so it is not deleted.
pkgversion=`port info --version -D ${pkgname} | awk '{ print $2 }'`
mv -f ${workpath}/${pkgname}-arcstandalone-${pkgversion}.pkg ${pkgname}/.
mv -f ${pkgname}/${pkgname}-arcstandalone-${pkgversion}.pkg/Contents/Resources/English.lproj/Description.plist \
${pkgname}/${pkgname}-arcstandalone-${pkgversion}.pkg/Contents/Resources/.
rm -rf ${pkgname}/${pkgname}-arcstandalone-${pkgversion}.pkg/Contents/Resources/English.lproj
description=`port info --long_description -D ${pkgname} | sed "s/^long_description: //"`
description=${description//\//\\\/}
gsed -i "s/<string><\/string>/<string>${description}<\/string>/" \
${pkgname}/${pkgname}-arcstandalone-${pkgversion}.pkg/Contents/Resources/Description.plist
toggleownmacportconf on
# Install package since others packages might depend on it.
port install -D ${pkgname} prefix=${location} build_arch=${architecture}
if test $? != 0; then
echo "Unable to install package ${pkgname}"
return 1
fi
# Sanity check. Check if libraries are linked properly.
depslibs=`port contents -D ${pkgname} | grep ${location} | grep dylib`
toggleownmacportconf off
if [[ -n ${depslibs} ]] && [[ `otool -L ${depslibs} | grep -v ${location} |\
grep -v /usr/lib |\
grep -c -v /System/Library` -ne 0 ]]
then
echo "The ${pkgname} package libraries are linked inconsistently."
otool -L ${depslibs} | grep -v ${location} | grep -v /usr/lib | grep -v /System/Library
return 1
fi
return 0
}
function makeglobuspackages() {
# Make globus packages. grid-packaging-tools and globus-core is needed to build the other packages.
makeglobuspackage grid-packaging-tools || return 1
makeglobuspackage core || return 1
for package in ${globuspkgs[@]}
do
makeglobuspackage $package || return 1
done
return 0
}
function makearcmetapackage() {
# Create the Nordugrid ARC stand-alone package.
toggleownmacportconf on
# Build and test the stand-alone
port -d build -D ${workdir}/${name} prefix=${location} build_arch=${architecture}
if [[ $? != 0 ]]
then
toggleownmacportconf off
echo "Building ${name} failed"
return 1
fi
if test "x${domakecheck}" == "xyes"; then
port -d test -D ${workdir}/${name} prefix=${location} build_arch=${architecture} distpath=${workdir}/${name}/files
if [[ $? != 0 ]]
then
toggleownmacportconf off
echo "Make check failed for ${name}"
return 1
fi
fi
# Then destroot it in order to extract the globus dependend modules.
port destroot -D ${workdir}/${name} prefix=${location} build_arch=${architecture} distpath=${workdir}/${name}/files
if [[ $? != 0 ]]
then
toggleownmacportconf off
echo "Make install failed for ${name}"
return 1
fi
workpath=`port work -D ${workdir}/${name}`
# Sanity check. Check if libraries are linked properly.
depslibs=`find ${workpath}/destroot/opt/local/nordugrid -name "*.dylib"`
if [[ -n ${depslibs} ]] && [[ `otool -L ${depslibs} | grep -v ${location} |\
grep -v /usr/lib |\
grep -c -v /System/Library` -ne 0 ]]
then
toggleownmacportconf off
echo "The ${name} package libraries are linked inconsistently."
otool -L ${depslibs} | grep -v ${location} | grep -v /usr/lib | grep -v /System/Library
return 1
fi
if test "x${makeglobus}" == "xyes"
then
# Make directory for modules and move them there.
mkdir -p ${workdir}/${arcglobusmoduledir}/destroot/${location}/lib/arc
mv ${workpath}/destroot/${location}/lib/arc/lib{dmc{gridftp,rls},accARC0,mccgsi}.* ${workdir}/${arcglobusmoduledir}/destroot/${location}/lib/arc/.
fi
# Make meta package which should contain dependencies as well.
port mpkg -D ${workdir}/${name} prefix=${location} build_arch=${architecture}
if [[ $? != 0 ]]
then
toggleownmacportconf off
echo "Creating meta-package ${name} failed"
return 1
fi
toggleownmacportconf off
# Copy meta package for convenience.
cp -a ${workpath}/${name}-${version}.mpkg ${workdir}/.
return 0
}
function groupdependencypackages() {
# Group all required dependencies.
mkdir -p ${name}-${version}.mpkg/Contents/Packages/arcstandalone-dependencies.mpkg/Contents/{Packages,Resources}
cp -a ${name}-${version}.mpkg/Contents/PkgInfo ${name}-${version}.mpkg/Contents/Packages/arcstandalone-dependencies.mpkg/Contents/.
cat << EOF > ${name}-${version}.mpkg/Contents/Packages/arcstandalone-dependencies.mpkg/Contents/Resources/Description.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IFPkgDescriptionDescription</key>
<string>This group of packages are required to be installed for ARC client to be functional.</string>
<key>IFPkgDescriptionTitle</key>
<string>External dependencies</string>
</dict>
</plist>
EOF
cat << EOF > ${name}-${version}.mpkg/Contents/Packages/arcstandalone-dependencies.mpkg/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleGetInfoString</key>
<string>arcstandalone-dependencies</string>
<key>CFBundleIdentifier</key>
<string>org.macports.mpkg.arcstandalone-dependencies</string>
<key>CFBundleName</key>
<string>arcstandalone-dependencies</string>
<key>CFBundleShortVersionString</key>
<string>0</string>
<key>IFMajorVersion</key>
<integer>0</integer>
<key>IFMinorVersion</key>
<integer>0</integer>
<key>IFPkgFlagComponentDirectory</key>
<string>./Contents/Packages</string>
<key>IFPkgFlagPackageList</key>
<array>
</array>
<key>IFPkgFormatVersion</key>
<real>0.10000000149011612</real>
</dict>
</plist>
EOF
for package in ${deppackages[@]}
do
insertpackage ${package} `port info --version -D ${package} | awk '{print $2}'` required arcstandalone-dependencies.mpkg || return 1
done
gsed -i "/<\/array>/i \\
\ <dict>\\
\ <key>IFPkgFlagPackageLocation</key>\\
\ <string>arcstandalone-dependencies.mpkg</string>\\
\ <key>IFPkgFlagPackageSelection</key>\\
\ <string>required</string>\\
\ </dict>
" ${name}-${version}.mpkg/Contents/Info.plist
return 0
}
function groupglobuspackages() {
# Group all Globus dependencies.
mkdir -p ${name}-${version}.mpkg/Contents/Packages/globus-dependencies.mpkg/Contents/{Packages,Resources}
cp -a ${name}-${version}.mpkg/Contents/PkgInfo ${name}-${version}.mpkg/Contents/Packages/globus-dependencies.mpkg/Contents/.
cat << EOF > ${name}-${version}.mpkg/Contents/Packages/globus-dependencies.mpkg/Contents/Resources/Description.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IFPkgDescriptionDescription</key>
<string>The Globus packages are needed for Job Submission and Management against the Grid-Manager Computing Element.</string>
<key>IFPkgDescriptionTitle</key>
<string>Globus packages</string>
</dict>
</plist>
EOF
cat << EOF > ${name}-${version}.mpkg/Contents/Packages/globus-dependencies.mpkg/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleGetInfoString</key>
<string>arcstandalone-dependencies</string>
<key>CFBundleIdentifier</key>
<string>org.macports.mpkg.arcstandalone-dependencies</string>
<key>CFBundleName</key>
<string>arcstandalone-dependencies</string>
<key>CFBundleShortVersionString</key>
<string>0</string>
<key>IFMajorVersion</key>
<integer>0</integer>
<key>IFMinorVersion</key>
<integer>0</integer>
<key>IFPkgFlagBackgroundAlignment</key>
<string>bottomleft</string>
<key>IFPkgFlagBackgroundScaling</key>
<string>none</string>
<key>IFPkgFlagComponentDirectory</key>
<string>./Contents/Packages</string>
<key>IFPkgFlagPackageList</key>
<array>
</array>
<key>IFPkgFormatVersion</key>
<real>0.10000000149011612</real>
</dict>
</plist>
EOF
for package in ${globuspkgs[@]}
do
insertpackage globus-${package} `port info --version -D globus-${package} | awk '{print $2}'` required globus-dependencies.mpkg || return 1
done
gsed -i "/<\/array>/i \\
\ <dict>\\
\ <key>IFPkgFlagPackageLocation</key>\\
\ <string>globus-dependencies.mpkg</string>\\
\ <key>IFPkgFlagPackageSelection</key>\\
\ <string>selected</string>\\
\ </dict>
" ${name}-${version}.mpkg/Contents/Info.plist
return 0
}
function packagearcglobusmodule() {
# Package ARC globus modules.
mkdir -p ${arcglobusmoduledir}/${arcglobusmoduledir}-arcstandalone-${version}.pkg/Contents/Resources
mkbom ${arcglobusmoduledir}/destroot ${arcglobusmoduledir}/${arcglobusmoduledir}-arcstandalone-${version}.pkg/Contents/Archive.bom
pax -w ${arcglobusmoduledir}/destroot/opt -x cpio \
-f ${arcglobusmoduledir}/${arcglobusmoduledir}-arcstandalone-${version}.pkg/Contents/Archive.pax \
-s /${arcglobusmoduledir}\\\/destroot/./
gzip ${arcglobusmoduledir}/${arcglobusmoduledir}-arcstandalone-${version}.pkg/Contents/Archive.pax
cat << EOF > ${arcglobusmoduledir}/${arcglobusmoduledir}-arcstandalone-${version}.pkg/Contents/Resources/Description.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IFPkgDescriptionDescription</key>
<string>Globus modules for the ARC client. This includes job and data management modules.</string>
<key>IFPkgDescriptionTitle</key>
<string>nordugrid-arc-plugins-globus</string>
</dict>
</plist>
EOF
cat << EOF > ${arcglobusmoduledir}/${arcglobusmoduledir}-arcstandalone-${version}.pkg/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleGetInfoString</key>
<string>nordugrid-arc-plugins-globus ${version}</string>
<key>CFBundleIdentifier</key>
<string>nordugrid-arc-plugins-globus</string>
<key>CFBundleName</key>
<string>nordugrid-arc-plugins-globus ${version}</string>
<key>CFBundleShortVersionString</key>
<string>${version}</string>
<key>IFMajorVersion</key>
<integer>0</integer>
<key>IFMinorVersion</key>
<integer>0</integer>
<key>IFPkgFlagAllowBackRev</key>
<true/>
<key>IFPkgFlagAuthorizationAction</key>
<string>RootAuthorization</string>
<key>IFPkgFlagDefaultLocation</key>
<string>/</string>
<key>IFPkgFlagFollowLinks</key>
<true/>
<key>IFPkgFlagInstallFat</key>
<false/>
<key>IFPkgFlagInstalledSize</key>
<integer>648</integer>
<key>IFPkgFlagIsRequired</key>
<false/>
<key>IFPkgFlagOverwritePermissions</key>
<false/>
<key>IFPkgFlagRelocatable</key>
<false/>
<key>IFPkgFlagRestartAction</key>
<string>NoRestart</string>
<key>IFPkgFlagRootVolumeOnly</key>
<true/>
<key>IFPkgFlagUpdateInstalledLanguages</key>
<false/>
<key>IFPkgFormatVersion</key>
<real>0.10000000149011612</real>
</dict>
</plist>
EOF
echo -n "pmkrpkg1" > ${arcglobusmoduledir}/${arcglobusmoduledir}-arcstandalone-${version}.pkg/Contents/PkgInfo
echo "major: 1" > ${arcglobusmoduledir}/${arcglobusmoduledir}-arcstandalone-${version}.pkg/Contents/Resources/package_version
echo -n "minor: 1" >> ${arcglobusmoduledir}/${arcglobusmoduledir}-arcstandalone-${version}.pkg/Contents/Resources/package_version
insertpackage ${arcglobusmoduledir} ${version} required globus-dependencies.mpkg || return 1
return 0
}
function packagecertificates() {
toggleownmacportconf on
# Include igtf-certificates in the standalone package.
port pkg igtf-certificates prefix=${location} build_arch=${architecture}
if test $? != 0; then
echo "Unable to create IGTF certificates package."
toggleownmacportconf off
return 1
fi
workpath=`port work igtf-certificates`
toggleownmacportconf off
igtfversion=`port info --version igtf-certificates | awk '{ print $2 }'`
mkdir -p ${workdir}/igtf-certificates
mv -f ${workpath}/igtf-certificates-${igtfversion}.pkg \
${workdir}/igtf-certificates/igtf-certificates-arcstandalone-${igtfversion}.pkg
if [[ $? != 0 ]]; then
echo "igtf-certificates package not found"
return 1
fi
insertpackage igtf-certificates ${igtfversion} selected || return 1
return 0
}
function completepackage() {
# Add PATHs to environment by using postinstall script. Copy ReadMe to location. Set to executable.
cat << EEOOFF > ${name}-${version}.mpkg/Contents/Resources/postinstall
#!/bin/bash
cat << EOF > /etc/paths.d/${name}
${location}/bin
EOF
export PATH=\$PATH:${location}/bin
cp \${PACKAGE_PATH}/Contents/Resources/ReadMe ${location}/.
EEOOFF
chmod +x ${name}-${version}.mpkg/Contents/Resources/postinstall
toggleownmacportconf on
cp `port work -D ${name}`/${source//.tar.gz}/LICENSE \
${name}-${version}.mpkg/Contents/Resources/License
toggleownmacportconf off
cat << EOF > ${name}-${version}.mpkg/Contents/Resources/ReadMe
NOTE: You need to do the following steps after installation of ARC
-------------------------------------------------------------------
Install Grid certificate and private key:
Copy your user certificate (e.g. usercert.pem) to: \$HOME/.globus/usercert.pem
Copy your user key (e.g. userkey.pem) to: \$HOME/.globus/userkey.pem
Also you must set the environment variable GLOBUS_LOCATION to ${location} in
the shell where ARC will be executed in order for the certain ARC modules to
function. E.g. for bash:
export GLOBUS_LOCATION=${location}
Other information
-----------------
Default client.conf, jobs.xml directory location (these directories are
hidden by default):
\$HOME/.arc
Uninstalling this package
-------------------------
To uninstall this package simply remove the '${location}' directory and the
file '/etc/paths.d/${name}'. Additionally user configuration files might
exist in the \$HOME/.arc directory, which can safely be removed.
EOF
# Remove MacPorts background and use own background.
wget -q http://www.nordugrid.org/images/ng-logo.png -O ${name}-${version}.mpkg/Contents/Resources/background
if [[ $? != 0 ]]; then
echo "WARNING: Unable to fetch NG-logo"
else
rm -f ${name}-${version}.mpkg/Contents/Resources/background.tiff
# Put logo in bottom-left corner, and do not scale it.
gsed -i \
-e "/<key>IFPkgFlagComponentDirectory<\/key>/i \\
\ <key>IFPkgFlagBackgroundAlignment</key>\\
\ <string>bottomleft</string>\\
\ <key>IFPkgFlagBackgroundScaling</key>\\
\ <string>none</string>\\
" \
-e "/<string>${name}-${version}.pkg<\/string>/,/<string>selected<\/string>/s/selected/required/" \
${name}-${version}.mpkg/Contents/Info.plist
fi
return 0
}
function compresspackage() {
# Rename package
mv ${workdir}/${name}-${version}.mpkg ${workdir}/${name}-${version}-snow_leopard-${architecture}.mpkg
# Compress package
zip -qr ${workdir}/${name}-${version}-snow_leopard-${architecture}.mpkg.zip ${name}-${version}-snow_leopard-${architecture}.mpkg
if [[ $? != 0 ]]; then
echo "Unable to compress package."
return 1
fi
rm -rf ${workdir}/${name}-${version}-snow_leopard-${architecture}.mpkg
mv ${workdir}/${name}-${version}-snow_leopard-${architecture}.mpkg.zip ${basedir}/.
if [[ $? != 0 ]]; then
echo "Unable to move package \"${workdir}/${name}-${version}-snow_leopard-${architecture}.mpkg.zip\" to \"${basedir}/.\""
return 1
fi
return 0
}
function cleanup() {
toggleownmacportconf on
# Clean package.
port -q clean --all -D ${workdir}/${name}
port -q clean --all igtf-certificates
# Remove arcstandalone packages and delete temporary directories.
for package in ${deppackages[@]}
do
port -q uninstall -D ${workdir}/${package}
rm -rf ${package}
done
for package in ${globuspkgs[@]}
do
port -q uninstall globus-${package}-arcstandalone
rm -rf globus-${package}
done
port -q uninstall grid-packaging-tools-arcstandalone
rm -rf grid-packaging-tools
port -q uninstall globus-core-arcstandalone
rm -rf globus-core
toggleownmacportconf off
rm -rf ${location}/*
cd ${basedir}
rm -rf ${workdir}
return 0
}
function build_standalone() {
date
echo "Building ARC standalone for Mac OS X with the following options:"
echo "Name: $name"
echo "Version: $version"
echo "Channel: $type"
echo "Install location: $location"
echo "Architecture: $architecture"
echo "Build globus module: $makeglobus"
initialise || return 1
echo "Working directory: $workdir"
requiredpackagescheck || return 1
fetchsource || return 1
createportfile || return 1
installpkgconfig || return 1
makedependencypackages || return 1
if test "x${makeglobus}" == "xyes"
then
makeglobuspackages || return 1
fi
makearcmetapackage || return 1
groupdependencypackages || return 1
if test "x${makeglobus}" == "xyes"
then
groupglobuspackages || return 1
packagearcglobusmodule || return 1
fi
packagecertificates || return 1
completepackage || return 1
compresspackage || return 1
cleanup || return 1
echo "Creating ${name}-standalone finished successfully"
date
}
if test "x${ARC_BUILD_CHANNEL}" != "xreleases" && test "x${ARC_BUILD_CHANNEL}" != "xtesting" && test "x${ARC_BUILD_CHANNEL}" != "xexperimental"; then
type="nightlies"
else
type=${ARC_BUILD_CHANNEL}
if test "x${ARC_BUILD_VERSION}" == "x"; then
echo "ARC_BUILD_VERSION environment variable must be set for the \"${type}\" channel."
exit 1
fi
fi
version=
test "x${ARC_BUILD_VERSION}" != "x" && version=${ARC_BUILD_VERSION}
architecture="x86_64"
test "x${ARC_BUILD_ARCHITECTURE}" != "x" && architecture=${ARC_BUILD_ARCHITECTURE}
domakecheck="no"
test "x${ARC_BUILD_MAKECHECK}" == "xyes" && domakecheck="yes"
makeglobus="yes"
test "x${ARC_BUILD_GLOBUS}" == "xno" && makeglobus="no"
test "x${ARC_BUILD_INTERACTIVE}" != "xyes" && build_standalone