summaryrefslogtreecommitdiff
path: root/src/core/libs
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2010-12-17 15:57:51 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2010-12-17 15:57:51 +0100
commit397ffbe6a738e0f5a242ebecca6b2615d86f202e (patch)
tree492f1e9127271e186672d10b111dc53d8303ed5f /src/core/libs
parent27d2bfc7c8aa3eb187df5a7ac20236eac8e30952 (diff)
cleanup interactive_select_packages()
Diffstat (limited to 'src/core/libs')
-rw-r--r--src/core/libs/lib-ui-interactive.sh56
1 files changed, 25 insertions, 31 deletions
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index f199b5a..a590d3d 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -725,41 +725,35 @@ interactive_select_packages() {
Note that right now the packages (and groups) selection is limited to the repos available at this time ($repos). Once you have your Arch system up and running, you have access to more repositories and packages.\n\n
If any previous configuration you've done until now (like fancy filesystems) require extra packages, we've already preselected them for your convenience"
- # show group listing for group selection, base is ON by default, all others are OFF
- local _grouplist="base ^ ON"
- for i in $(list_package_groups | sed "s/^base$/ /g"); do
- _grouplist="${_grouplist} ${i} - OFF"
- done
+ # show group listing for group selection, base is ON by default, all others are OFF
+ local grouplist=(base ^ ON)
+ for i in $(list_package_groups | grep -v '^base$'); do
+ grouplist+=(${i} - OFF)
+ done
- ask_checklist "Select Package groups\nDO NOT deselect BASE unless you know what you're doing!" $_grouplist || return 1
- _grouplist=("${ANSWER_CHECKLIST[@]}") # _grouplist is now an array containing all selected groups
-
- # assemble a list of packages with groups, marking pre-selected ones
- # <package> <group> <selected>
- local _pkgtmp="$(list_packages repo core | awk '{print $2}')" # all packages in core repository. TODO: we should use $repos here
- local _pkglist=''
-
- which_group "$_pkgtmp"
- # assemble some packages which we'll definitely select by default because we figured out we'll need them:
- needed_pkgs=("${needed_pkgs_fs[@]}")
- while read pkgname pkggroup; do
- # check if this package is in a selected group
- # slightly ugly but sorting later requires newlines in the variable
- if check_is_in "$pkggroup" "${_grouplist[@]}" || check_is_in $pkgname "${needed_pkgs[@]}"
- then
- _pkglist="$(echo -e "${_pkglist}\n${pkgname} ${pkggroup} ON")"
- else
- _pkglist="$(echo -e "${_pkglist}\n${pkgname} ${pkggroup} OFF")"
- fi
- done <<< "$PACKAGE_GROUPS"
+ ask_checklist "Select Package groups\nDo not deselect base unless you know what you're doing!" "${grouplist[@]}" || return 1
+ grouplist=("${ANSWER_CHECKLIST[@]}")
- # sort by group
- _pkglist="$(echo "$_pkglist" | sort -f -k 2)"
- [ -z "$_pkglist" ] && show_warning "No packages found" "Sorry. I could not find any packages. maybe your network is not setup correctly, you lost connection, no mirror setup, bad group, ..." && return 1
+ # get sorted array of available packages, with their groups. TODO: we should use $repos here
+ local pkgall=($(list_packages repo core | cut -d ' ' -f2))
+ which_group "${pkgall[@]}"
- ask_checklist "Select Packages To Install." $_pkglist || return 1
+ # build the list of options, sorted primarily by group, then by packagename (this is already). marking where appropriate
+ local pkglist=()
+ needed_pkgs=("${needed_pkgs_fs[@]}")
+ while read pkgname pkggroup; do
+ mark=OFF
+ if check_is_in "$pkggroup" "${grouplist[@]}" || check_is_in $pkgname "${needed_pkgs[@]}"; then
+ mark=ON
+ fi
+ pkglist+=("$pkgname" "$pkggroup" $mark)
+ done < <(echo "$PACKAGE_GROUPS" | sort -f -k 2)
+
+ [ ${#pkglist[@]} -eq 0 ] && show_warning "No packages found" "Sorry. I could not find any packages. maybe your network is not setup correctly, you lost connection, no mirror setup, bad group, ..." && return 1
+
+ ask_checklist "Select Packages To Install." "${pkglist[@]}" || return 1
var_TARGET_PACKAGES="${ANSWER_CHECKLIST[@]}"
- return 0
+ return 0
}