#!/bin/sh -e1#2# Copyright (c) 2003-2004 Oliver Eikemeier. All rights reserved.3#4# Redistribution and use in source and binary forms, with or without5# modification, are permitted provided that the following conditions are6# met:7#8# 1. Redistributions of source code must retain the above copyright notice9# this list of conditions and the following disclaimer.10#11# 2. Redistributions in binary form must reproduce the above copyright12# notice, this list of conditions and the following disclaimer in the13# documentation and/or other materials provided with the distribution.14#15# 3. Neither the name of the author nor the names of its contributors may be16# used to endorse or promote products derived from this software without17# specific prior written permission.18#19# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,20# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY21# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE22# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,23# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT24# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF28# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29#30# MAINTAINER= [email protected]31#32# PKGORIGIN connects packaged or installed ports to the directory they33# originally came from. Although often overlooked, they are extremly34# important for tools like pkg_version or portupgrade to work correctly.35# Wrong PKGORIGINs are usually caused by a wrong order of CATEGORIES36# after a repocopy.37#38# This tool checks all ports in the ports tree (even those not connected39# to the build) for a wrong PKGORIGIN. Run this tool periodically and40# after every repocopy and correct errors immediately.41#42# Usage:43# [env PORTSDIR=/usr/ports] chkorigin.sh [category ...]44#4546opt_verbose=false47opt_quiet=false4849while getopts vq opt; do50case "$opt" in51q)52opt_quiet=true;;53v)54opt_verbose=true;;55?)56echo "Usage: $0 [-qv] [category ...]"57exit 2;;58esac59done6061shift $((${OPTIND}-1))6263rc=06465$opt_quiet || echo "checking categories for ports with a wrong PKGORIGIN"6667cd "${PORTSDIR:=/usr/ports}"68if [ $# -gt 0 ]; then69CATEGORIES=`echo $@`70else71CATEGORIES=`echo [a-z]*`72fi7374for category in ${CATEGORIES}; do75if [ ! -d "${PORTSDIR}/${category}" ]; then continue; fi76case "${category}" in77CVS) continue ;;78Mk) continue ;;79Templates) continue ;;80Tools) continue ;;81distfiles) continue ;;82packages) continue ;;83esac8485$opt_quiet || echo "==> ${category}"8687cd "${PORTSDIR}/${category}"88PORTS=`echo *`8990for port in ${PORTS}; do91if [ ! -d "${PORTSDIR}/${category}/${port}" ]; then continue; fi92case "${port}" in93CVS) continue ;;94pkg) continue ;;95esac9697$opt_verbose && echo "==> ${category}/${port}"9899cd "${PORTSDIR}/${category}/${port}"100PKGORIGIN=`/usr/bin/make -VPKGORIGIN 2>/dev/null || true`101102if [ "${PKGORIGIN}" != "${category}/${port}" ]; then103echo "port \"${category}/${port}\" has the wrong PKGORIGIN \"${PKGORIGIN}\""104rc=1105fi106done107done108109return ${rc}110111112