#!/bin/sh
-
###############################################################################
+ #
+ # Package Frontend.
+ #
+ # By: Sulev-Madis Silber <madis555 at hot dot ee>
+ #
+ #
+ ###############################################################################
# Configuration file
#
plural()
{
- if [ "$1" -a "$1" -ne 1 ]
+ if [ ! "$1" ]
then
+ ierror 'plural: invalid parameters'
+ fi
+
+
+ if [ "$1" -ne 1 ]
+ then
echo s
fi
}
#
- # Removes file
+ # Removes "'" from a stream.
#
+ makesafe()
+ {
+ tr -d "'"
+ }
+
+
+ #
+ # Removes file.
+ #
unlink_file()
{
- if [ "$1" -a -f "$1" ]
+ if [ ! "$1" ]
then
+ ierror 'unlink_file: invalid parameters'
+ fi
+
+
+ if [ -f "$1" ]
+ then
rm -f "$1"
fi
}
#
error()
{
- if [ "$1" ]
+ if [ ! "$1" ]
then
- echo "`prog`: $1"
-
- cleanexit 1
+ ierror 'error: invalid parameters'
fi
+
+
+ echo "`prog`: $1" >&2
+
+ cleanexit 1
}
#
+ # Prints internal error and exits.
+ #
+ ierror()
+ {
+ if [ ! "$1" ]
+ then
+ ierror 'ierror: invalid parameters'
+ fi
+
+
+ echo "`prog`: internal error: $1" >&2
+
+ cleanexit 1
+ }
+
+
+ #
# Prints error.
#
notice()
{
- if [ "$1" ]
+ if [ ! "$1" ]
then
- echo "`prog`: $1"
+ ierror 'notice: invalid parameters'
fi
+
+
+ echo "`prog`: $1" >&2
}
#
+ # Prints usage and exits.
+ #
+ usage()
+ {
+ if [ ! "$1" ]
+ then
+ ierror 'usage: invalid parameters'
+ fi
+
+
+ echo "usage: `prog` $1" >&2
+
+ cleanexit 1
+ }
+
+
+ #
# Does clean exit.
#
cleanexit()
{
- unlink_file "$LOCKFILE"
+ del_tempfile
+ unlink_file "$lock_file"
exit ${1:-0}
}
#
exitcode()
{
- if [ $# -ne 2 ]
+ if [ ! "$1" -o ! "$2" ]
then
- return 1
+ ierror 'exitcode: invalid parameters'
fi
echo
error "command '$1' failed with exit code $2"
+ echo
}
{
if [ ! "$1" ]
then
- return 1
+ ierror 'showcmd: invalid parameters'
fi
{
if [ ! "$1" ]
then
- return 1
+ ierror 'checkyesno: invalid parameters'
fi
#
- # Creates temporary files.
+ # Creates temporary file.
#
- make_temp()
+ make_tempfile()
{
- if [ ! "$TEMP_PREFIX" ]
+ touch "$temp_file"
+
+ if cmd_failed $?
then
- error 'internal error: $TEMP_PREFIX is empty'
+ error "cannot create temp file '$temp_file'"
fi
-
-
- mktemp "$TEMP_PREFIX.XXX" || error 'mktemp error'
}
#
+ # Deletes temporary file.
+ #
+ del_tempfile()
+ {
+ unlink_file "$temp_file"
+ }
+
+
+ #
# Shows menu or checklist using dialog(1).
#
show_dialog()
{
if [ $# -ne 3 -a $# -ne 4 ]
then
- return 1
+ ierror 'show_dialog: invalid parameters'
fi
- local name text options type options_tempfile exitcode selected_options
+ local name text options type stderr_file exitcode selected_options
name=$1
options=$3
type=checklist
+ stderr_file="$temp_file"
case $4
in
''|checklist)
- options_tempfile=`make_temp`
+ make_tempfile
;;
menu)
type=$4
+
+ stderr_file=/dev/null
;;
*)
- unset name text options type options_tempfile exitcode selected_options
-
- return 1
+ ierror 'show_dialog: invalid type'
;;
esac
- if [ ! "$options" ]
+ if [ ! "$name" ]
then
- error 'internal error: $options is empty'
+ ierror 'show_dialog: name is empty'
+
+ elif [ ! "$text" ]
+ then
+ ierror 'show_dialog: text is empty'
+
+ elif [ ! "$options" ]
+ then
+ ierror 'show_dialog: options is empty'
fi
- eval "dialog --title '`prog`: $name' \
- --$type '\n$text\n' \
- -1 -1 $dialog_list_rows \
- $options \
- 2> '${options_tempfile:-/dev/null}'"
+ eval "dialog --title '`prog`: $name'"\
+ "--$type '\n$text\n'"\
+ "-1 -1 $dialog_list_rows"\
+ "$options"\
+ "2> '$stderr_file'"
exitcode=$?
eval selopt_${name}_exitcode=\$exitcode
- unset text options exitcode
+ unset text options stderr_file exitcode
if [ "$type" = checklist ]
then
- selected_options=`sed 's|"||g' < "$options_tempfile"`
+ selected_options=`sed 's|"||g' < "$temp_file"`
- unlink_file "$options_tempfile"
+ del_tempfile
- unset options_tempfile
-
eval selopt_${name}_values="\$selected_options"
unset selected_options
#
show_confirm()
{
- if [ $# -ne 2 -a "$1" -a "$2" ]
+ if [ ! "$1" -o ! "$2" ]
then
- return 1
+ ierror 'show_confirm: invalid parameters'
fi
- local type package packages count dialog_options confirm_message cancel_message
+ local type package comment packages count dialog_options confirm_message cancel_message
type=$1
do
count=$(($count + 1))
- dialog_options="$dialog_options '$package' ' '"
+
+ comment=' '
+
+ if [ "$type" = upgrade ]
+ then
+ if checkyesno upgrade_show_new_version
+ then
+ comment=`grep "$package" "$status_file" | awk '{print $2}'`
+ fi
+ fi
+
+ dialog_options="$dialog_options '$package' '$comment'"
done
- unset package packages
+ unset package comment packages
case $type
;;
*)
- error "show_confirm: internal error: invalid type '$type'"
+ ierror 'show_confirm: invalid type'
;;
esac
#
+ # Shows packages before executing
+ # install, upgrade or deinstall.
+ #
+ show_packages()
+ {
+ if [ ! "$1" -o ! "$2" ]
+ then
+ ierror 'show_packages: invalid parameters'
+ fi
+
+
+ local package
+
+
+ echo
+ echo "$1:"
+ echo
+
+ shift
+
+
+ for package in $*
+ do
+ echo "$package"
+ done
+
+
+ echo
+
+ unset package
+ }
+
+
+ #
# Shows package deinstall dialog.
#
package_deinstall()
show_confirm deinstall "$packages"
- command="pkg_deinstall $packages"
+ command="${root_command_prefix}pkg_deinstall $packages"
- unset packages
-
if ! checkyesno enable_real_deinstall
then
cat <<- EOF
fi
+ show_packages Deinstalling $packages
+
+ unset packages
+
+
showcmd "$command"
$command
#
do_help()
{
- grep -A100 '^#__HELP__$' "$0" | \
- sed "s|^#||; s|^__HELP__||; s|%P%|`prog`|g; s|%PORTS_PATH%|$PORTS_PATH|g; s|%PKGDB_PATH%|$PKGDB_PATH|g"
+ cat <<- EOF
+ Help of `prog` is now moved to man page,
+ see pkgfe(8)
+
+ EOF
+
cleanexit
}
#
do_list()
{
- local tempfile command exitcode count
+ local command exitcode count
- tempfile=`make_temp`
+ make_tempfile
- command='portversion -vl <'
+ command="${root_command_prefix}portversion -vl <"
showcmd "$command"
- $command > "$tempfile"
+ $command > "$temp_file"
exitcode=$?
if cmd_failed $exitcode
then
- unlink_file "$tempfile"
+ del_tempfile
exitcode "$command" $exitcode
fi
sed 's|<||; s|needs updating (port has ||; s|) *$||; s|) (| |' \
- < "$tempfile" \
- > "$status_file"
+ < "$temp_file" | \
+ makesafe > "$status_file"
- unlink_file "$tempfile"
+ del_tempfile
if ! checkyesno ignore_held
then
- tempfile=`make_temp`
+ make_tempfile
- cat "$status_file" > "$tempfile"
+ cat "$status_file" > "$temp_file"
- grep -v '\[held\]' < "$tempfile" > "$status_file"
+ grep -v '\[held\]' < "$temp_file" > "$status_file"
- unlink_file "$tempfile"
+ del_tempfile
fi
- unset tempfile
-
count=`wc -l "$status_file" | awk '{print $1}'`
echo
echo '-----------------------------------'
echo "Found $count outdated package`plural $count`"
echo '-----------------------------------'
+ echo
if [ "$count" -eq 0 -a "$1" = exit-if-none ]
fi
unset count
-
-
- echo
}
local command exitcode
- check_supfile "$csup_supfile"
+ check_supfile
- command="csup $csup_args $csup_supfile"
+ command="${root_command_prefix}csup $csup_args $csup_supfile"
showcmd "$command"
fi
- command='portsdb -Fu'
+ command="${root_command_prefix}portsdb -Fu"
echo
showcmd "$command"
local command exitcode
- command='portsnap fetch'
+ command="${root_command_prefix}portsnap fetch"
+ if ! checkyesno old_portsnap
+ then
+ command="$command update"
+ fi
+
showcmd "$command"
$command
fi
- command='portsnap update'
-
- echo
- showcmd "$command"
-
- $command
-
-
- exitcode=$?
-
- if cmd_failed $exitcode
+ if checkyesno old_portsnap
then
- exitcode "$command" $exitcode
+ command="${root_command_prefix}portsnap update"
+
+ echo
+ showcmd "$command"
+
+ $command
+
+
+ exitcode=$?
+
+ if cmd_failed $exitcode
+ then
+ exitcode "$command" $exitcode
+ fi
fi
- command='portsdb -u'
+ command="${root_command_prefix}portsdb -u"
echo
showcmd "$command"
local command exitcode
- command='pkgdb -F'
+ command="${root_command_prefix}pkgdb -F"
showcmd "$command"
case $search_string
in
name|key)
- if [ ! "$2" ]
- then
- error 'usage: name|key searchstring'
- fi
-
-
search_string=$2
type=$1
if [ ! "$search_string" ]
then
- error 'empty search string'
+ usage 'find [name|key] [regex]'
fi
cd "$PORTS_PATH" || cleanexit 1
- make search "$type=$search_string" | "$PAGER_PROGRAM"
+ make_tempfile
+
+ make search "$type=$search_string" > "$temp_file"
+
+
+ if [ ! -s "$temp_file" ]
+ then
+ del_tempfile
+
+ echo
+ error "no matches for '$search_string'"
+ fi
+
unset search_string type
+ clear
+
+ "$PAGER_PROGRAM" "$temp_file"
+
+ del_tempfile
+
+
cleanexit
}
#
# Command:
+ # does "make config" in port's directory.
+ #
+ do_config()
+ {
+ local portpath
+
+
+ portname=$1
+
+
+ if [ ! "$portname" ]
+ then
+ usage 'c [port]'
+ fi
+
+
+ portpath=`whereis -sB "$PORTS_PATH" -f "$portname" | cut -d ' ' -f 2`
+
+
+ if [ ! -d "$portpath" ]
+ then
+ error "port '$portname' not found"
+ fi
+
+
+ showcmd "cd $portpath && make config"
+
+ cd "$portpath" || cleanexit 1
+
+ ${root_command_prefix}make config
+
+ unset portpath
+
+
+ cleanexit
+ }
+
+
+ #
+ # Command:
# does search in ports tree
# and shows install dialog.
#
do_find_install()
{
- local tempfile search_string index_file name comments count dialog_options
+ local search_string index_file name comments count dialog_options
search_string=$1
+ index_file="$PORTS_PATH/INDEX-`uname -r | cut -d . -f 1`"
- if [ -f "$PORTS_PATH/INDEX-6" ]
+
+ if [ ! -f "$index_file" ]
then
- index_file="$PORTS_PATH/INDEX-6"
-
- elif [ -f "$PORTS_PATH/INDEX" ]
- then
- index_file="$PORTS_PATH/INDEX"
-
- else
- error 'no valid INDEX found'
+ if [ -f "$PORTS_PATH/INDEX" ]
+ then
+ index_file="$PORTS_PATH/INDEX"
+ else
+ error "no valid INDEX file found under '$PORTS_PATH'"
+ fi
fi
if [ ! "$search_string" ]
then
- error 'search regex is required'
+ usage 'findi [regex]'
fi
- tempfile=`make_temp`
+ make_tempfile
- grep -iE "$search_string" "$index_file" | cut -d '|' -f 1,4 | tr '|' ' ' > "$tempfile"
+ cut -d '|' -f 1,4 "$index_file" | makesafe | grep -iE -- "$search_string" | \
+ awk -F '|' '{print $1" "(length($2) > '$findi_description_length' ? substr($2, 0, '$findi_description_length')"..." : $2)}' \
+ > "$temp_file"
+
unset index_file
- if [ ! -s "$tempfile" ]
+ if [ ! -s "$temp_file" ]
then
- unlink_file "$tempfile"
+ del_tempfile
error "no packages matching '$search_string' found"
fi
unset search_string
+ count=`wc -l "$temp_file" | awk '{print $1}'`
+
+ echo
+ echo "$count result`plural $count` found. Generating dialog..."
+ echo
+
+
while read name comments
do
- count=$(($count + 1))
-
- dialog_options="$dialog_options '$name' '`echo "$comments" | awk '{print substr($0, 0, 26)}'`...' OFF"
+ dialog_options="$dialog_options '$name' '$comments' OFF"
done \
- < "$tempfile"
+ < "$temp_file"
- unlink_file "$tempfile"
+ del_tempfile
- unset name comments tempfile
+ unset name comments
- show_dialog find "Found $count package`plural $count`.\nSelect one`plural $count` you want to install" "$dialog_options" checklist
+ show_dialog find "Found $count package`plural $count`.\nSelect one`plural $count` you want to install" "$dialog_options"
unset count dialog_options
if [ ! "$search_string" ]
then
- error 'search regex is required'
+ usage 'ls [regex]'
fi
ls -1 "$PKGDB_PATH" | \
- grep -v ^pkgdb\. | \
- grep -iE "$search_string"
+ grep -v '^pkgdb\.' | \
+ grep -iE -- "$search_string"
if cmd_failed $?
cd "$PKGDB_PATH" || cleanexit 1
- for name in *
+ for name in `ls -1 | grep -v '^pkgdb\.' | makesafe`
do
- if [ ! $name = pkgdb.db -a ! -f $name/+REQUIRED_BY ]
+ count=$(($count + 1))
+
+
+ if [ ! -f $name/+REQUIRED_BY ]
then
- count=$(($count + 1))
-
dialog_options="$dialog_options '$name' 'no +REQUIRED_BY' OFF"
+
+ elif [ ! -s $name/+REQUIRED_BY ]
+ then
+ dialog_options="$dialog_options '$name' 'empty +REQUIRED_BY' OFF"
fi
done
cd "$PKGDB_PATH" || cleanexit 1
- for name in *
+ for name in `ls -1 | grep -v '^pkgdb\.' | makesafe`
do
- if [ ! $name = pkgdb.db ]
+ count=$(($count + 1))
+
+ if [ -f $name/+REQUIRED_BY ]
then
- count=$(($count + 1))
-
+ dialog_options="$dialog_options '$name' 'Required by others' OFF"
+ else
dialog_options="$dialog_options '$name' ' ' OFF"
fi
done
local command exitcode
- command="portaudit -Fd"
+ command="${root_command_prefix}portaudit -Fd"
showcmd "$command"
#
# Command:
+ # shows upgrade dialog.
+ #
+ do_upgrade()
+ {
+ local name comments count dialog_options
+
+
+ if [ ! -s "$status_file" ]
+ then
+ do_list exit-if-none
+ fi
+
+
+ count=`wc -l "$status_file" | awk '{print $1}'`
+
+
+ while read name comments
+ do
+ dialog_options="$dialog_options '$name' '< $comments' OFF"
+ done \
+ < "$status_file"
+
+ unset name comments
+
+
+ show_dialog list "Found $count outdated package`plural $count`\nSelect one`plural $count` you want to upgrade" "$dialog_options"
+
+ unset count dialog_options
+
+
+ if [ ! "$selopt_list_values" ]
+ then
+ echo
+ echo 'No packages selected for upgrade'
+ echo
+
+ cleanexit
+ fi
+
+
+ show_confirm upgrade "$selopt_list_values"
+
+
+ do_portinstall_portupgrade portupgrade $selopt_list_values
+ }
+
+
+ #
+ # Command:
# runs portinstall(1) or portupgrade(1) with
# verbose mode and additional arguments.
#
do_portinstall_portupgrade()
{
- local program command exitcode
+ local program message command exitcode
program=$1
case $program
in
- portinstall|portupgrade)
+ portinstall)
+ message=Installing
;;
+
+ portupgrade)
+ message=Upgrading
+ ;;
+
*)
- error "do_portinstall_portupgrade: internal error: invalid program '$program'"
+ ierror 'do_portinstall_portupgrade: invalid program'
;;
esac
+ if [ ! "$*" ]
+ then
+ ierror 'do_portinstall_portupgrade: arguments cannot be empty'
+ fi
+
+
+ show_packages $message $*
+
+
if checkyesno update_portaudit_db
then
- echo
do_padb
fi
- command="$program -v $portupgrade_args $*"
+ command="$root_command_prefix$program $portupgrade_args $*"
showcmd "$command"
unset program command exitcode
- echo
-
cleanexit
}
exitcode=0
- echo 'Checking for existence of required programs...'
+ echo 'Checking for existence of binaries we need...'
echo
- for binary in portupgrade portversion \
- dialog csup portsdb pkgdb portaudit \
- pkg_deinstall $PAGER_PROGRAM \
- sed grep cat touch id uname cut portsnap
+ for binary in portupgrade portinstall portversion \
+ dialog csup portsdb pkgdb portaudit pkg_deinstall \
+ "$PAGER_PROGRAM" sed grep cat touch id uname cut \
+ portsnap awk wc whereis
do
+
which "$binary" > /dev/null
+
if cmd_failed $?
then
notice "$binary: program not found"
#
- # Checks configuration file.
+ # Command:
+ # shows configuration.
#
- check_configfile()
+ do_showconfig()
{
- if [ ! -f "$1" ]
+ local default
+
+
+ if [ ! -f "$CONFIG_FILE" ]
then
- error "$1: configuration file not found"
+ notice "configuration file '$CONFIG_FILE' is not found"
- elif [ ! -r "$1" ]
+ default=1
+
+ elif [ ! "$root_command_prefix" -a ! -r "$CONFIG_FILE" ]
then
- error "$1: configuration file not readable"
+ notice "configuration file '$CONFIG_FILE' is not readable"
+
+ default=1
fi
+
+
+ echo
+
+ if [ "$default" ]
+ then
+ echo 'using default configuration:'
+ else
+ echo "$CONFIG_FILE:"
+ fi
+
+ unset default
+
+
+ cat <<- EOF
+ ---------------------------------------------------------------------
+
+ portupgrade_logdir="$portupgrade_logdir"
+
+ portupgrade_args="$portupgrade_args"
+
+ csup_supfile="$csup_supfile"
+
+ csup_args="$csup_args"
+
+ root_command_prefix="$root_command_prefix"
+
+ status_file="$status_file"
+
+ lock_file="$lock_file"
+
+ temp_file="$temp_file"
+
+ dialog_list_rows="$dialog_list_rows"
+
+ findi_description_length="$findi_description_length"
+
+ listup_after_upgrade="$listup_after_upgrade"
+
+ ignore_held="$ignore_held"
+
+ update_portaudit_db="$update_portaudit_db"
+
+ enable_real_deinstall="$enable_real_deinstall"
+
+ listup_after_deinstall="$listup_after_deinstall"
+
+ old_portsnap="$old_portsnap"
+
+ ---------------------------------------------------------------------
+ EOF
+
+
+ cleanexit
}
#
+ # Checks boolean variables in configuration file.
+ #
+ check_boolean_variables()
+ {
+ local variable
+
+
+ for variable in \
+ listup_after_upgrade \
+ ignore_held \
+ update_portaudit_db \
+ enable_real_deinstall \
+ listup_after_deinstall \
+ old_portsnap \
+ upgrade_show_new_version
+ do
+ checkyesno $variable
+ done
+
+ unset variable
+ }
+
+
+ #
+ # Checks numeric variables in configuration file.
+ #
+ check_numeric_variables()
+ {
+ local variable value
+
+
+ for variable in \
+ dialog_list_rows \
+ findi_description_length
+ do
+ eval value=\$$variable
+
+ case "$value"
+ in
+ [0-9]|[0-9][0-9])
+ ;;
+
+ *)
+ error "variable '$variable' has invalid or not numeric value in '$CONFIG_FILE'"
+ ;;
+ esac
+ done
+
+ unset variable value
+ }
+
+
+ #
# Checks (and creates) status file.
#
check_statusfile()
{
- if [ ! "$1" ]
+ if [ ! -f "$status_file" ]
then
- error "please define status_file in $CONFIG_FILE"
- fi
-
-
- if [ ! -r "$1" ]
- then
- touch "$1"
+ touch "$status_file"
if cmd_failed $?
then
- error "cannot create status file '$1'"
+ error "cannot create status file '$status_file'"
fi
fi
}
#
check_supfile()
{
- if [ ! "$1" ]
+ if [ ! "$csup_supfile" ]
then
- error "please define csup_supfile in $CONFIG_FILE"
+ error "please define csup_supfile in '$CONFIG_FILE'"
- elif [ ! -r "$1" ]
+ elif [ ! -f "$csup_supfile" ]
then
- error "$1: file not readable"
+ error "supfile '$csup_supfile' is not found"
+
+ elif [ ! "$root_command_prefix" -a ! -r "$csup_supfile" ]
+ then
+ error "supfile '$csup_supfile' is not readable"
fi
}
#
check_portupgrade_logdir()
{
- if [ ! "$1" ]
+ if [ ! "$portupgrade_logdir" ]
then
return 0
fi
- if [ ! -d "$1" ]
+
+ if [ ! -d "$portupgrade_logdir" ]
then
- notice "$1: directory not found"
+ notice "portupgrade log directory '$portupgrade_logdir' is not found"
- elif [ ! -w "$1" ]
+ elif [ ! "$root_command_prefix" -a ! -w "$portupgrade_logdir" ]
then
- notice "$1: directory not writable"
-
+ notice "portupgrade log directory '$portupgrade_logdir' is not writable"
else
return 0
fi
#
check_lockfile()
{
- if [ ! "$LOCKFILE" ]
+ if [ -f "$lock_file" ]
then
- error 'internal error: LOCKFILE is empty'
- fi
-
-
- if [ -f "$LOCKFILE" ]
- then
- notice "lock file '$LOCKFILE' exists"
+ notice "lock file '$lock_file' exists"
cat <<- EOF
before you can run `prog` again.
EOF
- exit 1
+ cleanexit 1
fi
- touch "$LOCKFILE"
+ touch "$lock_file"
if cmd_failed $?
then
- notice "cannot create lock file '$LOCKFILE'"
- exit 1
+ error "cannot create lock file '$lock_file'"
fi
}
- ##################################################
+ #
+ # Checks for privileges.
+ #
+ check_privs()
+ {
+ if [ `id -u` -gt 0 ]
+ then
+ if [ ! "$root_command_prefix" ]
+ then
+ notice 'please switch to root'
+
+ cat <<- EOF
+
+ Alternatively, define root_command_prefix
+ in $CONFIG_FILE
+ EOF
+
+ cleanexit 1
+ fi
+ else
+ root_command_prefix=
+ fi
+ }
- if [ `id -u` -gt 0 ]
- then
- error 'requires root'
- fi
+ ###############################################################################
if [ `uname -s` != FreeBSD ]
then
fi
- ##################################################
+ if [ -f "$CONFIG_FILE" -a -r "$CONFIG_FILE" ]
+ then
+ . "$CONFIG_FILE"
+ fi
- check_configfile "$CONFIG_FILE"
- . "$CONFIG_FILE"
-
-
- : ${portupgrade_args=""}
- : ${csup_args=""}
+ : ${portupgrade_logdir=""}
+ : ${portupgrade_args="-v"}
+ : ${csup_supfile=""}
+ : ${csup_args="-L 2"}
+ : ${root_command_prefix="sudo "}
+ : ${status_file="$TEMP_DIR/`prog`.status"}
+ : ${lock_file="$TEMP_DIR/`prog`.lock"}
+ : ${temp_file="$TEMP_DIR/`prog`.tmp"}
: ${dialog_list_rows="10"}
+ : ${findi_description_length="26"}
: ${listup_after_upgrade="YES"}
: ${ignore_held="YES"}
: ${update_portaudit_db="YES"}
: ${enable_real_deinstall="NO"}
: ${listup_after_deinstall="YES"}
+ : ${old_portsnap="NO"}
+ : ${upgrade_show_new_version="NO"}
- check_portupgrade_logdir "$portupgrade_logdir"
+ check_boolean_variables
- check_statusfile "$status_file"
+ check_numeric_variables
+ check_privs
- TEMP_PREFIX="$TEMP_DIR/`prog`.tmp"
+ check_portupgrade_logdir
- LOCKFILE="$TEMP_DIR/`prog`.lock"
check_lockfile
+ check_statusfile
- trap 'cleanexit 1' 2 15
+ trap 'cleanexit 1' 1 2 15 30 31
- ##################################################
+ ###############################################################################
+
case $1
in
+ '')
+ do_upgrade
+ ;;
+
listup|list)
do_list
cleanexit
;;
+ all)
+ do_csup
+ do_upgrade
+ ;;
+
+ snap+run)
+
+ do_portsnap
+ do_upgrade
+ ;;
+
+ listup+run|list+run)
+
+ do_list
+ do_upgrade
+ ;;
+
fixdb|fix)
do_fixdb
find|portfind)
- do_find "$2" "$3"
+ shift
+ do_find "$1" "$2"
;;
+ config|conf|c)
+
+ shift
+ do_config "$1"
+ ;;
+
findi|findv)
- do_find_install "$2"
+ shift
+ do_find_install "$1"
;;
ls|lspkg)
- do_ls "$2"
+ shift
+ do_ls "$1"
;;
chkreq|notreq|noreq)
cleanexit
;;
- all)
- do_csup
- ;;
-
- listup+run|list+run)
-
- do_list
- ;;
-
install|i)
shift
+
+ if [ ! "$*" ]
+ then
+ usage 'i [port]'
+ fi
+
do_portinstall_portupgrade portinstall $*
;;
upgrade|u)
shift
+
+ if [ ! "$*" ]
+ then
+ usage 'u [port]'
+ fi
+
do_portinstall_portupgrade portupgrade $*
;;
do_checkbinaries
;;
+ showconf)
+
+ do_showconfig
+ ;;
+
help)
do_help
;;
- '')
- ;;
-
*)
- error "$1: invalid parameter"
+ error "invalid parameter '$1'"
;;
esac
-
+ cleanexit
- ##################################################
-
- if [ ! -s "$status_file" ]
- then
- do_list exit-if-none
- fi
-
-
- while read name comments
- do
- count=$(($count + 1))
-
- dialog_options="$dialog_options '$name' '< $comments' OFF"
- done \
- < "$status_file"
-
- unset name comments
-
-
- show_dialog list "Found $count outdated package`plural $count`\nSelect one`plural $count` you want to upgrade" "$dialog_options"
-
- unset count dialog_options
-
-
- if [ ! "$selopt_list_values" ]
- then
- echo
- echo 'No packages selected for upgrade'
- echo
-
- cleanexit
- fi
-
-
- show_confirm upgrade "$selopt_list_values"
-
-
- do_portinstall_portupgrade portupgrade $selopt_list_values
-
-
- #__HELP__
- # Package Frontend help
- #-----------------------
- #
- #%P% Show upgrade dialog
- #
- #%P% list Update list of outdated packages,
- # using "portversion -vl <"
- #
- #%P% cvs Update ports tree using csup
- # Run "portsdb -Fu"
- # Run %P% list
- #
- #%P% snap Update ports tree using portsnap
- # Run %P% list
- #
- #%P% all Run %P% cvs
- # Run %P%
- #
- #%P% snap+run Run %P% snap
- # Run %P%
- #
- #%P% list+run Run %P% list
- # Run %P%
- #
- #%P% fix Run "pkgdb -F"
- #
- #%P% find Run "make search" in %PORTS_PATH%
- #
- #%P% findi Search for packages and show install dialog
- #
- #%P% ls Search packages in %PKGDB_PATH%
- #
- #%P% noreq Check for not required packages
- #
- #%P% deins Deinstall package(s) by name
- #
- #%P% padb Update portaudit database, using "portaudit -Fd"
- #
- #%P% i Run portinstall with -v $portupgrade_args
- #
- #%P% u Run portupgrade with -v $portupgrade_args
- #
- #%P% chkbin Check for existence of required programs
- #
- #%P% help This help
- #
+ ##################################################
#
+ # Package Frontend configuration file.
+ #
+ #
+ # This file is actually sourced in by sh(1),
+ # so please DON'T put anything other than
+ # variable="value" here.
+ #
+ ##################################################
+
+
+ #
# Log directory for portupgrade(1).
#
# If set, writable directory is required.
#
+ # Default: ""
+ #
- #portupgrade_logdir=/tmp/pkgfe-logs
+ #portupgrade_logdir="/tmp/pkgfe-logs"
#portupgrade_logdir=~/.pkgfe-logs
- #portupgrade_logdir=/usr/local/portupgrade
+ #portupgrade_logdir="/usr/local/portupgrade"
#
# Additional arguments for portupgrade(1).
#
- # Default: None, except "-v" which is always specified.
+ # Default: "-v"
#
+ #portupgrade_args="-v"
#portupgrade_args="-L ${portupgrade_logdir}/%s::%s.log -l ${portupgrade_logdir}/all.log"
+ #portupgrade_args="-vbe -L ${portupgrade_logdir}/%s::%s.log -l ${portupgrade_logdir}/all.log"
+ #portupgrade_args="-vbe"
#
# Configuration file for csup(1).
+ # Only required when updating the ports tree
+ # using csup(1).
#
- # Only required when updating the ports tree.
+ # Note: please look "pkgfe snap".
#
+ # Default: ""
+ #
#csup_supfile=~/ports-supfile
- #csup_supfile=/usr/share/examples/cvsup/ports-supfile
+ #csup_supfile="/usr/share/examples/cvsup/ports-supfile"
#
# Additional arguments for csup(1).
#
- # Default: None
+ # Default: "-L 2"
#
#csup_args="-L 2"
#
+ # Use root only when it's absolutely required.
+ # Otherwise, run as unprivileged user.
+ #
+ # Note: It's automatically set to ""
+ # if pkgfe runs under root.
+ #
+ # Default: "sudo "
+ #
+
+ #root_command_prefix="su -lc "
+ #root_command_prefix="sudo "
+ #root_command_prefix="echo --- "
+
+
+ #
# Status file. Used for storing
# current list of outdated packages.
#
- # *Required!*
+ # Default: "TEMPDIR/PROGNAME.status"
#
- #status_file=/tmp/pkgfe.status
+ #status_file="/tmp/pkgfe.status"
#status_file=~/.pkgfe.status
#
+ # Lock file. Used to prevent
+ # multiple sessions of pkgfe.
+ #
+ # Default: "TEMPDIR/PROGNAME.lock"
+ #
+
+ #lock_file="/tmp/pkgfe.lock"
+ #lock_file=~/.pkgfe.lock
+
+
+ #
+ # Temporary file. Used for
+ # pkgfe's temporary data.
+ #
+ # Default: "TEMPDIR/PROGNAME.tmp"
+ #
+
+ #temp_file="/tmp/pkgfe.tmp"
+ #temp_file=~/.pkgfe.tmp
+
+
+ #
# How much rows to display at once.
# For example, about 10 when you are
# using 80x24 terminal.
#
- # Default: 10
+ # Default: "10"
#
#dialog_list_rows="10"
#dialog_list_rows="15"
#dialog_list_rows="20"
+ #dialog_list_rows="30"
+ #
+ # How many characters of port description
+ # to show per line, when displaying findi dialog.
+ # Truncates line and suffixes if with "...",
+ # if it's longer.
+ # For example, about 26 when you are
+ # using 80x24 terminal.
+ #
+ # Default: "26"
+ #
+
+ #findi_description_length="26"
+ #findi_description_length="50"
+
+
##################################################
#
# Enable feature: "YES", "TRUE", "ON", or "1"
# Update list of outdated packages
# after successful upgrade.
#
- # Default: YES
+ # Default: "YES"
#
#listup_after_upgrade="YES"
# Ignore packages those are held by user,
# using the HOLD_PKGS variable in pkgtools.conf(5).
#
- # Default: YES
+ # Default: "YES"
#
#ignore_held="YES"
# Update portaudit database
# before each upgrade.
#
- # Default: YES
+ # Default: "YES"
#
#update_portaudit_db="YES"
+ #update_portaudit_db="NO"
#
# not just printing out the command
# when using "pkgfe deins" feature.
#
- # Default: NO
+ # Default: "NO"
#
#enable_real_deinstall="NO"
+ #enable_real_deinstall="YES"
#
# Update list of outdated packages
# after successful deinstall.
#
- # Default: YES
+ # Default: "YES"
#
#listup_after_deinstall="YES"
+
+
+ #
+ # Enable when your portsnap don't support
+ # "fetch update", only "fetch" and "update".
+ #
+ # Default: "NO"
+ #
+
+ #old_portsnap="NO"
+
+
+ #
+ # Show new version in confirm upgrade dialog.
+ # A bit slow.
+ #
+ # Default: "NO"
+ #
+
+ #upgrade_show_new_version="NO"