Date: Wed, 5 Sep 2007 13:01:11 +0200 (CEST) From: Charlie & <root@dargor.servebeer.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Gabriel Linder <linder@jeuxvideo.com> Subject: ports/116127: New port: ports-mgmt/lskobs - List supported knobs and options for a port Message-ID: <200709051101.l85B1Bit028722@dargor.servebeer.com> Resent-Message-ID: <200709051730.l85HU467093417@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 116127 >Category: ports >Synopsis: New port: ports-mgmt/lskobs - List supported knobs and options for a port >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Sep 05 17:30:03 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Gabriel Linder >Release: FreeBSD 6.2-STABLE i386 >Organization: >Environment: System: FreeBSD dargor.servebeer.com 6.2-STABLE FreeBSD 6.2-STABLE #0: Sat Sep 1 21:26:57 CEST 2007 root@dargor.servebeer.com:/usr/obj/usr/src/sys/SMP i386 >Description: This is a tiny shell script that I wrote, which lists all knobs and options supported by a port and its dependencies, with color as an option (if CLICOLOR variable is set). I tested it with gnome2 metaport and portlint, everything seems ok. It requires portconf, from which I copied the Makefile to make this port. >How-To-Repeat: >Fix: --- lsknobs begins here --- # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # lsknobs # lsknobs/pkg-descr # lsknobs/Makefile # lsknobs/files # lsknobs/files/pkg-message.in # lsknobs/files/lsknobs.sh.in # echo c - lsknobs mkdir -p lsknobs > /dev/null 2>&1 echo x - lsknobs/pkg-descr sed 's/^X//' >lsknobs/pkg-descr << 'END-of-lsknobs/pkg-descr' Xlsknobs is a simple sh(1) script designed to help configure Xports knobs and options by listing them together with their Xstatus (either enabled or not). It uses portconf for knobs. END-of-lsknobs/pkg-descr echo x - lsknobs/Makefile sed 's/^X//' >lsknobs/Makefile << 'END-of-lsknobs/Makefile' X# New ports collection makefile for: lsknobs X# Date created: 5 Sep 2007 X# Whom: Gabriel Linder <linder.gabriel@gmail.com> X# X# $FreeBSD$ X# X# This port is self contained in the files directory. X# X XPORTNAME= lsknobs XPORTVERSION= 1.0 XCATEGORIES= ports-mgmt XMASTER_SITES= # none XDISTFILES= # none X XMAINTAINER= linder.gabriel@gmail.com XCOMMENT= Simple script to help configure ports knobs and options X XRUN_DEPENDS= ${LOCALBASE}/libexec/portconf:${PORTSDIR}/ports-mgmt/portconf X XNO_BUILD= yes XSUB_FILES= pkg-message ${PORTNAME}.sh X XPLIST_FILES= sbin/${PORTNAME} X Xdo-fetch: X @${DO_NADA} X Xdo-install: X @${INSTALL_SCRIPT} ${WRKDIR}/${PORTNAME}.sh ${PREFIX}/sbin/${PORTNAME} X @${CAT} ${PKGMESSAGE} X X.include <bsd.port.mk> END-of-lsknobs/Makefile echo c - lsknobs/files mkdir -p lsknobs/files > /dev/null 2>&1 echo x - lsknobs/files/pkg-message.in sed 's/^X//' >lsknobs/files/pkg-message.in << 'END-of-lsknobs/files/pkg-message.in' XTypical use : X X 1) Choose a port X# cd /usr/ports/editors/vim X X 2) Configure it, with its dependencies X# lsknobs X# make config-recursive X (repeat these two steps until you agree with what is shown) X X 3) Install everything X# make install clean END-of-lsknobs/files/pkg-message.in echo x - lsknobs/files/lsknobs.sh.in sed 's/^X//' >lsknobs/files/lsknobs.sh.in << 'END-of-lsknobs/files/lsknobs.sh.in' X#!/bin/sh X# X# Copyright (c) 2007, Gabriel Linder <linder.gabriel@gmail.com> X# This work is based on a script written by Maxim Khitrov and posted X# on FreeBSD Questions mailing list at Wed, 22 Aug 2007. X# X# Permission to use, copy, modify, and distribute this software for any X# purpose with or without fee is hereby granted, provided that the above X# copyright notice and this permission notice appear in all copies. X# X# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES X# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF X# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR X# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES X# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN X# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF X# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. X# X Xdir="`pwd`" Xdir="`dirname $dir`" Xdir="`dirname $dir`" Xif [ "/usr/ports" != "$dir" ] Xthen X echo 1>&2 "This script must be run from a port directory !" X exit 1 Xfi X Xif [ ! -z "$CLICOLOR" ] && [ -t 1 ] Xthen X NORMAL="\033[0;0m" X BLACK="\033[1;30m" X RED="\033[1;31m" X GREEN="\033[1;32m" X YELLOW="\033[1;33m" X BLUE="\033[1;34m" X MAGENTA="\033[1;35m" X CYAN="\033[1;36m" X WHITE="\033[1;37m" Xelse X NORMAL="" X BLACK="" X RED="" X GREEN="" X YELLOW="" X BLUE="" X MAGENTA="" X CYAN="" X WHITE="" Xfi X Xprint_knob() X{ X port="$1" X knob="$2" X if [ -z "`cd /usr/ports/$port && /usr/local/libexec/portconf | grep $knob`" ] X then X echo -e " $RED[KNOB]$NORMAL $WHITE$knob$NORMAL" X else X echo -e " $RED[KNOB]$NORMAL $MAGENTA(*)$NORMAL $BLACK$knob$NORMAL" X fi X} X Xprint_option() X{ X port="$1" X knob="$2" X options="$3" X pre="`echo $knob | cut -d _ -f 1`" X if [ "$pre" = "WITH" ] || [ "$pre" = "WITHOUT" ] X then X opt="`echo $knob | sed s,${pre}_,,`" X else X opt="$knob" X fi X if [ -z "`echo $options | grep -Eho $opt=on`" ] X then X if [ -z "`echo $options | grep -Eho $opt=off`" ] X then X print_knob "$port" "$knob" X else X echo -e " $GREEN[OPTION]$NORMAL $WHITE$opt$NORMAL" X fi X else X echo -e " $GREEN[OPTION]$NORMAL $MAGENTA(*)$NORMAL $BLACK$opt$NORMAL" X fi X} X Xports="`make missing` `pwd | sed s,/usr/ports/,,`" Xfor port in $ports Xdo X 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`" X if [ -z "$knobs" ] X then X continue X fi X echo "==> $port" X options="`make showconfig | grep -Eho '^[:space:]*.+=(on|off)'`" X for knob in $knobs X do X if [ -z "$options" ] X then X print_knob "$port" "$knob" X else X print_option "$port" "$knob" "$options" X fi X done Xdone END-of-lsknobs/files/lsknobs.sh.in exit --- lsknobs ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709051101.l85B1Bit028722>