-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbg-debugCntr
More file actions
executable file
·2295 lines (2037 loc) · 94.2 KB
/
bg-debugCntr
File metadata and controls
executable file
·2295 lines (2037 loc) · 94.2 KB
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# (done) TODO: when bootstrapping on fresh VM, sourcing this is the fisrt step but between that and vinstalling bg-core/bg-dev, these functions
# can not find the rest of the libs. Add logic to automatically vininstall bg-core and bg-dev based on the path being sourced
# TODO: when bootstrapping on fresh VM, check the <sanbbox>/.bglocal/hostManifest to see if the paths are valid and make a <sanbbox>/.bglocal/hostManifest.$$
# with fixed up paths
# (done) TODO: when bootstrapping on fresh VM, check and install minum dependencies (binutils, ...)
# CRITICALTODO: see below
# SECURITY: consider how we can discourage use of bg-debugCntr on production servers -- provide an alternative that only controlls tracing -- put similar code here as in bg_core.sh to detect mode and hide/disable fetures based on that. Of course a user can do want they want with their environment but we can avoid facilitating a insecure practice
# maybe this means that bg-debugCntr and Makefile both should only be in bg-scriptprojectdev -- maybe a stripped done bg-traceCntr should be in bg-lib
# see also function bgListAllInstalledCodeFiles() -- whow it finds Makefile
# Command
# usage: bg-debugCntr [status]
# usage: bg-debugCntr trace [ on[:fileName] | off | status ]
# bg-debugCntr trace bashCompOpts:(verbose | terse | cachingOff | cachingOn)
# bg-debugCntr trace tests:(on | off)
# bg-debugCntr trace errorStack [showSource|no-showSource|oneline|no-oneline|debugStack|no-debugStack|callerColumn|no-callerColumn]
# usage: bg-debugCntr vinstall [reinstall]
# bg-debugCntr vinstall [-v] status
# bg-debugCntr vinstall [-r] [\<sandboxPath>|\<projectPath>]
# bg-debugCntr vinstall sourceCore
# bg-debugCntr vinstall --remove [-r] all|\<sandboxPath>|\<projectPath>
# bg-debugCntr vinstall devBash <pathToBash>
# usage: bg-debugCntr debugger [status]
# bg-debugCntr debugger cntr-C:(on|off)
# bg-debugCntr debugger stopOnAssert:(on|off)
# bg-debugCntr debugger destination <dbgDriver>:<destination>
# bgdb [--breakAt=stopOnLibInit|stopOnFirstScriptLine] <cmd> [<arg1>..<argN>]
# usage: bg-debugCntr utils name <termName>
# bg-debugCntr utils termIdent
# bg-debugCntr utils banner [status | on | off]
# bg-debugCntr utils bashCmdHooks [status]
# bg-debugCntr utils bashCmdHooks on | off
# bg-debugCntr utils bashCmdHooks trace [status]
# bg-debugCntr utils bashCmdHooks trace on | off
# bg-debugCntr utils installDevCapsForUser
# usage: bg-debugCntr listCodeFiles
# usage: bg-debugCntr codeGrep
# usage: bg-debugCntr tags
# control debugging features of script commands.
# The bg-debugCntr command controls the development environment for script projects in a terminal. Typically to start devolomnet
# you open a terminal, cd to the project or sandbox project that conatins scripts that you want to develop and source this command
# into the terminal's bash process.
# ~/github/bg-core$ . bg-debugCntr
# BGTracing status : disabled
# VIinstall Status : none
# Banner Status : on
# Debugger Status : off
# BashCmdHooks Status: on
# HostProductionMode : development
# Development Features: installed
# ~/github/bg-core$
#
# You can then virtually install the project so that you can run its commands without building a package and installing it for real.
# ~/github/bg-core$ bg-debugCntr vinstall .
# virtually installed 565 assets from bg-core
# ~/github/bg-core$
#
# Its handy to turn on tracing to another terminal. I divide the left side of my monitor between a terminal showing the trace output
# on the top half and one on the bottom half configured with bg-debugCntr
# ~/github/bg-core$ bg-debugCntr trace on:
# BGTracing status : desination='/tmp/bgtrace.out' (bgTracingOn='on:')
# ~/github/bg-core$
# Note the : at the end of on:. That tells the command that a file will follow which will be the destination of the trace output
# produced at this terminal but since its empty, its using the default at /tmp/bgtrace.out
#
# Then in another terminal window tail -f that file
# ~/github/bg-core$ tail -f /tmp/bgtrace.out
#
# Sub Commands:
# The some sub commands have separate man pages. See the See Also section below.
#
# **listCodeFiles** : lists the assets from the current virtually installed projects.
#
# **codeGrep** : grep the set of virtually installed assets
#
# **tags** : show the code tags (e.g. TODO: ...) in the set of virtually installed assets
#
# See Also:
# man(1) bg-debugCntr-debugger
# man(1) bg-debugCntr-vinstall
# man(1) bg-debugCntr-trace
# man(1) bg-debugCntr-utils
# man(1.bashCmd) bg-debugCntr-utils
# usage: bg-debugCntr utils name <termName>
# bg-debugCntr utils termIdent
# bg-debugCntr utils banner [status | on | off]
# bg-debugCntr utils bashCmdHooks [status]
# bg-debugCntr utils bashCmdHooks on | off
# bg-debugCntr utils bashCmdHooks trace [status]
# bg-debugCntr utils bashCmdHooks trace on | off
# bg-debugCntr utils installDevCapsForUser
# Miscellaneous sub commands in bg-debugCntr.
#
# name:
# Set the name that will be displayed in the title bar or tab for this terminal.
#
# termIdent:
# This will send commands to all of the tty on the host to set their terminal titles to show their process ID and tty.
# It also prints a ps command that show all of the bash processes currently running.
#
# The idea of this utility is that it allows you to find out which termianl window is running which bash process. For example if
# a terminal's bash process is locked and not responding to cntr-c, this will help you figure out which PID to kill.
#
# banner:
# When bg-debugCntr is installed in a terminal, each srcipt that uses oob_invokeOutOfBandSystem will write a banner line at its
# start summarizing its configuration to remind you that you that you are running cmds in a development mode. This sub command
# can be used to turn that off.
#
# bashCmdHooks:
# When bg-debugCntr is installed in a terminal, it uses a DEBUG trap and prompt commands to monitor commands entered on the cmdline.
# This can be used to disable or configure that feature.
# * autoload imported script libraries when they are modified. (see bg-debugCntr vinstall sourceCore )
# * When testing [[ =~ ]] regex, the BASH_REMATCH var is copied into rematch where is wont be clobbered
#
# installDevCapsForUser:
# In order to run vinstalled commands as root, the user working on the package must be given the sudo rights to run sudo with the -E
# option which preserves the unprivileged user's environment. This is needed so that the vinstalled PATH will be used for the root
# session so that it will find the vinstalled versions of commands. This would be a security violation on a production server but
# on a developer's host where the developer already has super user privilege, it is OK.
#
# See Also:
# man(1) bg-debugCntr
#
declare -x bgVinstallInhibitPostProcessing
# This script implements a pattern where it can be installed into the user's bash session by sourcing
# it directly into the interactive bash shell. Once installed, a function by the same name will be
# defined so that when this command's name is ran in the interactive prompt or in a script, the
# sourced function version will be executed instead of the disk file.
# bgDebugCntrRunMode is maintained to let global code in this file know the context that its being ran
# its undefined at the end of the script so that when sourced functions run normally it will not be
# defined. [ ! "${bgDebugCntrRunMode+exits}" ] && echo "sourced function running"
# This is implemented as a function because bash 5.x no longer sets FUNCNAME[0] to 'main' or 'source'
# in the global scope
declare bgDebugCntrRunMode=""
function _getGlobalBashScope()
{
case "PRE.${FUNCNAME[@]: -1}" in
PRE.main|PRE.) bgDebugCntrRunMode="extScript" ;;
PRE.source) bgDebugCntrRunMode="sourcing" ;;
PRE.debugCntr) bgDebugCntrRunMode="reloading" ;;
PRE.bg-debugCntr) bgDebugCntrRunMode="reloading" ;;
PRE.cmdlineHook_debugTrap) bgDebugCntrRunMode="reloading" ;;
PRE.cmdlineHook_promtCmdHook) bgDebugCntrRunMode="reloading" ;;
*) bgDebugCntrRunMode="unknown:${FUNCNAME[@]: -1}"; echo "error: bg-debugCntr:_getGlobalBashScope() the reported top level bash FUNCNAME ($bgDebugCntrRunMode) is not recognized so we do not know the context that this script is running." >&2 ;;
esac
}
_getGlobalBashScope
#################################################################################################################################
# Entry Point Functions
# These functions are meant to be invoked directly by the user. They typically exist as an external
# command script but when they are sourced, these functions override the invocation of those scripts.
# FUNCMAN_SKIP
# this sets the user's bgtrace environment variable that effects scripts run in the current bash session
# This function has the same name as the external script. After the user sources the script into their
# bash terminal environment, subsequent invocations will be handled by the script and not the external
# file unless the full path to the external file is specified
function bg-debugCntr()
{
# disable the DEBUG trap handler while we are in this function
builtin trap - DEBUG
if [ "development" != "$([ ! -f /etc/bgHostProductionMode ] || awk '/^[[:space:]]*mode[[:space:]]*[:=][[:space:]]*development/ {print "development"; exit}' /etc/bgHostProductionMode)" ]; then
cat - <<-EOS
This host is not yet authorized to run bg-core development features.
If you have admin privileges on this host you can authorize it by
executing this cmd...
echo "mode=development" | sudo tee /etc/bgHostProductionMode >/dev/null
EOS
return 1
fi
local verboseFlag
while [ $# -gt 0 ]; do case $1 in
-v) verboseFlag="-v" ;;
-hbOOBCompGen|-hb|-hbo) break ;;
*) break; esac; shift; # simplified version of bgOptionsEndLoop
done
local bgCoreAvail=""; (source /usr/lib/bg_core.sh 2>/dev/null) && bgCoreAvail="yes"
local cmd="${1:-status}"; shift
local cmd2="${1:-status}"
case $cmd:$cmd2 in
sourceCore:*|vinstall:sourceCore)
source /usr/lib/bg_core.sh $2; importCntr reloadAll --init
unset -f command_not_found_handle
bg-debugCntr utils name "inside"
;;
trace:*) _traceCntr "$@" ;;
vinstall:*) _vinstall "$@" ;;
vuninstall:*) _vuninstall "$@" ;;
codeGrep:*) _codeGrep "$@" ;;
tags:*) _tagsGrep "$@" ;;
debugger:*) _debugger "$@" ;;
listCodeFiles:*) (
bgTracingBanner=""
source /usr/lib/bg_core.sh --minimal
bgListAllInstalledCodeFiles
) ;;
utils:banner) _bannerCntr "${@:2}" ;;
utils:name)
declare -g bgTermName="$2"
declare -g bgTermTitle="$bgTermName($bgTermID)"
PS1="${PS1#*\\a}"
(source /usr/lib/bg_core.sh || exit 1; import bg_cui.sh; $L1;$L2; cuiSetTitle "$bgTermTitle" >/dev/tty)
;;
utils:termIdent)
local -A pidsByTty
local pid tty pids; while read -r pid tty; do
pidsByTty[${tty:-notty}]+="${pidsByTty[${tty:-notty}]:+,}$pid"
pids+=("$pid")
done < <(ps -C bash -o pid=,tty=)
for tty in "${!pidsByTty[@]}"; do
[ -e "/dev/$tty" ] && echo -en "\e]0;Temp Ident: pid= ${pidsByTty[$tty]} tty= /dev/$tty\a" > /dev/$tty
done
echo "the titles of these bash terminal windows owned by you have temporarily been changed to identify their pid and tty"
ps -f --forest --pid "${pids[@]}"
;;
utils:bashCmdHooks) _bashComandHooks "${@:2}" ;;
utils:installDevCapsForUser) _installDevCapsForUser "${@:2}" ;;
-hb:*|-hbOOBCompGen:*|-hbo:*) _bg-debugCntrBC "$@" ;;
-h:*) man bg-debugCntr ;;
status:*)
while [ $# -gt 0 ]; do case $1 in
-v) verboseFlag="-v" ;;
*) break; esac; shift; # simplified version of bgOptionsEndLoop
done
[ ! "$bgHostProductionMode" ] && bgHostProductionMode="$(source /usr/lib/bg_core.sh --queryMode; echo $bgHostProductionMode)"
if [ "$ bgHostProductionMode" == "production" ]; then
cat <<-EOS
This host is currently in production mode and therefore development features will not work with any installed
scripts. If you have admin privilege on this host you can put it in development mode by creating the file
/etc/bgHostProductionMode with the contents 'mode=development'
EOS
else
_traceCntr status $verboseFlag
_vinstall status $verboseFlag
_bannerCntr status $verboseFlag
_debugger status $verboseFlag
_bashComandHooks status $verboseFlag
_installDevCapsForUser status $verboseFlag
echo "HostProductionMode : $bgHostProductionMode"
# If we are running as the external script as opposed to the sourced function, dev features are not installed
if [ "$bgDebugCntrRunMode" == ""extScript"" ]; then
cat <<-EOS
Development Features: off
Development and Debugging features are not currently installed in this terminal but you can install them by
sourceing this command instead of running it. This only has to be done once per terminal and then you can
and should run this command without the 'source' prefix.
Run the following command to install development and debugging features.
source $(basename $0)
EOS
elif [ "$bgCoreAvail" ]; then
(
source /usr/lib/bg_core.sh
echo "Development Features: installed"
echo "Manifest file : $(manifestGetHostManifest)"
echo "Plugin Manifest file : $(manifestGetHostPluginManifest)"
)
else
echo "Development Features: installed"
echo
echo "bg-core is not installed on the host. You should either install it or use the 'vinstall' sub command to virtually install a source folder of the bg-core project"
fi
echo
fi
;;
*) _assertError "unknown sub command '$cmd' '$cmd2'" ;;
esac
# if this feature is turned on, re-enable the DEBUG trap handler
if [ "$bgBashCmdHookFeature" ]; then
set +T
builtin trap 'cmdlineHook_debugTrap' DEBUG
fi
}
export -f bg-debugCntr
complete -F _bgbc-complete-viaCmdDelegation bg-debugCntr
# This is the bash command line completion function for the bg-debugCntr entry point
function _bg-debugCntrBC()
(
# note that this function uses () instead of {} so that we can source bg_core.sh without it
# being permanent
local bgTracingBanner=""
source /usr/lib/bg_core.sh --minimal
import bg_outOfBandScriptFeatures.sh ;$L1;$L2
local words cword cur prev optWords posWords posCwords
parseForBashCompletion --compat2 words cword cur prev optWords posWords posCwords "$@"
local cmd1="${posWords[1]}"
case $cmd1:$posCwords in
*:1) echo "trace vinstall status codeGrep listCodeFiles tags debugger utils" ;;
trace:*)
local cmd2="${posWords[2]}"
local colonCount="${cmd2//[^:]}"
case ${cmd2%:*}:$posCwords:${#colonCount} in
*:2:0) echo "status off on:%3A bashCompOpts:%3A errorStack openWin closeWin tests:%3A " ;;
on:2:1)
echo "\$(cur:${cmd2#on:})"
echo "1 2 tty stderr stdout file: winNew win"
ls /tmp/bgtrace.win?.cntr 2>/dev/null | sed 's|/tmp/bgtrace[.]||; s|[.]cntr||'
;;
on:2:file:*)
echo "\$(cur:${cmd2#on:file:})"
echo "\$(_fileDir)"
;;
bashCompOpts:2:*)
echo "\$(cur:${cmd2#bashCompOpts:})"
echo "verbose terse cachingOff cachingOn"
;;
tests:2:*)
echo "\$(cur:${cmd2#tests:})"
echo "on off"
;;
errorStack:3:*) echo "showSource no-showSource oneline no-oneline debugStack no-debugStack callerColumn no-callerColumn" ;;
esac
;;
utils:2) echo "termIdent banner bashCmdHooks installDevCapsForUser name" ;;
utils:*)
utilCmd="${posWords[2]}"
case $utilCmd:$((posCwords-2)) in
name:1) echo "<name>" ;;
banner:1) echo "status on off" ;;
bashCmdHooks:*)
case ${posWords[3]}:${posWords[4]}:$((posCwords-2)) in
*:*:1) echo "on off status trace" ;;
trace:*:2) echo "on off status" ;;
trace:on:*) echo "\$(usingListmode ,) b4Cmdline b4SimpleCmd afterSimpleCmd afterCmdline" ;;
esac
;;
esac
;;
vinstall:2) echo "status --remove sourceCore devBash" ;;&
vinstall:*)
if [ "${posWords[2]}" == "--remove" ]; then
[ ${posCwords:-0} -eq 3 ] && echo "status all"
echo "<vInstalledProjects>"
echo "$bgVinstalledPaths:" | tr ":" "\n" | sed -e 's|.*/| |'
return
fi
if [ "${posWords[2]}" == "devBash" ]; then
echo "\$(doDirs) <pathToBashExec>"
return
fi
if [ "$cur" ] && [[ ! "status" =~ ^$cur ]]; then
echo "\$(doDirs) reinstall"
else
find -H * -name node_modules -prune -false -o -path "*.bg-sp/config" | sed 's|/.bg-sp/config||'
echo "<projectFolders> reinstall"
fi
;;
vuninstall:2) echo "all status" ;;&
vuninstall:*)
echo "<vInstalledProjects>"
echo "$bgVinstalledPaths:" | tr ":" "\n" | sed -e 's|.*/| |'
;;
codeGrep:*)
case $prev in
-f) echo "<filterOnAssetTypes> $(bg-awkData -g manifest.assetType)"; return ;;
-A) echo "<number_lines_after> 1 2 3"; return ;;
-B) echo "<number_lines_before> 1 2 3"; return ;;
-C) echo "<linesType> onlyComments codeOnly tagsOnly"; return ;;
-O) echo "<output_mode> summary matchingFiles"; return ;;
-T) echo "<TAG> CRITICALTODO TODO SECURITY DEPRECIATED UPDATE BGENV OBSOLETE NOTE AWKLIB DOMCONFIG"; return ;;
esac
[ $posCwords -eq 2 ] || [[ "$prev" =~ ^- ]] && echo "-C -A -B -O -T -t -l -i -f -F <regexSearchExpr>"
;;
tags:2)
echo "<TAG> CRITICALTODO TODO SECURITY DEPRECIATED UPDATE BGENV OBSOLETE NOTE AWKLIB DOMCONFIG"
;;
debugger:2)
if [[ ! "$cur" =~ : ]]; then
echo "status destination cntr-C:%3A stopOnAssert:%3A"
elif [[ "$cur" =~ ^cntr-C: ]]; then
echo "\$(cur:${cur#cntr-C:}) on off"
elif [[ "$cur" =~ ^stopOnAssert: ]]; then
echo "\$(cur:${cur#stopOnAssert:}) on off"
fi
;;
debugger:*)
case ${posWords[2]}:$((posCwords-2)) in
destination:1)
if [[ ! "$cur" =~ : ]]; then
echo "integrated:%3A remote:%3A atom:%3A <dbgDriver>"
else
dbgDriver="${cur%%:*}"
cur="${cur#*:}"
echo "\$(cur:$cur)"
case $dbgDriver in
integrated) echo "<ttyDev> self cuiWin /dev/pts/" ;;
remote) echo "<remoteDbgInstancePipe> cuiWin >" ;;
atom)
echo "<atomInstanceRunningPlugin> "
local codeEnvironment="${bgVinstalledSandbox##*/}"
ls /tmp/bgAtomDebugger-$USER/${codeEnvironment}-toAtom 2>/dev/null | gawk -v USER="$USER" '{
print gensub("^/tmp/bgAtomDebugger-"USER"/|-toAtom$","","g")
}'
;;
esac
fi
;;
on:1) echo "<startingPoint> stopOnLibInit stopOnFirstScriptLine " ;;
esac
;;
esac
exit
)
export -f _bg-debugCntrBC
#################################################################################################################################
# Sub Command Functions
# these implement the various sub commands of bg-debugCntr
# man(1.bashCmd) bg-debugCntr-trace
# usage: bg-debugCntr trace [ on[:<filename>] | off | status ]
# bg-debugCntr trace bashCompOpts:(verbose | terse | cachingOff | cachingOn)
# bg-debugCntr trace tests:(on | off)
# this configures attributes of the bgtracing system for scripts ran in the same terminal.
# Sub Commands:
# on[:[<filename>]] : send tracing output produced in this terminal to the specified destination file
# on : send output to stderr
# on: : send output to /tmp/bgtrace.out (the default <filename> if none is given)
# on:<filename> : <filename> can be and file that the user has permission to write to
# on:win[:winID] : send output to a cuiWin. The default cuiWinID is 'out' which makes it shared with any other terminal
# configured the same way. Use on:win:$$ to make a cuiWin termianl open that is unique and persistent to the specific
# terminal
# on:tty : send output to /dev/tty
# on:stderr : send output to stderr
# off : disable bgtrace output from this terminal. bgtrace* statements in the scrip will be ignored.
# status : print the current configuration
# bashCompOpts : configure how the _bgbc-complete-viaCmdDelegation produces bgtrace output. terse and cachingOn is the default.
# When debugging the oob_printBashCompletion function in a script command, tracing is particularely convenient. The bgtrace
# output from _bgbc-complete-viaCmdDelegation show how the output of oob_printBashCompletion is interpreted.
# tests : by default, when .ut scripts are ran, bgtracing is disabled because testcases often throw exceptions which cause
# stack traces to be sent to the trace file. This can be used to override that so that you can see traces from .ut scripts.
# See Also:
# man(7) bg_unitTest.sh
function _traceCntr()
{
local quietFlag
while [ $# -gt 0 ]; do case $1 in
-q) quietFlag="-q" ;;
*) break; esac; shift; # simplified version of bgOptionsEndLoop
done
local cmd="${1:-status}"; shift
case $cmd in
on*) assertBgDebugEnvironmentIsActive
[ "$bgTracingOn" ] && _traceCntr -q off
if [[ "$cmd" =~ ^on:win ]]; then
_traceCntr openWin "${cmd#on:}"
else
# this condition is meant to be true when we are running in a headless VM. The assumption is that the bgVinstalledSandbox
# is shared with the host OS so the developer can tail the bgtrace.out file from there
if [ ! "$DISPLAY" ] && [ "$cmd" == "on:" ] && [ "$bgVinstalledSandbox" ]; then
export bgTracingOn="on:$bgVinstalledSandbox/.bglocal/bgtrace.out.${HOSTNAME#bgcore-}"
fi
export bgTracingOn="$cmd"
fi
# 2022-08 bobg: commented out turning on extdebug. I think that was put in before sourcing bg_core turned it on
# shopt -s extdebug
[ ! "$quietFlag" ] && _traceCntr status
;;
off) assertBgDebugEnvironmentIsActive
if [[ "$bgTracingOn" =~ ^on:win[0-9] ]]; then
_traceCntr closeWin "${bgTracingOn#on:}"
fi
# 2022-08 bobg: commented out turning on extdebug. I think that was put in before sourcing bg_core turned it on
#shopt -u extdebug
export bgTracingOn=""
unset bgTracingOn
[ ! "$quietFlag" ] && _traceCntr status
;;
status)
# if the user sets bgTracingOn directly to winNew, then we need to call this outside the ()
[[ "$bgTracingOn" =~ ^(on:)?(winNew)$ ]] && _traceCntr openWin "${bgTracingOn#on:}"
if [ "$bgCoreAvail" ]; then
(
bgTracingBanner=""
source /usr/lib/bg_core.sh --minimal
if ! bgtraceIsActive; then
echo "BGTracing status : disabled"
elif touch $_bgtraceFile 2>/dev/null; then
echo "BGTracing status : desination='$_bgtraceFile'"
else
echo "BGTracing status : desination='$_bgtraceFile' error: '$_bgtraceFile' is not writable"
fi
if [ "$bgErrorStack" ]; then
echo " stack trace options : '$bgErrorStack'"
fi
)
else
echo "BGTracing status : ${bgTracingOn:-off}"
fi
;;
bashCompOpts:*)
declare -gA _bgbcData
local option="${cmd#bashCompOpts:}"
case $option in
cachingOff) _bgbcData[noCache]="1" ;;
cachingOn) _bgbcData[noCache]="" ;;
verbose)
assertBgDebugEnvironmentIsActive
_bgbcData[tracingDetail]="verbose"
_bgbcData[noCache]="1"
! type -t bgtraceVars &>/dev/null && echo -e \
"\n\twarning: in order to see the full verbose output for completion, you need to 'source /usr/lib/bg_core.sh' in this terminal\n"
;;
terse)
assertBgDebugEnvironmentIsActive
_bgbcData[tracingDetail]=""
_bgbcData[noCache]=""
;;
*) _assertError "unknown option '$option'"
esac
;;
tests:*)
local subCmd="${cmd#tests:}"
case $subCmd in
on) declare -gx bgTracingTestRunner=on ;;
off) declare -gx bgTracingTestRunner= ;;
esac
;;
errorStack)
local subCmd="$1"
case $subCmd in
showSource) export bgErrorStack="${bgErrorStack/--source} --source" ;;
no-showSource) export bgErrorStack="${bgErrorStack/--source}" ;;
oneline) export bgErrorStack="${bgErrorStack/--oneline} --oneline" ;;
no-oneline) export bgErrorStack="${bgErrorStack/--oneline}" ;;
debugStack) export bgErrorStack="${bgErrorStack/--stackDebug} --stackDebug" ;;
no-debugStack) export bgErrorStack="${bgErrorStack/--stackDebug}" ;;
callerColumn) export bgErrorStack="${bgErrorStack/--no-callerColumn}" ;;
no-callerColumn) export bgErrorStack="${bgErrorStack/--no-callerColumn} --no-callerColumn" ;;
esac
;;
openWin)
local win winTraceFile
case ${1:-winNew} in
win[0-9]) win="$1" ;;
win) win="out" ;;
winNew)
local i; for ((i=0; i<10; i++)); do
[ ! -e ${cuiWinCntrFilePrefix}$win.cntr ] && { win="win$i"; break; }
done
[ ! "$win" ] && _assertError "
no available win communication pipes were found. looking for one of these that do not yet exist -- '/tmp/bgtrace.win{0..9}.cntr'
"
;;
*) _assertError "invalid bgtrace window identifier. Expecting win[0-9]|winNew|win but got '$1'" ;;
esac
winTraceFile="/tmp/bgtrace.$win"
touch "$winTraceFile" || _assertError "file '$winTraceFile' can not be used as a trace file because it is not writable"
[ "$win" ] && [ "$winTraceFile" ] && (
source /usr/lib/bg_core.sh
import bg_cuiWin.sh ;$L1;$L2
local tty; cuiWinCntr -R tty "$win" open || assertError -v win "failed to open cuiWin '$win'"
cuiWinCntr "$win" tailFile "$winTraceFile" || assertError -v win -v winTraceFile "failed to tail '$winTraceFile' in cuiWin '$win'"
) && declare -gx bgTracingOn="on:${win/%out/win}"
;;
closeWin)
local win="$1"
[ "$win" ] && (
source /usr/lib/bg_core.sh
import bg_cuiWin.sh ;$L1;$L2
cuiWinCntr "$win" close || assertError -v win "failed to close cuiWin '$win'"
)
;;
*) _assertError "unknown command '$cmd'"
esac
}
export -f _traceCntr
# usage: _traceCntr [ on[:fileName] | off | status ]
# this sets the user's bgtrace environment variable that effects scripts run in the current bash session
function _bannerCntr()
{
local cmd="${1:-status}"
case $cmd in
on) assertBgDebugEnvironmentIsActive
export bgTracingBanner="on"
_bannerCntr status
;;
off)assertBgDebugEnvironmentIsActive
export bgTracingBanner=""
unset bgTracingBanner
_bannerCntr status
;;
status)
if [ "$bgTracingBanner" ]; then
echo "Banner Status : on"
else
echo "Banner Status : off"
fi
;;
*) _assertError "unknown banner command cmd='$cmd'"
esac
}
export -f _bannerCntr
# usage: _vinstallStatus
function _vinstallStatus()
{
local verboseFlag
while [ $# -gt 0 ]; do case $1 in
-v) verboseFlag="-v" ;;
*) break; esac; shift; # simplified version of bgOptionsEndLoop
done
if [ "$bgVinstalledPaths" ]; then
echo "VIinstall Status : ${bgVinstalledSandbox:-one or more projects are vinstalled. use -v to enumerate them}"
if [ "$verboseFlag" ]; then
echo " affected environment vars: PATH, MANPATH, AWKPATH, bgLibPath and bgDataPath"
echo " vinstalled projects: "
echo "$bgVinstalledPaths:" | tr ":" "\n" | sed -e 's/./ &/; /^[[:space:]]*$/d'
fi
else
echo "VIinstall Status : none"
fi
}
export -f _vinstallStatus
# usage: _vinstallMakePathList -R <foldersVar> -S <sandboxFolderVar> [-r] [<path> [..<pathN>]]
# This processes the path arguments for the _vinstall and _vuninstall functions to create the expanded project folder list and
# the sandbox path if one is specified
# Params:
# <pathN> : 0 or more paths of sandbox or package projects that will be acted on
# Options:
# -R <foldersVar> : an array var to return the expanded project folder list
# -S <sandboxFolderVar> : a variable that will return the sandbox root folder if one is specified.
# -r : if a folder is neither a sandbox nor package project, this will determine if the path will be descended to find child
# project folders
# -e : (expand). expand each project folder and sandbox folder into its full, absolute path. vinstall wants this but vuninstall does not.
function _vinstallMakePathList()
{
local recurse verboseFlag path foldersVar sandboxFolderVar expandFlag
while [ $# -gt 0 ]; do case $1 in
-v) verboseFlag="-v" ;;
-r) recurse="-r" ;;
-e) expandFlag="-e" ;;
-R) foldersVar="$2"; shift ;;
-S) sandboxFolderVar="$2"; shift ;;
*) break;
esac; shift; done
# expand the list of folders to be installed taking into account the types of folders they are
# -r only effects folders that do not have a .bg-sp/config file
while [ $# -gt 0 ]; do
path="$1"; shift
[ -d "$path" ] || _assertError "error: '$path' is not a folder path" || continue
[ "$expandFlag" ] && path=$(cd ${path:-.}; pwd)
# get pathType for this folder using -r option to determine unknown types
pathType="$(gawk -F= '$1=="projectType" {print $2}' $path/.bg-sp/config 2>/dev/null)"
[ ! "$pathType" ] && [ -f "$path/.bg-sp/config" ] && pathType="package" # if .bg-sp/config exists the default projectType is 'package'
case ${pathType:-notOurs} in
sandbox)
[ "${!sandboxFolderVar}" ] && _assertError "Only one sandbox folder can be vinstalled in any given terminal window."
[ "$sandboxFolderVar" ] && printf -v "$sandboxFolderVar" "%s" "$path"
local folderValue; for folderValue in $(ls -d ${path%/}/*/.bg-sp/ 2>/dev/null); do
folderValue="${folderValue%/.bg-sp*}"
local folderType="$(gawk -F= '$1=="projectType" {print $2}' $folderValue/.bg-sp/config 2>/dev/null)"
[ "$folderType" == "package" ] && [ "$foldersVar" ] && eval $foldersVar'+=("$folderValue")'
done
;;
package)
[ "$foldersVar" ] && eval $foldersVar'+=("$path")'
;;
notOurs)
# find all subfolders that have a .bg-sp/config and if the projectType is 'package', add it. Do not consider below node_modules
if [ "$recurse" ]; then
local folderValue; for folderValue in $(find -L "${path}" -name node_modules -prune -false -o -path "*/.bg-sp/config"); do
folderValue="${folderValue%/.bg-sp*}"
local folderType="$(gawk -F= '$1=="projectType" {print $2}' $folderValue/.bg-sp/config 2>/dev/null)"
[ "$folderType" == "package" ] && [ "$foldersVar" ] && eval $foldersVar'+=("$folderValue")'
done
fi
;;
esac
done
}
export -f _vinstallMakePathList
# man(1.bashCmd) bg-debugCntr-vinstall
# usage: bg-debugCntr vinstall [reinstall]
# bg-debugCntr vinstall [-v] status
# bg-debugCntr vinstall [-r] [<sandboxPath>|<projectPath>]
# bg-debugCntr vinstall sourceCore
# bg-debugCntr vinstall --remove [-r] all|<sandboxPath>|<projectPath>
# bg-debugCntr vinstall devBash <pathToBash>
# virtually install a project folder or set of project folders from a sandbox project.
# Virtual installation adjusts the PATH and other environment of the terminal (bash process) where its ran so that the assets
# contained in the project(s) are active when executed from that terminal. It does not affect other terminals.
#
# The main feature of vinstall is that commands located in the project root or its "./bin" folders can be launched from any CWD/PWD
# folder the terminal is currently in and any libraries that the command uses will be loaded from vinstalled projects before
# any actually installed libraries of the same name. The import syntax provided by bg_core.sh works with vinstalled folders.
# bash completion works for vinstalled commands including newly added commands to the project.
#
# Other asset types contained in projects managed by bg-dev cooperate with vinstall to make them work similar to being installed
# whereever possible. If you have custom install hooks in a project those can not be tested by vinstalling the project.
#
# In general a project only needs to be vinstalled once at the start of working on a project in a terminal but you can re-vinstall
# projects as needed. Each time vinstall is ran, funcman will update all the generated manpages from the sources in the project.
# There may be other features that get updated when vinstall is ran.
#
# Hooks:
# If your project has special assets that are not yet covered by vinstall, you can add hooks in your project that get invoked in
# the terminal's process space when vinstall or vuninstall is called on your project. The hooks can modify environment variables
# or take other actions. The hook scripts are placed in the ./.bg-sp/ folder as .bg-sp/onVInstall and .bg-sp/onVUninstall
#
# sourceCore:
# This sub command is a convenient shortcut for typing `source /usr/lib/bg_core.sh` in your terminal. Source the core libraries
# makes the terminal work like the inside of a script that sources bg_core.sh. You have access to all the core bash functions.
# While developing scripts, its convenient to copy and paste command into the terminal to test them as you write the script.
#
# devBash:
# This sub command allows you to specify an alternate bash executable to use instead of the system installed bash. This could be
# to test a different bash version or it could be a bash built for debugging.
#
# Options:
# --quick : skip the maintentance of the manifest and plugin registries
# -v : be more verbose
# --remove): uninstall the projects listed on the command line
# See Also:
# man(1) bg-dev
# man(1) bg-debugCntr
function _vinstall()
{
local recurse verboseFlag quickFlag
while [ $# -gt 0 ]; do case $1 in
-v) verboseFlag="-v" ;;
-r) recurse="-r" ;;
--quick) quickFlag="--quick" ;;
--remove)
shift
_vuninstall "$@"
return
;;
*) break;
esac; shift; done
if [ "$1" == "status" ]; then
shift
_vinstallStatus $verboseFlag "$@"
return
elif [ "$1" == "devBash" ]; then
local devPath
if [ -f "$2" ]; then
devPath="${2%/*}"
elif [ -f "${2}/bash" ]; then
devPath="${2}"
fi
echo "executing the bash found at devPath='$devPath'"
if [ ! "$devPath" ]; then
_assertError "the path to the alternate bash executable file is a required argument"
fi
devPath="$(cd ${devPath:-.}; pwd)"
[[ ! ":${PATH}:" =~ :$devPath: ]] && export PATH="$devPath:$PATH"
export bgBashPath="${devPath}/bash"
echo "bgBashPath='$bgBashPath'"
bash
return 0
fi
assertBgDebugEnvironmentIsActive
local gdeps folders folder addedFlag sandboxFromFolderList
# default is to reinstall the projects that are already vinstalled
# this block populates folders.
if [ $# -eq 0 ] || [ "${1:-reinstall}" == "reinstall" ]; then
if [ ! "$bgVinstalledPaths" ]; then
echo "there are no vinstalled projects in this terminal"
return
fi
echo "re-installing all projects registered in \$bgVinstalledPaths"
IFS=":" read -a folders <<<$bgVinstalledPaths
[ "$bgVinstalledSandbox" ] && ( (
cd "$bgVinstalledSandbox"
[ -x makeCtags.sh ] && ./makeCtags.sh &>/dev/null
) & )
shift
fi
# expand the cmdline parameters into the list of <folders> to operate on
# if folders is already populated, this will only add to them
_vinstallMakePathList -e -R folders -S sandboxFromFolderList $recurse "$@"
# if the user is vinstalling a sandbox folder, we record it in the ENV separately and it activates some special features
# the sandbox's project folders are already in $folders
if [ "$sandboxFromFolderList" ]; then
declare -gx bgVinstalledSandbox="$sandboxFromFolderList"
fi
### choose a host manifest file for use in this vinstalled session
if [ "$bgVinstalledSandbox" ]; then
export bgVinstalledManifest="$bgVinstalledSandbox/.bglocal/hostmanifest"
export bgVinstalledPluginManifest="$bgVinstalledSandbox/.bglocal/hostPluginManifest"
elif [ ${#folders[@]} -gt 0 ] || [ "$bgVinstalledPaths" ]; then
export bgVinstalledManifest="$(mktemp --tmpdir bgVinstalledManifest.$$.XXXXXXX)"
export bgVinstalledPluginManifest="$(mktemp --tmpdir bgVinstalledPluginManifest.$$.XXXXXXX)"
else
unset bgVinstalledManifest
unset bgVinstalledPluginManifest
fi
# make sure that it exists
if [ "$bgVinstalledManifest" ] && [ ! -s "$bgVinstalledManifest" ]; then
if [ -f "/var/lib/bg-core/manifest" ]; then
cp "/var/lib/bg-core/manifest" "$bgVinstalledManifest"
else
touch "$bgVinstalledManifest"
fi
fi
### when a sandbox includes build dep projects like bg-core and bg-dev, we have a chicken and egg problem.
# the following blocks attempts to avieviate that by pre installing parts of them
# separate the build dep projects from other projects being installed
local foldersBldDeps foldersOthers
for folder in "${folders[@]}"; do
# build deps are bg-core,bg-dev and any package that contains a PackageAsset plugin
if [[ "$folder" =~ (bg-core|bg-dev)(.git)?$ ]] || [ "$(find -L "$folder" \( -type d -name ".?*" \) -prune -o -type f -name "*..PackageAsset" -printf "%P\n" 2>/dev/null)" ]; then
foldersBldDeps+=("$folder")
else
foldersOthers+=("$folder")
fi
done
# make sure that the build dep projects are first
folders=( "${foldersBldDeps[@]}" "${foldersOthers[@]}" )
# pre-install the build dep packages
for folder in "${foldersBldDeps[@]}"; do
echo "pre-installing build dependency package: ${folder##*/}"
_vinstallOneProject --preInst $quickFlag "$folder"
done
if ! which bg-dev &>/dev/null; then
echo "error: can not complete the virtual installation because the bg-dev command is not available. You must either install the bg-dev package or include it in the packages being vinstalled"
return
fi
# build the host manifest up to this point so that all the PackageAsset plugins will be known during the rest of the vinstalls
if [ ! "$quickFlag" ] && [ "$bgVinstalledManifest" ]; then
(
echo "updating host manifest with newly installed build deb assets"
source /usr/lib/bg_core.sh
import PackageAsset.PluginType ;$L1;$L2
static::PackageAsset::updateVInstalledHostmanifest
)
fi
### do the vinstall on each folder in the list,
for folder in "${foldersBldDeps[@]}" "${foldersOthers[@]}"; do
_vinstallOneProject $quickFlag "$folder"
done
### now that the project manifest files are updated, update the vinstalled host manifest
if [ ! "$quickFlag" ] && [ "$bgVinstalledManifest" ]; then
(
source /usr/lib/bg_core.sh
import PackageAsset.PluginType ;$L1;$L2
static::PackageAsset::updateVInstalledHostmanifest
)
fi
# build the host plugin manifest in the background. as of 2022-02 no instalation task needs the plugin attributes. the manifest already lists all the plugins
if [ ! "$quickFlag" ] && [ "$bgVinstalledPluginManifest" ]; then
((
source /usr/lib/bg_core.sh
import bg_plugins.sh ;$L1;$L2
# $Plugin::buildAwkDataTable ... failed when processing PluginType:Collect (Collect[0] was overwritten with 'Class')
# bg_plugins.sh: line 386: _bgclassCall Plugin Class 0 |: expression recursion level exceeded (error token is "Plugin Class 0 |")
static::Plugin::buildAwkDataTable | fsPipeToFile "$bgVinstalledPluginManifest"
)&)
fi
[ ! "$quickFlag" ] && for folder in "${folders[@]}"; do
local fullpath=$(cd ${folder:-.}; pwd)
local projName="${fullpath##*/}"
# update the funcman man pages in the background
which bg-dev &>/dev/null && [ ! "$bgVinstallInhibitPostProcessing" ] && (
(export bgTracingBanner=""; cd "$fullpath"; bg-dev funcman update >/dev/null) &
)
done
# report if there are any uninstalled dependencies
[ "$addedFlag" ] && __bgCheckForMissingDeps "$gdeps"
}
export -f _vinstall
function _vinstallOneProject()
{
local preInstallFlag quickFlag
while [ $# -gt 0 ]; do case $1 in
--preInst) preInstallFlag="--preInst" ;;
--quick) quickFlag="--quick" ;;
*) break;
esac; shift; done
local folder="$1"
local fullpath=$(cd ${folder:-.}; pwd)
local projName="${fullpath##*/}"
# the package name is typically the foldername but it could be different. Look in .bg-sp/config and then the deb control file
local pkgName="$(gawk -F= '$1==packageName {print $2}' "$fullpath/.bg-sp/config" 2>/dev/null)"
[ ! "$pkgName" ] && pkgName="$(gawk -F: '$1=="Package" {print $2}' $fullpath/pkgControl/debControl 2>/dev/null )"
[ ! "$pkgName" ] && pkgName="${fullpath##*/}"
pkgName=$(echo $pkgName) # remove leading and trailing spaces
# keep track of reloading or new install state. addedFlag is the running state to see if any have been added even if some are reloaded
local status="updated"
if [[ ! ":${bgInstalledPkgNames}:" =~ :$pkgName: ]]; then
status="added"
addedFlag="1"
fi
# make sure this project appears in each of these paths but dont add it twice.
[[ ! ":${PATH}:" =~ :$fullpath: ]] && export PATH="$fullpath:$PATH"
[[ ! ":${BASH_LOADABLES_PATH}:" =~ :$fullpath: ]] && export BASH_LOADABLES_PATH="$fullpath:$BASH_LOADABLES_PATH"
[[ ! ":${BASH_LOADABLES_PATH}:" =~ :$fullpath/bin: ]] && export BASH_LOADABLES_PATH="$fullpath/bin:$BASH_LOADABLES_PATH"
[[ ! ":${MANPATH}:" =~ :$fullpath: ]] && export MANPATH="$fullpath:$MANPATH"
[[ ! ":${MANPATH}:" =~ :$fullpath/.bglocal/funcman: ]] && export MANPATH="$fullpath/.bglocal/funcman:$MANPATH"
[[ ! ":${AWKPATH}:" =~ :$fullpath: ]] && export AWKPATH="$fullpath:${AWKPATH:-$(gawk 'BEGIN {print ENVIRON["AWKPATH"]}')}"
[[ ! ":${AWKPATH}:" =~ :$fullpath/lib: ]] && export AWKPATH="$fullpath/lib:${AWKPATH:-$(gawk 'BEGIN {print ENVIRON["AWKPATH"]}')}"
#(done in node-cli) [[ ! ":${NODE_PATH}:" =~ :$fullpath/node_modules: ]] && export NODE_PATH="$fullpath/node_modules:$NODE_PATH"
[[ ! ":${NODE_PATH}:" =~ :$fullpath/global_node_modules: ]] && export NODE_PATH="$fullpath/global_node_modules:$NODE_PATH"
[[ ! ":${bgLibPath}:" =~ :$fullpath: ]] && export bgLibPath="$fullpath:$bgLibPath"
[[ ! ":${bgDataPath}:" =~ :$fullpath: ]] && export bgDataPath="$fullpath:$bgDataPath"
[[ ! ":${bgVinstalledPaths}:" =~ :$fullpath: ]] && export bgVinstalledPaths="$fullpath:$bgVinstalledPaths"
[ ! "$preInstallFlag" ] && [[ ! ":${bgInstalledPkgNames}:" =~ :$pkgName: ]] && export bgInstalledPkgNames="$pkgName:$bgInstalledPkgNames"
# invoke the project's vinstall hook if it exists
# at the time of adding [ ! "$quickFlag" ], the only onVInstall scripts were light but we pass the flag to the scripts so that
# each script can respect the flag if something heavy is added
local savedPWD=$PWD; cd $fullpath
if [ -f "$fullpath/.bg-sp/onVInstall" ]; then
source "$fullpath/.bg-sp/onVInstall" $quickFlag || echo "$pkgName:.bg-sp/onVInstall exitted with a non-zero exit code"
fi
cd $savedPWD
# make sure that the manifest file is up to date
if which bg-dev &>/dev/null; then
if [ ! "$quickFlag" ]; then
(export bgTracingBanner=""; cd $fullpath; bg-dev assets update -q)
# now catch up the packages that were vinstalled before bg-dev was available
if [ "$pkgName" == "bg-dev" ] && [ ${#_bgTmpPkgListNotUpdated[@]} -gt 0 ]; then
local _tmpPath; for _tmpPath in "${_bgTmpPkgListNotUpdated[@]}"; do
(export bgTracingBanner=""; cd $_tmpPath; bg-dev assets update -q)
done