1- #! /bin/bash
1+ #! /usr/local/ bin/bash
22
33pn () {
44 { [ $# -gt 1 ] && [[ " ${2} " == " -n" ]] && echo -en " ${1} " >&3 ; } || echo -e " ${1} " >&3
@@ -23,7 +23,7 @@ leave() {
2323}
2424
2525err () {
26- pn " \033 [31;1mERROR:\033 [0m ${1} "
26+ pn " \e [31;1mERROR:\e [0m ${1} "
2727 leave
2828}
2929
8181 pn "
8282 usage: ./make.sh -hndivk
8383
84- \033 [1mOptions\033 [0m:
84+ \e [1mOptions\e [0m:
8585 -h, --help : Shows this help message; ignores all other options
8686 -n, --new : Runs processes that only need to happen once, specifically creating a certificate
8787 and adding support swift files. You must run this at least once after cloning the
8888 repo or else it won't build.
89- -d, --deb : Builds a .deb. Requires either the command line utility \033 [1mdpkg\033 [0m, or a jailbroken
89+ -d, --deb : Builds a .deb. Requires either the command line utility \e [1mdpkg\e [0m, or a jailbroken
9090 iDevice on the local network to ssh into to create the archive
9191 -i, --ipa : Builds a .ipa
9292 -v, --verbose : Runs verbose; doesn't hide any output
93- -k, --keep : Don't remove extracted \033 [1mSMServer.app\033 [0m files when cleaning up
94- -m, --minify : Minify css & html file when compiling assets using minify (\033 [1mbrew install tdewolff/tap/minify\033 [0m)
93+ -k, --keep : Don't remove extracted \e [1mSMServer.app\e [0m files when cleaning up
94+ -m, --minify : Minify css & html file when compiling assets using minify (\e [1mbrew install tdewolff/tap/minify\e [0m)
9595 "
9696 exit
9797fi
9898
9999! command -v xcodebuild & > /dev/null && err " Please install xcode command line tools"
100100
101- [ " $new " = true ] && ! command -v openssl & > /dev/null && err " Please install \033 [1mopenssl\033 [0m (required to build new certificates)"
101+ [ " $new " = true ] && ! command -v openssl & > /dev/null && err " Please install \e [1mopenssl\e [0m (required to build new certificates)"
102102[ " $deb " = true ] && ! command -v dpkg & > /dev/null && err " Please install dpkg to create deb pagkage"
103103
104- ls -A " ${ROOTDIR} " /libsmserver/* || err " It looks like you haven't yet set up this repository's submodules. Please run \033 [1mgit submodule init && git submodule update --remote\033 [0m and try again."
104+ ls -A " ${ROOTDIR} " /libsmserver/* || err " It looks like you haven't yet set up this repository's submodules. Please run \e [1mgit submodule init && git submodule update --remote\e [0m and try again."
105105
106106[ -z ${DEV_CERT+x} ] && DEV_CERT=$( security find-identity -v -p codesigning | head -n1 | cut -d ' "' -f2)
107107
108108if [ " $new " = true ]
109109then
110- pn " \n\033 [33mWARNING:\033 [0m Running this with the \033 [1m-n\033 [0m flag will delete the existing \033 [1mcert.der\033 [0m file and replace it with one you will be creating."
110+ pn " \n\e [33mWARNING:\e [0m Running this with the \e [1m-n\e [0m flag will delete the existing \e [1mcert.der\e [0m file and replace it with one you will be creating."
111111 pn " This is necessary to build from source. If you'd like to continue, hit enter. Else, cancel execution of this script\n"
112112 pn " These new certificates will need a password to function correctly, which you'll need to provide."
113113
@@ -118,14 +118,14 @@ then
118118
119119 while ! [[ " ${pass} " == " ${passcheck} " ]]
120120 do
121- pn " \n\033 [33mWARNING:\033 [0m passwords are not equal. Please try again."
121+ pn " \n\e [33mWARNING:\e [0m passwords are not equal. Please try again."
122122 pn " Please enter the password: " -n
123123 read -r pass
124124 pn " Please enter again for verification: " -n
125125 read -r passcheck
126126 done
127127
128- pn " \033 [35m==>\033 [0m Creating certificate..."
128+ pn " \e [35m==>\e [0m Creating certificate..."
129129 openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 9999 -nodes -subj " /C=ZZ/ST=./L=./O=./CN=smserver.com"
130130 openssl x509 -outform der -in cert.pem -out " ${ROOTDIR} /src/SMServer/cert.der"
131131 openssl pkcs12 -export -out " ${ROOTDIR} /src/SMServer/identity.pfx" -inkey key.pem -in cert.pem -password pass:" $pass "
136136
137137 olddir=" $( pwd) "
138138 cd " ${ROOTDIR} /src" || err " Source directory is gone"
139- pn " \033 [35m==>\033 [0m Installing pods..."
139+ pn " \e [35m==>\e [0m Installing pods..."
140140 pod install
141141
142142 cd " $olddir " || err " $olddir is gone"
145145
146146if [ " $deb " = true ] || [ " $ipa " = true ]
147147then
148- pn " \033 [34m==>\033 [0m Checking files and LLVM Version..."
148+ pn " \e [34m==>\e [0m Checking files and LLVM Version..."
149149 llvm_vers=$( llvm-gcc --version | grep -oE " clang\-[0-9]{4,}" | sed ' s/clang\-//g' )
150150 [ " ${llvm_vers} " -lt 1200 ] && \
151151 err " You are using llvm < 1200 (Xcode 11.7 or lower); this will fail to compile. Please install Xcode 12.0 or higher to build SMServer."
152152
153153 { ! [ -f ${ROOTDIR} /src/SMServer/identity.pfx ] || ! [ -f ${ROOTDIR} /src/SMServer/shared/IdentityPass.swift ]; } && \
154- err " You haven't created some files necessary to compile this. Please run this script with the \033 [1m-n\033 [0m or \033 [1m--new\033 [0m flag first"
154+ err " You haven't created some files necessary to compile this. Please run this script with the \e [1m-n\e [0m or \e [1m--new\e [0m flag first"
155155
156156 if [ " $min " = true ]
157157 then
158158 ! command -v minify && err " Please install minify to minify asset files"
159159
160- pn " \033 [34m==>\033 [0m Minifying css & html files..."
160+ pn " \e [34m==>\e [0m Minifying css & html files..."
161161 cp -r " ${html_dir} /" " ${html_tmp} /"
162162
163- find " $html_tmp " -name " *.css" | while read -r file
163+ ls " $html_tmp " / * .css | while read -r file
164164 do
165165 newfile=" ${file// $(printf " %q" " $html_tmp " )/ $(printf " %q" " $html_dir " )} "
166166 minify " $file " > " $newfile "
167167 done
168168
169- find " $html_tmp " -name " *.html" | while read -r file
169+ ls " $html_tmp " / * .html | while read -r file
170170 do
171171 newfile=" ${file// $(printf " %q" " $html_tmp " )/ $(printf " %q" " $html_dir " )} "
172172 minify --html-keep-comments --html-keep-document-tags --html-keep-end-tags --html-keep-quotes --html-keep-whitespace " $file " > " $newfile "
173173 done
174174 fi
175175
176176 rm -rf " ${ROOTDIR} /package/SMServer.xcarchive"
177- pn " \033 [34m==>\033 [0m Cleaning and archiving package..."
177+ pn " \e [34m==>\e [0m Cleaning and archiving package..."
178178 xcodebuild clean archive -workspace " ${ROOTDIR} /src/SMServer.xcworkspace" -scheme SMServer -archivePath " ${ROOTDIR} /package/SMServer.xcarchive" -destination generic/platform=iOS -allowProvisioningUpdates \
179- || err " Failed to archive package. Run again with \033 [1m-v\033 [0m to see why"
179+ || err " Failed to archive package. Run again with \e [1m-v\e [0m to see why"
180180
181- pn " \033 [34m==>\033 [0m Codesigning..."
181+ pn " \e [34m==>\e [0m Codesigning..."
182182 codesign --entitlements " ${ROOTDIR} /src/app.entitlements" -f --deep -s " ${DEV_CERT} " " ${ROOTDIR} /package/SMServer.xcarchive/Products/Applications/SMServer.app"
183183
184- pn " ✅ \033 [1mSMServer.app successfully created\033 [0m\n"
184+ pn " ✅ \e [1mSMServer.app successfully created\e [0m\n"
185185fi
186186
187187if [ " $deb " = true ]
188188then
189189 recv=false
190190
191- pn " \033 [92m==>\033 [0m Extracting \033 [1mSMServer.app\033 [0m..."
191+ pn " \e [92m==>\e [0m Extracting \e [1mSMServer.app\e [0m..."
192192 mkdir -p " ${ROOTDIR} /package/deb/Applications"
193193 rm -rf " ${ROOTDIR} /package/deb/Applications/SMServer.app"
194194 cp -r " ${ROOTDIR} /package/SMServer.xcarchive/Products/Applications/SMServer.app" " ${ROOTDIR} /package/deb/Applications/SMServer.app"
195195
196- pn " \033 [92m==>\033 [0m Building \033 [1mlibsmserver\033 [0m..."
196+ pn " \e [92m==>\e [0m Building \e [1mlibsmserver\e [0m..."
197197 cd " ${ROOTDIR} /libsmserver" || err " The libsmserver directory is gone."
198198
199- make -B package FINALPACKAGE=1 || err " Failed to build libsmserver. Run with the \033 [1m-v\033 [0m to see details"
199+ make -B package FINALPACKAGE=1 || err " Failed to build libsmserver. Run with the \e [1m-v\e [0m to see details"
200200 cd " .." || err " The parent directory is gone."
201201
202202 cp " ${ROOTDIR} /libsmserver/lib/libsmserver.dylib" " ${ROOTDIR} /package/deb/Library/MobileSubstrate/DynamicLibraries/"
203203 cp " ${ROOTDIR} /libsmserver/libsmserver.plist" " ${ROOTDIR} /package/deb/Library/MobileSubstrate/DynamicLibraries/"
204204
205- pn " \033 [92m==>\033 [0m Building \033 [1m.deb\033 [0m..."
205+ pn " \e [92m==>\e [0m Building \e [1m.deb\e [0m..."
206206 dpkg -b " ${ROOTDIR} /package/deb"
207207 { mv " ${ROOTDIR} /package/deb.deb" " ${ROOTDIR} /package/SMServer_${vers} .deb" && recv=true; } || \
208- pn " \033 [33;1mWARNING:\033 [0m Failed to create .deb. Run with \033 [1m-v\033 [0m to see more details."
208+ pn " \e [33;1mWARNING:\e [0m Failed to create .deb. Run with \e [1m-v\e [0m to see more details."
209209
210210 if [ " $recv " = true ]
211211 then
212- pn " ✅ SMServer_${vers} .deb successfully created at \033 [1m${ROOTDIR} /package/SMServer_${vers} .deb\033 [0m\n"
212+ pn " ✅ SMServer_${vers} .deb successfully created at \e [1m${ROOTDIR} /package/SMServer_${vers} .deb\e [0m\n"
213213 else
214214 rm " ${ROOTDIR} /package/SMServer_${vers} .deb" # Since it may be corrupted
215215 fi
216216fi
217217
218218if [ " $ipa " = true ]
219219then
220- pn " \033 [35m==>\033 [0m Extracting \033 [1mSMServer.app\033 [0m..."
220+ pn " \e [35m==>\e [0m Extracting \e [1mSMServer.app\e [0m..."
221221 mkdir -p " ${ROOTDIR} /package/Payload"
222222 rm -r " ${ROOTDIR} /package/Payload/SMServer.app"
223223 cp -r " ${ROOTDIR} /package/SMServer.xcarchive/Products/Applications/SMServer.app" " ${ROOTDIR} /package/Payload/SMServer.app"
224224
225- pn " \033 [35m==>\033 [0m Compressing payload into \033 [1mSMServer_${vers} .ipa\033 [0m..."
225+ pn " \e [35m==>\e [0m Compressing payload into \e [1mSMServer_${vers} .ipa\e [0m..."
226226 ditto -c -k --sequesterRsrc --keepParent " ${ROOTDIR} /package/Payload" " ${ROOTDIR} /package/SMServer_${vers} .ipa"
227227
228- pn " ✅ SMServer_${vers} .ipa successfully created a† \033 [1m${ROOTDIR} /package/SMServer_${vers} .ipa\033 [0m"
228+ pn " ✅ SMServer_${vers} .ipa successfully created a† \e [1m${ROOTDIR} /package/SMServer_${vers} .ipa\e [0m"
229229fi
230230
231231leave
0 commit comments