5 Usage: $0 update|remove --spec <prio>:<path>:<alt-path>
16 $UCI ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} "$@"
20 local path
="${IPKG_INSTROOT}$1"
22 [ -L "$path" -o ! -e "$path" ] ||
{
23 errmsg
"$0: $path exists and is not an symbolic file"
30 local found_section found_altpath
31 local found_prio
=-1 found_prio_altpath
35 config_foreach find_path alternatives
"$prio" "$path"
36 if [ -n "$found_prio_altpath" ]; then
37 IFS
=:; set -- $found_prio_altpath; altpath
=$2; IFS
="$oIFS"
38 cur
="$(readlink -f "$path")"
39 if [ "$cur" != "$altpath" ]; then
40 errmsg
"link $path -> $altpath"
41 ln -sf "$altpath" "${IPKG_INSTROOT}$path"
43 elif [ -n "$found_section" ]; then
44 errmsg
"remove empty alternatives section for $path"
45 uci_ delete
"opkg.$found_section"
47 rm -f "${IPKG_INSTROOT}$path"
56 local cfgprio cfgaltpath_
57 local oIFS
="$IFS"; IFS
=:; set -- $cfgaltpath; cfgprio
="$1"; cfgaltpath_
="$2"; IFS
="$oIFS"
59 if [ "$cfgaltpath_" = "$altpath" ]; then
60 found_altpath
="$cfgaltpath"
62 if [ "$cfgprio" -gt "$found_prio" ]; then
64 found_prio_altpath
="$cfgaltpath"
75 config_get cfgpath
"$cfg" path
76 [ "$cfgpath" = "$path" ] ||
return
78 config_list_foreach
"$cfg" altpath find_altpath
"$cfg" "$prio" "$altpath"
83 local prio path altpath
85 local found_section found_altpath
86 local found_prio
=-1 found_prio_altpath
88 IFS
=:; set -- $spec; IFS
="$oIFS"
93 if [ ! -e "${IPKG_INSTROOT}$altpath" ]; then
94 errmsg
"$altpath does not exist"
99 config_foreach find_path alternatives
"$prio" "$path" "$altpath"
100 if [ -z "$found_section" ]; then
101 found_section
="$(uci_ add opkg alternatives)"
102 uci_
set opkg.
$found_section.path
=$path
104 if [ -n "$found_altpath" ]; then
105 if [ "$found_altpath" != "$prio:$altpath" ]; then
107 uci_ del_list opkg.
$found_section.altpath
=$found_altpath
108 uci_ add_list opkg.
$found_section.altpath
=$prio:$altpath
111 uci_ add_list opkg.
$found_section.altpath
=$prio:$altpath
119 local prio path altpath
121 local found_section found_altpath
122 local found_prio
=-1 found_prio_altpath
124 IFS
=:; set -- $spec; IFS
="$oIFS"
131 config_foreach find_path alternatives
"$prio" "$path" "$altpath"
132 if [ -n "$found_section" -a -n "$found_altpath" ]; then
133 uci_ del_list opkg.
$found_section.altpath
=$found_altpath
137 errmsg
"spec $spec not found"
141 .
${IPKG_INSTROOT}/lib
/functions.sh
143 UCI
="${UCI:-/sbin/uci}"
144 UCI_STATE_DIR
="${IPKG_INSTROOT}/var/state"
147 while [ "$#" -gt 0 ]; do
161 [ -n "$ARG_CMD" -a -n "$ARG_SPEC" ] || usage
163 cmd_
$ARG_CMD "$ARG_SPEC"