-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_macos.sh
executable file
·71 lines (49 loc) · 2.13 KB
/
package_macos.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
#!/bin/sh
app=${APP_NAME}
binary=fiiish
binary_dir=fiiish-rs
platform=macos
# TODO: make this check if cargo get is available
# faster than installing cargo-get:
version=$(grep version ${binary_dir}/Cargo.toml|cut -d"\"" -f2)
# version=$(cd ${binary_dir} && cargo get version)
echo "Version: ${version}"
build_number=$(git rev-list ${version} --count)
echo "Build number: ${build_number}"
app_dir=package/${app}-${platform}-${version}/fiiish-rs.app
echo "Creating folder structure in ${app_dir}"
mkdir -p ${app_dir}
mkdir -p ${app_dir}/Contents/MacOS # save a few mkdir calls by starting with a deep directory
mkdir -p ${app_dir}/Contents/Resources
echo "Combining binaries into fat binaries"
lipo -create -output ${app_dir}/Contents/MacOS/${binary} \
${binary_dir}/target/aarch64-apple-darwin/release/${binary} \
${binary_dir}/target/x86_64-apple-darwin/release/${binary}
echo "Patching up Info.plist"
exp1="s/<key>CFBundleVersion<\\/key><string>.*<\\/string>/<key>CFBundleVersion<\\/key><string>${build_number}<\\/string>/g"
exp2="s/<key>CFBundleShortVersionString<\\/key><string>.*<\\/string>/<key>CFBundleShortVersionString<\\/key><string>${version}<\\/string>/g"
cat ${binary_dir}/Info.plist|sed ${exp1} |sed ${exp2} > ${app_dir}/Contents/Info.plist
echo "Compiling AppIcon"
temp=$(mktemp -d)
# TODO: hard coded path is probably a bad idea
/Applications/Xcode.app/Contents/Developer/usr/bin/actool \
--compile ${app_dir}/Contents/Resources/ \
--app-icon AppIcon \
--platform macosx \
--minimum-deployment-target 10.0 \
${binary_dir}/Assets.xcassets \
--output-partial-info-plist ${temp}/Info.plist # :TODO: this should be merged with Info.plist above
cat ${temp}/Info.plist
rm -r ${temp}
echo "Packing data"
cd fiiish-data
ls -1 |grep -v paklist.txt >paklist.txt
cd -
omt-packer pack --basepath fiiish-data --output fiiish-data.omar --paklist fiiish-data/paklist.txt
cd dummy-data
ls -1 |grep -v paklist.txt >paklist.txt
cd -
omt-packer pack --basepath dummy-data --output dummy-data.omar --paklist dummy-data/paklist.txt
echo "Adding resources"
cp fiiish-data.omar ${app_dir}/Contents/Resources/
cp dummy-data.omar ${app_dir}/Contents/Resources/