update: safe leaf_update_package_datebase
This commit is contained in:
17
leaf
17
leaf
@@ -548,18 +548,25 @@ leaf_conffile_is_unmodified() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
leaf_update_package_database() {
|
leaf_update_package_database() {
|
||||||
local _item="$(echo "$2" | awk 'BEGIN{FS="/";OFS="\\/"}{print $1,$2}')"
|
local action=$1 atom=$2 db="${INSTALLED_PACKAGES}"
|
||||||
case $1 in
|
local tmp="${db}.tmp.$$"
|
||||||
|
|
||||||
|
case "$action" in
|
||||||
add)
|
add)
|
||||||
sed -i "/${_item}/d" "${INSTALLED_PACKAGES}"
|
{ [ -f "$db" ] && grep -Fvx -- "$atom" "$db" || :; printf '%s\n' "$atom"; } >"$tmp" &&
|
||||||
echo "$2" >> ${INSTALLED_PACKAGES}
|
mv -f -- "$tmp" "$db"
|
||||||
;;
|
;;
|
||||||
delete)
|
delete)
|
||||||
sed -i "/${_item}/d" "${INSTALLED_PACKAGES}"
|
grep -Fvx -- "$atom" "$db" >"$tmp" &&
|
||||||
|
mv -f -- "$tmp" "$db"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
leaf_error "unknown operation leaf_update_package_database ${action}."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
leaf_update_environment() {
|
leaf_update_environment() {
|
||||||
ldconfig
|
ldconfig
|
||||||
[ ! -r /etc/profile ] || source /etc/profile
|
[ ! -r /etc/profile ] || source /etc/profile
|
||||||
|
|||||||
Reference in New Issue
Block a user