-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-kstars.sh
executable file
·873 lines (738 loc) · 27.5 KB
/
build-kstars.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
#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ANNOUNCE=""
INDI_ONLY=""
SKIP_BREW=""
BUILD_INDI=""
KSTARS_BUILD_TYPE=""
GENERATE_DMG=""
FORCE_RUN=""
KSTARS_APP=""
FORCE_BREW_QT=""
#This will print out how to use the script
function usage
{
cat <<EOF
options:
-a Announce stuff as you go
-c Build kstars via cmake (ONLY one of -c , -x, or -e can be used)
-d Generate dmg
-e Build kstars via craft (ONLY one of -c , -x, or -e can be used)
-f Force build even if there are script updates
-i Build libindi
-q Use the brew-installed qt
-s Skip brew (only use this if you know you already have them)
-x Build kstars via cmake with xcode (ONLY one of -c , -x, or -e can be used)
To build a complete craft you would do:
$0 -aeid
To build a complete cmake build you would do:
$0 -acid
To build a complete cmake build with an xcode project you would do:
$0 -axid
EOF
}
#This function prints the usage information if the user enters an invalid option or no option at all and quits the program
function dieUsage
{
echo ""
echo $*
echo ""
usage
exit 9
}
#These functions are involved in quitting the script
function dieError
{
echo ""
echo $*
echo ""
exit 9
}
function exitEarly
{
announce "$*"
trap - EXIT
exit 0
}
function scriptDied
{
announce "Something failed"
}
#This function processes the user's options for running the script
function processOptions
{
while getopts "acdeiqsx" option
do
case $option in
a)
ANNOUNCE="Yep"
;;
c)
KSTARS_BUILD_TYPE="CMAKE"
FORCE_BREW_QT="Yep"
echo "Due to a current error in building Phonon with non brew qt using cmake, we have to use the brew qt for cmake"
;;
d)
GENERATE_DMG="Yep"
;;
e)
KSTARS_BUILD_TYPE="CRAFT"
;;
f)
FORCE_RUN="Yep"
;;
i)
BUILD_INDI="Yep"
;;
q)
FORCE_BREW_QT="Yep"
;;
s)
SKIP_BREW="Yep"
;;
x)
KSTARS_BUILD_TYPE="XCODE"
FORCE_BREW_QT="Yep"
echo "Due to a current error in building Phonon with non brew qt using xcode, we have to use the brew qt for xcode"
;;
*)
dieUsage "Unsupported option $option"
;;
esac
done
shift $((${OPTIND} - 1))
echo ""
echo "ANNOUNCE = ${ANNOUNCE:-Nope}"
echo "BUILD_INDI = ${BUILD_INDI:-Nope}"
echo "KSTARS_BUILD_TYPE = ${KSTARS_BUILD_TYPE:-None}"
echo "GENERATE_DMG = ${GENERATE_DMG:-Nope}"
echo "SKIP_BREW = ${SKIP_BREW:-Nope}"
}
#This function installs a program with homebrew if it is not installed, otherwise it moves on.
function brewInstallIfNeeded
{
brew ls $1 > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "Installing : $*"
brew install $*
else
echo "brew : $* is already installed"
fi
}
#This function checks to see that all connections are available before starting the script
#That could save time if one of the repositories is not available and it would crash later
function checkForConnections
{
git ls-remote ${KSTARS_REPO} &> /dev/null
git ls-remote ${LIBINDI_REPO} &> /dev/null
git ls-remote ${CRAFT_REPO} &> /dev/null
statusBanner "All Git Respositories found"
if curl --output /dev/null --silent --head --fail "https://sourceforge.net/projects/flatplanet/files/maps/1.0/maps_alien-1.0.tar.gz";then
statusBanner "XPlanet Images found"
else
echo "XPlanet Image File Failure"
fi
}
#This checks to see if QT is installed before starting.
# function checkForQT
# {
# if [ -z "${FORCE_BREW_QT}" ]
# then
# if [ -n "$QT5_DIR" ]
# then
# if [ ! -d "$QT5_DIR" ]
# then
# dieUsage "Please check your build-env.sh for the QT5 variable. QT5 cannot be found. Either QT is not installed or the wrong directory is selected. You can also use the homebrew QT. Please see the readme file."
# fi
# else
# dieUsage "Please check your build-env.sh for the QT5 variable. It is blank. You need to either specify it or use the homebrew QT. Please see the readme file."
# fi
# fi
# }
#This checks to see that this script is up to date. If it is not, you can use the -f option to force it to run.
function checkUpToDate
{
cd "$DIR"
localVersion=$(git log --pretty=%H ...refs/heads/master^ | head -n 1)
remoteVersion=$(git ls-remote origin -h refs/heads/master | cut -f1)
cd - > /dev/null
echo ""
echo ""
if [ "${localVersion}" != "${remoteVersion}" ]
then
if [ -z "$FORCE_RUN" ]
then
announce "Script is out of date"
echo ""
echo "override with a -f"
echo ""
echo "There is a newer version of the script available, please update - run"
echo "cd $DIR ; git pull"
echo "Aborting run"
exit 9
else
echo "WARNING: Script is out of date"
echo "Forcing run"
fi
else
echo "Script is up-to-date"
echo ""
fi
}
#This installs the kde programs if it is doing the XCode or Cmake version of the build
#It gets the files from the homebrew KDE-mac repo. It uses the homebrew version of QT.
function installHomebrewKf5Stuff
{
# I deleted the homebrew hacks to use the non-brew qt since there were some issues with that.
brew untap KDE-mac/kde
brew tap KDE-mac/kde
brewInstallIfNeeded qt
brew link --force gettext
mkdir -p /usr/local/lib/libexec
brewInstallIfNeeded KDE-mac/kde/kf5-kwallet
brewInstallIfNeeded KDE-mac/kde/kf5-kcoreaddons
brew link --overwrite kf5-kcoreaddons
brewInstallIfNeeded KDE-mac/kde/kf5-kcrash
# This had to be added due to an issue with kf5 sonnet.
brew install aspell
brewInstallIfNeeded KDE-mac/kde/kf5-knotifyconfig
brewInstallIfNeeded KDE-mac/kde/kf5-knotifications
brewInstallIfNeeded KDE-mac/kde/kf5-kplotting
brewInstallIfNeeded KDE-mac/kde/kf5-kxmlgui
brewInstallIfNeeded KDE-mac/kde/kf5-kdoctools
brewInstallIfNeeded KDE-mac/kde/kf5-knewstuff
brewInstallIfNeeded KDE-mac/kde/kf5-kded
cd - > /dev/null
}
#This installs dependencies needed for KStars and INDI with homebrew.
#These files are needed regardless of the build type.
#This function does not include the kde programs that are handled above.
function installBrewDependencies
{
announce "updating homebrew"
brew upgrade
announce "Installing xcode command line tools"
xcode-select --install
announce "Installing brew dependencies"
brewInstallIfNeeded cmake
brewInstallIfNeeded wget
brewInstallIfNeeded coreutils
brewInstallIfNeeded p7zip
brewInstallIfNeeded gettext
brewInstallIfNeeded ninja
brewInstallIfNeeded python3
brewInstallIfNeeded bison
brewInstallIfNeeded boost
brewInstallIfNeeded shared-mime-info
# These for gphoto
#
brewInstallIfNeeded dcraw
brewInstallIfNeeded gphoto2
brewInstallIfNeeded libraw
brew tap brewsci/science #Note homebrew-science is depreciated and we may need to make changes.
brewInstallIfNeeded pkgconfig
brewInstallIfNeeded cfitsio
brewInstallIfNeeded eigen
brewInstallIfNeeded astrometry-net
brewInstallIfNeeded xplanet
brewInstallIfNeeded gsl
brewInstallIfNeeded python
/usr/local/bin/pip2 install pyfits
brewInstallIfNeeded libftdi
brewInstallIfNeeded ffmpeg
brewInstallIfNeeded libdc1394
brewInstallIfNeeded libfftw3
brewInstallIfNeeded librtlsdr
brewInstallIfNeeded gpsd
# This is needed because astrometry-net requires an old version of cfitsio for now.
mkdir -p /usr/local/opt/cfitsio/lib/
cp -f ${DIR}/libcfitsio.5.dylib /usr/local/opt/cfitsio/lib/libcfitsio.5.dylib
brewInstallIfNeeded dbus
#These are needed for Translations
brewInstallIfNeeded gpg
ln -sf /usr/local/bin/gpg /usr/local/bin/gpg2
brewInstallIfNeeded ruby
#For some reason the new ruby 2.5 is not accepted by fetch-translations
brewInstallIfNeeded [email protected]
export PATH=/usr/local/opt/[email protected]/bin:$PATH
brewInstallIfNeeded jamiesmith/astronomy/libnova
brewInstallIfNeeded jamiesmith/astronomy/gsc
gem install logger-colors
# These needed to be added because KDocTools now fails to install if they aren't installed ahead of time.
brew install docbook
brew install docbook-xsl
announce "Attempting to install cpan and URI for kdoctools."
brewInstallIfNeeded cpanminus
cpanm URI
announce "IF Kdoctools fails to install, exit the script, run cpanm URI, and then restart the script"
announce "Installing XML parser for Craft."
cpanm XML::Parser
#This is a hack that will allow Craft to handle intltool
#Because the latest version of perl 5.26.0 causes errors when running intltool-update
#This should be changed back once the error is fixed!
#This forces the system to use /usr/bin perl which should be an older version than /usr/local/bin/perl
brew remove perl
ln -s /usr/bin/perl /usr/local/bin/perl
# Only do this if we are doing a cmake build
#
if [ "$KSTARS_BUILD_TYPE" == "CMAKE" ] || [ "$KSTARS_BUILD_TYPE" == "XCODE" ]
then
installHomebrewKf5Stuff
fi
}
function buildThirdPartyLibrary
{
mkdir -p "${INDI_DIR}/build/3rdparty/$*"
cd "${INDI_DIR}/build/3rdparty/$*"
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MACOSX_RPATH=1 "${INDI_DIR}/indi/3rdparty/$*"
make
make install
}
#This builds the INDI 3rd Party Drivers
function buildThirdParty
{
mkdir -p ${INDI_DIR}/build/3rdparty
## Build 3rd party Libraries
buildThirdPartyLibrary libqsi
buildThirdPartyLibrary libqhy
buildThirdPartyLibrary libapogee
buildThirdPartyLibrary libsbig
buildThirdPartyLibrary libfishcamp
buildThirdPartyLibrary libdspau
buildThirdPartyLibrary libfli
buildThirdPartyLibrary libtoupcam
buildThirdPartyLibrary libatik
buildThirdPartyLibrary libaltaircam
cd ${INDI_DIR}/build/3rdparty
## Run cmake and make install twice
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MACOSX_RPATH=1 ${INDI_DIR}/indi/3rdparty
statusBanner "make 3rd party drivers"
make
make install
#Copy Atik Drivers from Cloudmakers
#cp -f ${DIR}/atik-cloudmakers/indi_atik_wheel /usr/local/bin/indi_atik_wheel
#cp -f ${DIR}/atik-cloudmakers/indi_atik_ccd /usr/local/bin/indi_atik_ccd
#cp -f ${DIR}/atik-cloudmakers/libindi.dylib /usr/local/lib/libindi.dylib
}
#This builds and installs libindi and starts the 3rd party build
function buildINDI
{
mkdir -p ${INDI_DIR}
##########################################
# Indi
announce "building libindi"
cd ${INDI_DIR}/
if [ ! -d indi ]
then
statusBanner "Cloning indi library"
git clone ${LIBINDI_REPO}
cd indi/libindi
else
statusBanner "Updating indi"
cd indi
git pull
cd ..
fi
mkdir -p ${INDI_DIR}/build/libindi
cd ${INDI_DIR}/build/libindi
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MACOSX_RPATH=1 ${INDI_DIR}/indi/libindi
statusBanner "make indi"
make
# This might need a sudo.
#
statusBanner "make install indi"
make install
announce "Building Third Party Drivers"
buildThirdParty
}
#This builds KStars using Craft
function craftKstars
{
mkdir -p ${CRAFT_DIR}
cd ${CRAFT_DIR}/
if [ ! -d oxygen ]
then
git clone https://github.com/KDE/oxygen.git
fi
if [ ! -d craft ]
then
statusBanner "Cloning craft"
wget https://raw.githubusercontent.com/KDE/craft/master/setup/CraftBootstrap.py -O setup.py && python3.6 setup.py --prefix ${CRAFT_DIR}
#This is the old way of doing it. This method works, so you can go back if there is a problem
#git clone ${CRAFT_REPO}
#cd craft
#git reset --hard de8e9a79fde9bede703da3756fe641ffefc659f7
#cd ..
else
statusBanner "Updating Craft"
cd craft
git pull
cd ..
fi
#These are related to the old way stated above.
#mkdir -p etc
#cp -f craft/kdesettings.mac etc/kdesettings.ini
#source craft/kdeenv.sh
statusBanner "Copying Craft Settings"
cp ${DIR}/CraftSettings.ini ${CRAFT_DIR}/etc/
cp ${DIR}/BlueprintSettings.ini ${CRAFT_DIR}/etc/
cd ${CRAFT_DIR}
source craft/craftenv.sh
statusBanner "Crafting icons"
craft breeze-icons
#These currently are done separately because it fails when done while crafting kstars for some reason
statusBanner "Crafting libjpeg-turbo"
craft -vvv libjpeg-turbo
statusBanner "Crafting libraw"
craft -vvv libraw
statusBanner "Crafting KStars"
craft -vvv -i kstars
cp -f ${CRAFT_DIR}/oxygen/sounds/*.ogg ${CRAFT_DIR}/share/sounds/
announce "CRAFT COMPLETE"
}
#This builds KStars for the XCode or Cmake build.
function buildKstars
{
mkdir -p ${KSTARS_CMAKE_DIR}
announce "Building k stars via c make"
cd ${KSTARS_CMAKE_DIR}/
if [ ! -d kstars ]
then
statusBanner "Cloning kstars"
git clone ${KSTARS_REPO}
else
statusBanner "Updating kstars"
cd kstars
git pull
cd ..
fi
mkdir -p kstars-build
cd kstars-build
if [ "$KSTARS_BUILD_TYPE" == "XCODE" ]
then
cmake -DCMAKE_INSTALL_PREFIX=${KSTARS_XCODE_DIR} -G Xcode ../kstars
xcodebuild -target fetch-translations build
xcodebuild -project kstars.xcodeproj -alltargets -configuration Debug
xcodebuild install
else
cmake -DCMAKE_INSTALL_PREFIX=${KSTARS_CMAKE_DIR} ../kstars
make fetch-translations
make
make install
fi
if [ ! -d ${KSTARS_CMAKE_DIR}/breeze-icons ]
then
statusBanner "Downloading icons"
cd ${KSTARS_CMAKE_DIR}
git clone https://github.com/KDE/breeze-icons.git
else
statusBanner "Updating icons"
cd ${KSTARS_CMAKE_DIR}/breeze-icons
git pull
fi
mkdir -p ${KSTARS_CMAKE_DIR}/breeze-icons-build
cd ${KSTARS_CMAKE_DIR}/breeze-icons-build
cmake -DCMAKE_INSTALL_PREFIX=${KSTARS_CMAKE_DIR} ../breeze-icons
make
make install
}
#This function handles KStars after it is built.
#It copies in needed programs and files and prepares them for future steps.
function postProcessKstars
{
##########################################
statusBanner "Post-processing KStars Build"
echo "KSTARS_APP=${KSTARS_APP}"
##########################################
statusBanner "Editing info.plist"
plutil -insert NSPrincipalClass -string NSApplication ${KSTARS_APP}/Contents/info.plist
plutil -insert NSHighResolutionCapable -string True ${KSTARS_APP}/Contents/info.plist
plutil -insert NSRequiresAquaSystemAppearance -string NO ${KSTARS_APP}/Contents/info.plist
plutil -replace CFBundleName -string KStars ${KSTARS_APP}/Contents/info.plist
plutil -replace CFBundleVersion -string $KSTARS_VERSION ${KSTARS_APP}/Contents/info.plist
plutil -replace CFBundleLongVersionString -string $KSTARS_VERSION ${KSTARS_APP}/Contents/info.plist
plutil -replace CFBundleShortVersionString -string $KSTARS_VERSION ${KSTARS_APP}/Contents/info.plist
plutil -replace NSHumanReadableCopyright -string "© 2001 - 2018, The KStars Team, Freely Released under GNU GPL V2" ${KSTARS_APP}/Contents/info.plist
##########################################
statusBanner "The Data Directory and Translations Directory"
appDataFolder=${KSTARS_APP}/Contents/Resources/data
appTranslationsFolder=${KSTARS_APP}/Contents/Resources/locale
echo mkdir -p $appDataFolder
mkdir -p $appDataFolder
echo mkdir -p $appTranslationsFolder
mkdir -p $appTranslationsFolder
# Craft and cmake now put them in the same directory, but if it is the Xcode version, it is a subdirectory.
#
if [ "$KSTARS_BUILD_TYPE" == "CMAKE" ] && [ -d "${KSTARS_CMAKE_DIR}/share/kstars" ]
then
typeset src_dir="${KSTARS_CMAKE_DIR}/share/"
echo "copying from $src_dir and homebrew share"
cp -rf $src_dir/kstars/* $appDataFolder/
cp -rf /usr/local/share/locale/* $appTranslationsFolder/
cp -rf $src_dir/locale/* $appTranslationsFolder/
elif [ "$KSTARS_BUILD_TYPE" == "CRAFT" ] && [ -d "${CRAFT_DIR}/share/kstars" ]
then
typeset src_dir="${CRAFT_DIR}/share/"
echo "copying from $src_dir"
cp -rf $src_dir/kstars/* $appDataFolder/
cp -rf $src_dir/locale/* $appTranslationsFolder/
statusBanner "NOTE: For now Craft cannot build translations for Kstars. Trying to copy from the CMAKE build instead."
if [ -d ${KSTARS_CMAKE_DIR}/share/locale/ ]
then
cp -rf ${KSTARS_CMAKE_DIR}/share/locale/* $appTranslationsFolder/ #This is needed until we can get craft to build the kstars translations.
statusBanner "Copy Successful."
else
statusBanner "CMAKE Version translations not found, skipping copy."
fi
elif [ "$KSTARS_BUILD_TYPE" == "XCODE" ] && [ -d "${KSTARS_XCODE_DIR}/kstars/kstars/data" ]
then
echo "copying from XCode folders and homebrew share"
cp -rf ${KSTARS_XCODE_DIR}/kstars/kstars/data/* $appDataFolder/
cp -rf /usr/local/share/locale/* $appTranslationsFolder/
cp -rf ${KSTARS_XCODE_DIR}/kstars-build/locale/* $appTranslationsFolder/
else
announce "Cannot find k stars data"
fi
##########################################
statusBanner "The indi drivers"
mkdir -p ${KSTARS_APP}/Contents/MacOS/indi
cp -f /usr/local/bin/indi* ${KSTARS_APP}/Contents/MacOS/indi/
##########################################
statusBanner "The gsc executable"
sourceDir="$(brew --prefix gsc)"
cp -f ${sourceDir}/bin/gsc ${KSTARS_APP}/Contents/MacOS/indi/
#This is needed so we will be able to run the install_name_tool on it.
chmod +w ${KSTARS_APP}/Contents/MacOS/indi/gsc
##########################################
statusBanner "The astrometry files"
if [ -n "${KSTARS_APP}" ]
then
sourceDir="$(brew --prefix astrometry-net)"
targetDir="${KSTARS_APP}/Contents/MacOS/astrometry"
mkdir -p ${targetDir}
cp -Rf ${sourceDir}/bin ${targetDir}/
cp -Rf ${sourceDir}/lib ${targetDir}/
cp -f ${sourceDir}/etc/astrometry.cfg ${targetDir}/bin/
#This is needed so we will be able to run the install_name_tool on them.
chmod +w ${targetDir}/bin/*
mkdir -p ${KSTARS_APP}/Contents/MacOS/netpbm
cp -Rf $(brew --prefix netpbm)/bin ${KSTARS_APP}/Contents/MacOS/netpbm/
chmod +w ${KSTARS_APP}/Contents/MacOS/netpbm/bin/*
mkdir -p ${KSTARS_APP}/Contents/MacOS/python/bin
cp -f $(brew --prefix python2)/bin/python2 ${KSTARS_APP}/Contents/MacOS/python/bin/python
mkdir -p ${KSTARS_APP}/Contents/MacOS/python/bin/site-packages
cp -RLf /usr/local/lib/python2.7/site-packages/numpy ${KSTARS_APP}/Contents/MacOS/python/bin/site-packages/
cp -RLf /usr/local/lib/python2.7/site-packages/pyfits ${KSTARS_APP}/Contents/MacOS/python/bin/site-packages/
chmod -R +w ${KSTARS_APP}/Contents/MacOS/python
fi
##########################################
statusBanner "Set up some xplanet pictures..."
tar -xzf ${DIR}/maps_alien-1.0.tar -C "$(brew --prefix xplanet)" --strip-components=2
xplanet_dir=${KSTARS_APP}/Contents/MacOS/xplanet/
mkdir -p ${xplanet_dir}
cp -rf $(brew --prefix xplanet)/bin ${xplanet_dir}
chmod +w ${xplanet_dir}/bin/xplanet
cp -rf $(brew --prefix xplanet)/share ${xplanet_dir}
statusBanner "Copying qhy, apogee, and DSI firmware"
cp -rf /usr/local/lib/indi/DriverSupport ${KSTARS_APP}/Contents/Resources/
##########################################
statusBanner "Copying Driver XML Files"
cp -f /usr/local/share/indi/* ${KSTARS_APP}/Contents/Resources/DriverSupport/
statusBanner "And all the missed Driver XML Files"
FILES="$(find ${INDI_DIR} -name '*.xml.cmake')"
for FILE in $FILES; do
FILENAME=$(basename $FILE)
NEWFILENAME="$(echo $FILENAME | sed 's/.cmake//')"
echo $NEWFILENAME
DESTINATION=${KSTARS_APP}/Contents/Resources/DriverSupport/$NEWFILENAME
cp -f $FILE $DESTINATION
done
##########################################
statusBanner "Copying Math Plugins"
cp -rf /usr/local/lib/indi/MathPlugins ${KSTARS_APP}/Contents/Resources/
##########################################
statusBanner "Copying GPhoto Plugins"
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
GPHOTO_VERSION=$(pkg-config --modversion libgphoto2)
PORT_VERSION=$(pkg-config --modversion libgphoto2_port)
mkdir -p ${KSTARS_APP}/Contents/Resources/DriverSupport/gphoto/IOLIBS
mkdir -p ${KSTARS_APP}/Contents/Resources/DriverSupport/gphoto/CAMLIBS
cp -rf $(brew --prefix libgphoto2)/lib/libgphoto2_port/${PORT_VERSION}/* ${KSTARS_APP}/Contents/Resources/DriverSupport/gphoto/IOLIBS/
cp -rf $(brew --prefix libgphoto2)/lib/libgphoto2/${GPHOTO_VERSION}/* ${KSTARS_APP}/Contents/Resources/DriverSupport/gphoto/CAMLIBS/
#This is needed so we will be able to run the install_name_tool on them.
chmod +w ${KSTARS_APP}/Contents/Resources/DriverSupport/gphoto/IOLIBS/*
chmod +w ${KSTARS_APP}/Contents/Resources/DriverSupport/gphoto/CAMLIBS/*
##########################################
statusBanner "Copying dbus programs and files."
cp -f $(brew --prefix dbus)/bin/dbus-daemon ${KSTARS_APP}/Contents/MacOS/
chmod +w ${KSTARS_APP}/Contents/MacOS/dbus-daemon
cp -f $(brew --prefix dbus)/bin/dbus-send ${KSTARS_APP}/Contents/MacOS/
chmod +w ${KSTARS_APP}/Contents/MacOS/dbus-send
mkdir -p ${KSTARS_APP}/Contents/PlugIns/dbus
cp -f $(brew --prefix dbus)/share/dbus-1/session.conf ${KSTARS_APP}/Contents/PlugIns/dbus/kstars.conf
cp -f ${DIR}/org.freedesktop.dbus-kstars.plist ${KSTARS_APP}/Contents/PlugIns/dbus/
##########################################
statusBanner "Copying phonon backend and vlc plugins"
tar -xzf ${DIR}/backend.zip -C ${KSTARS_APP}/Contents/PlugIns/
tar -xzf ${DIR}/vlc.zip -C ${KSTARS_APP}/Contents/PlugIns/
##########################################
if [ "$KSTARS_BUILD_TYPE" == "CRAFT" ]
then
statusBanner "Copying k i o slave."
#I am not sure why this is needed, but it doesn't seem to be able to access KIOSlave otherwise.
#Do we need kio_http_cache_cleaner?? or any others?
cp -f ${CRAFT_DIR}/lib/libexec/kf5/kioslave ${KSTARS_APP}/Contents/MacOS/
statusBanner "Copying plugins"
if [ -e "${CRAFT_DIR}/lib/plugins/" ]
then
cp -rf ${CRAFT_DIR}/lib/plugins/* ${KSTARS_APP}/Contents/PlugIns/
fi
statusBanner "Copying Notifications."
cp -rf ${CRAFT_DIR}/share/knotifications5 ${KSTARS_APP}/Contents/Resources/
statusBanner "Copying Sounds."
cp -rf ${CRAFT_DIR}/share/sounds ${KSTARS_APP}/Contents/Resources/
statusBanner "Copying icons."
mkdir ${KSTARS_APP}/Contents/Resources/icons
cp -f ${CRAFT_DIR}/share/icons/breeze/breeze-icons.rcc ${KSTARS_APP}/Contents/Resources/icons/
cp -f ${CRAFT_DIR}/share/icons/breeze-dark/breeze-icons-dark.rcc ${KSTARS_APP}/Contents/Resources/icons/
elif [ "$KSTARS_BUILD_TYPE" == "CMAKE" ] || [ "$KSTARS_BUILD_TYPE" == "XCODE" ]
then
statusBanner "Copying k i o slave."
#Do we need kio_http_cache_cleaner?? or any others?
#This hack is needed because for some reason on my system klauncher cannot access kioslave even in the app directory.
cp -f /usr/local/lib/libexec/kf5/kioslave /usr/local/opt/kf5-kinit/lib/libexec/kf5/kioslave
cp -f /usr/local/lib/libexec/kf5/kioslave ${KSTARS_APP}/Contents/MacOS/
statusBanner "Copying plugins"
if [ -e "/usr/local/lib/qt5/plugins/" ]
then
cp -rf /usr/local/lib/qt5/plugins/* ${KSTARS_APP}/Contents/PlugIns/
fi
if [ -e "/usr/local/lib/plugins/" ]
then
cp -rf /usr/local/lib/plugins/* ${KSTARS_APP}/Contents/PlugIns/
fi
statusBanner "Copying Frameworks for VLC/Phonon."
tar -xzf ${DIR}/FrameworksForVLC.zip -C ${KSTARS_APP}/Contents/
statusBanner "Copying Notifications."
cp -rf ${KSTARS_CMAKE_DIR}/share/knotifications5 ${KSTARS_APP}/Contents/Resources/
statusBanner "Copying Sounds."
cp -rf ${KSTARS_CMAKE_DIR}/share/sounds ${KSTARS_APP}/Contents/Resources/
statusBanner "Copying icons."
mkdir ${KSTARS_APP}/Contents/Resources/icons
cp -f ${KSTARS_CMAKE_DIR}/share/icons/breeze/breeze-icons.rcc ${KSTARS_APP}/Contents/Resources/icons/
cp -f ${KSTARS_CMAKE_DIR}/share/icons/breeze-dark/breeze-icons-dark.rcc ${KSTARS_APP}/Contents/Resources/icons/
else
announce "Plugins and K I O Slave ERROR"
fi
#This will allow otool to be run on them
statusBanner "Preparing plugins for otool"
chmod -R +w ${KSTARS_APP}/Contents/MacOS/kioslave
chmod -R +w ${KSTARS_APP}/Contents/PlugIns/
if [ "$KSTARS_BUILD_TYPE" == "CRAFT" ]
then
statusBanner "Copying Craft app bundle into build folder in case you want to edit kstars in QT Creator."
cp -rf ${KSTARS_APP} ${CRAFT_DIR}/build/kde/applications/kstars/work/RelWithDebInfo-$KSTARS_VERSION/kstars
fi
}
########################################################################################
# This is where the main part of the script starts!
#
#Process the command line options to determine what to do.
processOptions $@
#Check to see that this script is up to date. If you want it to run anyway, use the -f option.
checkUpToDate
# Prepare to run the script by setting all of the environment variables
source "${DIR}/build-env.sh"
# Before starting, check for QT and to see if the remote servers are accessible
# checkForQT
checkForConnections
#Check first that the user has entered build options, if not, print the list of options and quit.
if [ -z "$KSTARS_BUILD_TYPE" ] && [ -z "$BUILD_INDI" ]
then
dieUsage "Please either select to build indi and/or KStars"
fi
#Announce the script is starting and what will be done.
if [ -n "$KSTARS_BUILD_TYPE" ] && [ -n "$BUILD_INDI" ]
then
announce "Starting script, building INDI and KStars with $KSTARS_BUILD_TYPE"
elif [ -z "$KSTARS_BUILD_TYPE" ] && [ -n "$BUILD_INDI" ]
then
announce "Starting script, building INDI only"
elif [ -n "$KSTARS_BUILD_TYPE" ] && [ -z "$BUILD_INDI" ]
then
announce "Starting script, building KStars with $KSTARS_BUILD_TYPE"
fi
if [ -n "$GENERATE_DMG" ]
then
announce "and then building a DMG"
fi
#Warn about the fact that it is using the homebrew qt even though that was not explicitly requested.
# if [ -z "${FORCE_BREW_QT}" ] && [ "$QT5_DIR" == "$(brew --prefix qt)" ]
# then
# announce "Currently the path to the QT being used in this build is the homebrew version. If you want to build with the system QT please update the variable in build-env.sh"
# fi
#This will install KStars dependencies from Homebrew. If you know they are installed, you can skip it.
if [ -z "$SKIP_BREW" ]
then
installBrewDependencies
else
announce "Skipping brew dependencies"
fi
#The xcode installation is very similar to the cmake installation. But the directory is different.
#This will just set the cmake directory to be the xcode directory.
if [ "$KSTARS_BUILD_TYPE" == "XCODE" ]
then
export KSTARS_CMAKE_DIR=${KSTARS_XCODE_DIR}
fi
# From here on out exit if there is a failure
#
set -e
trap scriptDied EXIT
#This will build indi, including the 3rd Party drivers.
if [ -n "${BUILD_INDI}" ]
then
buildINDI
else
announce "Skipping INDI Build"
fi
#This will select which type of build to do and will set the KStars app directory appropriately.
if [ "$KSTARS_BUILD_TYPE" == "CRAFT" ]
then
KSTARS_APP="${CRAFT_DIR}/Applications/KDE/KStars.app"
rm -rf ${KSTARS_APP}
craftKstars
elif [ "$KSTARS_BUILD_TYPE" == "XCODE" ]
then
KSTARS_APP="${KSTARS_XCODE_DIR}/kstars-build/kstars/Debug/KStars.app"
rm -rf ${KSTARS_APP}
buildKstars
elif [ "$KSTARS_BUILD_TYPE" == "CMAKE" ]
then
KSTARS_APP="${KSTARS_CMAKE_DIR}/kstars-build/kstars/KStars.app"
rm -rf ${KSTARS_APP}
buildKstars
else
announce "Not building k stars"
fi
#If KStars is being built of any type, postprocess it.
if [ -n "$KSTARS_BUILD_TYPE" ]
then
postProcessKstars
fi
#For the xcode build, this will copy the code to the release folder in addition to the debug folder.
if [ "$KSTARS_BUILD_TYPE" == "XCODE" ]
then
statusBanner "Copying to XCode Release Folder"
mkdir -p ${KSTARS_APP}/../../Release
rm -rf ${KSTARS_APP}/../../Release/KStars.app
cp -Rf ${KSTARS_APP} ${KSTARS_APP}/../../Release/KStars.app
fi
#This will package everything up into the app and then make a dmg.
if [ -n "$GENERATE_DMG" ]
then
source ${DIR}/generate-dmg.sh
fi
# Finally, remove the trap
trap - EXIT
announce "Script execution complete"