-
Notifications
You must be signed in to change notification settings - Fork 17
/
update-macOS.sh
executable file
·131 lines (117 loc) · 3.29 KB
/
update-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
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
#!/bin/bash
#
# Script to copy changed files from Scorch's updated F-Engrave
# to staging directory for creating macOS package.
#
# 1. Copy over new files from directory specified on command line
# 2. Apply macOS patches from `macOS.patch` and update version numbers
# 3. Run the build script
# 4. Create a disk image (.dmg) for release
#
MD5="md5 -q"
files="INSTALL.txt build.bat fengrave.ico gpl-3.0.txt py2exe_setup.py \
TTF2CXF_STREAM/INSTALL.txt TTF2CXF_STREAM/Makefile \
TTF2CXF_STREAM/gpl-2.0.txt TTF2CXF_STREAM/ttf2cxf_stream.cpp"
CLEAN_SOURCE=false
while getopts "hvf:u:d:" OPTION; do
case "$OPTION" in
h) echo "Update F-Engrave and build macOS Application"
echo "update_macOS.sh [-hv] [-d <dir>] | [-f <zipfile>] | [-u <url>] | [<url>]"
echo " -h Print help (this)"
echo " -v Verbose output"
echo " -c Clean up (delete) new sources (ON when downloading from URL)"
echo " -d <dir> Use existing source directory"
echo " -f <file> Use existing .zip file"
echo " -u <url> Download archive from URL"
exit 1
;;
v) VERBOSE=true
;;
c) CLEAN_SOURCE=true
;;
d) UPDATE_DIR=${OPTARG}
unset SOURCE_ZIP
unset URL
;;
f) SOURCE_ZIP=${OPTARG}
unset UPDATE_DIR
unset URL
;;
u) URL=${OPTARG}
unset SOURCE_ZIP
unset UPDATE_DIR
;;
*) echo "Incorrect option provided $1"
exit 1
;;
esac
done
if [ -z ${URL+x} ] && [ -z ${SOURCE_ZIP+x} ] && [ -z ${UPDATE_DIR+x} ]
then
URL=$1
fi
# http://www.scorchworks.com/K40whisperer/K40_Whisperer-0.29_src.zip
if [ ! -z ${URL+x} ]
then
echo "Download F-Engrave source archive..."
CLEAN_SOURCE=true
SOURCE_ZIP=$(echo $URL | rev | cut -f1 -d/ | rev)
curl -o $SOURCE_ZIP $URL
if [ ! -f $SOURCE_ZIP ]
then
echo "Download failed."
exit 1
fi
fi
if [ -f "$SOURCE_ZIP" ]
then
echo "Extract F-Engrave source files..."
unzip -oq $SOURCE_ZIP
UPDATE_DIR=$(basename $SOURCE_ZIP .zip)
if [ ! -d $UPDATE_DIR ]
then
echo "Extraction failed."
exit 1
fi
fi
# Check that the update directory has K40 in it.
if [ ! -f ${UPDATE_DIR}/f-engrave.py ] ; then
echo "F-Engrave does not exist at \$1 = ${UPDATE_DIR}!"
exit
fi
NEW_APP=$(ls -1 ${UPDATE_DIR}/f-engrave.py)
VERSION=$(grep "^version " ${UPDATE_DIR}/f-engrave.py | grep -Eo "[\.0-9]+")
echo "Updating to version $VERSION"
# Copy over changed supporting files
echo "Copy updated files from ${UPDATE_DIR}..."
# rsync
# -a archive mode
# -v verbose
# -h human readable sizes
# -i show all file comparison information
# -c use checksum comparison
rsync -avhi --checksum ${UPDATE_DIR}/ .
# Apply macOS patches to f-engrave.py
echo "Patch f-engrave for macOS..."
patch -p0 -i macOS.patch
# Update version in setup script
echo "Update version number in setup scripts..."
sed -i.orig "s/version = .*/version = \"${VERSION}\"/" setup.py
sed -i.orig "s/'CFBundleShortVersionString': '.*'/'CFBundleShortVersionString': '${VERSION}'/" f-engrave.spec
echo "Pausing..."
read
# Build macOS application
echo "Build macOS Application..."
./build-macOS.sh -d || exit
# Make new patch file
echo "Update macOS.patch file..."
rm macOS-${VERSION}.patch
for i in $(grep +++ macOS.patch | cut -f1|cut -d\ -f2)
do
diff -Naur $UPDATE_DIR/$i $i >> macOS-${VERSION}.patch
done
if [ ! -z ${CLEAN_SOURCE+x} ]
then
echo "🧹 Cleaning up downloaded source files..."
rm -rf $SOURCE_ZIP $UPDATE_DIR
fi