Renamed/revised remove_obsolete_packages() and added -O option

This revision converts remove_obsolete_packages() to
remove_uninstalled_packages() to better reflect what it currently
actually does and makes other minor revisions related to it. It also
adds a command line option (-O) to access this function. It's still
mnemonic with 'obsolete' because we're running out of option letters and
the function may yet be modified to remove obsolete sources.
This commit is contained in:
slakmagik 2010-05-20 21:22:23 +00:00
parent 0b89dd392f
commit ff5d028f1f
4 changed files with 41 additions and 14 deletions

View file

@ -24,4 +24,7 @@ enhancements:
evals and conditionals in check_for_updates and info_item.
* Fixed a bug which could result in some sources being missed when checking
for obsolete sources.
* Added a command line option '-O' to access the 'remove uninstalled
packages' function which had previously only been accessible from the
dialog interface.
+--------------------------+

View file

@ -27,3 +27,14 @@ tools it uses:
the .info file, and warns the user about it.
Workaround: none needed
* while you are free to set PAGER to any value you like, be aware that some
pagers and settings may cause unexpected behavior. An example is if paging
less than a screenful of output from the obsolete packages option - the
default pager 'more' will exit, displaying the packages and a prompt. 'less'
may prompt for exit and clear its output on exit. Setting the environment
variable LESS to include the F and X options will make less behave more like
more in this instance. Other pagers may have other behaviors and other means
of configuration.
Workaround: pager-specific

View file

@ -180,6 +180,11 @@ versions of installed packages.
.B -l
Display the SBo ChangeLog.txt and quit.
.TP 5
.B -O
List the cached package files which are not currently installed on the
system and optionally delete them.
.TP 5
.B -o
List the currently installed cached source files which are deemed as

View file

@ -3003,10 +3003,10 @@ remove_obsolete_sources() {
remove_files $SRCDIR "obsolete sources" $SOURCES ON
}
remove_obsolete_packages() {
# Remove obsolete packages from $OUTPUT
remove_uninstalled_packages() {
# Remove uninstalled packages from $OUTPUT
local PACKAGES=$SBOPKGTMP/sbopkg_obsolete_packages
local PACKAGES=$SBOPKGTMP/sbopkg_uninstalled_packages
local PKG
rm -f $PACKAGES
@ -3017,7 +3017,7 @@ remove_obsolete_packages() {
fi
done
remove_files $OUTPUT "obsolete packages" $PACKAGES ON
remove_files $OUTPUT "uninstalled packages" $PACKAGES ON
}
reverse_choices() {
@ -3097,10 +3097,8 @@ remove_files() {
cat - $FILES_DELETING | $PAGER
while :; do
echo
echo "Do you want to delete these files?"
echo "Press (Y)es to delete or (N)o to keep them."
read ANS
case $ANS in
read -n1 -ep "Do you want to delete these files? [y/n] "
case $REPLY in
n* | N* ) break ;;
y* | Y* ) DELETE=1; break ;;
* ) echo "Unknown response." ;;
@ -3115,9 +3113,9 @@ remove_files() {
if [[ $DIAG ]]; then
dialog --title "Done" --msgbox \
"$(crunch "The selected $TOPIC have been \
cleared.")" 8 30
deleted.")" 7 35
else
echo "$(crunch "The $TOPIC have been cleared.")"
echo "$(crunch "The $TOPIC have been deleted.")"
fi
fi
else
@ -4096,7 +4094,7 @@ utilities_menu() {
"Log" "View the permanent build log" \
"Repository" "Select repository [ $REPO_BRANCH ($REPO_NAME) ]" \
"Latest" "Check for an update to sbopkg" \
"Obsolete packages" "View obsolete packages" \
"Uninstalled packages" "View uninstalled packages" \
"Obsolete sources" "View obsolete cached sources" 2> $ANSWERFILE
DEFAULTITEM=$(< $ANSWERFILE)
@ -4106,7 +4104,7 @@ utilities_menu() {
"Log" ) view_perm_log ;;
"Repository" ) select_repository ;;
"Latest" ) check_for_latest ;;
"Obsolete packages" ) remove_obsolete_packages ;;
"Uninstalled packages" ) remove_uninstalled_packages ;;
"Obsolete sources" ) remove_obsolete_sources ;;
*) break ;;
esac
@ -4374,6 +4372,7 @@ unset BUILDLIST # List of packages to build/install (from CLI)
unset BUILD BFLAG IFLAG CHK_UPDATES GENSEARCH CHANGELOG OBSOLETESRC GETPKGS
unset RSYNC SEARCH UPDATE VERSION CUSTOMVER SKIP_INSTALLED PREVIEW_READMES
unset UNINSTPKG
SCRIPT=${0##*/}
SBOPKG_CONF=${SBOPKG_CONF:-/etc/sbopkg/sbopkg.conf}
@ -4415,7 +4414,7 @@ else
fi
# This is the command line options and help.
while getopts ":b:cd:e:f:g:hi:klopqrRs:uV:v" OPT; do
while getopts ":b:cd:e:f:g:hi:klOopqrRs:uV:v" OPT; do
case $OPT in
b ) # Build
BFLAG=1
@ -4455,6 +4454,10 @@ while getopts ":b:cd:e:f:g:hi:klopqrRs:uV:v" OPT; do
CHANGELOG=1
unset DIAG
;;
O ) # Show uninstalled packages
UNINSTPKG=1
unset DIAG
;;
o ) # Show obsolete sources
OBSOLETESRC=1
unset DIAG
@ -4508,7 +4511,8 @@ Options are:
-i pkg/queue(s) Like '-b', but also install built packages.
-k Skip installed packages when building.
-l Display the repo's ChangeLog.txt and then quit.
-o Display the obsolete source files and prompt for deletion.
-O Display the uninstalled package files & prompt for deletion.
-o Display the obsolete source files & prompt for deletion.
-p List installed repo's packages.
-q Quiet some of the command-line output.
-r Sync the remote repository with the local mirror and then
@ -4716,6 +4720,10 @@ else
show_changelog
fi
if [[ $UNINSTPKG ]]; then
remove_uninstalled_packages
fi
if [[ $OBSOLETESRC ]]; then
remove_obsolete_sources
fi