[csw-devel] SF.net SVN: gar:[6203] csw/mgar/gar/v2/bin/checkpkg

bdwalton at users.sourceforge.net bdwalton at users.sourceforge.net
Sun Sep 6 03:04:38 CEST 2009


Revision: 6203
          http://gar.svn.sourceforge.net/gar/?rev=6203&view=rev
Author:   bdwalton
Date:     2009-09-06 01:04:38 +0000 (Sun, 06 Sep 2009)

Log Message:
-----------
GAR: update checkpkg to handle multiple package sets (inter-dependencies)

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/checkpkg

Modified: csw/mgar/gar/v2/bin/checkpkg
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg	2009-09-05 22:18:43 UTC (rev 6202)
+++ csw/mgar/gar/v2/bin/checkpkg	2009-09-06 01:04:38 UTC (rev 6203)
@@ -1,8 +1,8 @@
 #!/bin/ksh -p
 
-# checkpkg 1.46a (diff to 1.46: modified errmsg -> warnmsg on two places)
+# checkpkg 1.50 (diff to 1.46a: check multiple package files)
 # This script examines a package that has been put together
-# for submittal to the CSW archive
+# for submittal to the CSW archive at opencsw.org
 #
 # It examines it for compliance with the packaging standards at
 # http://www.opencsw.org/standards/
@@ -29,10 +29,15 @@
 		rm -rf $EXTRACTDIR
 	fi
 	if [[ "$TMPARCHIVE" != "" ]] ; then
-		rm $TMPARCHIVE
+		[ -f "$TMPARCHIVE" ] && rm $TMPARCHIVE
 	fi
 }
 
+cleanupset(){
+    if [ "`echo $SETINF*`" != "$SETINF*" ]; then
+	rm $SETINF*
+    fi
+}
 warnmsg(){
 	print WARNING: $* >/dev/fd/2
 	if [[ "$quit_on_warn" != "" ]] ; then
@@ -45,6 +50,7 @@
 errmsg(){
 	print ERROR: $* >/dev/fd/2
 	cleanup
+	cleanupset
 	exit 1
 }
 
@@ -58,6 +64,12 @@
 	shift
 fi
 
+# a unique filename for the list of package deps and libs we see in a 'set'
+SETINF=/tmp/checkpkg.$$.`date +%Y%m%d%H%M%S`
+SETLIBS=$SETINF.libs
+SETDEPS=$SETINF.deps
+
+
 for f in "$@"
 do
 
@@ -123,7 +135,6 @@
 TMPFILE=$EXTRACTDIR/pkginfo
 
 
-
 dd if=$f skip=1 | (cd $EXTRACTDIR; cpio -ivd $pkgname/pkginfo)
 if [[ $? -ne 0 ]] ; then
 	print ERROR: could not extract $f
@@ -217,6 +228,13 @@
 		print ERROR: VERSION field not allowed to have '"-"' in it
 		exit 1
 	;;
+	*,REV=20[01][0-9].[0-9][0-9].[0-9][0-9]*)
+		:
+	;;
+	*)
+		print ERROR: no REV=YYYY.MM.DD field in VERSION
+		exit 1
+	;;
 esac
 
 case $pkgarch in
@@ -377,17 +395,19 @@
 	# man ld.so.1 for more info on this hack
 	export LD_NOAUXFLTR=1
 
-	listbinaries $EXTRACTDIR/$pkgname >$EXTRACTDIR/tmplist
+	listbinaries $EXTRACTDIR/$pkgname >$EXTRACTDIR/elflist
 	# have to do this for ldd to work. arrg.
-	if [ -s "$EXTRACTDIR/tmplist" ] ; then
-		chmod 0755 `cat $EXTRACTDIR/tmplist`
+	if [ -s "$EXTRACTDIR/elflist" ] ; then
+		chmod 0755 `cat $EXTRACTDIR/elflist`
 
-	#cat $EXTRACTDIR/tmplist| xargs ldd  2>/dev/null |fgrep  '.so' |
+	#cat $EXTRACTDIR/elflist| xargs ldd  2>/dev/null |fgrep  '.so' |
 	#              sed 's:^.*=>[^/]*::' | nawk '{print $1}' |sort -u >$EXTRACTDIR/liblist
 
-		cat $EXTRACTDIR/tmplist| xargs dump -Lv |nawk '$2=="NEEDED"{print $3}' |
+		cat $EXTRACTDIR/elflist| xargs dump -Lv |nawk '$2=="NEEDED"{print $3}' |
 			sort -u | egrep -v $EXTRACTDIR >$EXTRACTDIR/liblist
 
+			
+
 		print libraries used are:
 		cat $EXTRACTDIR/liblist
 		print "cross-referencing with depend file (May take a while)"
@@ -399,6 +419,10 @@
 #If these dont exist, it is Bad.
 touch $EXTRACTDIR/liblist $EXTRACTDIR/libpkgs
 
+# store things that look like shared objects from the package map for
+# delayed library validation.
+grep "\.so" $EXTRACTDIR/$pkgname/pkgmap >> $SETLIBS
+
 if [[ -f $EXTRACTDIR/$pkgname/install/depend ]] ; then
 	print 
 	print "Examining 'depend' file"
@@ -416,11 +440,26 @@
 	exit 1
 fi
 
+#to retain a record of all packages currently being examined from $@
+echo $pkgname >> $SETDEPS
+
 nawk '$1=="P" {print $2}'  $EXTRACTDIR/$pkgname/install/depend |
 	sort >$EXTRACTDIR/deppkgs
 for dep in `cat $EXTRACTDIR/deppkgs`
 do
-	pkginfo $dep || warnmsg  invalid package $dep specified
+    pkginfo $dep
+    if [[ $? -ne 0 ]]; then
+	#if we've already looked at the package named $dep,
+	#it'll be in the file.
+ 	awk "\$1 == \"$dep\" {print}" $SETDEPS | /usr/xpg4/bin/grep -q $dep
+ 	if [[ $? -ne 0 ]]; then #we haven't yet seen this package in our set
+	    echo "Can't validate dependence on $dep.  Storing for delayed validation."
+	    #store for validation at the end.
+	    echo "$dep $pkgname" >> $SETDEPS.missing
+	else
+	    echo "Found $dep as part of the package set being evaluated."
+	fi
+    fi
 done
 
 egrep -v 'SUNWbcp|SUNWowbcp|SUNWucb' /var/sadm/install/contents |
@@ -433,13 +472,20 @@
 	if [[ $? -eq 0 ]] ; then
 		echo $lib provided by package itself
 		continue
+	else
+	    grep "[/=]$lib[ =]" $SETLIBS
+	    if [[ $? -eq 0 ]]; then
+		echo "$lib provided by package set being evaluated."
+		continue
+	    fi
 	fi
 
 	libpkg=`grep /$lib $EXTRACTDIR/shortcatalog |
 	      sed 's/^.* \([^ ]*\)$/\1/' |sort -u`
 
 	if [[ -z "$libpkg" ]] ; then
-		warnmsg cannot find package for $lib
+		echo "$lib $pkgname" >> $SETLIBS.missing
+		print Cannot find package providing $lib.  Storing for delayed validation.
 	else
 		print $libpkg | fmt -1 >>$EXTRACTDIR/libpkgs
 	fi
@@ -458,19 +504,53 @@
 
 
 if [[ "$basedir" != "" ]] ; then
-	print 
-	print "Checking relocation ability..."
-	xargs strings <$EXTRACTDIR/tmplist | grep /opt/csw
-	if [[ $? -eq 0 ]] ; then
-		errmsg package build as relocatable, but binaries have hardcoded /opt/csw paths in them
+	print
+	if [[ -f $EXTRACTDIR/elflist ]] ; then
+		print "Checking relocation ability..."
+		xargs strings < $EXTRACTDIR/elflist| grep /opt/csw
+		if [[ $? -eq 0 ]] ; then
+			errmsg package build as relocatable, but binaries have hardcoded /opt/csw paths in them
+		else
+			print trivial check passed
+		fi
 	else
-		print trivial check passed
+		echo No relocation check done for non-binary relocatable package.
 	fi
 fi
 
+
 cleanup
 
-
 print ""
 
 done
+
+if [ -s $SETDEPS.missing ]; then
+    print "Doing late evaluations of package dependencies."
+    while read mdep; do
+	dep=`echo $mdep | nawk '{print $1}'`
+	pkg=`echo $mdep | nawk '{print $2}'`
+	/usr/xpg4/bin/grep -q $dep $SETDEPS
+	if [ $? -ne 0 ]; then
+	    errmsg "Couldn't validate $dep as a dependency in package $pkg"
+	else
+	    print "Validated $dep as a dependency for $pkg."
+	fi
+    done < $SETDEPS.missing
+fi
+
+if [ -s $SETLIBS.missing ]; then
+    print "Doing late evaluations of package library dependencies."
+    while read ldep; do
+	lib=`echo $ldep | nawk '{print $1}'`
+	pkg=`echo $ldep | nawk '{print $2}'`
+	/usr/xpg4/bin/grep -q "[/=]$lib[ =]" $SETLIBS
+	if [ $? -ne 0 ]; then
+	    errmsg "Couldn't find a package providing $lib"
+	else
+	    print "A package in the set being evaluated provides $lib"
+	fi
+    done < $SETLIBS.missing
+fi
+
+cleanupset


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list