Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Aug 2012 21:13:21 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r239078 - head/usr.sbin/portsnap/portsnap
Message-ID:  <201208052113.q75LDLF1027294@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Sun Aug  5 21:13:21 2012
New Revision: 239078
URL: http://svn.freebsd.org/changeset/base/239078

Log:
  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

Modified:
  head/usr.sbin/portsnap/portsnap/portsnap.8
  head/usr.sbin/portsnap/portsnap/portsnap.sh

Modified: head/usr.sbin/portsnap/portsnap/portsnap.8
==============================================================================
--- head/usr.sbin/portsnap/portsnap/portsnap.8	Sun Aug  5 20:19:27 2012	(r239077)
+++ head/usr.sbin/portsnap/portsnap/portsnap.8	Sun Aug  5 21:13:21 2012	(r239078)
@@ -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 t
 .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

Modified: head/usr.sbin/portsnap/portsnap/portsnap.sh
==============================================================================
--- head/usr.sbin/portsnap/portsnap/portsnap.sh	Sun Aug  5 20:19:27 2012	(r239077)
+++ head/usr.sbin/portsnap/portsnap/portsnap.sh	Sun Aug  5 21:13:21 2012	(r239078)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208052113.q75LDLF1027294>