aboutsummaryrefslogtreecommitdiff
path: root/ports-mgmt/lsknobs
diff options
context:
space:
mode:
authorMartin Wilke <miwi@FreeBSD.org>2008-01-24 15:01:12 +0000
committerMartin Wilke <miwi@FreeBSD.org>2008-01-24 15:01:12 +0000
commit0ce79ac0ab01af1784beea24d8e1e7e2b014331e (patch)
treed24e8247273886f4190e9b15e9d56431f9626bb4 /ports-mgmt/lsknobs
parentd40b2db8d197bc563f5e078dee97715ee3543723 (diff)
downloadports-0ce79ac0ab01af1784beea24d8e1e7e2b014331e.tar.gz
ports-0ce79ac0ab01af1784beea24d8e1e7e2b014331e.zip
Notes
Diffstat (limited to 'ports-mgmt/lsknobs')
-rw-r--r--ports-mgmt/lsknobs/Makefile33
-rw-r--r--ports-mgmt/lsknobs/files/lsknobs.sh.in108
-rw-r--r--ports-mgmt/lsknobs/files/pkg-message.in12
-rw-r--r--ports-mgmt/lsknobs/pkg-descr3
4 files changed, 156 insertions, 0 deletions
diff --git a/ports-mgmt/lsknobs/Makefile b/ports-mgmt/lsknobs/Makefile
new file mode 100644
index 000000000000..e9b80ac753af
--- /dev/null
+++ b/ports-mgmt/lsknobs/Makefile
@@ -0,0 +1,33 @@
+# New ports collection makefile for: lsknobs
+# Date created: 5 Sep 2007
+# Whom: Gabriel Linder <linder.gabriel@gmail.com>
+#
+# $FreeBSD$
+#
+# This port is self contained in the files directory.
+#
+
+PORTNAME= lsknobs
+PORTVERSION= 1.0
+CATEGORIES= ports-mgmt
+MASTER_SITES= # none
+DISTFILES= # none
+
+MAINTAINER= linder.gabriel@gmail.com
+COMMENT= Simple script to help configure ports knobs and options
+
+RUN_DEPENDS= ${LOCALBASE}/libexec/portconf:${PORTSDIR}/ports-mgmt/portconf
+
+NO_BUILD= yes
+SUB_FILES= pkg-message ${PORTNAME}.sh
+
+PLIST_FILES= sbin/${PORTNAME}
+
+do-fetch:
+ @${DO_NADA}
+
+do-install:
+ @${INSTALL_SCRIPT} ${WRKDIR}/${PORTNAME}.sh ${PREFIX}/sbin/${PORTNAME}
+ @${CAT} ${PKGMESSAGE}
+
+.include <bsd.port.mk>
diff --git a/ports-mgmt/lsknobs/files/lsknobs.sh.in b/ports-mgmt/lsknobs/files/lsknobs.sh.in
new file mode 100644
index 000000000000..7f1c6855deff
--- /dev/null
+++ b/ports-mgmt/lsknobs/files/lsknobs.sh.in
@@ -0,0 +1,108 @@
+#!/bin/sh
+#
+# Copyright (c) 2007, Gabriel Linder <linder.gabriel@gmail.com>
+# This work is based on a script written by Maxim Khitrov and posted
+# on FreeBSD Questions mailing list at Wed, 22 Aug 2007.
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+dir="`pwd`"
+dir="`dirname $dir`"
+dir="`dirname $dir`"
+if [ "/usr/ports" != "$dir" ]
+then
+ echo 1>&2 "This script must be run from a port directory !"
+ exit 1
+fi
+
+if [ ! -z "$CLICOLOR" ] && [ -t 1 ]
+then
+ NORMAL="\033[0;0m"
+ BLACK="\033[1;30m"
+ RED="\033[1;31m"
+ GREEN="\033[1;32m"
+ YELLOW="\033[1;33m"
+ BLUE="\033[1;34m"
+ MAGENTA="\033[1;35m"
+ CYAN="\033[1;36m"
+ WHITE="\033[1;37m"
+else
+ NORMAL=""
+ BLACK=""
+ RED=""
+ GREEN=""
+ YELLOW=""
+ BLUE=""
+ MAGENTA=""
+ CYAN=""
+ WHITE=""
+fi
+
+print_knob()
+{
+ port="$1"
+ knob="$2"
+ if [ -z "`cd /usr/ports/$port && /usr/local/libexec/portconf | grep $knob`" ]
+ then
+ echo -e " $RED[KNOB]$NORMAL $WHITE$knob$NORMAL"
+ else
+ echo -e " $RED[KNOB]$NORMAL $MAGENTA(*)$NORMAL $BLACK$knob$NORMAL"
+ fi
+}
+
+print_option()
+{
+ port="$1"
+ knob="$2"
+ options="$3"
+ pre="`echo $knob | cut -d _ -f 1`"
+ if [ "$pre" = "WITH" ] || [ "$pre" = "WITHOUT" ]
+ then
+ opt="`echo $knob | sed s,${pre}_,,`"
+ else
+ opt="$knob"
+ fi
+ if [ -z "`echo $options | grep -Eho $opt=on`" ]
+ then
+ if [ -z "`echo $options | grep -Eho $opt=off`" ]
+ then
+ print_knob "$port" "$knob"
+ else
+ echo -e " $GREEN[OPTION]$NORMAL $WHITE$opt$NORMAL"
+ fi
+ else
+ echo -e " $GREEN[OPTION]$NORMAL $MAGENTA(*)$NORMAL $BLACK$opt$NORMAL"
+ fi
+}
+
+ports="`make missing` `pwd | sed s,/usr/ports/,,`"
+for port in $ports
+do
+ knobs="`grep -Eho '(defined[:space:]*\([:space:]*.+[:space:]*\))|(^\.ifdef[:space:]*\([:space:]*.+[:space:]*\))|(^\.ifndef[:space:]*\([:space:]*.+[:space:]*\))' /usr/ports/$port/Makefile | sed -E 's,defined\(([^)]*)\),\1,g;s,\.ifdef\(([^)]*)\),\1,g;s,\.ifndef\(([^)]*)\),\1,g' | tr -d '&|!' | tr ' ' '\n' | grep -Eho '^[A-Z_0-9]+$' | sort | uniq`"
+ if [ -z "$knobs" ]
+ then
+ continue
+ fi
+ echo "==> $port"
+ options="`make showconfig | grep -Eho '^[:space:]*.+=(on|off)'`"
+ for knob in $knobs
+ do
+ if [ -z "$options" ]
+ then
+ print_knob "$port" "$knob"
+ else
+ print_option "$port" "$knob" "$options"
+ fi
+ done
+done
diff --git a/ports-mgmt/lsknobs/files/pkg-message.in b/ports-mgmt/lsknobs/files/pkg-message.in
new file mode 100644
index 000000000000..0c0b94674483
--- /dev/null
+++ b/ports-mgmt/lsknobs/files/pkg-message.in
@@ -0,0 +1,12 @@
+Typical use :
+
+ 1) Choose a port
+# cd /usr/ports/editors/vim
+
+ 2) Configure it, with its dependencies
+# lsknobs
+# make config-recursive
+ (repeat these two steps until you agree with what is shown)
+
+ 3) Install everything
+# make install clean
diff --git a/ports-mgmt/lsknobs/pkg-descr b/ports-mgmt/lsknobs/pkg-descr
new file mode 100644
index 000000000000..09dad6116b00
--- /dev/null
+++ b/ports-mgmt/lsknobs/pkg-descr
@@ -0,0 +1,3 @@
+lsknobs is a simple sh(1) script designed to help configure
+ports knobs and options by listing them together with their
+status (either enabled or not). It uses portconf for knobs.