summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/share/media/http.subr
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bsdconfig/share/media/http.subr')
-rw-r--r--usr.sbin/bsdconfig/share/media/http.subr55
1 files changed, 44 insertions, 11 deletions
diff --git a/usr.sbin/bsdconfig/share/media/http.subr b/usr.sbin/bsdconfig/share/media/http.subr
index 97c4ed0..23c146c 100644
--- a/usr.sbin/bsdconfig/share/media/http.subr
+++ b/usr.sbin/bsdconfig/share/media/http.subr
@@ -77,7 +77,8 @@ f_dialog_menu_media_http()
f_dialog_title_restore
local prompt="$msg_please_select_the_site_closest_to_you_or_other"
local menu_list="
- '$msg_main_site' 'ftp.freebsd.org'
+ 'dist $msg_main_site' 'ftp.freebsd.org'
+ 'pkg $msg_main_site' 'pkg.freebsd.org'
'URL' '$msg_specify_some_other_http_site'
" # END-QUOTE
local hline="$msg_select_a_site_thats_close"
@@ -452,6 +453,11 @@ f_media_init_http()
local dev="$1"
f_dprintf "Init routine called for HTTP device. dev=[%s]" "$dev"
+ if [ "$HTTP_INITIALIZED" ]; then
+ f_dprintf "HTTP device already initialized."
+ return $SUCCESS
+ fi
+
#
# First verify access
#
@@ -481,7 +487,7 @@ f_media_init_http()
case "$rel" in
__RELEASE|any)
- setvar $VAR_HTTP_PATH "$VAR_HTTP_DIR"
+ f_getvar $VAR_HTTP_DIR $VAR_HTTP_PATH
f_http_check_access
http_found=$?
;;
@@ -493,22 +499,31 @@ f_media_init_http()
#
local fdir hp
f_getvar $VAR_HTTP_PATH%/ hp
- for fdir in $HTTP_DIRS; do
- setvar $VAR_HTTP_PATH "$hp/$fdir/$rel"
- if f_http_check_access; then
- http_found=$SUCCESS
- break
- fi
- done
+ setvar $VAR_HTTP_PATH "$hp/$PKG_ABI/latest"
+ if [ "$PKG_ABI" ] && f_http_check_access; then
+ http_found=$SUCCESS
+ setvar $VAR_HTTP_PATH "$hp"
+ else
+ for fdir in $HTTP_DIRS; do
+ setvar $VAR_HTTP_PATH "$hp/$fdir/$rel"
+ if f_http_check_access; then
+ http_found=$SUCCESS
+ break
+ fi
+ done
+ fi
esac
- [ $http_found -eq $SUCCESS ] && break
+ if [ $http_found -eq $SUCCESS ]; then
+ HTTP_INITIALIZED=YES
+ break
+ fi
f_getvar $VAR_HTTP_PATH http_path
f_show_msg "$msg_please_check_the_url_and_try_again" \
"$http_path"
- unset $VAR_HTTP_PATH
+ unset HTTP_INITIALIZED $VAR_HTTP_PATH
f_media_set_http || break
done
@@ -558,6 +573,11 @@ f_media_get_http()
f_getvar $VAR_HTTP_HOST http_host
f_getvar $VAR_HTTP_PORT http_port
+ if [ ! "$HTTP_INITIALIZED" ]; then
+ f_dprintf "No HTTP connection open, can't get file %s" "$file"
+ return $FAILURE
+ fi
+
if ! {
f_validate_ipaddr "$http_host" ||
f_validate_ipaddr6 "$http_host" ||
@@ -595,6 +615,7 @@ f_media_get_http()
local url="$http_path/$file" rx
f_dprintf "sending http request for: %s" "$url"
+ f_dprintf "using nc to connect to: %s:%s" "$host" "$http_port"
printf "GET %s HTTP/1.0\r\n\r\n" "$url" | nc -n "$host" "$http_port" |
(
#
@@ -648,6 +669,18 @@ f_media_get_http()
return $FAILURE
}
+# f_media_shutdown_http $device
+#
+# Shuts down the HTTP device. Return status should be ignored. Note that since
+# we don't maintain an open connection to the HTTP server, nothing to do.
+#
+f_media_shutdown_http()
+{
+ [ "$HTTP_INITIALIZED" ] || return $SUCCESS
+
+ unset HTTP_INITIALIZED
+}
+
############################################################ MAIN
f_dprintf "%s: Successfully loaded." media/http.subr
OpenPOWER on IntegriCloud