first version.
[build-srcpkg.git] / bin / shlibopt.sh
blobf7bca304bc8b38bd95cdf060641a2cfd03a02196
1 #!/bin/bash
2 ############################################################
3 # source: shlib
4 # author: CottonCandyOwner(CottonCandyOwner@126.com)
5 # date: 2022-03-13
6 ############################################################
7 # Copyright (C) 2022- Free Software Foundation, Inc.
8 # This configure script is free software; the Free Software
9 # Foundation gives unlimited permission to copy, distribute
10 # and modify it.
11 ############################################################
12 # note:
13 # shlib option program. if this cmd is used for set global
14 # paramters, use 'source shlibopt' instead of single shlibopt.
15 ############################################################
18 # todoļ¼š
19 # @ create shlibinst, shliblist, shlibattr, shlibfunc as a ln file.
20 # @
23 #. shlibinc
25 #include stdio.shlib
28 ##############################
29 # section: public comment info
30 ##############################
35 ##############################
36 # section: variable define
37 ##############################
42 ##############################
43 # section: private function
44 ##############################
49 ##############################
50 # section: public function
51 ##############################
54 shlibopt_usage='
55 syntax: shlibopt [option] <paramter>
56 description: set paramters for shlib using.
58 --debug-info
59 view the debug info module which is enabled.
61 --debug-on <module-name>
62 --debug-off <module-name>
63 enable/disable debug output for the specified module.
64 syntax of name is <module-name>-<type>. eg: shlibinc-inc.
66 -i dispaly debug enable list.
67 -e <module> enable debug string output of a specified module.
68 -d <module> disable debug string output of a specified module.
70 -g get shlib path.
71 -a <path> append path to shlib path.
72 -c <path> clear the path in system. zero or none paramter delete
73 the latest path in shlib path.
75 -l [shlib] list shlib files in include path.
76 -i <file> install file to shlib path.
77 -u <file> uninstall file from shlib path.
79 -b init shlib on system boot.
80 -s <user> init shlib on session init.
81 -p init shlib on program start.
83 -v print shlib version info.
84 -h helper information.
87 [[ ! -v SHLIB_DBGOUT_OPT ]] && declare -g -x SHLIB_DBGOUT_OPT=":"
90 # fsyntax: dbgflag_info
91 # fdesc: display module info in SHLIB_DBGOUT_OPT.
93 dbgflag_info ()
95 echo "$SHLIB_DBGOUT_OPT" | tr -s ':' '
100 # fsyntax: dbgflag_set <module-name>
101 # fdesc: set module enable in SHLIB_DBGOUT_OPT.
103 dbgflag_set ()
105 if [[ ! "$SHLIB_DBGOUT_OPT" =~ "$1" ]]; then
106 [[ ! -v SHLIB_DBGOUT_OPT ]] && declare -g -x SHLIB_DBGOUT_OPT
107 SHLIB_DBGOUT_OPT+="$1:"
108 echo "SHLIB_DBGOUT_OPT=$SHLIB_DBGOUT_OPT"
113 # fsyntax: dbgflag_unset <module-name>
114 # fdesc: unset module in SHLIB_DBGOUT_OPT.
116 dbgflag_unset ()
118 if [[ "$SHLIB_DBGOUT_OPT" =~ "$1" ]]; then
119 SHLIB_DBGOUT_OPT=${SHLIB_DBGOUT_OPT//$1:/}
125 # main <eval-str>
127 main ()
129 local varin="$1"
130 local varout="$2"
131 local tmp
132 local bar=
133 local param=
135 # init_dbglogout 2 shlibopt 20000
138 # args dispatch
140 #while getopts :xie:d:ga:c:li:u:bspvh opt; do
141 while [[ "$1" != "" ]]; do
142 if [[ ${1:0:1} != - ]]; then
143 param+="$1 "
144 continue;
146 bar=1
147 if [[ ${1:1:1} == - ]]; then
148 bar=2
151 eval tmp=\${1:$bar}
152 case "$tmp" in
154 dbgflag_info
157 dbgflag_set "$2"
158 shift
161 dbgflag_unset "$2"
162 shift
166 get_shlib_path
169 echo "OPTIND=$OPTIND"
170 echo "optstr=$optstr"
171 add_shlib_path "$2"
172 shift
175 del_shlib_path "$1"
176 shift
180 get_shlib_path | while read line; do
181 echo -ne "\033[32m[$line]\n\033[0m"
182 find $line/* | grep -E "\.shlib\$"
183 done
186 tmp=( $(get_shlib_path) )
187 cp $2 $tmp
190 tmp=( $(get_shlib_path) )
191 ls $tmp
192 rm $tmp/$2
196 if [[ -z "$(cat $ROOTFS/etc/bash.bashrc | grep -E '. shlibinc')" ]]; then
197 echo ". shlibinc" > $ROOTFS/etc/bash.bashrc
201 if [[ -z "$(cat $ROOTFS/home/$user/.bashrc | grep -E '. shlibinc')" ]]; then
202 echo ". shlibinc" > $ROOTFS/home/$user/.bashrc
210 info "shlib v$SHLIB_VERSION"
213 info "$shlibopt_usage"
216 warn "does not use '-$opt' opt.\n"
218 esac
220 shift
221 done
225 main "$@"
227 ##############################
228 # section: file tail
229 ##############################