Deleted Added
full compact
any.subr (250535) any.subr (251190)
1if [ ! "$_MEDIA_ANY_SUBR" ]; then _MEDIA_ANY_SUBR=1
2#
3# Copyright (c) 2012-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:
9# 1. Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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#
1if [ ! "$_MEDIA_ANY_SUBR" ]; then _MEDIA_ANY_SUBR=1
2#
3# Copyright (c) 2012-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:
9# 1. Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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/media/any.subr 250535 2013-05-12 00:39:25Z dteske $
27# $FreeBSD: head/usr.sbin/bsdconfig/share/media/any.subr 251190 2013-05-31 19:07:17Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." media/any.subr
34f_include $BSDCFG_SHARE/dialog.subr
35f_include $BSDCFG_SHARE/struct.subr
36f_include $BSDCFG_SHARE/media/cdrom.subr
37f_include $BSDCFG_SHARE/media/directory.subr
38f_include $BSDCFG_SHARE/media/dos.subr
39f_include $BSDCFG_SHARE/media/floppy.subr
40f_include $BSDCFG_SHARE/media/ftp.subr
41f_include $BSDCFG_SHARE/media/httpproxy.subr
42f_include $BSDCFG_SHARE/media/nfs.subr
43f_include $BSDCFG_SHARE/media/options.subr
44f_include $BSDCFG_SHARE/media/ufs.subr
45f_include $BSDCFG_SHARE/media/usb.subr
46
47BSDCFG_LIBE="/usr/libexec/bsdconfig"
48f_include_lang $BSDCFG_LIBE/include/messages.subr
49
50MEDIA_HELPFILE=$BSDCFG_LIBE/include/media.hlp
51
52############################################################ FUNCTIONS
53
54# f_media_get_type
55#
56# Prompt the user to select amongst the known media types (included above).
57#
58# If the user does not cancel or press Esc, invokes the f_media_set_* function
59# associated with the chosen media type. If after all that we have a struct
60# named `device_media' then success is returned, otherwise failure.
61#
62# NOTE: The f_media_set_* function should create the `device_media' struct.
63# See `struct.subr' and the above `media/*.subr' includes for more details.
64#
65f_media_get_type()
66{
67 f_dialog_title "$msg_choose_installation_media"
68 local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
69 f_dialog_title_restore
70 local prompt="$msg_choose_installation_media_description"
71 local hline="$hline_choose_help_for_more_information_on_media_types"
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." media/any.subr
34f_include $BSDCFG_SHARE/dialog.subr
35f_include $BSDCFG_SHARE/struct.subr
36f_include $BSDCFG_SHARE/media/cdrom.subr
37f_include $BSDCFG_SHARE/media/directory.subr
38f_include $BSDCFG_SHARE/media/dos.subr
39f_include $BSDCFG_SHARE/media/floppy.subr
40f_include $BSDCFG_SHARE/media/ftp.subr
41f_include $BSDCFG_SHARE/media/httpproxy.subr
42f_include $BSDCFG_SHARE/media/nfs.subr
43f_include $BSDCFG_SHARE/media/options.subr
44f_include $BSDCFG_SHARE/media/ufs.subr
45f_include $BSDCFG_SHARE/media/usb.subr
46
47BSDCFG_LIBE="/usr/libexec/bsdconfig"
48f_include_lang $BSDCFG_LIBE/include/messages.subr
49
50MEDIA_HELPFILE=$BSDCFG_LIBE/include/media.hlp
51
52############################################################ FUNCTIONS
53
54# f_media_get_type
55#
56# Prompt the user to select amongst the known media types (included above).
57#
58# If the user does not cancel or press Esc, invokes the f_media_set_* function
59# associated with the chosen media type. If after all that we have a struct
60# named `device_media' then success is returned, otherwise failure.
61#
62# NOTE: The f_media_set_* function should create the `device_media' struct.
63# See `struct.subr' and the above `media/*.subr' includes for more details.
64#
65f_media_get_type()
66{
67 f_dialog_title "$msg_choose_installation_media"
68 local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
69 f_dialog_title_restore
70 local prompt="$msg_choose_installation_media_description"
71 local hline="$hline_choose_help_for_more_information_on_media_types"
72 local menu_list size
72 local menu_list
73
74 menu_list="
75 '1 $msg_cd_dvd' '$msg_install_from_a_freebsd_cd_dvd'
76 '2 $msg_ftp' '$msg_install_from_an_ftp_server'
77 '3 $msg_ftp_passive'
78 '$msg_install_from_an_ftp_server_thru_firewall'
79 '4 $msg_http' '$msg_install_from_an_ftp_server_thru_proxy'
80 '5 $msg_directory' '$msg_install_from_the_existing_filesystem'
81 '6 $msg_nfs' '$msg_install_over_nfs'
82 '7 $msg_dos' '$msg_install_from_a_dos_partition'
83 '8 $msg_ufs' '$msg_install_from_a_ufs_partition'
84 '9 $msg_floppy' '$msg_install_from_a_floppy_disk_set'
85 'A $msg_usb' '$msg_install_from_a_usb_drive'
86 'X $msg_options' '$msg_view_set_various_media_options'
87 " # END-QUOTE
88
73
74 menu_list="
75 '1 $msg_cd_dvd' '$msg_install_from_a_freebsd_cd_dvd'
76 '2 $msg_ftp' '$msg_install_from_an_ftp_server'
77 '3 $msg_ftp_passive'
78 '$msg_install_from_an_ftp_server_thru_firewall'
79 '4 $msg_http' '$msg_install_from_an_ftp_server_thru_proxy'
80 '5 $msg_directory' '$msg_install_from_the_existing_filesystem'
81 '6 $msg_nfs' '$msg_install_over_nfs'
82 '7 $msg_dos' '$msg_install_from_a_dos_partition'
83 '8 $msg_ufs' '$msg_install_from_a_ufs_partition'
84 '9 $msg_floppy' '$msg_install_from_a_floppy_disk_set'
85 'A $msg_usb' '$msg_install_from_a_usb_drive'
86 'X $msg_options' '$msg_view_set_various_media_options'
87 " # END-QUOTE
88
89 size=$( eval f_dialog_menu_size \
90 \"\$title\" \
91 \"\$btitle\" \
92 \"\$prompt\" \
93 \"\$hline\" \
94 $menu_list )
89 local height width rows
90 eval f_dialog_menu_size height width rows \
91 \"\$title\" \
92 \"\$btitle\" \
93 \"\$prompt\" \
94 \"\$hline\" \
95 $menu_list
95
96 local dialog_menu
97
98 while :; do
99 dialog_menu=$( eval $DIALOG \
96
97 local dialog_menu
98
99 while :; do
100 dialog_menu=$( eval $DIALOG \
100 --title \"\$title\" \
101 --backtitle \"\$btitle\" \
102 --hline \"\$hline\" \
103 --ok-label \"\$msg_ok\" \
104 --cancel-label \"\$msg_cancel\" \
105 --help-button \
106 --help-label \"\$msg_help\" \
107 ${USE_XDIALOG:+--help \"\"} \
108 --menu \"\$prompt\" $size $menu_list \
101 --title \"\$title\" \
102 --backtitle \"\$btitle\" \
103 --hline \"\$hline\" \
104 --ok-label \"\$msg_ok\" \
105 --cancel-label \"\$msg_cancel\" \
106 --help-button \
107 --help-label \"\$msg_help\" \
108 ${USE_XDIALOG:+--help \"\"} \
109 --menu \"\$prompt\" \
110 $height $width $rows \
111 $menu_list \
109 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
110 )
111 local retval=$?
112 setvar DIALOG_MENU_$$ "$dialog_menu"
113
114 local mtag
115 mtag=$( f_dialog_menutag )
116 f_dprintf "retval=%s mtag=[%s]" $retval "$mtag"
117
118 if [ $retval -eq 2 ]; then
119 # The Help button was pressed
120 f_show_help "$MEDIA_HELPFILE"
121 continue
122 elif [ $retval -ne 0 ]; then
123 return $FAILURE
124 fi
125
126 case "$mtag" in
127 ?" $msg_cd_dvd") f_media_set_cdrom ;;
128 ?" $msg_ftp") f_media_set_ftp_active ;;
129 ?" $msg_ftp_passive") f_media_set_ftp_passive ;;
130 ?" $msg_http") f_media_set_http_proxy ;;
131 ?" $msg_directory") f_media_set_directory ;;
132 ?" $msg_dos") f_media_set_dos ;;
133 ?" $msg_nfs") f_media_set_nfs ;;
134 ?" $msg_ufs") f_media_set_ufs ;;
135 ?" $msg_floppy") f_media_set_floppy ;;
136 ?" $msg_usb") f_media_set_usb ;;
137 ?" $msg_options")
138 f_media_options_menu
139 continue
140 ;;
141 esac
142 break
143 done
144
145 f_struct device_media || return $FAILURE
146}
147
148############################################################ MAIN
149
150f_dprintf "%s: Successfully loaded." media/any.subr
151
152fi # ! $_MEDIA_ANY_SUBR
112 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
113 )
114 local retval=$?
115 setvar DIALOG_MENU_$$ "$dialog_menu"
116
117 local mtag
118 mtag=$( f_dialog_menutag )
119 f_dprintf "retval=%s mtag=[%s]" $retval "$mtag"
120
121 if [ $retval -eq 2 ]; then
122 # The Help button was pressed
123 f_show_help "$MEDIA_HELPFILE"
124 continue
125 elif [ $retval -ne 0 ]; then
126 return $FAILURE
127 fi
128
129 case "$mtag" in
130 ?" $msg_cd_dvd") f_media_set_cdrom ;;
131 ?" $msg_ftp") f_media_set_ftp_active ;;
132 ?" $msg_ftp_passive") f_media_set_ftp_passive ;;
133 ?" $msg_http") f_media_set_http_proxy ;;
134 ?" $msg_directory") f_media_set_directory ;;
135 ?" $msg_dos") f_media_set_dos ;;
136 ?" $msg_nfs") f_media_set_nfs ;;
137 ?" $msg_ufs") f_media_set_ufs ;;
138 ?" $msg_floppy") f_media_set_floppy ;;
139 ?" $msg_usb") f_media_set_usb ;;
140 ?" $msg_options")
141 f_media_options_menu
142 continue
143 ;;
144 esac
145 break
146 done
147
148 f_struct device_media || return $FAILURE
149}
150
151############################################################ MAIN
152
153f_dprintf "%s: Successfully loaded." media/any.subr
154
155fi # ! $_MEDIA_ANY_SUBR