Skip to content

Instantly share code, notes, and snippets.

@relrod
Created October 22, 2009 00:51
Show Gist options
  • Save relrod/215627 to your computer and use it in GitHub Desktop.
Save relrod/215627 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
#@ Ricky Elrod - dev/perl/portscripts/sconf.pl
#@ Modified: Mon Oct 12 04:21:52 EDT 2009
#@ vim:ts=3 shiftwidth=3
use warnings;
use strict;
use Cwd;
use Text::ASCIITable;
my $initdir = getcwd();
my $port;
my $st;
if(defined($ARGV[0])){
$port = $ARGV[0];
} elsif($initdir !~ /^\/usr\/ports/){
print ">> Cannot complete without a port name.\n";
exit 0;
}
if(defined($port)){
if(-e "/usr/ports/$port"){
chdir "/usr/ports/$port";
} else {
print "The port ($port) does not exist in /usr/ports/.\n";
exit 0;
}
}
# At this point, we should be in the port directory
# whether we started there, or cd'd there @ :25.
my $currentconfig = `make showconfig`;
#===> The following configuration options are available for boost-libs-1.39.0:
# VERBOSE_BUILD=off "Show compiler messages"
# DEBUG=off "Build debugging symbols"
# ICU=on "Boost.Regex with ICU unicode support"
# OPTIMIZED_CFLAGS=off "Enable -O3 optimization"
#===> Use 'make config' to modify these settings
my @conflines = split("\n",$currentconfig);
$conflines[0] =~ /available for (.*):/;
my $title = $1;
my $t = Text::ASCIITable->new({ headingText => $title });
$t->setCols('Status','Flag','Description');
foreach my $line (@conflines) {
if($line =~ /^ (.*)=(.*) \"(.*)\"/i){
if($2 eq 'on'){
$st = " [*] ";
} else {
$st = " [ ] ";
}
$t->addRow($st,$1,$3);
}
}
print $t;
# Try to return the user to their working directory, if changed.
# This *SHOULD* happen already, but we'll make sure...
`cd $initdir`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment