1if [ ! "$_PACKAGES_PACKAGES_SUBR" ]; then _PACKAGES_PACKAGES_SUBR=1 2# 3# Copyright (c) 2013 Devin Teske 4# All Rights Reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# |
27# $FreeBSD: head/usr.sbin/bsdconfig/share/packages/packages.subr 252775 2013-07-05 06:52:07Z dteske $ |
28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." "$0" 34f_include $BSDCFG_SHARE/dialog.subr 35f_include $BSDCFG_SHARE/device.subr --- 615 unchanged lines hidden (view full) --- 651 # XXX Re-install package 652 done 653 for package in $SELECTED_PACKAGES; do 654 mark= 655 f_str2varname "$package" varpkg 656 debug= f_getvar _mark_$varpkg mark 657 [ "$mark" = "U" ] || continue 658 f_dprintf "%s: Uninstalling %s package" $fname "$package" |
659 f_package_delete "$package" || continue |
660 f_package_deselect "$package" 661 done 662 663 return $SUCCESS 664} 665 666# f_package_config 667# --- 384 unchanged lines hidden (view full) --- 1052 else 1053 f_show_info "$msg_package_was_added_successfully" "$name" 1054 sleep 1 1055 fi 1056 1057 return $SUCCESS 1058} 1059 |
1060# f_package_delete $name 1061# 1062# Delete package by full $name (lacks archive suffix; e.g., `.tbz'). 1063# 1064f_package_delete() 1065{ 1066 local name="$1" 1067 local fname=f_package_delete 1068 1069 if ! { [ "$name" ] || { f_getvar $VAR_PACKAGE name && [ "$name" ]; }; } 1070 then 1071 f_dprintf "packageDelete: %s" \ 1072 "$msg_no_package_name_passed_in_package_variable" 1073 return $FAILURE 1074 fi 1075 1076 f_dprintf "%s: name=[%s]" $fname "$name" 1077 1078 [ "$name" ] || return $FAILURE 1079 1080 { # Verify and initialize device media if-defined 1081 f_media_verify && 1082 f_device_init media && 1083 f_index_initialize packages/INDEX 1084 } || return $FAILURE 1085 1086 # Now we have (indirectly via f_index_read()): 1087 # CATEGORY_MENU_LIST _categories_{varpkg} _rundeps_{varpkg} 1088 # PACKAGE_CATEGORIES _npkgs 1089 1090 local varpkg 1091 f_str2varname "$name" varpkg 1092 1093 # Just as-in the user-interface (opposed to scripted-use), only allow 1094 # packages with at least one category to be recognized. 1095 # 1096 local pkgcat= 1097 if ! f_getvar _categories_$varpkg pkgcat || [ ! "$pkgcat" ]; then 1098 # $pkg may be a partial name, search the index (this is slow) 1099 f_index_search PACKAGE_INDEX "$name" name 1100 if [ ! "$name" ]; then 1101 f_show_msg \ 1102 "$msg_sorry_package_was_not_found_in_the_index" \ 1103 "$name" 1104 return $FAILURE 1105 fi 1106 f_str2varname "$name" varpkg 1107 fi 1108 1109 # If invoked through the scripted interface, we likely have not yet 1110 # detected the installed packages -- something we should do only once. 1111 # 1112 if [ ! "$PACKAGES_DETECTED" ]; then 1113 f_dprintf "%s: Detecting installed packages" $fname 1114 f_package_detect_installed 1115 export PACKAGES_DETECTED=1 # exported for awk(1) ENVIRON[] 1116 fi 1117 # Now we have: _mark_{varpkg}=X for all installed packages 1118 1119 # 1120 # Return failure if the package is not already installed. 1121 # 1122 local pkgmark= 1123 f_getvar _mark_$varpkg pkgmark 1124 if ! [ "$pkgmark" -a ! "${pkgmark#[XUR]}" ]; then 1125 f_show_msg "$msg_package_not_installed_cannot_delete" "$name" 1126 return $FAILURE 1127 fi 1128 1129 # 1130 # Check for dependencies 1131 # 1132 local pkgsel depc=0 udeps= 1133 for pkgsel in $SELECTED_PACKAGES; do 1134 local mark= 1135 f_str2varname $pkgsel varpkg 1136 debug= f_getvar _mark_$varpkg mark 1137 [ "$mark" -a ! "${mark#[XUR]}" ] || continue 1138 local dep rundeps= 1139 debug= f_getvar _rundeps_$varpkg rundeps 1140 for dep in $rundeps; do 1141 if [ "$dep" = "$name" ]; then 1142 # Maybe this package is marked for deletion too 1143 if [ "$mark" = "U" ]; then 1144 udeps="$udeps $pkgsel" 1145 else 1146 depc=$(( $depc + 1 )) 1147 fi 1148 break 1149 fi 1150 done 1151 done 1152 if [ $depc -gt 0 ]; then 1153 local grammatical_s= 1154 [ $depc -gt 1 ] && grammatical_s=s 1155 f_show_msg \ 1156 "$msg_package_is_needed_by_other_installed_packages" \ 1157 "$name" "$depc" "$grammatical_s" 1158 return $FAILURE 1159 fi 1160 1161 # 1162 # Chase dependencies that are marked for uninstallation 1163 # 1164 for pkgsel in $udeps; do 1165 f_dprintf "%s: Uninstalling dependecy %s (marked for delete)" \ 1166 $fname "$pkgsel" 1167 f_package_delete "$pkgsel" 1168 done 1169 1170 # 1171 # OK to perform the delete (no other packages depend on it)... 1172 # 1173 f_show_info "$msg_uninstalling_package_waiting_for_pkg_delete" "$name" 1174 if f_debugging; then 1175 pkg_delete -v "$name" 1176 else 1177 f_quietly pkg_delete "$name" 1178 fi 1179 if [ $? -ne $SUCCESS ]; then 1180 f_show_msg "$msg_pkg_delete_failed" "$name" 1181 return $FAILURE 1182 else 1183 f_dprintf "%s: pkg_delete(1) of %s successful" $fname "$name" 1184 f_str2varname "$name" varpkg 1185 setvar _mark_$varpkg "" 1186 fi 1187} 1188 |
1189############################################################ MAIN 1190 1191f_dprintf "%s: Successfully loaded." packages/packages.subr 1192 1193fi # ! $_PACKAGES_PACKAGES_SUBR |