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 250538 2013-05-12 00:46:18Z 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/strings.subr
--- 256 unchanged lines hidden (view full) ---
292 local prompt="$msg_please_select_a_category_to_display"
293 local hline=""
294
295 menu_list="
296 '> $msg_review' '$msg_review_desc' '$msg_review_help'
297 $category_list
298 " # End-Quote
299
300 local size dialog_menu
301 size=$( eval f_dialog_menu_with_help_size \
302 \"\$DIALOG_TITLE\" \
303 \"\$DIALOG_BACKTITLE\" \
304 \"\$prompt\" \
305 \"\$hline\" \
306 $menu_list )
307 dialog_menu=$( eval $DIALOG \
308 --title \"\$DIALOG_TITLE\" \
309 --backtitle \"\$DIALOG_BACKTITLE\" \
310 --hline \"\$hline\" \
311 --item-help \
312 --default-item \"\$defaultitem\" \
313 --ok-label \"$msg_select\" \
314 --cancel-label \"$msg_cancel\" \
315 --menu \"\$prompt\" $size \
316 $menu_list \
317 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
318 )
319 local retval=$?
320 setvar DIALOG_MENU_$$ "$dialog_menu"
321 return $retval
322}
323
--- 126 unchanged lines hidden (view full) ---
450 case "$category" in
451 "$msg_all"|"") f_category_desc_get "All" prompt ;;
452 *) f_category_desc_get "$category" prompt ;;
453 esac
454 prompt="$prompt $( printf "$msg_page_of_npages" \
455 "$page" "$npages" )"
456
457 local hline="$hline_arrows_tab_punc_enter"
458 local size isize dialog_menu item
459 size=$( eval f_dialog_menu${SHOW_DESC:+_with_help}_size \
460 \"\$DIALOG_TITLE\" \
461 \"\$DIALOG_BACKTITLE\" \
462 \"\$prompt\" \
463 \"\$hline\" \
464 $menu_list )
465 isize=$( f_dialog_infobox_size \
466 "$DIALOG_TITLE" \
467 "$DIALOG_BACKTITLE" \
468 "$msg_processing_selection" )
469 dialog_menu=$( eval $DIALOG \
470 --title \"\$DIALOG_TITLE\" \
471 --backtitle \"\$DIALOG_BACKTITLE\" \
472 --hline \"\$hline\" \
473 --keep-tite \
474 --ok-label \"$msg_select\" \
475 --cancel-label \"$msg_back\" \
476 ${SHOW_DESC:+--item-help} \
477 --default-item \"\$defaultitem\" \
478 --menu \"\$prompt\" $size \
479 $menu_list \
480 --and-widget \
481 ${USE_XDIALOG:+--no-buttons} \
482 --infobox \"\$msg_processing_selection\" $isize \
483 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
484 )
485 local retval=$?
486 setvar DIALOG_MENU_$$ "$dialog_menu"
487
488 if [ $retval -eq $SUCCESS ]; then
489 item=$( eval f_dialog_menutag2item${SHOW_DESC:+_with_help} \
490 \"\$dialog_menu\" $menu_list )
--- 8 unchanged lines hidden (view full) ---
499# Display a menu, asking the user what they would like to do with $package
500# with regard to "deselecting" an already installed package. Choices include
501# uninstall, re-install, or cancel (leave $package marked as installed).
502# Returns success if the user does not press ESC or choose Cnacel. Use the
503# f_dialog_menutag() function upon success to retrieve the user's choice.
504#
505f_package_menu_deselect()
506{
507 local package="$1" prompt menu_list size dialog_menu
508 prompt=$( printf "$msg_what_would_you_like_to_do_with" "$package" )
509 local hline="$hline_alnum_arrows_punc_tab_enter"
510 menu_list="
511 'X $msg_installed' '$msg_installed_desc'
512 'R $msg_reinstall' '$msg_reinstall_desc'
513 'U $msg_uninstall' '$msg_uninstall_desc'
514 " # End-Quote
515 size=$( eval f_dialog_menu_size \
516 \"\$DIALOG_TITLE\" \
517 \"\$DIALOG_BACKTITLE\" \
518 \"\$prompt\" \
519 \"\$hline\" \
520 $menu_list )
521 dialog_menu=$( eval $DIALOG \
522 --title \"\$DIALOG_TITLE\" \
523 --backtitle \"\$DIALOG_BACKTITLE\" \
524 --hline \"\$hline\" \
525 --ok-label \"$msg_select\" \
526 --cancel-label \"$msg_cancel\" \
527 --menu \"\$prompt\" $size \
528 $menu_list \
529 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
530 )
531 local retval=$?
532 setvar DIALOG_MENU_$$ "$dialog_menu"
533 return $retval
534}
535
536# f_package_review
537#
538# Display a review screen, showing selected packages and what they are marked
539# for, before proceeding (if the user does not press ESC or choose Cancel) to
540# operate on each selection. Returns error if no packages have been selected,
541# or the user has pressed ESC, or if they have chosen Cancel.
542#
543f_package_review()
544{
545 local prompt size dialog_menu package varpkg mark menu_list=
546 prompt=$( printf "$msg_reviewing_selected_packages" \
547 "$_All_nselected" )
548 local hline="$hline_alnum_arrows_punc_tab_enter"
549 f_dprintf "f_package_review: SELECTED_PACKAGES=[%s]" \
550 "$SELECTED_PACKAGES"
551 for package in $SELECTED_PACKAGES; do
552 mark=
553 f_str2varname "$package" varpkg
554 f_getvar _mark_$varpkg mark
555 [ "$mark" -a ! "${mark#[IRUD]}" ] || continue
556 menu_list="$menu_list
557 '$mark' '$package'
558 " # End-Quote
559 done
560 if [ ! "$menu_list" ]; then
561 f_show_msg "$msg_no_packages_were_selected_for_extraction"
562 return $FAILURE # They might have selected this by accident
563 fi
564 menu_list=$( echo "$menu_list" | sort )
565 size=$( eval f_dialog_menu_size \
566 \"\$DIALOG_TITLE\" \
567 \"\$DIALOG_BACKTITLE\" \
568 \"\$prompt\" \
569 \"\$hline\" \
570 $menu_list )
571 dialog_menu=$( eval $DIALOG \
572 --title \"\$DIALOG_TITLE\" \
573 --backtitle \"\$DIALOG_BACKTITLE\" \
574 --hline \"\$hline\" \
575 --ok-label \"\$msg_proceed\" \
576 --cancel-label \"\$msg_cancel\" \
577 --menu \"\$prompt\" $size \
578 $menu_list \
579 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
580 )
581 local retval=$?
582 setvar DIALOG_MENU_$$ "$dialog_menu"
583
584 #
585 # XXX
--- 174 unchanged lines hidden ---
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 250538 2013-05-12 00:46:18Z 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/strings.subr
--- 256 unchanged lines hidden (view full) ---
292 local prompt="$msg_please_select_a_category_to_display"
293 local hline=""
294
295 menu_list="
296 '> $msg_review' '$msg_review_desc' '$msg_review_help'
297 $category_list
298 " # End-Quote
299
300 local size dialog_menu
301 size=$( eval f_dialog_menu_with_help_size \
302 \"\$DIALOG_TITLE\" \
303 \"\$DIALOG_BACKTITLE\" \
304 \"\$prompt\" \
305 \"\$hline\" \
306 $menu_list )
307 dialog_menu=$( eval $DIALOG \
308 --title \"\$DIALOG_TITLE\" \
309 --backtitle \"\$DIALOG_BACKTITLE\" \
310 --hline \"\$hline\" \
311 --item-help \
312 --default-item \"\$defaultitem\" \
313 --ok-label \"$msg_select\" \
314 --cancel-label \"$msg_cancel\" \
315 --menu \"\$prompt\" $size \
316 $menu_list \
317 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
318 )
319 local retval=$?
320 setvar DIALOG_MENU_$$ "$dialog_menu"
321 return $retval
322}
323
--- 126 unchanged lines hidden (view full) ---
450 case "$category" in
451 "$msg_all"|"") f_category_desc_get "All" prompt ;;
452 *) f_category_desc_get "$category" prompt ;;
453 esac
454 prompt="$prompt $( printf "$msg_page_of_npages" \
455 "$page" "$npages" )"
456
457 local hline="$hline_arrows_tab_punc_enter"
458 local size isize dialog_menu item
459 size=$( eval f_dialog_menu${SHOW_DESC:+_with_help}_size \
460 \"\$DIALOG_TITLE\" \
461 \"\$DIALOG_BACKTITLE\" \
462 \"\$prompt\" \
463 \"\$hline\" \
464 $menu_list )
465 isize=$( f_dialog_infobox_size \
466 "$DIALOG_TITLE" \
467 "$DIALOG_BACKTITLE" \
468 "$msg_processing_selection" )
469 dialog_menu=$( eval $DIALOG \
470 --title \"\$DIALOG_TITLE\" \
471 --backtitle \"\$DIALOG_BACKTITLE\" \
472 --hline \"\$hline\" \
473 --keep-tite \
474 --ok-label \"$msg_select\" \
475 --cancel-label \"$msg_back\" \
476 ${SHOW_DESC:+--item-help} \
477 --default-item \"\$defaultitem\" \
478 --menu \"\$prompt\" $size \
479 $menu_list \
480 --and-widget \
481 ${USE_XDIALOG:+--no-buttons} \
482 --infobox \"\$msg_processing_selection\" $isize \
483 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
484 )
485 local retval=$?
486 setvar DIALOG_MENU_$$ "$dialog_menu"
487
488 if [ $retval -eq $SUCCESS ]; then
489 item=$( eval f_dialog_menutag2item${SHOW_DESC:+_with_help} \
490 \"\$dialog_menu\" $menu_list )
--- 8 unchanged lines hidden (view full) ---
499# Display a menu, asking the user what they would like to do with $package
500# with regard to "deselecting" an already installed package. Choices include
501# uninstall, re-install, or cancel (leave $package marked as installed).
502# Returns success if the user does not press ESC or choose Cnacel. Use the
503# f_dialog_menutag() function upon success to retrieve the user's choice.
504#
505f_package_menu_deselect()
506{
507 local package="$1" prompt menu_list size dialog_menu
508 prompt=$( printf "$msg_what_would_you_like_to_do_with" "$package" )
509 local hline="$hline_alnum_arrows_punc_tab_enter"
510 menu_list="
511 'X $msg_installed' '$msg_installed_desc'
512 'R $msg_reinstall' '$msg_reinstall_desc'
513 'U $msg_uninstall' '$msg_uninstall_desc'
514 " # End-Quote
515 size=$( eval f_dialog_menu_size \
516 \"\$DIALOG_TITLE\" \
517 \"\$DIALOG_BACKTITLE\" \
518 \"\$prompt\" \
519 \"\$hline\" \
520 $menu_list )
521 dialog_menu=$( eval $DIALOG \
522 --title \"\$DIALOG_TITLE\" \
523 --backtitle \"\$DIALOG_BACKTITLE\" \
524 --hline \"\$hline\" \
525 --ok-label \"$msg_select\" \
526 --cancel-label \"$msg_cancel\" \
527 --menu \"\$prompt\" $size \
528 $menu_list \
529 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
530 )
531 local retval=$?
532 setvar DIALOG_MENU_$$ "$dialog_menu"
533 return $retval
534}
535
536# f_package_review
537#
538# Display a review screen, showing selected packages and what they are marked
539# for, before proceeding (if the user does not press ESC or choose Cancel) to
540# operate on each selection. Returns error if no packages have been selected,
541# or the user has pressed ESC, or if they have chosen Cancel.
542#
543f_package_review()
544{
545 local prompt size dialog_menu package varpkg mark menu_list=
546 prompt=$( printf "$msg_reviewing_selected_packages" \
547 "$_All_nselected" )
548 local hline="$hline_alnum_arrows_punc_tab_enter"
549 f_dprintf "f_package_review: SELECTED_PACKAGES=[%s]" \
550 "$SELECTED_PACKAGES"
551 for package in $SELECTED_PACKAGES; do
552 mark=
553 f_str2varname "$package" varpkg
554 f_getvar _mark_$varpkg mark
555 [ "$mark" -a ! "${mark#[IRUD]}" ] || continue
556 menu_list="$menu_list
557 '$mark' '$package'
558 " # End-Quote
559 done
560 if [ ! "$menu_list" ]; then
561 f_show_msg "$msg_no_packages_were_selected_for_extraction"
562 return $FAILURE # They might have selected this by accident
563 fi
564 menu_list=$( echo "$menu_list" | sort )
565 size=$( eval f_dialog_menu_size \
566 \"\$DIALOG_TITLE\" \
567 \"\$DIALOG_BACKTITLE\" \
568 \"\$prompt\" \
569 \"\$hline\" \
570 $menu_list )
571 dialog_menu=$( eval $DIALOG \
572 --title \"\$DIALOG_TITLE\" \
573 --backtitle \"\$DIALOG_BACKTITLE\" \
574 --hline \"\$hline\" \
575 --ok-label \"\$msg_proceed\" \
576 --cancel-label \"\$msg_cancel\" \
577 --menu \"\$prompt\" $size \
578 $menu_list \
579 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
580 )
581 local retval=$?
582 setvar DIALOG_MENU_$$ "$dialog_menu"
583
584 #
585 # XXX
--- 174 unchanged lines hidden ---