[BACK]Return to checkver CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib

File: [cvs.NetBSD.org] / src / lib / checkver (download)

Revision 1.13, Wed Apr 30 13:10:50 2008 UTC (15 years, 11 months ago) by martin
Branch: MAIN
CVS Tags: yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, yamt-pagecache-tag8, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, wrstuden-revivesa, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, matt-premerge-20091211, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-premerge-20101231, matt-mips64-base2, jym-xensuspend-nbase, jym-xensuspend-base, jym-xensuspend, hpcarm-cleanup-nbase, cherry-xenmp-base, cherry-xenmp, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2
Branch point for: yamt-pagecache, tls-maxphys
Changes since 1.12: +1 -8 lines

Convert TNF licenses to new 2 clause variant

#!/bin/sh
#	$NetBSD: checkver,v 1.13 2008/04/30 13:10:50 martin Exp $
#
# Copyright (c) 1998 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Eric Haszlakiewicz.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

#--------------------------------------------------------------------#
# checkver - 
#	Check for libraries that appear to be newer than the
#	one we're about to install.
#
# checkver [-q] [-v shlib_version_file] -d [installedlibdir [library name]]"
# checkver [-q] [-v shlib_version_file] -s [setlistdir [library name]]"
# checkver [-q] [-v shlib_version_file] -f liblistfile [library name]"
#
# One of -d, -s or -f must be specified.
#
# all: If library name is not specified it is assumed to
#	be the name of the current directory.
#
# -d: Checks the version against the installed libraries.
#	If no further arguments are given "/usr/lib" is
#	used as the location of installed libraries.
#
# -s: Checks the version against the sets.  If no argument
#	follows the sets directory defaults to "/usr/src/distrib/sets/lists".
#	The directory may be specified as either the top of the
#	source tree or as the lists directory.
#
# -f: Checks the version against the provided list.  A filename
#	must be supplied.
#
# -v: Specify the filename of the shlib_version file.  Defaults
#     to "./shlib_version".
#
# This script produces no output if all library version are not
# large than the source version.  If an installed library with a
# version greater than the source is found, checkver prints a
# header and a list of the names of the offending installed libraries.
#
# The header may be supressed by passing "-q" as the first argument.
#

TMP=/tmp/checkver.$$
# Can't trap 11 (SEGV) in the Real Bourne Shell, since it uses it for
# internal malloc!
trap "exit 2" 1 2 3 4 5 6 7 8 10 12 13 14 15
trap "[ -d $TMP ] && rm -rf $TMP" 0

Usage() {
    echo "Usage: $1 [-q] [-v version_file] -d [installedlibdir [library name]]"
    echo "       $1 [-q] [-v version_file] -s [setlistdir [library name]]"
    echo "       $1 [-q] [-v version_file] -f liblistfile [library name]"
    echo "	$1 is a script that looks for installed libraries with"
    echo "	   versions greater than that in the version file."
    echo "	For more information, read the comments."
}

basedir=/usr/src
setsdir=$basedir/distrib/sets/lists
libdir=/usr/lib
shlib_version=./shlib_version

error=0
quiet=0
usedir=0
usefile=0
usesets=0
CWD=`pwd`
args=`getopt "df:shqv:" "$@"`
if [ $? -ne 0 ] ; then
    Usage $0
    exit 0
fi

set -- $args

while [ ! -z "$1" ]; do
    case "$1" in
	-d) usedir=1 ; shift
	    if [ $usefile -eq 1 -o $usesets -eq 1 ]; then
		Usage $0 ; exit 2
	    fi;;
	-f) usefile=1 ; arg1=$2 ; shift ; shift
	    if [ $usedir -eq 1 -o $usesets -eq 1 ]; then
		Usage $0 ; exit 2
	    fi;;
	-s) usesets=1 ; shift
	    if [ $usedir -eq 1 -o $usefile -eq 1 ]; then
		Usage $0 ; exit 2
	    fi;;
	-v) shlib_version=$2; shift ; shift ;;
	-h) Usage $0 ; exit 0;;
	-q) quiet=1 ; shift;;
	--) shift ; break;;
    esac
done

if [ $usedir -eq 0 -a $usefile -eq 0 -a $usesets -eq 0 ] ; then
    Usage $0 ; exit 2
fi

if [ $usefile -eq 1 ] ; then
   LIBLIST="$arg1"
else
   mkdir -m 0700 $TMP
   if [ $?  != 0 ]; then
	echo "$0: Unable to create temp directory."
	exit 2
   fi
   LIBLIST=$TMP/libs.lst
fi

# Build list from the installed libraries.
if [ $usedir -eq 1 ] ; then
    if [ "X$1" != "X" ] ; then
	libdir="$1"
    fi
    for f in $libdir ; do
	ls $f/lib*.so.*.*
    done > $LIBLIST 2> /dev/null
fi

# Build list from set lists.  Parameter may be either
# the "lists" directory or the top of the source tree.
if [ $usesets -eq 1 ] ; then
    if [ "X$1" != "X" ] ; then
	setsdir="$1"
	if [ -d "$setsdir/distrib/sets/lists" ] ; then
	    setsdir="$setsdir/distrib/sets/lists"
	fi
    fi
    (cd $setsdir ;
     cat */[a-z]* | grep '^./usr/lib/lib.*\.so\.[0-9][0-9]*\.[0-9][0-9]*' \
		  | sort -u > $LIBLIST
    )
fi

#
# The file $LIBLIST now contains a list of libraries.
#

if [ "X$2" = "X" ] ; then
    makefile=$CWD/Makefile
    libname=`grep '^LIB=' $makefile | sed -e 's/^LIB=[[:space:]]*//'`

    # Assume the library name is the name of the current directory.
    if [ -z $libname ]; then
	libname=`basename $CWD`
    fi
else
    libname="$2"
fi
echo $libname | grep "^lib" 1>&2 2> /dev/null
if [ $? != 0 ]; then
    libname="lib$libname"
fi


if [ ! -f $shlib_version ] ; then
    echo "$0: unable to find $shlib_version"
    exit 2
fi

# Grab major and minor numbers from the source.
. $shlib_version

if [ "X$minor" = "X" -o "X$major" = "X" ] ; then
    echo "$0: $shlib_version doesn't contain the version."
    exit 2
fi

# Find every shared object library with the same base name.
 for instlib in `grep $libname.so "$LIBLIST" ` ; do
    # Grab the major and minor from the installed library.
    instmajor=`basename $instlib | awk 'BEGIN { FS="." } { print $3 } '`
    instminor=`basename $instlib | awk 'BEGIN { FS="." } { print $4 } '`
    instteeny=`basename $instlib | awk 'BEGIN { FS="." } { print $5 + 0 } '`

    # If they're greater than the source, complain.
    if [ "0$major" -eq "0$instmajor" ] ; then
	if [ "0$minor" -eq "0$instminor" ] ; then
	    if [ "0$teeny" -lt "0$instteeny" ] ; then
		if [ $error -eq 0 -a $quiet -eq 0 ]; then
		    echo -n "The following libraries have versions greater"
		    echo " than the source:"
	        fi
		echo $instlib > /dev/stderr
		error=1
	    fi
        elif [ "0$minor" -lt "0$instminor" ] ; then
	    if [ $error -eq 0 -a $quiet -eq 0 ]; then
		echo -n "The following libraries have versions greater"
		echo " than the source:"
	    fi
	    echo $instlib > /dev/stderr
	    error=1
	fi
    elif [ "0$major" -lt "0$instmajor" ] ; then
	if [ $error -eq 0 -a $quiet -eq 0 ] ; then
	    echo -n "The following libraries have versions greater"
	    echo " than the source:"
	fi
	echo $instlib > /dev/stderr
	error=1
    fi
 done

exit $error