forked from macfuse/macfuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·2428 lines (1990 loc) · 74.6 KB
/
build.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
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# OSXFUSE build tool
# Copyright (c) 2008-2009 Google Inc.
# Copyright (c) 2011-2012 Benjamin Fleischer
# All rights reserved.
# Configurables
#
# Beware: GNU libtool cannot handle directory names containing whitespace.
# Therefore, do not set M_CONF_TMPDIR to such a directory.
#
readonly M_CONF_TMPDIR=/tmp
readonly M_PLISTSIGNER_TEST_KEY="`dirname $0`/prefpane/autoinstaller/TestKeys/private_key.der"
# Other constants
#
readonly M_PROGDESC="OSXFUSE build tool"
readonly M_PROGNAME=`basename $0`
readonly M_PROGVERS=2.0
readonly M_DEFAULT_VALUE=__default__
readonly M_CONFIGURATIONS="Debug Release" # default is Release
readonly M_TARGETS="clean release dist core osxfusefs kext examples lib reload"
readonly M_TARGETS_WITH_PLATFORM="kext examples lib"
readonly M_DEFAULT_PLATFORM="$M_DEFAULT_VALUE"
readonly M_DEFAULT_TARGET="$M_DEFAULT_VALUE"
# Globals
#
declare m_args=
declare m_active_target=""
declare m_configuration="Release"
declare m_developer=0
declare m_osname=""
declare m_platform="$M_DEFAULT_PLATFORM"
declare m_archs=""
declare m_release=""
declare m_shortcircuit=0
declare m_srcroot=""
declare m_stderr=/dev/stderr
declare m_stdout=/dev/stdout
declare m_suprompt=" invalid "
declare m_target="$M_DEFAULT_TARGET"
declare m_signing_id=""
declare m_plistsigner_key=""
declare m_usdk_dir=""
declare m_compiler=""
declare m_xcode_dir=""
declare m_xcode_version=""
declare m_xcode_latest=""
declare mp_package_maker=""
declare mp_package_maker_version=""
# Other implementation details
#
declare M_XCODE32=""
declare M_XCODE32_VERSION=3.2
readonly M_XCODE32_COMPILER="4.2"
declare M_XCODE40=""
declare M_XCODE40_VERSION=4.0
readonly M_XCODE40_COMPILER="4.2"
declare M_XCODE41=""
declare M_XCODE41_VERSION=4.1
readonly M_XCODE41_COMPILER="4.2"
declare M_XCODE42=""
declare M_XCODE42_VERSION=4.2
readonly M_XCODE42_COMPILER="com.apple.compilers.llvmgcc42"
declare M_XCODE43=""
declare M_XCODE43_VERSION=4.3
readonly M_XCODE43_COMPILER="com.apple.compilers.llvmgcc42"
declare M_XCODE44=""
declare M_XCODE44_VERSION=4.4
readonly M_XCODE44_COMPILER="com.apple.compilers.llvmgcc42"
declare M_XCODE45=""
declare M_XCODE45_VERSION=4.5
readonly M_XCODE45_COMPILER="com.apple.compilers.llvmgcc42"
declare M_XCODE46=""
declare M_XCODE46_VERSION=4.6
readonly M_XCODE46_COMPILER="com.apple.compilers.llvmgcc42"
declare M_ACTUAL_PLATFORM=""
declare M_PLATFORMS=""
declare M_PLATFORMS_REALISTIC=""
declare M_XCODE_VERSION_REQUIRED=""
# SDK 10.5
readonly M_SDK_105_ARCHS="ppc ppc64 i386 x86_64"
declare M_SDK_105=""
declare M_SDK_105_XCODE=""
declare M_SDK_105_COMPILER=""
# SDK 10.6
readonly M_SDK_106_ARCHS="i386 x86_64"
declare M_SDK_106=""
declare M_SDK_106_XCODE=""
declare M_SDK_106_COMPILER=""
# SDK 10.7
readonly M_SDK_107_ARCHS="i386 x86_64"
declare M_SDK_107=""
declare M_SDK_107_XCODE=""
declare M_SDK_107_COMPILER=""
# SDK 10.8
readonly M_SDK_108_ARCHS="i386 x86_64"
declare M_SDK_108=""
declare M_SDK_108_XCODE=""
declare M_SDK_108_COMPILER=""
declare M_FSBUNDLE_NAME="osxfuse.fs"
declare M_KEXT_ID="com.github.osxfuse.filesystems.osxfusefs"
declare M_KEXT_NAME="osxfuse.kext"
readonly M_LOGPREFIX="OSXFUSEBuildTool"
readonly M_OSXFUSE_PRODUCT_ID="com.github.osxfuse.OSXFUSE"
readonly M_MACFUSE_MODE=1;
readonly M_PKG_VERSION="10.5"
# Core
readonly M_PKGID_CORE="com.github.osxfuse.pkg.Core"
readonly M_PKGBASENAME_CORE="OSXFUSECore"
readonly M_PKGNAME_CORE="${M_PKGBASENAME_CORE}.pkg"
# Preference Pane
readonly M_PKGID_PREFPANE="com.github.osxfuse.pkg.PrefPane"
readonly M_PKGBASENAME_PREFPANE="OSXFUSEPrefPane"
readonly M_PKGNAME_PREFPANE="${M_PKGBASENAME_PREFPANE}.pkg"
# MacFUSE compatibility layer
readonly M_PKGID_MACFUSE="com.google.macfuse.core"
readonly M_PKGBASENAME_MACFUSE="OSXFUSEMacFUSE"
readonly M_PKGNAME_MACFUSE="${M_PKGBASENAME_MACFUSE}.pkg"
# Distribution package
readonly M_PKGBASENAME_OSXFUSE="OSXFUSE"
readonly M_PKGNAME_OSXFUSE="${M_PKGBASENAME_OSXFUSE}.pkg"
# Redistribution package
readonly M_PKGID_REDIST="com.github.osxfuse.pkg.osxfuse"
readonly M_PKGBASENAME_REDIST="OSXFUSERedist"
readonly M_PKGNAME_REDIST="${M_PKGBASENAME_REDIST}.pkg"
readonly M_WANTSU="needs the Administrator password"
readonly M_WARNING="*** Warning"
function m_help()
{
cat <<__END_HELP_CONTENT
$M_PROGDESC version $M_PROGVERS
Copyright (C) 2008 Google Inc.
Copyright (C) 2011-2012 Benjamin Fleischer
All Rights Reserved.
Usage:
$M_PROGNAME
[-dhqsv] [-c configuration] [-p platform] [-i identity] [-u keyfile]
-t target
* configuration is one of: $M_CONFIGURATIONS (default is $m_configuration)
* platform is one of: $M_PLATFORMS (default is the host's platform)
* target is one of: $M_TARGETS
* platforms can only be specified for: $M_TARGETS_WITH_PLATFORM
* identity and keyfile are ignored for all targets but release
The target keywords mean the following:
clean clean all targets
release create release disk image and updater files
dist create a multi-platform distribution package
core create a multi-platform core package
osxfusefs build file system bundle
kext build kernel extension
examples build example file systems (e.g. fusexmp_fh and hello)
lib build the user-space library (e.g. to run fusexmp_fh)
reload rebuild and reload the kernel extension
Options for target release are:
-i identity
sign the installer package with the specified signing identity
-u keyfile
sign the update rules file with the specified private key
Other options are:
-d create a developer prerelease package instead of a regular release
-q enable quiet mode (suppresses verbose build output)
-s enable shortcircuit mode (useful for testing the build mechanism itself)
-v report version numbers and quit
__END_HELP_CONTENT
return 0
}
# m_version()
#
function m_version
{
echo "$M_PROGDESC version $M_PROGVERS"
m_set_platform
m_set_srcroot
local mv_release=`awk '/#define[ \t]*OSXFUSE_VERSION_LITERAL/ {print $NF}' "$m_srcroot/common/fuse_version.h"`
if [ ! -z "$mv_release" ]
then
echo "OSXFUSE version $mv_release"
fi
return 0
}
# m_log(msg)
#
function m_log()
{
printf "%-30s: %s\n" "$M_LOGPREFIX($m_active_target)" "$*"
}
# m_warn(msg)
#
function m_warn()
{
echo "$M_WARNING: $*"
}
# m_exit_on_error(errmsg)
#
function m_exit_on_error()
{
if [ "$?" != 0 ]
then
local retval=$?
echo "$M_LOGPREFIX($m_active_target) failed: $1" 1>&2
exit $retval
fi
# NOTREACHED
}
# m_set_suprompt(msg)
#
function m_set_suprompt()
{
m_suprompt="$M_LOGPREFIX($m_active_target) $M_WANTSU $*: "
}
# m_set_srcroot()
#
function m_set_srcroot()
{
local osxfuse_dir=""
local is_absolute_path=`echo "$0" | cut -c1`
if [ "$is_absolute_path" == "/" ]
then
osxfuse_dir="`dirname $0`/"
else
osxfuse_dir="`pwd`/`dirname $0`/"
fi
pushd . > /dev/null
cd "$osxfuse_dir" || exit 1
osxfuse_dir=`pwd`
popd > /dev/null
m_srcroot="$osxfuse_dir"
return 0
}
# m_set_platform()
#
function m_set_platform()
{
local retval=0
if [ "$m_platform" == "$M_DEFAULT_PLATFORM" ]
then
m_platform=$M_ACTUAL_PLATFORM
fi
case "$m_platform" in
10.5*)
m_osname="Leopard"
m_xcode_dir="$M_SDK_105_XCODE"
m_usdk_dir="$M_SDK_105"
m_compiler="$M_SDK_105_COMPILER"
m_archs="$M_SDK_105_ARCHS"
;;
10.6*)
m_osname="Snow Leopard"
m_xcode_dir="$M_SDK_106_XCODE"
m_usdk_dir="$M_SDK_106"
m_compiler="$M_SDK_106_COMPILER"
m_archs="$M_SDK_106_ARCHS"
;;
10.7*)
m_osname="Lion"
m_xcode_dir="$M_SDK_107_XCODE"
m_usdk_dir="$M_SDK_107"
m_compiler="$M_SDK_107_COMPILER"
m_archs="$M_SDK_107_ARCHS"
;;
10.8*)
m_osname="Mountain Lion"
m_xcode_dir="$M_SDK_108_XCODE"
m_usdk_dir="$M_SDK_108"
m_compiler="$M_SDK_108_COMPILER"
m_archs="$M_SDK_108_ARCHS"
;;
*)
m_osname="Unknown"
m_xcode_dir=""
m_usdk_dir=""
m_compiler=""
m_archs=""
retval=1
;;
esac
export DEVELOPER_DIR="$m_xcode_dir"
return $retval
}
# m_build_pkg(pkgversion, install_srcroot, install_payload, pkgid, pkgname, install_to, output_dir)
#
function m_build_pkg()
{
local bp_pkgversion="$1"
local bp_install_srcroot="$2"
local bp_install_payload="$3"
local bp_pkgid="$4"
local bp_pkgname="$5"
local bp_install_to="$6"
local bp_output_dir="$7"
if [ -z "$mp_package_maker" ]
then
# Find PackageMaker.app
local _IFS="$IFS"; IFS=$'\n'
m_package_maker_installed=(`mdfind 'kMDItemCFBundleIdentifier == "com.apple.PackageMaker"'`)
IFS="$_IFS"
if [[ ${#m_package_maker_installed[@]} -eq 0 ]]
then
false
m_exit_on_error "PackageMaker.app not found"
fi
# Use most recent version of PackageMaker.app
for m_pm in "${m_package_maker_installed[@]}";
do
m_pm_version=`mdls -name kMDItemVersion "$m_pm" | perl -ne '/kMDItemVersion = "(.*)"/ && print $1'`
m_version_compare "$mp_package_maker_version" "$m_pm_version"
if [[ $? -ne 2 ]]
then
mp_package_maker="$m_pm"
mp_package_maker_version="$m_pm_version"
fi
done
m_log "package maker: $mp_package_maker (version $mp_package_maker_version)"
mp_package_maker="$mp_package_maker/Contents/MacOS/PackageMaker"
fi
# Make the package
m_set_suprompt "to run packagemaker"
if [ -d "$bp_install_srcroot/Scripts" ]
then
sudo -p "$m_suprompt" \
"$mp_package_maker" -r "$bp_install_payload" \
-i "$bp_pkgid" \
-f "$bp_install_srcroot/PackageInfo" \
-o "$bp_output_dir/$bp_pkgname" \
-n "$bp_pkgversion" \
-l "$bp_install_to" \
-s "$bp_install_srcroot/Scripts" \
-g "$M_PKG_VERSION" \
-h system \
-m -w -v \
>$m_stdout 2>$m_stderr
else
sudo -p "$m_suprompt" \
"$mp_package_maker" -r "$bp_install_payload" \
-i "$bp_pkgid" \
-f "$bp_install_srcroot/PackageInfo" \
-o "$bp_output_dir/$bp_pkgname" \
-n "$bp_pkgversion" \
-l "$bp_install_to" \
-g "$M_PKG_VERSION" \
-h system \
-m -w -v \
>$m_stdout 2>$m_stderr
fi
m_exit_on_error "cannot create package '$bp_pkgname'."
return 0
}
# Build the user-space library
#
function m_handler_lib()
{
m_active_target="lib"
m_set_platform
local lib_dir="$m_srcroot"/fuse
if [ ! -d "$lib_dir" ]
then
false
m_exit_on_error "cannot access directory '$lib_dir'."
fi
local kernel_dir="$m_srcroot"/kext
if [ ! -d "$kernel_dir" ]
then
false
m_exit_on_error "cannot access directory '$kernel_dir'."
fi
local package_name="fuse"
rm -rf "$M_CONF_TMPDIR/$package_name"
if [ "$1" == "clean" ]
then
local retval=$?
m_log "cleaned (platform $m_platform)"
return $retval
fi
m_log "initiating Universal build for $m_platform"
cp -pRX "$lib_dir" "$M_CONF_TMPDIR"
m_exit_on_error "cannot copy OSXFUSE library source from '$lib_dir'."
cd "$M_CONF_TMPDIR/$package_name"
m_exit_on_error "cannot access OSXFUSE library source in '$M_CONF_TMPDIR/$package_name'."
m_log "configuring library source"
COMPILER="$m_compiler" ARCHS="$m_archs" SDKROOT="$m_usdk_dir" MACOSX_DEPLOYMENT_TARGET="$m_platform" ./darwin_configure.sh "$m_srcroot" >$m_stdout 2>$m_stderr
m_exit_on_error "cannot configure OSXFUSE library source for compilation."
m_log "running make"
xcrun make -j4 >$m_stdout 2>$m_stderr
m_exit_on_error "make failed while compiling the OSXFUSE library."
echo >$m_stdout
m_log "succeeded, results in '$M_CONF_TMPDIR/$package_name'."
echo >$m_stdout
return 0
}
# Rebuild and reload the kernel extension
#
function m_handler_reload()
{
m_active_target="reload"
# Argument validation would have ensured that we use native platform
# for this target.
m_set_platform
local kernel_dir="$m_srcroot"/kext
if [ ! -d "$kernel_dir" ]
then
false
m_exit_on_error "cannot access directory '$kernel_dir'."
fi
local ms_os_version="$m_platform"
local ms_osxfuse_version=`awk '/#define[ \t]*OSXFUSE_VERSION_LITERAL/ {print $NF}' "$m_srcroot"/common/fuse_version.h`
m_exit_on_error "cannot get platform-specific OSXFUSE version."
local ms_osxfuse_out="$M_CONF_TMPDIR/osxfuse-kext-$ms_os_version-$ms_osxfuse_version"
m_log "initiating kernel extension rebuild/reload for $m_platform"
kextstat -l -b "$M_KEXT_ID" | grep "$M_KEXT_ID" >/dev/null 2>/dev/null
if [ "$?" == "0" ]
then
m_log "unloading kernel extension"
m_set_suprompt "to unload OSXFUSE kext"
sudo -p "$m_suprompt" \
kextunload -v -b "$M_KEXT_ID" >$m_stdout 2>$m_stderr
m_exit_on_error "cannot unload kext '$M_KEXT_ID'."
fi
m_log "rebuilding kext"
m_shortcircuit="0"
m_configuration="Debug"
m_handler_kext "$1"
m_exit_on_error "failed to build kernel extension."
m_active_target="reload"
m_log "reloading kext"
m_set_suprompt "to load newly built kernel extension"
sudo -p "$m_suprompt" \
kextutil -s "$ms_osxfuse_out" \
-v "$ms_osxfuse_out/$M_KEXT_NAME" >$m_stdout 2>$m_stderr
m_exit_on_error "cannot load newly built kernel extension."
echo >$m_stdout
m_log "checking status of kernel extension"
kextstat -l -b "$M_KEXT_ID"
echo >$m_stdout
echo >$m_stdout
m_log "succeeded, results in '$ms_osxfuse_out'."
echo >$m_stdout
return 0
}
# Build examples from the user-space OSXFUSE library
#
function m_handler_examples()
{
m_active_target="examples"
m_set_platform
local lib_dir="$m_srcroot"/fuse
if [ ! -d "$lib_dir" ]
then
false
m_exit_on_error "cannot access directory '$lib_dir'."
fi
local kernel_dir="$m_srcroot"/kext
if [ ! -d "$kernel_dir" ]
then
false
m_exit_on_error "cannot access directory '$kernel_dir'."
fi
local package_name="fuse"
rm -rf "$M_CONF_TMPDIR/$package_name"
if [ "$1" == "clean" ]
then
local retval=$?
m_log "cleaned (platform $m_platform)"
return $retval
fi
m_log "initiating Universal build for $m_platform"
cp -pRX "$lib_dir" "$M_CONF_TMPDIR"
m_exit_on_error "cannot copy OSXFUSE library source from '$lib_dir'."
cd "$M_CONF_TMPDIR/$package_name"
m_exit_on_error "cannot access OSXFUSE library source in '$M_CONF_TMPDIR/$package_name'."
m_log "configuring library source"
COMPILER="$m_compiler" ARCHS="$m_archs" SDKROOT="$m_usdk_dir" MACOSX_DEPLOYMENT_TARGET="$m_platform" ./darwin_configure.sh "$m_srcroot" >$m_stdout 2>$m_stderr
m_exit_on_error "cannot configure OSXFUSE library source for compilation."
cd example
m_exit_on_error "cannot access examples source."
local me_installed_lib="/usr/local/lib/libosxfuse.la"
perl -pi -e "s#../lib/libosxfuse.la#$me_installed_lib#g" Makefile
m_exit_on_error "failed to prepare example source for build."
m_log "running make"
xcrun make -j4 >$m_stdout 2>$m_stderr
m_exit_on_error "make failed while compiling the OSXFUSE examples."
echo >$m_stdout
m_log "succeeded, results in '$M_CONF_TMPDIR/$package_name/example'."
echo >$m_stdout
return 0
}
# Build a multiplatform distribution package
#
function m_handler_dist()
{
m_active_target="dist"
m_platform="${M_PLATFORMS_REALISTIC%% *}"
m_set_platform
m_release_full=`awk '/#define[ \t]*OSXFUSE_VERSION_LITERAL/ {print $NF}' "$m_srcroot/common/fuse_version.h"`
m_release=`echo "$m_release_full" | cut -d . -f 1,2`
m_exit_on_error "cannot get OSXFUSE release version."
local md_osxfuse_out="$M_CONF_TMPDIR/osxfuse-dist-$m_release_full"
local md_osxfuse_root="$md_osxfuse_out/pkgroot/"
if [ "$m_shortcircuit" != "1" ]
then
if [ -e "$md_osxfuse_out" ]
then
m_set_suprompt "to remove a previously built distribution package"
sudo -p "$m_suprompt" rm -rf "$md_osxfuse_out"
m_exit_on_error "failed to clean up previous distribution package."
fi
if [ -e "$M_CONF_TMPDIR/osxfuse-dist-"* ]
then
m_warn "removing unrecognized version of distribution package"
m_set_suprompt "to remove unrecognized version of platform-specific package"
sudo -p "$m_suprompt" rm -rf "$M_CONF_TMPDIR/osxfuse-dist-"*
m_exit_on_error "failed to clean up unrecognized version of distribution package."
fi
else
if [ -e "$md_osxfuse_out/$M_PKGNAME_OSXFUSE" ]
then
echo >$m_stdout
m_log "succeeded (shortcircuited), results in '$md_osxfuse_out'."
echo >$m_stdout
return 0
fi
fi
if [ "$1" == "clean" ]
then
m_handler_core clean
m_active_target="dist"
m_set_platform
rm -rf "$m_srcroot/prefpane/autoinstaller/build"
m_log "cleaned internal subtarget autoinstaller"
rm -rf "$m_srcroot/prefpane/build"
m_log "cleaned internal subtarget prefpane"
return 0
fi
m_log "initiating Universal build of OSXFUSE"
# Create OSXFUSE subpackages
#
pushd . >/dev/null 2>/dev/null
m_handler_core
popd >/dev/null 2>/dev/null
m_active_target="dist"
m_platform="${M_PLATFORMS_REALISTIC%% *}"
m_set_platform
m_log "configuration is '$m_configuration'"
if [ "$m_developer" == "0" ]
then
m_log "packaging flavor is 'Mainstream'"
else
m_log "packaging flavor is 'Developer Prerelease'"
fi
# Autoinstaller
#
local md_ai_builddir="$m_srcroot/prefpane/autoinstaller/build"
if [ "$m_shortcircuit" != "1" ]
then
rm -rf "$md_ai_builddir"
# ignore any errors
fi
m_log "building the OSXFUSE autoinstaller"
pushd "$m_srcroot/prefpane/autoinstaller" >/dev/null 2>/dev/null
m_exit_on_error "cannot access the autoinstaller source."
xcodebuild -configuration "$m_configuration" -target "Build All" GCC_VERSION="$m_compiler" ARCHS="$m_archs" VALID_ARCHS="ppc i386 x86_64" SDKROOT="$m_usdk_dir" MACOSX_DEPLOYMENT_TARGET="$m_platform" CONFIGURATION_BUILD_DIR="$md_ai_builddir/$m_configuration" >$m_stdout 2>$m_stderr
m_exit_on_error "xcodebuild cannot build configuration $m_configuration for subtarget autoinstaller."
popd >/dev/null 2>/dev/null
local md_ai="$md_ai_builddir/$m_configuration/autoinstall-osxfuse-core"
if [ ! -x "$md_ai" ]
then
false
m_exit_on_error "cannot find autoinstaller '$md_ai'."
fi
local md_plistsigner="$md_ai_builddir/$m_configuration/plist_signer"
if [ ! -x "$md_plistsigner" ]
then
false
m_exit_on_error "cannot find plist signer '$md_plistsigner'."
fi
# Build the preference pane
#
local md_pp_builddir="$m_srcroot/prefpane/build"
if [ "$m_shortcircuit" != "1" ]
then
rm -rf "$md_pp_builddir"
# ignore any errors
fi
m_log "building the OSXFUSE prefpane"
pushd "$m_srcroot/prefpane" >/dev/null 2>/dev/null
m_exit_on_error "cannot access the prefpane source."
xcodebuild -configuration "$m_configuration" -target "OSXFUSE" GCC_VERSION="$m_compiler" ARCHS="$m_archs" SDKROOT="$m_usdk_dir" MACOSX_DEPLOYMENT_TARGET="$m_platform" CONFIGURATION_BUILD_DIR="$md_pp_builddir/$m_configuration" >$m_stdout 2>$m_stderr
m_exit_on_error "xcodebuild cannot build configuration $m_configuration for subtarget prefpane."
popd >/dev/null 2>/dev/null
local md_pp="$md_pp_builddir/$m_configuration/OSXFUSE.prefPane"
if [ ! -d "$md_pp" ]
then
false
m_exit_on_error "cannot find preference pane."
fi
cp "$md_ai" "$md_pp/Contents/MacOS"
m_exit_on_error "cannot copy the autoinstaller to the prefpane bundle."
# Build the container
#
m_log "building '$M_PKGNAME_OSXFUSE'"
mkdir -p "$md_osxfuse_out"
m_exit_on_error "cannot create directory '$md_osxfuse_out'."
mkdir -p "$md_osxfuse_root"
m_exit_on_error "cannot create directory '$md_osxfuse_root'."
m_log "copying generic container package payload"
mkdir -p "$md_osxfuse_root/Library/PreferencePanes"
m_exit_on_error "cannot make directory '$md_osxfuse_root/Library/PreferencePanes'."
cp -R "$md_pp" "$md_osxfuse_root/Library/PreferencePanes/"
m_exit_on_error "cannot copy the prefpane to '$md_osxfuse_root/Library/PreferencePanes/'."
m_set_suprompt "to chown '$md_osxfuse_root/'."
sudo -p "$m_suprompt" chown -R root:wheel "$md_osxfuse_root/"
# Build Preference Pane installer package
m_log "building installer package '$M_PKGNAME_PREFPANE'"
m_build_pkg "$m_release_full" "$m_srcroot/support/InstallerPackages/$M_PKGBASENAME_PREFPANE" "$md_osxfuse_root" "$M_PKGID_PREFPANE" "$M_PKGNAME_PREFPANE" "/" "$md_osxfuse_out"
m_exit_on_error "cannot create '$M_PKGNAME_PREFPANE'."
# Build OSXFUSE installer package
#
cp -R "$m_srcroot/support/InstallerPackages/$M_PKGBASENAME_OSXFUSE" "$md_osxfuse_out/OSXFUSE"
m_exit_on_error "cannot copy the packaging files for package '$M_PKGNAME_OSXFUSE'."
local md_dist_choices_outline;
local ms_core_out="$M_CONF_TMPDIR/osxfuse-core-$m_release_full"
if [ ! -d "$ms_core_out" ]
then
false
m_exit_on_error "cannot access directory '$ms_core_out'."
fi
pkgutil --expand "$ms_core_out/$M_PKGNAME_CORE" "$md_osxfuse_out/OSXFUSE/$M_PKGNAME_CORE"
m_exit_on_error "cannot expand flat package '$M_PKGNAME_CORE'."
pkgutil --expand "$ms_core_out/$M_PKGNAME_MACFUSE" "$md_osxfuse_out/OSXFUSE/$M_PKGNAME_MACFUSE"
m_exit_on_error "cannot expand flat package '$M_PKGNAME_MACFUSE'."
pkgutil --expand "$md_osxfuse_out/$M_PKGNAME_PREFPANE" "$md_osxfuse_out/OSXFUSE/$M_PKGNAME_PREFPANE"
m_exit_on_error "cannot expand flat package '$M_PKGNAME_PREFPANE'."
find "$md_osxfuse_out/OSXFUSE" -name ".DS_Store" -exec rm -f '{}' \;
m_exit_on_error "cannot remove '.DS_Store' files from package '$M_PKGNAME_OSXFUSE'."
local md_dist_out="$md_osxfuse_out/OSXFUSE/Distribution"
local md_dist_choices="${M_PKGBASENAME_CORE}:${M_PKGNAME_CORE};${M_PKGBASENAME_PREFPANE}:${M_PKGNAME_PREFPANE};${M_PKGBASENAME_MACFUSE}:${M_PKGNAME_MACFUSE}"
cat >> "$md_dist_out" <<__END_DISTRIBUTION
<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script minSpecVersion="1.0">
<title>FUSE for OS X (OSXFUSE)</title>
<background file="background.png" scaling="none" alignment="center"/>
<welcome file="Welcome.rtf"/>
<license file="License.rtf"/>
<options customize="always" rootVolumeOnly="true"/>
<choices-outline>
__END_DISTRIBUTION
m_exit_on_error "cannot write file 'Distribution' for package '$M_PKGNAME_OSXFUSE'."
OLD_IFS="$IFS"
IFS=";"
for i in $md_dist_choices
do
local md_dist_choice_name="${i%%:*}"
cat >> "$md_dist_out" <<__END_DISTRIBUTION
<line choice="$md_dist_choice_name"/>
__END_DISTRIBUTION
m_exit_on_error "cannot write file 'Distribution' for package '$M_PKGNAME_OSXFUSE'."
done
IFS="$OLD_IFS"
cat >> "$md_dist_out" <<__END_DISTRIBUTION
</choices-outline>
__END_DISTRIBUTION
m_exit_on_error "cannot write file 'Distribution' for package '$M_PKGNAME_OSXFUSE'."
OLD_IFS="$IFS"
IFS=";"
for i in $md_dist_choices
do
IFS="$OLD_IFS"
local md_dist_choice_name="${i%%:*}"
local md_dist_choice_packages="${i##*:}"
local md_dist_choice_name_uc=`echo "$md_dist_choice_name" | tr '[:lower:]' '[:upper:]'`
cat >> "$md_dist_out" <<__END_DISTRIBUTION
<choice id="$md_dist_choice_name"
title="${md_dist_choice_name_uc}_TITLE"
description="${md_dist_choice_name_uc}_DESCRIPTION"
start_selected="isChoiceSelected('$md_dist_choice_name')"
start_enabled="isChoiceEnabled('$md_dist_choice_name')"
visible="isChoiceVisible('$md_dist_choice_name')">
__END_DISTRIBUTION
m_exit_on_error "cannot write file 'Distribution' for package '$M_PKGNAME_OSXFUSE'."
IFS=","
for package in $md_dist_choice_packages
do
local md_dist_choice_pkg_path="$md_osxfuse_out/OSXFUSE/$package"
local md_dist_choice_pkg_relpath="#$package"
if [ ! -e "$md_dist_choice_pkg_path" ]
then
false
m_exit_on_error "cannot find package '$package'."
fi
local md_dist_choice_pkg_id=`perl -ne '/<pkg-info[^>]*\sidentifier="([^"]+)"/ && print $1' "$md_dist_choice_pkg_path/PackageInfo"`
m_exit_on_error "cannot extract property 'id' of '$package' for platform '$platform'."
local md_dist_choice_pkg_size=`perl -ne '/<payload[^>]*\sinstallKBytes="([^"]+)"/ && print $1' "$md_dist_choice_pkg_path/PackageInfo"`
m_exit_on_error "cannot extract property 'size' of '$package' for platform '$platform'."
local md_dist_choice_pkg_version=`perl -ne '/<pkg-info[^>]*\sversion="([^"]+)"/ && print $1' "$md_dist_choice_pkg_path/PackageInfo"`
m_exit_on_error "cannot extract property 'version' of '$package' for platform '$platform'."
local md_dist_choice_pkg_auth=`perl -ne '/<pkg-info[^>]*\sauth="([^"]+)"/ && print $1' "$md_dist_choice_pkg_path/PackageInfo"`
m_exit_on_error "cannot extract property 'auth' of '$package' for platform '$platform'."
cat >> "$md_dist_out" <<__END_DISTRIBUTION
<pkg-ref id="$md_dist_choice_pkg_id"
installKBytes="$md_dist_choice_pkg_size"
version="$md_dist_choice_pkg_version"
auth="$md_dist_choice_pkg_auth">$md_dist_choice_pkg_relpath</pkg-ref>
__END_DISTRIBUTION
m_exit_on_error "cannot write file 'Distribution' for package '$M_PKGNAME_OSXFUSE'."
done
IFS="$OLD_IFS"
cat >> "$md_dist_out" <<__END_DISTRIBUTION
</choice>
__END_DISTRIBUTION
m_exit_on_error "cannot write file 'Distribution' for package '$M_PKGNAME_OSXFUSE'."
IFS=";"
done
IFS="$OLD_IFS"
local md_dist_productversion
for platform in $M_PLATFORMS
do
md_dist_productversion=${md_dist_productversion:+"$md_dist_productversion || "}"isProductVersion('$platform')"
done
cat >> "$md_dist_out" <<__END_DISTRIBUTION
<installation-check script='installationCheck()'/>
<script><![CDATA[
function isProductVersion(version)
{
return system.version.ProductVersion.slice(0, version.length) == version;
}
function getChoice(package)
{
return choices[package];
}
function installationCheck()
{
if ($md_dist_productversion) return true;
my.result.type = 'Fatal';
my.result.message = system.localizedString('ERROR_OSXVERSION');
return false;
}
function choiceConflictCheck(package)
{
if (package == '$M_PKGBASENAME_MACFUSE')
{
return system.files.fileExistsAtPath(
'/Library/Filesystems/fusefs.fs/Contents/Info.plist');
}
return false;
}
function isPackageInstalled()
{
return getChoice('$M_PKGBASENAME_CORE').packageUpgradeAction != 'clean';
}
function isChoiceDefaultSelected(package)
{
switch (package)
{
case '$M_PKGBASENAME_CORE': return true;
case '$M_PKGBASENAME_PREFPANE': return true;
default: return false;
}
}
function isChoiceDefaultEnabled(package)
{
switch (package)
{
case '$M_PKGBASENAME_CORE': return false;
default: return true;
}
}
function isChoiceInstalled(package)
{
return getChoice(package).packageUpgradeAction != 'clean';
}
function isChoiceRequired(package)
{
return isChoiceInstalled(package) && !choiceConflictCheck(package);
}
function isChoiceSelected(package)
{
return (!isPackageInstalled() && isChoiceDefaultSelected(package)) ||
isChoiceRequired(package);
}
function isChoiceEnabled(package)
{
return isChoiceDefaultEnabled(package) && !isChoiceRequired(package);
}
function isChoiceVisible(package)
{
return true;
}
]]></script>
</installer-gui-script>
__END_DISTRIBUTION
m_exit_on_error "cannot write file 'Distribution' for package '$M_PKGNAME_OSXFUSE'."
m_log "flatten installer package '$M_PKGNAME_OSXFUSE'"
pkgutil --flatten "$md_osxfuse_out/OSXFUSE" "$md_osxfuse_out/$M_PKGNAME_OSXFUSE"
m_exit_on_error "cannot flatten package '$M_PKGNAME_OSXFUSE'."
echo >$m_stdout
m_log "succeeded, results in '$md_osxfuse_out'."
echo >$m_stdout
return 0
}
function m_handler_release()
{
m_active_target="release"
m_platform="$M_DEFAULT_PLATFORM"
m_set_platform
m_release_full=`awk '/#define[ \t]*OSXFUSE_VERSION_LITERAL/ {print $NF}' "$m_srcroot/common/fuse_version.h"`
m_release=`echo "$m_release_full" | cut -d . -f 1,2`
m_exit_on_error "cannot get OSXFUSE release version."
local mr_osxfuse_out="$M_CONF_TMPDIR/osxfuse-release-$m_release_full"
local mr_dmg_name="OSXFUSE-$m_release_full.dmg"
local mr_dmg_path="$mr_osxfuse_out/$mr_dmg_name"
if [ "$m_shortcircuit" != "1" ]
then
if [ -e "$mr_osxfuse_out" ]
then
m_set_suprompt "to remove a previously built release diskimage"
sudo -p "$m_suprompt" rm -rf "$mr_osxfuse_out"
m_exit_on_error "failed to clean up previous built release diskimage."
fi
if [ -e "$M_CONF_TMPDIR/osxfuse-release-"* ]
then
m_warn "removing unrecognized version of release diskimage"