Add interactive option to override portsnap's automagical detection of

a terminal.

Submitted by:	Hannes h2+fbsdports@fsfe.org
Approved by:	cperciva
MFC after:	1 week
This commit is contained in:
Eitan Adler 2012-08-05 21:13:21 +00:00
parent 787c338407
commit a6c38148a0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=239078
2 changed files with 24 additions and 4 deletions

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd September 15, 2008
.Dd August 5, 2012
.Dt PORTSNAP 8
.Os FreeBSD
.Sh NAME
@ -110,6 +110,12 @@ command only, operate only on parts of the ports tree starting with
.Ar sysutils/port
would extract sysutils/portsman, sysutils/portsnap,
sysutils/portupgrade, etc.)
.It Fl Fl interactive
override auto-detection of calling process.
Only use this when calling portsnap from an
.Sy interactive, non-terminal application.
(Cron jobs are particularly bad since they cause
load spikes on the Portsnap mirrors.)
.El
.Sh COMMANDS
The

View File

@ -48,6 +48,9 @@ Options:
(default: /usr/ports/)
-s server -- Server from which to fetch updates.
(default: portsnap.FreeBSD.org)
--interactive -- interactive: override auto-detection of calling process
(use this when calling portsnap from an interactive, non-
terminal application AND NEVER ELSE).
path -- Extract only parts of the tree starting with the given
string. (extract command only)
Commands:
@ -84,6 +87,7 @@ init_params() {
SERVERNAME=""
REFUSE=""
LOCALDESC=""
INTERACTIVE=""
}
# Parse the command line
@ -103,6 +107,9 @@ parse_cmdline() {
XARGST="-t"
DDSTATS=".."
;;
--interactive)
INTERACTIVE="YES"
;;
-f)
if [ $# -eq 1 ]; then usage; fi
if [ ! -z "${CONFFILE}" ]; then usage; fi
@ -228,6 +235,13 @@ default_params() {
eval ${X}=${__}
fi
done
if [ -z "${INTERACTIVE}" ]; then
if [ -t 0 ]; then
INTERACTIVE="YES"
else
INTERACTIVE="NO"
fi
fi
}
# Perform sanity checks and set some final parameters
@ -1023,10 +1037,10 @@ get_params() {
# Fetch command. Make sure that we're being called
# interactively, then run fetch_check_params and fetch_run
cmd_fetch() {
if [ ! -t 0 ]; then
if [ "${INTERACTIVE}" != "YES" ]; then
echo -n "`basename $0` fetch should not "
echo "be run non-interactively."
echo "Run `basename $0` cron instead."
echo "Run `basename $0` cron instead"
exit 1
fi
fetch_check_params
@ -1069,7 +1083,7 @@ cmd_update() {
# whether stdin is a terminal; then run 'update' or
# 'extract' depending on whether ${PORTSDIR} exists.
cmd_alfred() {
if [ -t 0 ]; then
if [ "${INTERACTIVE}" = "YES" ]; then
cmd_fetch
else
cmd_cron