forked from packagesdev/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·233 lines (129 loc) · 5.05 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
#!/bin/sh
BASEDIR="$( dirname "$0" )"
cd "$BASEDIR"
ABSOLUTE_FOLDER_PATH=`pwd`
ABSOLUTE_BUILD_PATH="$ABSOLUTE_FOLDER_PATH"/distribution/build
echo "$ABSOLUTE_FOLDER_PATH"
## Create the build folder if needed
/bin/mkdir -p distribution/build
## Create the artifacts folder if needed
/bin/mkdir -p distribution/artifacts
# Retrieve the version
VERSION="1.0"
if [ -f distribution/Version ];
then
VERSION=`cat distribution/Version`
fi
# Get the current year
CURRENT_YEAR=`date "+%Y"`
## Build goldin
pushd tool_goldin
/usr/bin/xcodebuild clean build -configuration Release -scheme "goldin" -derivedDataPath "$ABSOLUTE_BUILD_PATH" CONFIGURATION_BUILD_DIR="$ABSOLUTE_BUILD_PATH"
popd
## Build packagesutil
pushd packagesutil
/usr/bin/xcodebuild clean build -configuration Release -scheme "packagesutil" -derivedDataPath "$ABSOLUTE_BUILD_PATH" CONFIGURATION_BUILD_DIR="$ABSOLUTE_BUILD_PATH"
popd
## Build packagesbuild
pushd packagesbuild
/usr/bin/xcodebuild clean build -configuration Release -scheme "packagesbuild" -derivedDataPath "$ABSOLUTE_BUILD_PATH" CONFIGURATION_BUILD_DIR="$ABSOLUTE_BUILD_PATH"
popd
## Build packages_dispatcher
pushd packages_dispatcher
/usr/bin/xcodebuild clean build -configuration Release -scheme "packages_dispatcher" -derivedDataPath "$ABSOLUTE_BUILD_PATH" CONFIGURATION_BUILD_DIR="$ABSOLUTE_BUILD_PATH"
popd
## Build packages_builder
pushd packages_builder
/usr/bin/xcrun agvtool next-version -all
/usr/bin/xcodebuild clean build -configuration Release -scheme "packages_builder" -derivedDataPath "$ABSOLUTE_BUILD_PATH" CONFIGURATION_BUILD_DIR="$ABSOLUTE_BUILD_PATH"
pushd
## Build the plugins
pushd plugins/requirements
requirements_plugins_list=("CPU" "DiskSpace" "Files" "JavaScript" "OS" "RAM" "Script")
for requirement_plugin in "${requirements_plugins_list[@]}"
do
pushd $requirement_plugin
/usr/bin/xcodebuild clean build -configuration Release -scheme "$requirement_plugin" -derivedDataPath "$ABSOLUTE_BUILD_PATH/requirements" CONFIGURATION_BUILD_DIR="$ABSOLUTE_BUILD_PATH/requirements"
popd
done
popd
pushd plugins/locators
locators_plugins_list=("JavaScript" "Standard")
for locator_plugin in "${locators_plugins_list[@]}"
do
pushd $locator_plugin
/usr/bin/xcodebuild clean build -configuration Release -scheme "$locator_plugin" -derivedDataPath "$ABSOLUTE_BUILD_PATH/locators" CONFIGURATION_BUILD_DIR="$ABSOLUTE_BUILD_PATH/locators"
popd
done
popd
## Build the application
pushd app_packages
/usr/bin/xcrun agvtool next-version -all
/usr/bin/xcrun agvtool new-marketing-version $VERSION
/usr/bin/xcodebuild -project "app_packages.xcodeproj" clean build -configuration Release -scheme "app_packages" -derivedDataPath "$ABSOLUTE_BUILD_PATH" CONFIGURATION_BUILD_DIR="$ABSOLUTE_BUILD_PATH"
popd
## Create the distribution
pushd distribution
/usr/local/bin/packagesbuild --verbose --project Packages.pkgproj DISTRIBUTION_PRODUCT_VERSION="${VERSION}" COPYRIGHT_END_YEAR="${CURRENT_YEAR}"
## Create the disk image
DISKIMAGE_NAME="Packages"
## Convert disk image template to read-write disk image
if [ -f build/"$DISKIMAGE_NAME"_rw.dmg ]
then
/bin/rm build/"$DISKIMAGE_NAME"_rw.dmg
fi
/usr/bin/hdiutil convert Template/Template_ro.dmg -format UDRW -o build/"$DISKIMAGE_NAME"_rw.dmg > /dev/null
## Mount the disk image
/usr/bin/hdiutil attach build/"$DISKIMAGE_NAME"_rw.dmg -mountpoint build/diskimage_rw > /dev/null
## Rename the disk image
if [ -f Version ];
then
/usr/sbin/diskutil rename "$DISKIMAGE_NAME" "$DISKIMAGE_NAME $VERSION"
fi
## Copy the Read Before You Install Packages to the disk image and prevent edition
if [ -f "Documents/Read Before You Install Packages.rtf" ]
then
/usr/bin/sed '2 s/^/\\readonlydoc1/' <"Documents/Read Before You Install Packages.rtf" > "build/diskimage_rw/Read Before You Install Packages.rtf"
else
echo "Missing Read Before You Install Packages"
fi
## Copy the User Guide webloc
if [ -f "Documents/Packages User Guide.webloc" ]
then
/bin/cp "Documents/Packages User Guide.webloc" "build/diskimage_rw/Extras/Packages User Guide.webloc"
else
echo "Missing Packages User Guide.webloc"
fi
## Copy the uninstall.sh script
if [ -f "Scripts/uninstall.sh" ]
then
/bin/cp Scripts/uninstall.sh "build/diskimage_rw/Extras/uninstall.sh"
else
echo "Missing uninstall.sh"
fi
## Copy the distribution package to the disk image
if [ -f build/Packages.pkg ]
then
/bin/cp build/Packages.pkg build/diskimage_rw/packages/Packages.pkg
else
echo "Missing distribution packages"
fi
## Remove useless files for a disk image
/bin/rm "build/diskimage_rw/Desktop DB"
/bin/rm "build/diskimage_rw/Desktop DF"
/bin/rm -r build/diskimage_rw/.fseventsd
## Unmount the disk image
/usr/bin/hdiutil detach build/diskimage_rw > /dev/null
## Convert disk image to read-only
if [ -f artifacts/"$DISKIMAGE_NAME".dmg ]
then
/bin/rm artifacts/"$DISKIMAGE_NAME".dmg
fi
/usr/bin/hdiutil convert build/"$DISKIMAGE_NAME"_rw.dmg -format UDZO -o artifacts/"$DISKIMAGE_NAME".dmg > /dev/null
## Remove the temporary disk image
if [ -f build/"$DISKIMAGE_NAME"_rw.dmg ]
then
/bin/rm build/"$DISKIMAGE_NAME"_rw.dmg
fi
popd
exit 0