create nvabt2n(); revise list_packages()

PKG_LIST is now no longer used directly but makes for easier
manipulation into both PKG_CHECKLIST for the dialog menu and README_LIST
(created via nvabt2n()) as input for view_readmes(). Added the extra
button that calls view_readmes() with README_LIST.

While I was here, changed the package removal confirmation dialog to use
'--separate-output' and dumped the tr that was removing the quotes
dialog otherwise puts in.
This commit is contained in:
slakmagik 2011-03-07 01:26:27 +00:00
parent 31b07d91cc
commit c3eb9de996

View File

@ -421,10 +421,27 @@ EOF
fi
}
nvabt2n() {
# Converts a list of name-version-arch-build-tags to plain names - takes 2
# args of the input file and the output file.
local INPUT=$1
local OUTPUT=$2
local LINE PKG_NAME PKG_VER PKG_ARCH PKG_BUILD PKG_TAG
>$OUTPUT
while read LINE; do
split_pkg_name $LINE
echo $PKG_NAME >> $OUTPUT
done < $INPUT
}
list_packages() {
# Get a list of SBo packages.
local PKG_LIST=$SBOPKGTMP/sbopkg_pkg_list
local PKG_CHECKLIST=$SBOPKGTMP/sbopkg_pkg_checklist
local README_LIST=$SBOPKGTMP/sbopkg_readme_list
local REMOVE_LIST=$SBOPKGTMP/sbopkg_remove_list
local CONFIRM_LIST=$SBOPKGTMP/sbopkg_confirm_list
@ -433,20 +450,30 @@ list_packages() {
-printf "%P\n" 2> /dev/null | sort > $PKG_LIST
if [[ -s $PKG_LIST ]]; then
if [[ $DIAG ]]; then
sed -i 's/$/ "" OFF/' $PKG_LIST
dialog --separate-output --title "Installed $REPO_NAME Packages" --checklist \
"Check any packages you wish to uninstall" 20 65 13 \
--file $PKG_LIST 2> $REMOVE_LIST
if [[ -s $REMOVE_LIST ]]; then
sed 's/$/ "" ON/' $REMOVE_LIST > $CONFIRM_LIST
dialog --defaultno --title "Removepkg confirmation" \
--checklist "Remove the following packages?" 20 65 13 \
--file $CONFIRM_LIST 2> $REMOVE_LIST
if [[ $? == 0 ]]; then
removepkg $(tr -d \" < $REMOVE_LIST)
read -n1 -ep "Press any key to continue: "
fi
fi
sed 's/$/ "" OFF/' $PKG_LIST > $PKG_CHECKLIST
dialog --separate-output --title "Installed $REPO_NAME Packages" \
--extra-button --extra-label "View READMEs" \
--checklist "Check any packages you wish to uninstall" \
20 65 13 --file $PKG_CHECKLIST 2> $REMOVE_LIST
case $? in
0)
if [[ -s $REMOVE_LIST ]]; then
sed 's/$/ "" ON/' $REMOVE_LIST > $CONFIRM_LIST
dialog --separate-output --defaultno \
--title "Removepkg confirmation" \
--checklist "Remove the following packages?" 20 65 13 \
--file $CONFIRM_LIST 2> $REMOVE_LIST
if [[ $? == 0 ]]; then
removepkg $(cat $REMOVE_LIST)
read -n1 -ep "Press any key to continue: "
fi
fi
;;
3)
nvabt2n $PKG_LIST $README_LIST
view_readmes "Installed packages:" $README_LIST
;;
esac
else
$PAGER $PKG_LIST
fi