diff -r c95779327c61 -r 87ac9ed9a5f8 auto-symlink-virtual.sh --- a/auto-symlink-virtual.sh Fri Jun 05 11:54:22 2009 +0300 +++ b/auto-symlink-virtual.sh Fri Jun 05 14:08:47 2009 +0300 @@ -1,6 +1,34 @@ #!/usr/bin/env sh +progname=$(basename "$0") +usage() +{ + echo "$progname: create symlinks for virtual ports" + echo "" + echo "Usage: $progname [-hn] [-p portsdir]" + echo "" + echo " -h show this usage" + echo " -n run through ports, but do not modify anything" + echo " -p portsdir use portsdir as the root of the ports tree" + echo " the default is /usr/ports/" +} + portdir="/usr/ports" +while getopts hnp: OPT; do + case "$OPT" in + h) usage + exit 0 + ;; + n) dry_run=yes + ;; + p) portdir=$OPTARG + ;; + \?) usage >&2 + exit 1 + ;; + esac +done + for main_cat in $(make -V SUBDIR -C $portdir); do if [ -d $portdir/$main_cat ]; @@ -11,11 +39,11 @@ for item_cat in $(make -V CATEGORIES -C $portdir/$main_cat/$port); do echo -n "$item_cat " - if [ ! -d $item_cat ]; + if [ -z "$dry_run" -a ! -d $item_cat ]; then mkdir $item_cat; fi; - if [ ! -e $item_cat/$port ]; + if [ -z "$dry_run" -a ! -e $item_cat/$port ]; then #this won't create the main ports because we check to see if the main port one exits BUT #we add the main cat to the filename in case of name conflicts