1if [ ! "$_PACKAGES_INDEX_SUBR" ]; then _PACKAGES_INDEX_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 (INCLUDING, 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/index.subr 268999 2014-07-22 23:10:12Z dteske $ |
28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." packages/index.subr 34f_include $BSDCFG_SHARE/device.subr 35f_include $BSDCFG_SHARE/media/common.subr |
36f_include $BSDCFG_SHARE/packages/musthavepkg.subr |
37f_include $BSDCFG_SHARE/strings.subr 38 39BSDCFG_LIBE="/usr/libexec/bsdconfig" 40f_include_lang $BSDCFG_LIBE/include/messages.subr 41 42############################################################ GLOBALS 43 44PACKAGE_INDEX= --- 4 unchanged lines hidden (view full) --- 49# 50SQLITE_REPO="/var/db/pkg/repo-packagesite.sqlite" 51 52# 53# Default path to on-disk cache INDEX file 54# 55PACKAGES_INDEX_CACHEFILE="/var/run/bsdconfig/packages_INDEX.cache" 56 |
57############################################################ FUNCTIONS 58 59# f_index_initialize [$var_to_set] 60# 61# Read and initialize the global index. Returns success unless media cannot be 62# initialized for any reason (e.g. user cancels media selection dialog or an 63# error occurs). The index is sorted before being loaded into $var_to_set. 64# 65# NOTE: The index is processed with f_index_read() [below] after being loaded. 66# 67f_index_initialize() 68{ 69 local __funcname=f_index_initialize |
70 local __var_to_set="${1:-PACKAGE_INDEX}" |
71 72 [ "$_INDEX_INITTED" ] && return $SUCCESS 73 74 # Got any media? 75 f_media_verify || return $FAILURE 76 |
77 # Make sure we have a usable pkg(8) with $PKG_ABI 78 f_musthavepkg_init 79 |
80 # Does it move when you kick it? 81 f_device_init device_media || return $FAILURE 82 83 f_show_info "$msg_attempting_to_update_repository_catalogue" 84 85 # 86 # Generate $PACKAGESITE variable for pkg(8) based on media type 87 # --- 16 unchanged lines hidden (view full) --- 104 __site="$__site/packages/$PKG_ABI" ;; 105 $DEVICE_TYPE_CDROM) 106 __site="file://$MOUNTPOINT/packages/$PKG_ABI" 107 export REPOS_DIR="$MOUNTPOINT/packages/repos" ;; 108 *) # UFS, DISK, CDROM, USB, DOS, NFS, etc. 109 __site="file://$MOUNTPOINT/packages/$PKG_ABI" 110 esac 111 |
112 f_dprintf "PACKAGESITE=[%s]" "$__site" 113 if ! f_eval_catch $__funcname pkg \ 114 'PACKAGESITE="%s" pkg update' "$__site" 115 then |
116 f_show_err "$msg_unable_to_update_pkg_from_selected_media" 117 f_device_shutdown device_media 118 return $FAILURE 119 fi 120 121 # 122 # Try to get contents from validated on-disk cache 123 # --- 50 unchanged lines hidden (view full) --- 174 fi 175 # Otherwise, fall-thru to create a fresh cache from scratch 176 fi 177 178 # 179 # If we reach this point, we need to generate the data from scratch 180 # 181 |
182 f_show_info "$msg_generating_index_from_pkg_database" |
183 eval "$__var_to_set"='$( pkg rquery -I | sort )' |
184 185 # 186 # Attempt to create the persistant on-disk cache 187 # 188 189 # Create a new temporary file to write to 190 local __tmpfile 191 if f_eval_catch -dk __tmpfile $__funcname mktemp \ --- 221 unchanged lines hidden --- |