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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Thu Dec 24 02:13:46 CET 2009


Revision: 7729
          http://gar.svn.sourceforge.net/gar/?rev=7729&view=rev
Author:   wahwah
Date:     2009-12-24 01:13:45 +0000 (Thu, 24 Dec 2009)

Log Message:
-----------
checkpkg.d: checking multiple packages

Modified Paths:
--------------
    csw/mgar/gar/v2-checkpkg/bin/checkpkg
    csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg-dummy.py
    csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg-libs.py
    csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg.py

Modified: csw/mgar/gar/v2-checkpkg/bin/checkpkg
===================================================================
--- csw/mgar/gar/v2-checkpkg/bin/checkpkg	2009-12-23 23:53:20 UTC (rev 7728)
+++ csw/mgar/gar/v2-checkpkg/bin/checkpkg	2009-12-24 01:13:45 UTC (rev 7729)
@@ -35,11 +35,17 @@
 	if [[ -d "$EXTRACTDIR" ]] ; then
 		rm -rf $EXTRACTDIR
 	fi
-	if [[ "$TMPARCHIVE" != "" ]] ; then
-		[ -f "$TMPARCHIVE" ] && rm $TMPARCHIVE
-	fi
+	cleantmparchives
 }
 
+cleantmparchives() {
+	for TMPARCHIVE in $tmparchives; do
+		if [[ "$TMPARCHIVE" != "" ]]; then
+			[ -f "$TMPARCHIVE" ] && rm $TMPARCHIVE
+		fi
+	done
+}
+
 cleanupset(){
     if [ "`echo $SETINF*`" != "$SETINF*" ]; then
 	rm $SETINF*
@@ -61,6 +67,22 @@
 	exit 1
 }
 
+set_variables_for_individual_package_check() {
+	f=$1
+	file $f |sed 's/^.*://' |grep gzip >/dev/null
+	if [ $? -eq 0 ] ; then
+		TMPARCHIVE=/tmp/`basename $f`
+		if [[ -f $TMPARCHIVE ]] ; then
+			print ERROR: $TMPARCHIVE already exists
+			
+		fi
+		gzcat $f >$TMPARCHIVE || exit 1
+		f=$TMPARCHIVE
+	fi
+	pkgname=`nawk 'NR == 2 {print $1; exit;}' $f`
+	pkgnames="$pkgnames $pkgname"
+}
+
 if [[ "$1" == "-e" ]] ; then
 	quit_on_warn=1;
 	shift
@@ -75,8 +97,16 @@
 SETINF=/tmp/checkpkg.$$.`date +%Y%m%d%H%M%S`
 SETLIBS=$SETINF.libs
 SETDEPS=$SETINF.deps
+pkgnames=""
+tmparchives=""
 
+EXTRACTDIR=/tmp/dissect.$$
 
+if [ -d $EXTRACTDIR ] ; then
+	print ERROR: $EXTRACTDIR already exists
+	exit 1
+fi
+
 for f in "$@"
 do
 
@@ -89,9 +119,6 @@
 
 
 case $f in
-	cswutils-*)
-		:
-	;;
 	*)
 	print Examining $f
 
@@ -118,30 +145,13 @@
 	done
 esac
 
-print Extracting files for more detailed inspection...
+print Extracting all files for more detailed inspection...
 
-file $f |sed 's/^.*://' |grep gzip >/dev/null
-if [ $? -eq 0 ] ; then
-	TMPARCHIVE=/tmp/`basename $f`
-	if [[ -f $TMPARCHIVE ]] ; then
-		print ERROR: $TMPARCHIVE already exists
-		
-	fi
-	gzcat $f >$TMPARCHIVE || exit 1
-	f=$TMPARCHIVE
-fi
+set_variables_for_individual_package_check "$f"
 
-pkgname=`nawk 'NR == 2 {print $1; exit;}' $f`
-
-EXTRACTDIR=/tmp/dissect.$$
-
-if [ -d $EXTRACTDIR ] ; then
-	print ERROR: $EXTRACTDIR already exists
-	exit 1
-fi
-
 mkdir $EXTRACTDIR
 
+# FIXME: This doesn't support multiple packages
 TMPFILE=$EXTRACTDIR/pkginfo
 
 
@@ -311,7 +321,6 @@
 print Extracing pkg for examination of files...
 pkgtrans $f $EXTRACTDIR $pkgname
 
-
 #############################################################
 # We now have the package expanded, in "directory" form, in
 # $EXTRACTDIR/$pkgname
@@ -542,6 +551,15 @@
 # checkpkg is.  Each plugin file name should be an executable and begin with
 # "checkpkg-".
 
+tmparchives="$tmparchives $TMPARCHIVE"
+done
+
+# All packages have been extracted.
+
+# Now running all the plugin checks
+
+set_variables_for_individual_package_check "$f"
+
 echo "Running the experimental plugin infrastructure."
 checkpkg_scriptname=`basename $0`
 checkpkg_basedir=${0%/${checkpkg_scriptname}}
@@ -551,8 +569,8 @@
 	# echo plugin dir exists
 	for plugin in "${plugindir}"/checkpkg-*; do
 		if [[ -x "${plugin}" ]]; then
-			echo "Executing: '${plugin} -e \"${EXTRACTDIR}\" -p \"${pkgname}\"'"
-			${plugin} -e "${EXTRACTDIR}" -p "${pkgname}"
+			echo "Executing: ${plugin} -e \"${EXTRACTDIR}\" ${pkgnames}"
+			${plugin} -e "${EXTRACTDIR}" ${pkgnames}
 			if [[ "$?" -ne 0 ]]; then
 				errmsg "Plugin ${plugin} has returned an error."
 			fi
@@ -565,11 +583,13 @@
 fi
 # End of plugin section
 
-cleanup
+# Not doing the cleanup now
+# cleanup
 
 print ""
 
-done
+# Cleaning up after all packages
+cleanup
 
 if [ -s $SETDEPS.missing ]; then
     print "Doing late evaluations of package dependencies."

Modified: csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg-dummy.py
===================================================================
--- csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg-dummy.py	2009-12-23 23:53:20 UTC (rev 7728)
+++ csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg-dummy.py	2009-12-24 01:13:45 UTC (rev 7729)
@@ -6,11 +6,14 @@
 
 def main():
   options, args = checkpkg.GetOptions()
-  pkgpath = os.path.join(options.extractdir, options.pkgname)
-  if not os.path.isdir(pkgpath):
-  	raise checkpkg.PackageError("The package directory doesn't exist: %s" % pkgpath)
-  print ("Dummy plugin says the package %s is extracted to %s"
-         % (options.pkgname, options.extractdir))
+  if not os.path.isdir(options.extractdir):
+  	raise checkpkg.PackageError("The extract base directory doesn't exist: %s" % options.extractdir)
+  for pkgname in args:
+    pkgpath = os.path.join(options.extractdir, pkgname)
+    if not os.path.isdir(pkgpath):
+      raise checkpkg.PackageError("The package directory doesn't exist: %s" % pkgpath)
+    print ("Dummy plugin says the package %s is extracted to %s"
+           % (pkgname, options.extractdir))
 
 
 if __name__ == '__main__':

Modified: csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg-libs.py
===================================================================
--- csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg-libs.py	2009-12-23 23:53:20 UTC (rev 7728)
+++ csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg-libs.py	2009-12-24 01:13:45 UTC (rev 7729)
@@ -19,8 +19,16 @@
 def main():
   logging.basicConfig(level=logging.DEBUG)
   options, args = checkpkg.GetOptions()
-  checker = checkpkg.CheckpkgBase(options.extractdir, options.pkgname)
-  binaries = checker.ListBinaries()
+  pkgnames = args
+  checkers = []
+  for pkgname in pkgnames:
+    checker = checkpkg.CheckpkgBase(options.extractdir, pkgname)
+    checkers.append(checker)
+  binaries = []
+  for checker in checkers:
+    binaries.extend(checker.ListBinaries())
+  # Make them unique
+  binaries = set(binaries)
   ws_re = re.compile(r"\s+")
 
   # if [[ "$goodarch" = "yes" ]] ; then
@@ -128,6 +136,9 @@
     else:
     	print ("%s is required by %s, but we don't know what provides it."
     	       % (soname, binaries_by_soname[soname]))
+  # TODO: extract package names from the pkgmap lines
+  # TODO: print per-package deps (requires the transition: pkgname -> soname ->
+  # pkgname)
 
   # for lib in `cat $EXTRACTDIR/liblist` ; do
   #   grep "[/=]$lib[ =]" $EXTRACTDIR/$pkgname/pkgmap

Modified: csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg.py
===================================================================
--- csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg.py	2009-12-23 23:53:20 UTC (rev 7728)
+++ csw/mgar/gar/v2-checkpkg/bin/checkpkg.d/checkpkg.py	2009-12-24 01:13:45 UTC (rev 7729)
@@ -29,16 +29,12 @@
   parser = optparse.OptionParser()
   parser.add_option("-e", dest="extractdir",
                     help="The directory into which the package has been extracted")
-  parser.add_option("-p", dest="pkgname",
-                    help="The pkgname, e.g. CSWfoo")
   parser.add_option("-d", "--debug", dest="debug",
                     default=False, action="store_true",
                     help="Turn on debugging messages")
   (options, args) = parser.parse_args()
   if not options.extractdir:
     raise ConfigurationError("ERROR: -e option is missing.")
-  if not options.pkgname:
-    raise ConfigurationError("ERROR: -p option is missing.")
   return options, args
 
 


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