Skip to content

Commit 780462a

Browse files
authored
Merge pull request #58 from attdevsupport/bn153x-patch-2
Update vo_dependency_installer.sh
2 parents cdabb10 + cc5d71a commit 780462a

1 file changed

Lines changed: 99 additions & 45 deletions

File tree

vo_dependency_installer.sh

Lines changed: 99 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#=======================================
2020
# vo_dependency_installer.sh
21-
# version 1.0.0.1
21+
# version 1.0.0.2
2222
#
2323
# Howto use this script:
2424
# From your browser, select 'Save' and choose or create an empty folder. Make sure the script has the extension '.sh'.
@@ -237,65 +237,112 @@ echo ""
237237
install_libimobiledevice
238238
fi
239239
}
240-
241240
#=======================================
242241
function exit_install (){
243242
exit 0
244243
}
245244

246-
function machine_precheck (){
245+
#----------------------------
246+
# Brew config version checks
247+
#----------------------------
247248

248-
if [[ `which brew` == "" ]];then
249-
echo "brew is not installed"
250-
echo "To install, please visit: https://brew.sh"
251-
exit 0
252-
fi
249+
#=================================
250+
# regex extraction from target data
251+
# compares version Major.SUB_1.SUB_2
252+
# example regex pattern:
253+
# regex="(macOS): ([0-9]*)\.([0-9]*)\.([0-9]*)\-"
254+
#
255+
# args
256+
# 1: <$1> target data
257+
# 2: <$2> regex pattern
258+
# 3: <$3> label
259+
# 4: <$4> major version
260+
# 5: <$5> sub:1 version
261+
# 6: <$6> sub:1 version
262+
# 7: <$7> full version
263+
function check_version () {
253264

254-
BREW_CONFIG=`brew config`
255-
256-
regex="(macOS: ([0-9]*)\.([0-9]*)\.([0-9]*))\-.+(CLT: ([0-9]*)\.([0-9]*)\.([0-9]*)).+(Xcode: ([0-9]*)\.([0-9]*))"
265+
txt=$1
266+
rgx=$2
267+
label=$3
268+
M1=$4
269+
M2=$5
270+
M3=$6
271+
F_VERSION=$7
257272

258-
if [[ "$BREW_CONFIG" =~ $regex ]]
273+
# echo "[check $label]"
274+
if [[ "$txt" =~ $rgx ]]
259275
then
260-
FAIL=false
261-
echo ""
262-
echo "check "${BASH_REMATCH[1]}
263-
264-
if [ ${BASH_REMATCH[2]} \< 13 ]
276+
V_CHECK="pass"
277+
if [ ${BASH_REMATCH[2]} \< $M1 ] \
278+
|| [[ $M2 != "" && ${BASH_REMATCH[3]} < $M2 ]] \
279+
|| [[ $M3 != "" && ${BASH_REMATCH[4]} < $M3 ]]
265280
then
266-
if [ ${BASH_REMATCH[2]} \< 12 ] || [ ${BASH_REMATCH[3]} \< 6 ]
267-
then
268-
echo "${BASH_REMATCH[1]} version needs updating to at least 12.6.1"
269-
FAIL=true
270-
fi
271-
fi
272-
273-
echo "check "${BASH_REMATCH[5]}
274-
if [ ${BASH_REMATCH[6]} \< 15 ] ; then
275-
if [ ${BASH_REMATCH[6]} \< 14 ] || [ ${BASH_REMATCH[7]} \< 1 ] ; then
276-
echo "${BASH_REMATCH[5]} version needs updating to at least 14.1"
277-
FAIL=true
281+
if [ "${BASH_REMATCH[2]}" == "N/A" ]
282+
then
283+
CHECK="fail:$label needs to be installed"
284+
echo $CHECK
285+
else
286+
CHECK="fail:${BASH_REMATCH[1]} version needs updating to at least $F_VERSION"
287+
echo $CHECK
278288
fi
279-
fi
280-
281-
echo "check "${BASH_REMATCH[9]}
282-
if [ ${BASH_REMATCH[10]} \< 15 ] ; then
283-
if [ ${BASH_REMATCH[10]} \< 14 ] || [ ${BASH_REMATCH[11]} \< 1 ] ; then
284-
echo "${BASH_REMATCH[9]} version needs updating to at least 14.1"
285-
FAIL=true
286-
fi
287-
fi
288-
289-
if [ $FAIL == true ] ; then
290-
echo "This configuration cannot complete unless the above updates have been performed"
289+
V_CHECK="fail"
291290
else
292-
echo "ready to proceed!"
291+
V_CHECK="PASS"
293292
fi
294293
else
294+
# look for "N/A"
295+
rgx="($label): ([0-9A-Za-z/]*)"
296+
if [[ "$txt" =~ $rgx ]]
297+
then
298+
if [ ${BASH_REMATCH[2]} == "N/A" ]
299+
then
300+
CHECK="fail:$label needs to be installed, Please review installations of brew, Xcode and Xcode's commandline tools"
301+
echo $CHECK
302+
V_CHECK="fail"
303+
return
304+
fi
305+
fi
295306
echo "Unable to retrieve 'brew config' results"
296307
echo "Please review installations of brew, Xcode and Xcode's commandline tools"
297308
fi
298309
}
310+
311+
function machine_precheck (){
312+
313+
if [[ `which brew` == "" ]];then
314+
echo "brew is not installed"
315+
echo "To install, please visit: https://brew.sh"
316+
exit_install
317+
else
318+
BREW_CONFIG=`brew config`
319+
fi
320+
321+
322+
# macOS: 13.2.1-arm64
323+
regex="(macOS): ([0-9]*)\.([0-9]*)\.([0-9]*)\-"
324+
check_version "$BREW_CONFIG" "$regex" macOS 13 2 1 13.2.1
325+
326+
# CLT: 14.2.0.0.1.1668646533
327+
regex="(CLT): ([0-9A-Za-z/]*)\.([0-9]*)\.([0-9]*)"
328+
check_version "$BREW_CONFIG" "$regex" CLT 14 2 0 14.2.0 "CLT: 14.2.0.0.1.1668646533"
329+
330+
# Xcode: 14.1
331+
regex="(Xcode): ([0-9]*)\.([0-9]*)"
332+
check_version "$BREW_CONFIG" "$regex" Xcode 14 1 "" "Xcode: 14.1"
333+
echo $CHECK
334+
335+
if [[ ${CHECK} = "fail"* ]] ; then
336+
if [[ $CHECK == *"CLT"* ]] ; then
337+
echo "verify active developer directory with 'xcode-select -p'"
338+
echo "use 'xcode-select --install' to install the correct commandline tools for your Xcode installation"
339+
fi
340+
else
341+
echo "ready to proceed\!"
342+
fi
343+
344+
}
345+
299346
#-----------------------------------------------------
300347
# vo_installer.sh
301348
#-----------------------------------------------------
@@ -311,16 +358,23 @@ fi
311358

312359
machine_precheck > error.log
313360

314-
test=`cat error.log|grep "ready to proceed\!"`
361+
test=`cat error.log|grep "ready to proceed"`
315362

316-
if [ "$test" == "" ];then
363+
if [[ "$test" != "ready to proceed"* ]];then
317364
cat error.log
318-
exit 0
365+
echo ""
366+
echo "Aborting $0, no changes to your system"
367+
exit_install
319368
else
320369
rm error.log
321370
echo $test
322371
fi
323372

373+
#-----------------------------------------------------
374+
# version pre-checks DONE
375+
# will now configure system
376+
#-----------------------------------------------------
377+
324378
if [ ! "${PWD##*/}" = "libimobile_installation" ]
325379
then
326380
if [ ! -d libimobile_installation ]

0 commit comments

Comments
 (0)