#!/usr/bin/env bash # Charlemagne Ports Command # # Douglas Thrift # # $Id$ # Copyright 2006 Douglas Thrift # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. source `dirname $0`/defaults function fail() { if [[ $1 -ne 0 ]]; then echo "$bright$red!!$reset $2 for $display $bright$red$3$reset" 1>&2 exit $1 fi } cd $ports for category in *; do if [[ -d $category ]]; then display="$bright$category$reset" grep -Eq "^`escape $category` +" categories fail $? 'Categories' 'not in categories' fi done for port in */*; do if [[ ! -h $port ]] && [[ -f $port/port ]]; then (cd $port source port cd $ports category=${port%/*} port=${port#*/} display="$bright$categories$reset/$bright$name$reset" [[ $category != $categories ]] && fail 1 'Ports' 'category != categories' [[ $port != $name ]] && fail 1 'Ports' 'port != name' for ((index = 1; index != ${#categories[*]}; ++index)); do if [[ ! -h ${categories[$index]}/$port ]]; then ln -sfv ../$category/$port ${categories[$index]} fail $? 'Ports' 'link' fi done) || exit $? fi done