PKGDB_PATH=${PKG_DBDIR:-/var/db/pkg}
+ # Miscellaneous
+
+ PAGER_PROGRAM=${PAGER:-less}
+
+
###############################################################################
_prog()
basename $0
}
- _date()
+ _plural()
{
- date '+%Y-%m-%d %H:%M:%S'
+ if [ $1 -ne 1 ]
+ then
+ echo 's'
+ fi
}
$P cvs Update ports tree using Csup
Run make fetchindex in $PORTS_PATH
Run portsdb -u
- Run $P listup
+ Run $P list
$P all Run $P cvs
Run $P
}
- do_listup()
+ do_list()
{
local NUM PORTVERSION_COMMAND
echo
echo "> $PORTVERSION_COMMAND"
- $PORTVERSION_COMMAND > "$STATUSFILE" || exit 1
+ $PORTVERSION_COMMAND | \
+ sed 's/<//; s/needs updating (port has //; s/) *$//' > \
+ "$STATUSFILE" || exit 1
echo
NUM=`wc -l "$STATUSFILE" | awk '{print $1}'`
echo '-----------------------------------'
- echo "Found $NUM outdated package(s)"
+ echo "Found $NUM outdated package`_plural $NUM`"
echo '-----------------------------------'
if [ "$NUM" -eq 0 -a "$1" = exit-if-none ]
then
- echo 'Exiting...'
exit 0
fi
echo
- do_listup
+ do_list
}
do_fixdb()
TYPE=name
STR="$1"
+
+ if [ ! "$STR" ]
+ then
+ error "error: empty search string"
+ fi
+
+
case "$1"
in
name|key)
echo "> cd $PORTS_PATH && make search $TYPE=$STR"
cd $PORTS_PATH && \
- ( make search "$TYPE"="$STR" | less )
+ ( make search "$TYPE"="$STR" | $PAGER_PROGRAM )
exit 0
}
do
if [ ! "$name" = pkgdb.db -a ! -f "$name/+REQUIRED_BY" ]
then
- DIALOG_PKGLIST="$DIALOG_PKGLIST '$name' 'no +REQUIRED_BY' OFF"
+ DIALOG_OPTIONS="$DIALOG_OPTIONS '$name' 'no +REQUIRED_BY' OFF"
NUM=$(($NUM + 1))
fi
done
- eval "dialog --title '`_prog` - chkreq - `_date`' --checklist '\n$NUM not required package(s):\n' -1 -1 $DIALOG_LIST_HEIGHT $DIALOG_PKGLIST 2> '$tmpfile'"
+ eval "dialog --title '`_prog`: chkreq' \
+ --checklist '\n$NUM not required package`_plural $NUM`\n' \
+ -1 -1 $DIALOG_LIST_HEIGHT \
+ $DIALOG_OPTIONS \
+ 2> '$tmpfile'"
PACKAGES=`cat "$tmpfile"`
do_checkbinaries()
{
- for binary in portupgrade portversion dialog csup portsdb pkgdb portaudit
+ for binary in portupgrade portversion dialog \
+ csup portsdb pkgdb portaudit $PAGER_PROGRAM
do
which "$binary" > /dev/null
case "$1"
in
listup|list)
- do_listup
+ do_list
exit 0
;;
cvsup|cvs|csup)
do_csup
;;
listup+run|list+run)
- do_listup
+ do_list
;;
chkbin)
do_checkbinaries
if [ ! -s "$STATUSFILE" ]
then
- do_listup exit-if-none
+ do_list exit-if-none
fi
- TMPLISTFILE=`make_tmp`
TMPOPTIONSFILE=`make_tmp`
- case "$WITH_HELD_PKGS"
- in
- [Yy][Ee][Ss])
- sed 's/<//' < "$STATUSFILE" > "$TMPLISTFILE"
- ;;
- *)
- sed 's/<//' < "$STATUSFILE" | grep -v '\[held\]' > "$TMPLISTFILE"
- ;;
- esac
-
-
NUM=0
while read name comments
do
- DIALOG_OPTIONS="$DIALOG_OPTIONS '$name' '$comments' OFF"
+ DIALOG_OPTIONS="$DIALOG_OPTIONS '$name' '< $comments' OFF"
NUM=$(($NUM + 1))
done < \
- "$TMPLISTFILE"
+ "$STATUSFILE"
- rm -f "$TMPLISTFILE"
-
if [ ! "$DIALOG_OPTIONS" ]
then
error 'Error: $DIALOG_OPTIONS is empty'
fi
- eval "dialog --title '`_prog` - `_date`' --checklist '\n$NUM outdated package(s):\n' -1 -1 $DIALOG_LIST_HEIGHT $DIALOG_OPTIONS 2> '$TMPOPTIONSFILE'"
+ eval "dialog --title '`_prog`: list' \
+ --checklist '\nFound $NUM outdated package`_plural $NUM`\n' \
+ -1 -1 $DIALOG_LIST_HEIGHT \
+ $DIALOG_OPTIONS \
+ 2> '$TMPOPTIONSFILE'"
- PACKAGES=`cat "$TMPOPTIONSFILE" | sed 's/"//g'`
+ PACKAGES=`sed 's/"//g' < "$TMPOPTIONSFILE"`
rm -f "$TMPOPTIONSFILE"
if [ "$PACKAGES" ]
then
- echo
- echo 'Upgrading packages:'
-
NUM=0
+
for package in $PACKAGES
do
- echo "- $package"
+ UPGRADE_DIALOG="$UPGRADE_DIALOG '$package' ' '"
+
NUM=$(($NUM + 1))
done
- echo
- read -p "Upgrade $NUM package(s) [Y/n]? " -r CONFIRM
+ eval "dialog --title '`_prog`: upgrade' \
+ --menu '\nUpgrade $NUM package`_plural $NUM`?\n' \
+ -1 -1 $DIALOG_LIST_HEIGHT \
+ $UPGRADE_DIALOG \
+ 2> /dev/null"
- case "$CONFIRM"
+
+ case $?
in
- [Yy])
+ 0)
+ echo
do_padb
case "$LISTUP_AFTER_UPGRADE"
in
[Yy][Ee][Ss])
- do_listup
+ echo
+ do_list
;;
esac
fi
;;
*)
echo
- echo 'None of packages upgraded'
+ echo 'Upgrade cancelled'
echo
exit 0
else
echo
- echo 'Nothing to upgrade. exiting...'
+ echo 'No packages selected'
echo
exit 0