diff options
author | eadler <eadler@FreeBSD.org> | 2012-08-05 21:13:21 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2012-08-05 21:13:21 +0000 |
commit | d26d8ba30eaee1da4f99bbbd979e7ec9c80b7820 (patch) | |
tree | b6c2d54f1695cf863fb2f2e459111acb06225c7a | |
parent | 39743a5c95f98d60086dfc4af423a91dc7061b85 (diff) | |
download | FreeBSD-src-d26d8ba30eaee1da4f99bbbd979e7ec9c80b7820.zip FreeBSD-src-d26d8ba30eaee1da4f99bbbd979e7ec9c80b7820.tar.gz |
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
-rw-r--r-- | usr.sbin/portsnap/portsnap/portsnap.8 | 8 | ||||
-rw-r--r-- | usr.sbin/portsnap/portsnap/portsnap.sh | 20 |
2 files changed, 24 insertions, 4 deletions
diff --git a/usr.sbin/portsnap/portsnap/portsnap.8 b/usr.sbin/portsnap/portsnap/portsnap.8 index 0d9c261..f0b3628 100644 --- a/usr.sbin/portsnap/portsnap/portsnap.8 +++ b/usr.sbin/portsnap/portsnap/portsnap.8 @@ -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 diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh index 033bb55..8071820 100644 --- a/usr.sbin/portsnap/portsnap/portsnap.sh +++ b/usr.sbin/portsnap/portsnap/portsnap.sh @@ -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 |