-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·165 lines (121 loc) · 4.04 KB
/
setup.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
#!/bin/bash
PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
TURBOJPEG_LIB_NAME=libturbojpeg.0.dylib
TURBOJPEG_LIB_PATH=/opt/libjpeg-turbo/lib/$TURBOJPEG_LIB_NAME
TURBOJPEG_RELEASE_URL=https://sourceforge.net/projects/libjpeg-turbo/files/
FRAMEWORKS_DIR=Frameworks
EDSDK_ZIP_URL=https://downloads.canon.com/sdk/EDSDK_v131231_Macintosh.zip
if [ ! -d "Imago.xcodeproj" ]; then
echo "This script must be executed in the base directory of the Imago project"
exit 1
fi
installTurboJpeg() {
if [ -f "$TURBOJPEG_LIB_PATH" ]; then
return 0
else
if isBrewInstalled; then
while true; do
read -p "Do you wish to install TurboJPEG?" yn
case $yn in
[Yy]* ) brew install jpeg-turbo; return installTurboJpeg;;
[Nn]* ) askUserToInstallTurboJpeg ;;
* ) echo "Please answer yes or no.";;
esac
done
else
askUserToInstallTurboJpeg
fi
fi
}
askUserToInstallTurboJpeg() {
echo "TurboJPEG not found. Please install and re-run this script"
open $TURBOJPEG_RELEASE_URL
exit
}
isBrewInstalled() {
which -s brew
if [[ $? != 0 ]] ; then
return 0
else
return 1
fi
}
isTurboJpegSetup() {
if [ -f "$FRAMEWORKS_DIR/$TURBOJPEG_LIB_NAME" ]; then
return 0
else
return 1
fi
}
setupTurboJpegAsFramework() {
if installTurboJpeg; then
local newLibPath=$FRAMEWORKS_DIR/$TURBOJPEG_LIB_NAME
if [ -f "$TURBOJPEG_LIB_PATH" ]; then
echo "Copying $TURBOJPEG_LIB_NAME to $newLibPath"
cp $TURBOJPEG_LIB_PATH $newLibPath
echo "Updating $TURBOJPEG_LIB_NAME location to look in app bundle"
install_name_tool -id @executable_path/../Frameworks/$TURBOJPEG_LIB_NAME $newLibPath
echo "Updating $TURBOJPEG_LIB_NAME use system libgcc"
install_name_tool -change /opt/local/lib/libgcc/libgcc_s.1.dylib /usr/lib/libgcc_s.1.dylib $newLibPath
echo "Removing uncessary architectures from $TURBOJPEG_LIB_NAME"
lipo -thin x86_64 $newLibPath -o $newLibPath
fi
else
echo "TurboJPEG could not be installed."
fi
}
isEDSDKSetup() {
if [ -d "$PROJECTDIR/$FRAMEWORKS_DIR/EDSDK/EDSDK.framework" ]; then
return 0
else
return 1
fi
}
setupEDSDKAsFramework() {
local tmpDir=`mktemp -d`
local zipName=$(basename $EDSDK_ZIP_URL)
local diskImageName=Macintosh.dmg
local mountedImagePath=/Volumes/Macintosh
local edsdkDirectory="$mountedImagePath/EDSDK"
local frameworkDirectory="$PROJECTDIR/$FRAMEWORKS_DIR/EDSDK"
local frameworkName=EDSDK.framework
if [ ! -d "$frameworkDirectory/$frameworkName" ]; then
cd $tmpDir
echo "Downloading EDSDK.framework..."
curl -O $EDSDK_ZIP_URL &> /dev/null
if [ ! -f $zipName ]; then
echo "Download of $EDSDK_ZIP_URL failed"
cd $PROJECTDIR
return 1
fi
echo "Unziping EDSDK"
unzip -a $zipName &> /dev/null
unzip -a "$diskImageName.zip" &> /dev/null
if [ ! -f $diskImageName ]; then
echo "EDSDK disk image not found. Can not complete setup"
cd $PROJECTDIR
return 1
fi
echo "Attaching EDSDK disk image"
hdiutil attach $diskImageName &> /dev/null
echo "Creating required directory structure"
mkdir -p $frameworkDirectory/Header
echo "Copying $frameworkName and Headers"
cp -R $edsdkDirectory/Framework/$frameworkName $frameworkDirectory/$frameworkName
cp -R $edsdkDirectory/Header/* $frameworkDirectory/Header/
echo "Cleaning up..."
hdiutil detach $mountedImagePath &> /dev/null
cd $PROJECTDIR
echo "Done"
fi
}
if isTurboJpegSetup; then
echo "TurboJPEG is setup for Imago"
else
setupTurboJpegAsFramework
fi
if isEDSDKSetup; then
echo "EDSDK is setup for Imago"
else
setupEDSDKAsFramework
fi