[csw-devel] SF.net SVN: gar:[4858] csw/mgar/pkg

dmichelsen at users.sourceforge.net dmichelsen at users.sourceforge.net
Thu May 14 22:40:01 CEST 2009


Revision: 4858
          http://gar.svn.sourceforge.net/gar/?rev=4858&view=rev
Author:   dmichelsen
Date:     2009-05-14 20:40:01 +0000 (Thu, 14 May 2009)

Log Message:
-----------
cswutils: Initial commit

Added Paths:
-----------
    csw/mgar/pkg/cswutils/
    csw/mgar/pkg/cswutils/branches/
    csw/mgar/pkg/cswutils/tags/
    csw/mgar/pkg/cswutils/trunk/
    csw/mgar/pkg/cswutils/trunk/Makefile
    csw/mgar/pkg/cswutils/trunk/checksums
    csw/mgar/pkg/cswutils/trunk/files/
    csw/mgar/pkg/cswutils/trunk/files/COPYING
    csw/mgar/pkg/cswutils/trunk/files/checkpkg
    csw/mgar/pkg/cswutils/trunk/files/checkpkg.8
    csw/mgar/pkg/cswutils/trunk/files/cpan2pkg
    csw/mgar/pkg/cswutils/trunk/files/createpkg
    csw/mgar/pkg/cswutils/trunk/files/createpkg.8
    csw/mgar/pkg/cswutils/trunk/files/stagepkg
    csw/mgar/pkg/cswutils/trunk/files/stagepkg.8


Property changes on: csw/mgar/pkg/cswutils/trunk
___________________________________________________________________
Added: svn:ignore
   + cookies
download
work


Added: svn:externals
   + gar https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/gar/v2


Added: csw/mgar/pkg/cswutils/trunk/Makefile
===================================================================
--- csw/mgar/pkg/cswutils/trunk/Makefile	                        (rev 0)
+++ csw/mgar/pkg/cswutils/trunk/Makefile	2009-05-14 20:40:01 UTC (rev 4858)
@@ -0,0 +1,47 @@
+GARNAME = cswutils
+GARVERSION = 1.14.0
+CATEGORIES = utils
+
+DESCRIPTION = Utilities for CSW maintainers
+define BLURB
+endef
+
+MASTER_SITES = 
+DISTFILES = COPYING
+DISTFILES += checkpkg checkpkg.8
+DISTFILES += cpan2pkg
+DISTFILES += createpkg createpkg.8
+DISTFILES += stagepkg stagepkg.8
+
+REQUIRED_PKGS = CSWtextutils CSWfakeroot CSWperl
+
+WORKSRC = $(WORKDIR)
+
+CONFIGURE_SCRIPTS =
+BUILD_SCRIPTS =
+TEST_SCRIPTS =
+INSTALL_SCRIPTS = custom
+
+SPKG_SOURCEURL = http://www.opencsw.org/
+
+ARCHALL = 1
+
+# The package contains 'checkpkg', which checks for bad pathes. Of
+# course the bad pathes are inside the package, because it is checked
+# for them. So disable the test.
+ENABLE_CHECK = 0
+
+include gar/category.mk
+
+install-custom:
+	@ginstall -d $(DESTDIR)$(bindir)
+	@ginstall $(WORKSRC)/checkpkg $(DESTDIR)$(bindir)
+	@ginstall $(WORKSRC)/cpan2pkg $(DESTDIR)$(bindir)
+	@ginstall $(WORKSRC)/createpkg $(DESTDIR)$(bindir)
+	@ginstall $(WORKSRC)/stagepkg $(DESTDIR)$(bindir)
+	@ginstall $(GARDIR)/bin/fixlibtool $(DESTDIR)$(bindir)
+	@ginstall -d $(DESTDIR)$(mandir)/man8
+	@ginstall $(WORKSRC)/checkpkg.8 $(DESTDIR)$(mandir)/man8/
+	@ginstall $(WORKSRC)/createpkg.8 $(DESTDIR)$(mandir)/man8/
+	@ginstall $(WORKSRC)/stagepkg.8 $(DESTDIR)$(mandir)/man8/
+	@$(MAKECOOKIE)

Added: csw/mgar/pkg/cswutils/trunk/checksums
===================================================================
--- csw/mgar/pkg/cswutils/trunk/checksums	                        (rev 0)
+++ csw/mgar/pkg/cswutils/trunk/checksums	2009-05-14 20:40:01 UTC (rev 4858)
@@ -0,0 +1,8 @@
+091b12575ebc0e45cf8c3d8b43d8b638  download/COPYING
+7e5a50f1db3b6688c58da693f9ac408e  download/checkpkg
+6ec3b6597e04714430987ccc199db3c4  download/checkpkg.8
+9a637f6546cc50974159a987302d91c0  download/cpan2pkg
+2349d876bada6ee1bf025e576ec2c465  download/createpkg
+a605598f30195f9ab1b29fc3944d3b31  download/createpkg.8
+cd4496ee27bf86d5c8bc656c9c5974be  download/stagepkg
+8908a0a898aa07a7a928b2b8bd8384f0  download/stagepkg.8

Added: csw/mgar/pkg/cswutils/trunk/files/COPYING
===================================================================
--- csw/mgar/pkg/cswutils/trunk/files/COPYING	                        (rev 0)
+++ csw/mgar/pkg/cswutils/trunk/files/COPYING	2009-05-14 20:40:01 UTC (rev 4858)
@@ -0,0 +1,4 @@
+These script(s) are utility scripts used by people who package software
+for opencsw.org's Solaris "Community SoftWare" (CSW) effort.
+The scripts may be copied free of charge, but may be of limited use
+to other folks.

Added: csw/mgar/pkg/cswutils/trunk/files/checkpkg
===================================================================
--- csw/mgar/pkg/cswutils/trunk/files/checkpkg	                        (rev 0)
+++ csw/mgar/pkg/cswutils/trunk/files/checkpkg	2009-05-14 20:40:01 UTC (rev 4858)
@@ -0,0 +1,586 @@
+#!/bin/ksh -p
+
+# checkpkg 2.6
+# This script examines a package that has been put together
+# for submittal to the CSW archive at opencsw.org
+#
+# It examines it for compliance with the packaging standards at
+# http://www.opencsw.org/standards/
+# It DOES NOT CATCH EVERYTHING. However, the package will be
+# tested with this script before acceptance, so you may as well
+# save yourself some time, and run the script yourself!
+#
+# Be sure to occasionally do a "pkg-get update cswutils" so that
+# you know you are tracking the most current version.
+# 
+
+
+PATH=$PATH:/usr/sbin
+
+LOCAL_ARCH=`uname -p`
+
+
+# always print out a warning message. (to stderr)
+# exit script, if quit_on_warn set
+
+
+cleanup(){
+	if [[ -d "$EXTRACTDIR" ]] ; then
+		rm -rf $EXTRACTDIR
+	fi
+	if [[ "$TMPARCHIVE" != "" ]] ; then
+		rm $TMPARCHIVE
+	fi
+}
+
+warnmsg(){
+	print WARNING: $* >/dev/fd/2
+	if [[ "$quit_on_warn" != "" ]] ; then
+		cleanup
+		exit 1
+	fi
+}
+
+# Print error message, and quit program.
+errmsg(){
+	print ERROR: $* >/dev/fd/2
+	cleanup
+	exit 1
+}
+
+if [[ "$1" == "-e" ]] ; then
+	quit_on_warn=1;
+	shift
+fi
+if [[ "$1" == "-h" ]] ; then
+	print 'Usage: checkpkg [-e] pkg1 [pkg2 ....]'
+	print '   -e = "exit on warnings"'
+	shift
+fi
+
+for f in "$@"
+do
+
+
+
+if [[ ! -f $f ]] ; then
+	print ERROR: $f does not exist
+	exit 1
+fi
+
+
+case $f in
+	cswutils-*)
+		:
+	;;
+	*)
+	print Examining $f
+
+	print Looking for bad strings...
+
+	# XPG4 grep has some kind of magical "ignore ELF header" power.
+	#  but... not on sol8, just sol10?
+	# and so does /bin/grep. but NOT /bin/egrep???
+	#
+	# Need to rewrite this whole thing to also
+	# check for badly set RUNPATHs. sigh.
+	#
+	for badpath in /export/medusa /opt/build ; do
+		GREP=/bin/grep gzgrep "$badpath" $f
+		if [[ $? -eq 0 ]] ; then
+			print ""
+			print ERROR: build-machine paths found in file $f
+			print '($badpath)'
+			exit 1
+		fi
+	done
+esac
+
+print Extracting 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
+
+pkgname=`nawk 'NR == 2 {print $1; exit;}' $f`
+
+EXTRACTDIR=/tmp/checkpkg.$$
+
+if [ -d $EXTRACTDIR ] ; then
+	print ERROR: $EXTRACTDIR already exists
+	exit 1
+fi
+
+mkdir $EXTRACTDIR
+
+TMPFILE=$EXTRACTDIR/pkginfo
+
+
+
+dd if=$f skip=1 | (cd $EXTRACTDIR; cpio -ivd $pkgname/pkginfo)
+if [[ $? -ne 0 ]] ; then
+	print ERROR: could not extract $f
+	rm -rf $EXTRACTDIR $TMPARCHIVE
+	exit 1
+fi
+
+mv $EXTRACTDIR/$pkgname/pkginfo $EXTRACTDIR ; rmdir $EXTRACTDIR/$pkgname
+
+software=`sed -n 's/^NAME=\([^ -]*\) -.*$/\1/p' $TMPFILE`
+version=`sed -n 's/^VERSION=//p' $TMPFILE`
+desc=`sed -n 's/^DESC=//p' $TMPFILE`
+email=`sed -n 's/^EMAIL=//p' $TMPFILE`
+maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
+hotline=`sed -n 's/^HOTLINE=//p' $TMPFILE`
+basedir=`sed -n 's/^BASEDIR=//p' $TMPFILE`
+pkgarch=`sed -n 's/^ARCH=//p' $TMPFILE|head -1`
+
+case $software in
+     *[A-Z]*)
+	echo ERROR: $software must be all lowercase
+	exit 1
+	;;
+esac
+
+case `basename $f` in
+	${software}-${version}-*)
+		# file name looks okay
+	;;
+	${software}-*)
+		print ERROR: filename missing full version field $version
+		rm -rf $EXTRACTDIR $TMPARCHIVE
+		 exit 1
+	;;
+	*)
+		print ERROR: filename  should start with $software-$version-
+		rm -rf $EXTRACTDIR $TMPARCHIVE
+		exit  1
+esac
+
+
+
+if [ "$maintname" = "" ] ; then
+	# the old format, in the DESC field
+	maintname=`sed -n 's/^DESC=.*for CSW by //p' $TMPFILE`
+
+	# Since the DESC field has been coopted, take
+	# description from second half of NAME field now.
+	desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
+else
+	if [ "$desc" = "" ] ; then
+		desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
+	fi
+fi
+
+rm $TMPFILE
+
+# strip out '' chars, because it interferes with mysql
+desc=`print $desc | sed "s/'//g"`
+
+
+print Info for pkg $pkgname
+
+print software= "'$software'"
+print arch= "'$pkgarch'"
+print desc="'$desc'"
+print pkgname="'$pkgname'"
+print version="'$version'"
+print maintainer name="'$maintname'"
+print maint email="'$email'"
+print hotline="'$hotline'"
+if [ "$basedir" != "" ] ; then
+	print basedir="'$basedir'"
+fi
+
+if [[ ${#software} -gt 20 ]] ; then errmsg $f: software name greater than 20 chars ; fi
+if [[ ${#pkgname} -gt 20 ]] ; then errmsg $f: pkg name greater than 20 chars; fi
+
+if [ "$software" = "" ] ; then errmsg $f: software field not set properly in NAME ; fi
+if [ "$pkgname" = "" ] ; then errmsg $f: pkgname field blank ; fi
+if [ "$desc" = "" ] ; then errmsg $f: no description in either NAME or DESC field ; fi
+if [ ${#desc} -gt 100 ] ; then errmsg $f: description greater than 100 chars ; fi
+if [ "$version" = "" ] ; then errmsg $f: VERSION field blank ;  fi
+if [ "$maintname" = "" ] ; then errmsg $f: maintainer name not detected. Fill out VENDOR field properly ; fi
+if [ "$email" = "" ] ; then errmsg $f: EMAIL field blank ; fi
+if [ "$hotline" = "" ] ; then errmsg $f: HOTLINE field blank ; fi
+
+
+case $version in
+	*-*)
+		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
+	sparc|i386|all)
+	;;
+	sparc.*|i386.*)
+	;;
+
+	*)
+	print ERROR: non-standard ARCH def in package: $pkgarch
+	rm -rf $EXTRACTDIR $TMPARCHIVE
+	exit 1
+esac
+
+goodarch=yes
+case $f in
+	*${LOCAL_ARCH}*)
+		
+	;;
+	*)
+		print NOTE: pkg must be for arch $LOCAL_ARCH to check dynamic libs
+		goodarch=no		
+	;;
+esac
+
+
+#if [ "$goodarch" = "no" ] ; then
+#	# neutral architechture. cant check libraries for it.
+#	print ""
+#	rm -rf $EXTRACTDIR $TMPARCHIVE
+#	exit 0
+#fi
+
+
+# This function exists, because pkgtrans is BROKEN!!
+# It leaves a directory in /var/tmp/aaXXXXXXX, even after clean quit
+# SO, emulate pkgtrans behaviour, for "pkgtrans src destdir pkgname"
+#   Except that we ignore pkgname arg, and just do first one we find.
+#  and we are a bit hacky about how we do things.
+pkgtrans(){
+	if [[ ! -d $2 ]] ; then
+		print ERROR: $2 is not a directory >/dev/fd/2
+		return 1
+	fi
+	hdrblks=`(dd if=$1 skip=1 2>/dev/null| cpio -i -t  >/dev/null) 2>&1 |
+		nawk '{print $1; exit;}'`
+
+	## print initial hdrblks=$hdrblks
+
+	hdrblks=$(($hdrblks + 1))
+	mkdir $2/$3 || return 1
+
+	dd if=$1 skip=$hdrblks 2>/dev/null | (cd $2/$3 ; cpio -ivdm)
+	# on fail, SOMETIMES cpio returns 1, but sometimes it returns 0!!
+	if [[ ! -d $2/$3/install ]] ; then
+		print retrying extract with different archive offset...
+		# no, I cant tell in advance why/when the prev fails
+		hdrblks=$(($hdrblks + 1))
+		dd if=$1 skip=$hdrblks 2>/dev/null| (cd $2/$3 ; cpio -ivdm)
+	fi
+}
+
+print ""
+print Extracing pkg for examination of files...
+pkgtrans $f $EXTRACTDIR $pkgname
+
+
+#############################################################
+# We now have the package expanded, in "directory" form, in
+# $EXTRACTDIR/$pkgname
+# Now do some extended error checking on it.
+# This is similar to Debians "Lintian" phase for packages.
+
+/usr/sbin/pkgchk -d $EXTRACTDIR $pkgname || errmsg "Package failed integrity check"
+
+print "/usr/sbin/pkgchk passed."
+
+
+########################################
+# Check for some common errors
+if [[ $pkgname != "CSWcommon" ]] ; then
+
+	if [[ $LOGNAME != "root" ]] ; then
+		nawk '$6 == "'$LOGNAME'" {print; exit 1}' $EXTRACTDIR/$pkgname/pkgmap
+		if [[ $? -eq 1 ]] ; then
+			print ERROR: files owned by $LOGNAME in prototype file
+			rm -rf $EXTRACTDIR $TMPARCHIVE
+			exit 1
+		fi
+	fi
+
+	egrep 'd none /opt ' $EXTRACTDIR/$pkgname/pkgmap
+	if [[ $? -eq 0 ]] ; then
+	errmsg You should not have an entry for /opt in your prototype file
+	fi
+	egrep 'd none [^ ]* 06' $EXTRACTDIR/$pkgname/pkgmap
+	if [[ $? -eq 0 ]] ; then
+	errmsg You must have execute permission set on directories
+	fi
+	egrep '/opt/csw/man|d none man' $EXTRACTDIR/$pkgname/pkgmap
+	if [[ $? -eq 0 ]] ; then
+	errmsg /opt/csw/man should not have a directory entry in prototype
+	fi
+	egrep '/opt/csw/doc|d none doc' $EXTRACTDIR/$pkgname/pkgmap
+	if [[ $? -eq 0 ]] ; then
+	errmsg /opt/csw/doc should not have a directory entry in prototype
+	fi
+	egrep '/opt/csw/info|d none info' $EXTRACTDIR/$pkgname/pkgmap
+	if [[ $? -eq 0 ]] ; then
+	errmsg /opt/csw/info should not have a directory entry in prototype
+	fi
+	egrep 'lib/charset.alias' $EXTRACTDIR/$pkgname/pkgmap
+	if [[ $? -eq 0 ]] ; then
+	warnmsg Only CSWiconv should have lib/charset.alias in it
+	fi
+	egrep 'share/locale/locale.alias' $EXTRACTDIR/$pkgname/pkgmap
+	if [[ $? -eq 0 ]] ; then
+	warnmsg Only CSWcommon should have share/locale/locale.alias in it
+	fi
+	fgrep  '? ? ?' $EXTRACTDIR/$pkgname/pkgmap |
+	egrep '[/]opt[/]csw'
+	if [[ $? -eq 0 ]] ; then
+	errmsg "You should only use '? ? ?' for non-csw paths. Use appropriate explicit perms/ownership instead"
+	fi
+	# this is like "installed package info". It is acceptible
+	# to update it in a postinstall script, but not have it
+	# directly in the pkgmap. A "e" entry might be acceptible though.
+	egrep ' f .*/perllocal.pod' $EXTRACTDIR/$pkgname/pkgmap
+	if [[ $? -eq 0 ]] ; then
+	errmsg perllocal.pod should be removed from prototype file
+	fi
+fi
+# special case. sigh.
+if [[ $pkgname != "CSWtexinfo" ]] ; then
+	egrep '/opt/csw/share/info/dir[ ]|none share/info/dir[ ]' $EXTRACTDIR/$pkgname/pkgmap
+	if [[ $? -eq 0 ]] ; then
+	errmsg /opt/csw/share/info/dir should only be in CSWtexinfo
+	rm -rf $EXTRACTDIR $TMPARCHIVE
+	exit 1
+	fi
+fi
+#########################################
+# find all executables and dynamic libs,and list their filenames.
+listbinaries() {
+	if [ ! -d $1 ] ; then
+		print errmsg $1 not a directory
+		rm -rf $EXTRACTDIR
+		exit 1
+	fi
+
+	find $1 -print | xargs file |grep ELF |nawk -F: '{print $1}'
+}
+
+# Kinda a hardcode for one special package that cant be
+# detected by normal lib dependancies.
+checkforclasses () {
+	typeset local=no
+	classlist=`sed -n 's/CLASSES=//p' $EXTRACTDIR/$pkgname/pkginfo`
+	for c in $classlist ; do
+		case $c in
+			csw*)
+				local=yes
+			;;
+		esac
+	done
+	if [[ "$local" != "yes" ]] ; then
+		return 0;
+	fi
+	if grep CSWcswclassutils $EXTRACTDIR/$pkgname/install/depend >/dev/null
+	then
+		return 0;
+	fi
+	echo ERROR: package uses a csw CLASS but missing dependancy on CSWcswclassutils
+	return 1
+}
+
+
+# pass in name of dynamic object, and specific catalog file.
+# Will attempt "best match" heuristics appropriate for CSW dependancy file
+# and print out result.
+# We will always print out either ONE package, or NOTHING
+findlibincat() {
+	# important to use same grep as we did looking through pkgmap
+	 grep "[/=]$1[ =]" $2 |
+	      nawk '
+	      	$2 == "f" || $2 == "l" {pkg=$NF;next}
+		# Give 'real' files priority over symlinks
+		{if(pkg==""){pkg=$NF};
+		 next }
+		END {print pkg}
+	      	'
+
+	#old simple (inadequate) way:
+	# grep /$1 $2 |
+	#	      nawk '{print $NF}' |sort -u
+}
+
+####################################################################
+# Auto-dependancy checking section....
+# strategy currently: identify all ELF object files to elflist.
+# Then identify all dependancies to "liblist"
+# THEEEN go searching through SVR4 pkg "contents" file for PKG matches
+#   to those libraries.
+#   (but give priority to lib dependancies satisfied by current PKG itself)
+# Final output is saved to file "libpkgs"
+######################################################################
+sparccheck=""; sparcwarning=""
+if [[ "$pkgarch" = "sparc" ]] ; then
+	if [[ -d $EXTRACTDIR/$pkgname/root/opt/csw/bin ]] ; then
+		sparccheck=$EXTRACTDIR/$pkgname/root/opt/csw/bin
+	elif [[ -d $EXTRACTDIR/$pkgname/reloc/bin ]] ; then
+		sparccheck=$EXTRACTDIR/$pkgname/reloc/bin
+	fi
+	if [[ "$sparccheck" != "" ]] ; then
+		(cd $sparccheck && file *) | grep 'ELF.*V8+'
+		if [[ $? = 0 ]] ; then
+			sparcwarning="WARNING: found binaries in normal bin dir that are V8+"
+		fi
+	fi
+fi
+if [[ "$goodarch" = "yes" ]] ; then
+	# man ld.so.1 for more info on this hack
+	export LD_NOAUXFLTR=1
+
+	listbinaries $EXTRACTDIR/$pkgname >$EXTRACTDIR/elflist
+	# have to do this for ldd to work. arrg.
+	if [ -s "$EXTRACTDIR/elflist" ] ; then
+		chmod 0755 `cat $EXTRACTDIR/elflist`
+
+	#cat $EXTRACTDIR/elflist| xargs ldd  2>/dev/null |fgrep  '.so' |
+	#              sed 's:^.*=>[^/]*::' | nawk '{print $1}' |sort -u >$EXTRACTDIR/liblist
+
+		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
+	else
+		print No dynamic libraries in the package
+	fi
+fi
+
+#If these dont exist, it is Bad.
+touch $EXTRACTDIR/liblist $EXTRACTDIR/libpkgs
+
+if [[ -f $EXTRACTDIR/$pkgname/install/depend ]] ; then
+	print 
+	print "Examining 'depend' file"
+	cat $EXTRACTDIR/$pkgname/install/depend
+	print ""
+else
+	# They may have forgotten to create/add in a depend file
+	# Remind people what the package depends on
+	# print "Analysing dynamic dependancies, if any"
+	touch $EXTRACTDIR/$pkgname/install/depend
+fi
+
+# sanity check against "depends on self"
+nawk '$2=="'$pkgname'" {exit 1}' $EXTRACTDIR/$pkgname/install/depend
+if [[ $? -ne 0 ]] ; then
+	print ERROR: $pkgname references self in depend file
+	exit 1
+fi
+
+nawk '$1=="P" {print $2}'  $EXTRACTDIR/$pkgname/install/depend |
+	sort >$EXTRACTDIR/deppkgs
+for dep in `cat $EXTRACTDIR/deppkgs`
+do
+	pkginfo $dep || errmsg  Invalid package $dep specified. Check of $f fails
+done
+
+   #strategy update: poorly grep for all possible matches against our liblist,
+   # and save in "shortcswcatalog". and now "shortsuncatalog" too.
+   # in theory, slower for small pkgs, but should be faster for pkgs
+   # with lots of shared libs.
+   #
+
+
+if test -s $EXTRACTDIR/liblist ; then
+	print Building index from SVR4 installed packages database...
+	print '(May take a while)'
+	#It's noticably faster (30%) this way, than the second way, at least on a
+	# multiproc box.
+	grep CSW /var/sadm/install/contents |nawk '$2 ~ /^[fsl]$/ {print}' |
+		fgrep -f $EXTRACTDIR/liblist >$EXTRACTDIR/shortcswcatalog
+	grep SUNW /var/sadm/install/contents |nawk '$2 ~ /^[fsl]$/ {print}' |
+		egrep -v 'SUNWbcp|SUNWowbcp|SUNWucb' |
+		fgrep -f $EXTRACTDIR/liblist >$EXTRACTDIR/shortsuncatalog
+
+	#nawk '$2 ~ /^[fsl]$/  && $NF ~ /^CSW/ {print}' /var/sadm/install/contents |
+	#		fgrep -f $EXTRACTDIR/liblist >$EXTRACTDIR/shortcswcatalog
+	#nawk '$2 ~ /^[fsl]$/  && $NF ~ /^SUNW/ {print}' /var/sadm/install/contents |
+	#		egrep -v 'SUNWbcp|SUNWowbcp|SUNWucb' |
+	#		fgrep -f $EXTRACTDIR/liblist >$EXTRACTDIR/shortsuncatalog
+
+
+	print Cross-referencing indexes...
+fi
+
+
+# DEBUG: should we weed out libs already covered by pkg dependancy list?
+# that would be to handle things like libgcc_s.so.1 that are in both
+#  CSWgcc3rt and CSWgcc4rt but in different dirs
+
+for lib in `cat $EXTRACTDIR/liblist` ; do
+	grep "[/=]$lib[ =]" $EXTRACTDIR/$pkgname/pkgmap
+	if [[ $? -eq 0 ]] ; then
+		echo $lib provided by package itself
+		continue
+	fi
+
+	# We want to give priority to CSW packages.
+	# This is one way; force ONLY parsing CSW pkgs first.
+	# Then search SUNW pkgs only if nothing else
+	libpkg=`findlibincat $lib $EXTRACTDIR/shortcswcatalog`
+
+	if [[ -z "$libpkg" ]] ; then
+	libpkg=`findlibincat $lib $EXTRACTDIR/shortsuncatalog`
+	fi
+	if [[ -z "$libpkg" ]] ; then
+		errmsg cannot find package for $lib
+	else
+		print $libpkg >>$EXTRACTDIR/libpkgs
+		print "  found $libpkg for $lib"
+	fi
+done
+
+sort -u $EXTRACTDIR/libpkgs >$EXTRACTDIR/libpkgs.x
+mv $EXTRACTDIR/libpkgs.x $EXTRACTDIR/libpkgs
+
+diff $EXTRACTDIR/deppkgs $EXTRACTDIR/libpkgs >/dev/null
+if [[ $? -ne 0 ]] ; then
+	print SUGGESTION: you may want to add some or all of the following as depends:
+	print '   (Feel free to ignore SUNW or SPRO packages)'
+	diff $EXTRACTDIR/deppkgs $EXTRACTDIR/libpkgs | fgrep '>'
+fi
+
+checkforclasses
+
+if [[ "$basedir" != "" ]] ; then
+	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
+		echo No relocation check done for non-binary relocatable package.
+	fi
+fi
+
+cleanup
+
+
+print "$sparcwarning"
+
+done


Property changes on: csw/mgar/pkg/cswutils/trunk/files/checkpkg
___________________________________________________________________
Added: svn:executable
   + *

Added: csw/mgar/pkg/cswutils/trunk/files/checkpkg.8
===================================================================
--- csw/mgar/pkg/cswutils/trunk/files/checkpkg.8	                        (rev 0)
+++ csw/mgar/pkg/cswutils/trunk/files/checkpkg.8	2009-05-14 20:40:01 UTC (rev 4858)
@@ -0,0 +1,20 @@
+.TH checkpkg 8 "Jan 9, 2002" "CSW maintainers"
+.SH NAME
+\fBcheckpkg\fP
+\- CSW utility program to check a package for standards compliance
+.SH SYNOPSIS
+.br
+\fBcheckpkg pkg-file-name\fP
+
+.SH DESCRIPTION
+\fBcheckpkg\fP
+should always be used by CSW package maintainers to check a package
+before submitting it. You may call it either on a plain .pkg file, or a
+ .pkg.gz file
+
+.SH SEE ALSO
+\fBstagepkg\fP(8),\fBcreatepkg\fP(8)
+.SH AUTHORS
+Philip Brown
+.SH BUGS
+Cannot cover every possible standards issue

Added: csw/mgar/pkg/cswutils/trunk/files/cpan2pkg
===================================================================
--- csw/mgar/pkg/cswutils/trunk/files/cpan2pkg	                        (rev 0)
+++ csw/mgar/pkg/cswutils/trunk/files/cpan2pkg	2009-05-14 20:40:01 UTC (rev 4858)
@@ -0,0 +1,780 @@
+#!/opt/csw/bin/perl
+# Version 1.11 10/14/07
+#
+# Depends on gmake, csutils, pm_yaml, pm_htmltree, and pm_libwww
+#
+# This script will take a CPAN module as an argument and convert it into a
+# SysV package sutable for opencsw.org. It will do this by downloading the
+# module from CPAN, examining the modules's listed dependancies, and
+# recursivelly build them.  If a dependacy is a perl core module, or already
+# has a package on opencsw of the same or higer version, it will not be
+# rebuilt.  If a package file (e.g. <modname>-<ver>,REV=*.tar.gz) exists
+# in the directory wher you run this script, it is assumed that the package
+# is already built and it will not be re-built.
+#
+
+use strict;
+use warnings;
+
+use CPAN;
+use File::Copy;
+use File::Spec;
+use YAML qw(LoadFile);
+use Cwd;
+use LWP::UserAgent;
+use HTTP::Request::Common;
+use HTML::TreeBuilder;
+use File::Path;
+use File::Temp qw(:POSIX);
+use Getopt::Long;
+
+#
+# Global constants.
+#
+our $pgm = $0;
+our $cswdir = '/opt/csw';
+our $makecmd = "$cswdir/bin/gmake";
+our $maxsoftnmlen = 20;
+our $bwurl = 'http://www.opencsw.org';
+our $bwfsearch = '/filesearch.php';
+our @msearchpath = (  # Perl module search path
+	"/opt/csw/lib/perl/csw", 
+	"/opt/csw/share/perl/csw", 
+	"/opt/csw/lib/perl/site_perl", 
+	"/opt/csw/share/perl/site_perl"
+);
+our $cwd = getcwd();
+our $verbose;
+our $email;
+our $owner;
+our $logfile;
+
+our $http_proxy;
+our $ftp_proxy;
+
+our $version = "1.11";
+
+sub usage {
+
+ print STDERR "$pgm: Error, @_\n" if( @_ );
+ print STDERR <<_UEND;
+	Usage: $pgm <options> <modulename[,ver]> ...
+	    Required options:
+		-o|--owner <name> - Package maintainer name
+		-e|--email <address> - Package maintainer E-mail address
+	    Optional options:
+		-h|--help - Prints this message.
+		-v|--verbose - do not redirect output from commands
+		-V|--version - Prints the version number ($version)
+		-H|--http_proxy - HTTP Proxy to use (e.g. http://proxy:8080)
+		-F|--ftp_proxy - FTP Proxy to use (e.g. http://proxy:8080)
+		-n|--nooverwrite [<module>]
+			Do not overwrite the build directory, but do
+			everything else.  If no module is specified, do not
+			overwrite any build directories.  Can be specified as
+			many times as necessary.  Allows you to modify the
+			build directory and re-build.
+		-F|--nooverwritefile <file>
+			Same as --nooverwrite, but reads the module names from
+			a file.  Can only be specified once.
+
+	    Where <modulename[,ver]> is a standard CPAN module name with an
+	    optional comma seperated version number.  For example:
+
+		Email::Send
+
+	   and
+
+		Email::Send,2.185
+
+	   are both valid command line arguments.
+_UEND
+ exit 1;
+}
+
+
+#
+# These three routines are used to capture the output of sub processes and
+# perl routines (such as CPAN::Module::get) into a log file.  If the command
+# completes successfuly, the log file is thrown away.  If the command fails,
+# the log file is printed along with an error message by calling fail.
+#
+sub logoutput {
+
+	if( ! $verbose ) {
+
+		$logfile = tmpnam();
+		open( OLDOUT, '>&STDOUT' );
+		open( OLDERR, '>&STDERR' );
+		open( STDOUT, "> $logfile" );
+		open( STDERR, "> $logfile" );
+
+	}
+
+
+}
+
+sub endlog {
+
+	if( ! $verbose ) {
+
+		# Reference fh to silence warning
+		select( OLDERR ); select( OLDOUT );
+
+		# Restore output.
+		select( STDOUT);
+		close( STDOUT );
+		open( STDOUT, ">&OLDOUT" );
+		close( STDERR );
+		open( STDERR, ">&OLDERR" );
+
+		rmtree( $logfile );
+
+	}
+
+}
+
+sub fail {
+
+	if( ! $verbose ) {
+
+		close( STDOUT );
+		open( STDOUT, ">&OLDOUT" );
+		close( STDERR );
+		open( STDERR, ">&OLDERR" );
+		open( LOG, "< $logfile" ) or
+			die "$pgm: Error, @_ - can't open log\n";
+		print foreach <LOG>;
+		close( LOG );
+		rmtree( $logfile );
+
+	}
+
+	die "\n$pgm: Error, @_\n";
+	
+}
+
+
+#
+# See if a given perl module is contained in a package.  If the
+# module is on opencsw and it's version is as good or better than requested,
+# return the opencsw package name.
+#
+# We have to be carefull because some of the data is corrupt.  Some package
+# links reutned when searching by file point to no-existant packages.  Make
+# sure the package is valid before returning.
+#
+# Takes three strings as argument:
+#	modname - the perl module name as in "Package::Module".
+#	ver - the required module version number.
+#	bver - the version number found at the CPAN site. This may be the
+#	       version of a CPAN bundle which may not match the module version.
+#
+sub findBWpkg ( $$$ ) {
+
+	my ($modname, $ver, $bver) = @_;
+
+	my $ua = LWP::UserAgent->new;
+	$ua->proxy( 'http' => $http_proxy ) if $http_proxy;
+	$ua->proxy( 'ftp' => $ftp_proxy ) if $ftp_proxy;
+
+	#
+	# Query for the module in each of the locations in which it might be
+	# installed.
+	#
+	my $tbl;
+	foreach my $path (@msearchpath) {
+
+		#
+		# Find all packages containing our module by querying the BW
+		# site.
+		#
+		my $file = $modname;
+		$file =~ s'::'/'g;
+		$file = $path . "/" . $file . '.pm'; # Anchor query string.
+		my $res = $ua->request( POST $bwurl . $bwfsearch,
+			[
+				filename => $file,
+				matchtype => 'exact',
+				searchfiles => 'Search Files'
+			]
+		);
+		die "can not query opencsw.org" unless $res->is_success;
+
+		#
+		# Now parse the returned HTML page.
+		#
+		my $tree = HTML::TreeBuilder->new;
+		$tree->parse( $res->as_string );
+		$tree->eof();
+
+		#
+		# Get the first table and extract the links to package info
+		# pages.  We must make sure these are links to vaild packages.
+		#
+		my $tbltree = $tree->find( 'table' ) or next;
+		foreach my $link (@{$tbltree->extract_links()}) {
+
+			#
+			# Follow the link and make sure it conatains a table.
+			#
+			$res = $ua->request( GET $bwurl . $link->[0] );
+			die "can not query opencsw.org"
+				unless $res->is_success;
+			$tree->delete;
+			
+			$tree = HTML::TreeBuilder->new;
+			$tree->parse( $res->as_string );
+			$tree->eof();
+
+			$tbl = ($tree->look_down('_tag','table'))[0] and last;
+
+		} 
+
+		last if( defined($tbl) ); # Found a good package table!
+
+	}
+	return unless $tbl; # No table with package info found.
+
+	#
+	# The pakage name and version are in the first table.  Extract
+	# them by position.
+	#
+	my @rows  = $tbl->look_down( '_tag', 'tr' );
+
+	# package name is in fifth row
+	my $name = (($rows[4]->look_down('_tag', 'td'))[1]->content_list)[0];
+	$name =~ s/\s//g; # Strip white space
+
+	# version is in second row
+	my $bwver = (($rows[1]->look_down('_tag', 'td'))[1]->content_list)[0];
+	$bwver =~ s/,REV=.*$//;
+	$bwver =~ s/\s//g; # Strip white space
+
+	#
+	# If the BW version is less than the module version and CPAN version
+	# (bundle version), return failure.
+	#
+	if( ($bwver lt $ver) and ($bwver lt $bver) ) {
+		print "WARNNING: opencsw package $name is out of date\n";
+		return;
+	}
+
+	print "Found existing opencsw package $name for $modname module\n";
+	return $name; # Success!
+
+}
+
+#
+# See if a module is a perl core module by looking where it is installed.
+# Takes a CPAN::Module reference as argument.
+#
+sub is_perl_core( $ ) {
+	my( $mod ) = @_;
+
+	my $instfile = $mod->inst_file() or return;
+	return unless( $instfile =~ m'^/opt/csw/(lib|share)/perl/[0-9\.]+/' );
+	return 1;
+
+}
+
+#
+# See if a given BW package name is uniq.  This routine will try to query for
+# the package name on the BW web site.
+#
+# Takes a single string as argument.  This can be either the software name
+# (e.g. pm_expect) or the package name (e.g. CSWpmexpect).
+#
+sub is_uniq ( $ ) {
+
+	my ($pkgname) = @_;
+
+
+	my $ua = LWP::UserAgent->new;
+	$ua->proxy( 'http' => $http_proxy ) if $http_proxy;
+	$ua->proxy( 'ftp' => $ftp_proxy ) if $ftp_proxy;
+
+	#
+	# See if the "show all files" query returns anything for our package.
+	#
+	my $res = $ua->request( POST $bwurl . $bwfsearch,
+		[
+			pkgname => $pkgname,
+			showfiles => 'Show Files'
+		]
+	);
+	die "could not query opencsw packages" unless $res->is_success;
+
+	#
+	# Now parse the returned HTML page.
+	#
+	my $tree = HTML::TreeBuilder->new;
+	$tree->parse( $res->as_string );
+	$tree->eof();
+	$tree->objectify_text();
+
+	#
+	# If we do not find a match, return success, otherwise failure.
+	#
+	$tree->look_down( 'text', qr/NO MATCH/ ) and return 1;
+	return;
+
+}
+
+#
+# This routine will build a SysV pakage including a dependancy file.  It will
+# take care that the package name meets the restrictions imposed by checkpkg.
+# If the output file that would have been generated for this package already
+# exists in the working directory, the package is assumed to be already built
+# and nothing is done.  This routine assumes that the source has already been
+# downloaded and unpacked into the working directory (the directory where the
+# script was launched).
+#
+# This routine takes five arguments:
+#	modname - the perl module name as in "Package::Module".
+#	moddir - the directory where the source code was unpacked.
+#	uid - the authors uid as returned by CPAN::Module->userid()
+#	bwdeps - an array reference to a list of BW package names on which
+#		 the given module depends.
+#	pkgver - a string with the version number of the package.
+#
+sub bldpkg ( $$$\@$ ) {
+	my ($modname, $moddir, $uid, $bwdeps, $pkgver) = @_;
+
+	# Construct software and package names.
+	my $pkgname = "pm_" . lc( $modname ); $pkgname =~ s/:://g;
+	my $pkgfile = "CSWpm" . lc( $modname ); $pkgfile =~ s/:://g;
+	
+	#
+	# If the package/software names are too long, truncate them and make
+	# sure they are still uniq.
+	#
+	if( length($pkgname) > $maxsoftnmlen ) {
+
+		$pkgname = substr( $pkgname, 0, $maxsoftnmlen );
+		die "can not make uniq name for $modname"
+			unless is_uniq( $pkgname );
+	}
+	if( length($pkgfile) > $maxsoftnmlen ) {
+
+		$pkgfile = substr( $pkgfile, 0, $maxsoftnmlen );
+		die "can not make uniq name for $modname"
+			unless is_uniq( $pkgfile );
+	}
+
+
+	#
+	# Do not rebuild the package if one already exists.
+	#
+	my @found = <$cwd/$pkgname-$pkgver,REV=*.pkg.gz>;
+	if( @found ge 1 ) {
+		print "Package for $modname already built, skipping\n";
+		return $pkgfile;
+	}
+
+	#
+	# Create the make file.
+	#
+	chdir( $moddir ) or die "Can not find module directory $moddir\n";
+	if( -f "Makefile.PL" ) {
+		logoutput();
+		system( "perl Makefile.PL INSTALLDIRS=vendor" ) == 0
+			or fail "Can not create Makefile for $modname";
+		endlog();
+	} else {
+		logoutput();
+		system( "perl Build.PL installdirs=vendor" ) == 0
+			or fail "Can not create Makefile for $modname";
+		endlog();
+	}
+
+	#
+	# Build everything but do not install yet.
+	#
+	logoutput();
+	system( "$makecmd" ) == 0 or fail "Can not build $modname";
+
+	#
+	# Stage the products.
+	#
+	my $stage = $moddir . "/cswstage";
+	my $stagecmd = "MAKE=$makecmd $cswdir/bin/stagepkg -a" .
+		" DESTDIR=$stage" .
+		" install"
+	;
+	system( $stagecmd ) == 0 or fail "Could not stage $modname";
+	endlog();
+
+	#
+	# Fix up the .packlist file (strip out the stageing directory).
+	#
+	my $pkfile = $stage . "$cswdir/lib/perl/csw/auto/" . $modname
+		. "/.packlist";
+	$pkfile =~ s'::'/'g;
+	open( PKFILE, "< $pkfile" ) or die "can not find $pkfile";
+	my @pklist = map {s/$stage//; $_} <PKFILE>;
+	close( PKFILE );
+	open( PKFILE, "> $pkfile" ) or die "can not update $pkfile";
+	print PKFILE @pklist;
+	close( PKFILE );
+
+	#
+	# Copy in the license if one is present.
+	#
+	if( -f 'LICENSE' ) {
+		copy( 'LICENSE', $stage . '/copyright' );
+	} else {
+		open( COPY, "> $stage/copyright" ) and close COPY;
+	}
+
+	chdir( $stage );
+
+	#
+	# Generate a prototype file.
+	#
+	my $filter = qr/( opt| var|perllocal.pod| copyright| prototype) /;
+	my @proto = map {s'none 'none /'; s' [^ ]+ [^ ]+$' root bin'; $_ . "\n"}
+			grep {!/$filter/}
+			`find . | /usr/bin/pkgproto`
+	;
+	die "Can not run pkgproto" if( $? != 0 );
+	open( PROTO, '> prototype' );
+	print PROTO "i copyright\n";
+	print PROTO "i depend\n";
+	print PROTO "i pkginfo\n";
+	print PROTO  @proto;
+	close PROTO;
+
+	#
+	# Generate dependancy file.
+	#
+	open( DEPFILE, '> depend' );
+	print DEPFILE "P\t" . $_ . "\n" foreach( @$bwdeps );
+	print DEPFILE "P\tCSWperl\n"; # Perl modules depend on perl!
+	close DEPFILE;
+
+	#
+	# Generate pkginfo file.
+	#
+	my $url = "http://search.cpan.org/~$uid/$modname-$pkgver";
+	$url =~ s/::/-/g;
+	my ($sec,$min,$hour,$mday,$mon,$year) = localtime;
+	my $verstr = $pkgver .  ",REV=" . (1900 + $year) . "." . $mon . "."
+		. $mday;
+	open( INFO, '> pkginfo' );
+	print INFO "PKG=$pkgfile\n";
+	print INFO "NAME=$pkgname - perl $modname module\n";
+	print INFO "VERSION=" . $verstr . "\n";
+	print INFO "CATEGORY=application\n";
+	print INFO "VENDOR=$url packaged for CSW by $owner\n";
+	print INFO "HOTLINE=http://www.opencsw.org/bugtrack/\n";
+	print INFO "EMAIL=$email\n";
+	close INFO;
+
+	#
+	# Create package and copy it to the working directory.
+	#
+	my $arch = `uname -p`; chomp( $arch );
+	my $osver = `uname -r`; chomp( $osver );
+	my $outfile = $pkgname . "-" . $verstr . "-SunOS" . $osver .
+		"-" . $arch . "-CSW.pkg";
+
+	#
+	# Build the package file.  We can not use createpkg because it calls
+	# checkpkg which requires the depenencies to already be installed.
+	#
+	my $spooldir = "$cwd" . "/" . $pkgfile;
+	rmtree( $spooldir ) if( -f $spooldir );
+	logoutput();
+	system( "pkgmk -o -r . -a $arch -f prototype -d $cwd" ) == 0
+		or fail "could not create package for $modname";
+	system( "pkgtrans $cwd $cwd/$outfile $pkgfile" ) == 0
+		or fail "could not convert $modname package to stream format";
+	system( "gzip -f $cwd/$outfile" ) == 0
+		or fail "could not gzip $modname package";
+	endlog();
+	rmtree( $spooldir );
+
+	return $pkgfile; #Sucess!
+}
+
+#
+# This routine queries the CPAN site fore a given perl module, downloads
+# it's source code, builds it, and creates a package.  This routine will also
+# recursively build packages for all the module's listed dependancies.  All
+# this is accomplished by calling the previous routines.
+#
+# If a module is a core perl module and it is not out of date, the module is
+# skipped.  If a moulde is already packaged and listed on the BW site and is
+# up to date, it will not be rebuilt (though it will be used for dependancies).
+# The source code and build directory for the module will be placed in the
+# working directory (the directory where this script was invoked) as will the
+# final package file.
+#
+# This routine takes five paramates:
+#	ndldall - a flag to indicate no CPAN source files are to be downloaded
+#		  and more importantly, the previous build directory is not to
+#		  be overwritten.
+#	ndld - a hash containing the names of modules that should not be
+#	       downloaded as above.
+#	modname - the perl module name as in "Package::Module".
+#	ver - a string with the minimum acceptable version number for the
+#	      given module.
+#	deptree - a hash in which the module disposition and dependacy hash
+#		  will be written.  This can be used to print a summary of
+#		  what happend.
+#
+sub pmtopkg ( $\%$$\% ); # Avoid warning because of recursive call.
+sub pmtopkg ( $\%$$\% ) {
+
+	my ($ndldall, $nodnld, $modname, $ver, $deptree) = @_;
+
+	$ver = "" if( !defined $ver );
+
+	#
+	# If the module is perl, check the running perl version.
+	#
+	if( $modname eq "perl" ) {
+		die "$modname requires perl version $ver" if( $^V < $ver );
+		$deptree->{$modname}{$ver} = ["perl OK",{}];
+		return;
+	}
+
+	#
+	# Look up the CPAN module.
+	#
+	my $mod = (CPAN::Shell->expand("Module", ($modname)))[0];
+	die "can not locate CPAN module $modname" unless( $mod );
+	logoutput();
+	my $instver = $mod->inst_version();
+	my $fname = $mod->cpan_file();
+	endlog();
+
+	#
+	# If CPAN substituted a bundle for our module, we need to use the
+	# bundle version number  when searching for the module on BW.
+	# Extract the (possibly new) version number from the CPAN file name.
+	#
+	$fname =~ m'.*/[^/]+-([0-9\.]+)\.tar\.gz';
+	my $bver = $1;
+
+	#
+	# If this is a perl core module and it is not out of date, skip it.
+	#
+	if( is_perl_core($mod) && defined($ver) && defined($instver) &&
+	    ($ver le $instver)
+	) {
+		print "Skiping core module $modname\n";
+		$deptree->{$modname}{$ver} = ["core module OK",{}];
+		return;
+	}
+
+	#
+	# If a BW package is found and it is not a core package, return it.
+	#
+	my $bwpkg = findBWpkg( $modname, $ver, $bver );
+	if( $bwpkg ) {
+		$deptree->{$modname}{$ver} = ["Existing BW package $bwpkg OK",{}];
+		return $bwpkg;
+	}
+
+	#
+	# Download the source from CPAN and unpack it in the CPAN build dir.
+	#
+	logoutput();
+	if( $ndldall || $nodnld->{$modname} ) {
+		print OLDOUT "Skipping download of $modname\n";
+	} else {
+		$mod->get();
+	}
+	my $cfile = $CPAN::Config->{keep_source_where} .
+		"/authors/id/" .
+		$fname;
+	;
+	fail( "can not download $modname from CPAN" ) if( ! -f $cfile );
+	if( !($ndldall || $nodnld->{$modname}) ) {
+		system( "cd $cwd; gunzip -c $cfile | tar -xvf -" ) == 0
+			or fail "can not unpack $cfile";
+	}
+	endlog();
+
+	#
+	# If we picked up a bundle, change to the bundle name.  Extract the
+	# (possibly new) module name from the CPAN file name.
+	#
+	$fname =~ m'.*/([^/]+)-[0-9\.]+\.tar\.gz';
+	my $nmodname = $1;
+	$nmodname =~ s/-/::/g;
+	
+	#
+	# Get the directory name where the source was unpacked.
+	#
+	my $chome = $CPAN::Config->{cpan_home};
+	$fname =~ m'.*/([^/]+-[0-9\.]+)\.tar\.gz';
+	my $moddir = $cwd . "/" . $1;
+
+	#
+	# Get the modules $nmodname requires from the YAML meta data.  Get it
+	# as a reference to a hash of module => "version".
+	#
+	my $metafile = $moddir . "/META.yml";
+	my $meta_data;
+	$meta_data = LoadFile( $metafile )
+		or die "Can not load dependancies for $nmodname";
+	my $req = $meta_data->{requires};
+
+	#
+	# Recursively make (or look up) pakages for each dependancy and save
+	# them for when we build the package.
+	#
+	my ($bwdep, @deps);
+	foreach( keys %$req ) {
+		$bwdep = pmtopkg($ndldall, %$nodnld, $_, $req->{$_}, %$deptree)
+			and push @deps, $bwdep;
+	}
+
+	#
+	# Build the package.
+	#
+	my $depname = bldpkg( $nmodname, $moddir, $mod->userid(), @deps, $meta_data->{version} )
+		or die "can not build package for $nmodname\n";
+
+	#
+	# Copy the original source file to our orginal working directory.
+	#
+	my ($vol, $dir, $file);
+	($vol, $dir, $file) = File::Spec->splitpath( $cfile );
+	$file = $cwd . '/' . $file;
+	copy( $cfile , $file ) or die "Could not copy $cfile to $file: $!";
+
+	chdir( $cwd ); # Go back to where we were.
+
+	$deptree->{$modname}{$ver} = ["New BW package for $nmodname!",$req];
+
+	# Return our new package name
+	return $depname
+}
+
+#
+# A little routine to print out a summary of what was done.  This routine will
+# recursively traverse the deptree structure built up in pmtopkg.  At each node
+# it will print out the disposition message, and recursively decend each listed
+# dependacy tree.
+#
+# This routien takes four parameters:
+#	modname - the perl module name as in "Package::Module".
+#	ver - a string with the minimum version number for the given module.
+#	indent - a string of spaces used to do indentation at each level.
+#	deptree - a referecne to the hash built up in pmtopkg.  Each entry
+#		  in the hash is an array containing a disposition string, and
+#	          a reference to a hash of dependancies (mod::name => version).
+#	
+sub disposition ( $$$\% );
+sub disposition ( $$$\% ) {
+	my ($modname, $ver, $indent, $deptree) = @_;
+
+	$ver = "" if( !defined $ver );
+
+	my $dispo = $deptree->{$modname}{$ver}[0];
+	print "$indent$modname $ver  -  $dispo\n" if( $dispo );
+	my $deps = $deptree->{$modname}{$ver}[1];
+
+	$indent = sprintf( "%s    ", $indent );
+	foreach( keys %$deps ) {
+		disposition( $_, $deps->{$_}, $indent, %$deptree );
+	}
+}
+
+my $ndldfile;
+my @ndld;
+my $ndldall;
+my $help;
+my $vflag;
+my %deptree;
+
+#
+# Parse the command line options.
+#
+Getopt::Long::Configure( 'prefix_pattern=(--|-)' );
+Getopt::Long::Configure( 'no_auto_abbrev' );
+Getopt::Long::Configure( 'no_ignore_case_always' );
+GetOptions(
+	"verbose|v" => \$verbose,
+	"version|V" => \$vflag,
+	"help|h" => \$help,
+	"owner|o=s" => \$owner,
+	"email|e=s" => \$email,
+	"http_proxy|H=s" => \$http_proxy,
+	"ftp_proxy|F=s" => \$ftp_proxy,
+	"nooverwritefile|f=s" => \$ndldfile,
+	"nooverwrite|n:s" => sub { if($_[1]){push @ndld, $_[1]} else {$ndldall = 1} }
+);
+
+usage if( $help );
+if( $vflag ) {
+	print "Version: $version\n";
+	exit 0;
+}
+
+#
+# Verify sanity of options.
+#
+usage "must specify module names " unless( @ARGV );
+usage "maintainer E-mail address required" unless( $email );
+usage "maintainer name required" unless( $owner );
+
+if( $ndldfile ) {
+
+	usage "bad no download file name $ndldfile" unless( -f $ndldfile );
+	open( NDLD, "< $ndldfile" );
+	push @ndld, map {chomp($_); $_} <NDLD>;
+	close( NDLD );
+
+}
+
+my %ndldmods;
+$ndldmods{$_} = 1 foreach( @ndld );
+
+#
+# Pick up proxies from /etc/opt/csw/pkg-get.conf if it exists.
+#
+my $cfgfile = "$cswdir/etc/pkg-get.conf";
+if( -f $cfgfile ) {
+
+	open( CFG, "< $cfgfile" );
+	my %vars =
+		map { m/([^=]+)=(.*)/; ($1, $2) }
+		grep { /=/ } map { s/#.*//; $_ } <CFG>
+	;
+
+	#
+	# Only pick up proxies if they were not already specified.
+	#
+	if( !defined($http_proxy) && defined($vars{http_proxy}) ) {
+		$http_proxy = $vars{http_proxy};
+	}
+	if( !defined($ftp_proxy) && defined($vars{ftp_proxy}) ) {
+		$ftp_proxy = $vars{ftp_proxy};
+	}
+
+}
+
+#
+# Build the packages for each module.
+#
+my @modlist = @ARGV;
+foreach( @modlist ) {
+
+	$_ =~ /^([^,]+),?(.*)/; #Extract mod name and version number
+	pmtopkg( $ndldall, %ndldmods, $1, $2, %deptree );
+
+}
+print "\nModule Disposition Summary:\n\n";
+foreach( @modlist ) {
+
+	$_ =~ /^([^,]+),?(.*)/; #Extract mod name and version number
+	disposition( $1, $2, "", %deptree );
+
+}
+
+exit 0;


Property changes on: csw/mgar/pkg/cswutils/trunk/files/cpan2pkg
___________________________________________________________________
Added: svn:executable
   + *

Added: csw/mgar/pkg/cswutils/trunk/files/createpkg
===================================================================
--- csw/mgar/pkg/cswutils/trunk/files/createpkg	                        (rev 0)
+++ csw/mgar/pkg/cswutils/trunk/files/createpkg	2009-05-14 20:40:01 UTC (rev 4858)
@@ -0,0 +1,134 @@
+#!/bin/ksh -p
+
+# createpkg 1.6 
+# This script actually builds the package.. once you have already
+# put together the pkginfo and prototype file.
+# See the makeproto script for a way to make a prototype file.
+
+
+if [[ "$FAKEROOTKEY" != "" ]] ; then
+	print ERROR: do not run createpkg under a fakeroot shell
+	# This is mainly because we unset LD_LIBRARY_PATH lower down,
+	# which would break fakeroot anyway
+	exit 1
+fi
+
+#This is only relevant for an absolute-path package
+ROOTDIR=/
+if [[ "$1" = "-r" ]] ; then
+	ROOTDIR="$2"
+	mode=absolute
+	shift
+	shift
+fi
+
+#This is only relevant for a relative-path package
+INSTALLBASEDIR=/opt/csw
+if [[ "$1" = "-b" ]] ; then
+	INSTALLBASEDIR="$2"
+	mode=relative
+	shift
+	shift
+fi
+
+if [[ $# -ne 0 ]] ; then
+	case $1 in
+	 *=*)
+	 	print Taking "'extra'" args, as variable assignments for pkgmk
+	 	;;
+	 *)
+		print ERROR: unrecognized args: $*
+		print read the manpage
+		exit 1
+		;;
+	esac
+
+fi
+
+ARCH=`sed -n 's/^ARCH=//p' pkginfo`
+if [[ "$ARCH" != "all" ]] ; then
+	ARCH=`uname -p`
+fi
+
+die()
+{
+	print ERROR: $*
+	exit 1
+}
+
+# check if we have multiple prototype files, vs a single unified prototype file
+if [[ -f prototype.$ARCH ]] ; then
+	PROTO=prototype.$ARCH
+else
+	PROTO=prototype
+fi
+
+grep 'i copyright' $PROTO || die need copyright in $PROTO
+grep 'root other' $PROTO && die fix $PROTO file
+grep 'csw/man' $PROTO && die fix csw/man entry in $PROTO file
+grep 'none man' $PROTO && die fix csw/man entry in $PROTO file
+grep 'csw/info' $PROTO && die fix csw/info entry in $PROTO file
+grep 'none info' $PROTO && die fix csw/info entry in $PROTO file
+grep 'csw/doc' $PROTO && die fix csw/doc entry in $PROTO file
+grep 'none doc' $PROTO && die fix csw/doc entry in $PROTO file
+
+grep 'Replace this file' copyright && die fix copyright file
+
+if [[ "$mode" = "" ]] ; then
+	grep /opt/csw $PROTO >/dev/null
+	if [[ $? -eq 0 ]] ; then
+		mode=absolute
+	else
+		mode=relative
+	fi
+fi
+
+PKG=`sed -n 's/^PKG=//p' pkginfo`
+PKGREV=`sed -n 's/^VERSION=//p' pkginfo`
+SOFTNAME=`sed -n 's/^NAME=//p' pkginfo|awk '{print $1}'`
+
+case $SOFTNAME in
+     *[A-Z]*)
+	echo ERROR: $SOFTNAME must be all lowercase
+	exit 1
+	;;
+esac
+
+PKGFILE=$SOFTNAME-$PKGREV-SunOS`uname -r`-$ARCH-CSW.pkg
+
+if [ "$PKGREV" = "" -o "$SOFTNAME" = "" ] ; then
+	echo ERROR: need VERSION and NAME defined properly in pkginfo
+	exit 1
+fi
+
+if [[ "$mode" = "absolute" ]] ; then
+	pkgmk -r $ROOTDIR -a $ARCH -f $PROTO "$@"
+else
+	pkgmk -b $INSTALLBASEDIR -a $ARCH -f $PROTO BASEDIR=/opt/csw "$@"
+fi
+
+if [[ $? -ne 0 ]] ; then die package creation failed ; fi
+
+pkgtrans -s /var/spool/pkg `pwd`/$PKGFILE $PKG
+
+print Conversion complete. Cleaning up in  /var/spool/pkg
+
+rm -r /var/spool/pkg/$PKG
+
+print ""
+print Running checkpkg on pkgfile
+LD_LIBRARY_PATH='' checkpkg $PKGFILE
+if [[ $? -ne 0 ]] ; then
+	print ERROR: failed check.
+	exit 1
+fi
+
+if [[ "$mode" = "absolute" ]] ; then
+	print packaging of files under $ROOTDIR complete
+else
+	print packaging of files under $INSTALLBASEDIR complete
+fi
+
+echo gzipping pkgfile
+gzip $PKGFILE
+


Property changes on: csw/mgar/pkg/cswutils/trunk/files/createpkg
___________________________________________________________________
Added: svn:executable
   + *

Added: csw/mgar/pkg/cswutils/trunk/files/createpkg.8
===================================================================
--- csw/mgar/pkg/cswutils/trunk/files/createpkg.8	                        (rev 0)
+++ csw/mgar/pkg/cswutils/trunk/files/createpkg.8	2009-05-14 20:40:01 UTC (rev 4858)
@@ -0,0 +1,50 @@
+.TH createpkg 8 "Jan 9, 2002" "CSW maintainers"
+.SH NAME
+\fBcreatepkg\fP
+\- CSW utility to put together a pkg file
+.SH SYNOPSIS
+.br
+\fBcreatepkg [-r rootdir] [-b basedir]\fP
+
+.SH DESCRIPTION
+\fBcreatepkg\fP
+is a convenience tool to automate the final steps needed to create
+a pkg file. It assumes you have done all compiling, and "staging", for the
+contents of the package already.
+It will convert the binaries into a single .pkg.gz file, and
+run checkpkg on it to check for common errors in packaging.
+
+You must have already created a prototype file, a copyright file,
+and a pkginfo file. If you need one, you must also have created a depend file,
+and added an entry into pkginfo for it.
+
+It is assumed that you will follow a proceedure similar to the
+following:
+
+ [untar software.tar.gz for building]
+ [configure and build the software]
+ stagepkg
+ mkdir $HOME/pkg/software
+ cp COPYING $HOME/pkg/software/copyright
+ cp cswstage/prototype $HOME/pkg/software/prototype
+ cd $HOME/pkg/software
+ [create pkginfo file]
+ [create depend file, if neccessary, and adjust prototype]
+ createpkg -b {/full/path/to/builddir}/cswstage/opt/csw
+
+If you need to make an absolute-path package, you would instead use
+
+ createpkg -r {/full/path/to/builddir}/cswstage
+
+.SH ADVANCED TECHNIQUES
+
+createpkg (and pkgmk) normally assume you have a 'prototype' file 
+in the current directory. However, if you need to have slightly different
+contents for sparc vs x86, createpkg will check for a prototype.{sparc|i386}
+file, and use the ARCH specific version, if present.
+
+.SH SEE ALSO
+\fBcheckpkg\fP(8)
+\fBstagepkg\fP(8)
+.SH AUTHORS
+Philip Brown

Added: csw/mgar/pkg/cswutils/trunk/files/stagepkg
===================================================================
--- csw/mgar/pkg/cswutils/trunk/files/stagepkg	                        (rev 0)
+++ csw/mgar/pkg/cswutils/trunk/files/stagepkg	2009-05-14 20:40:01 UTC (rev 4858)
@@ -0,0 +1,191 @@
+#!/bin/ksh -p
+
+# stagepkg 1.13
+
+# This script is for CSW maintainers to be able to more easily
+# do builds of a package, on the build machines, without
+# having root privileges.
+# It does some very generic package prototype generation.
+# For more custom jobs, you are encouraged to either copy this
+# script to your own location, with tweaks,
+# or ask a sysadmin to chown the target directories to you,
+# for purposes of doing a tweak/build/install/test cycle more easily.
+#
+
+MAKE=${MAKE:-make}
+# Note: This MUST BE AN ABSOLUTE PATH!!!
+DESTTOP=$PWD/cswstage
+
+
+
+
+PATH=$PATH:/usr/ccs/bin   # paranoia is always good
+
+
+setupstage(){
+	# We make a bunch of softlinks, so that programs that
+	# normally install to top-level directories, instead
+	# install to where WE want them to install, 
+	# without having to modify their makefiles.
+	mkdir -p $DESTTOP/opt/csw/share $DESTTOP/opt/csw/lib
+	mkdir -p $DESTTOP/opt/csw/bin $DESTTOP/opt/csw/sbin
+	mkdir $DESTTOP/opt/csw/share/doc
+	mkdir $DESTTOP/opt/csw/share/info
+	mkdir $DESTTOP/opt/csw/share/locale
+	mkdir $DESTTOP/opt/csw/share/man
+	ln -s share/man $DESTTOP/opt/csw/man
+	ln -s share/doc $DESTTOP/opt/csw/doc
+	ln -s share/info $DESTTOP/opt/csw/info
+	ln -s ../share/locale $DESTTOP/opt/csw/lib/locale
+}
+
+
+# Assume we are in top-level of source tree.
+# Create virtual csw tree
+# Do the "make install" to tree
+# Clean up unneeded directories after install
+# Generate prototype file
+install_and_proto(){
+
+	SHELL=ksh
+
+	echo $MAKE
+	echo $S_MAKEARGS
+	echo $DESTTOP
+	echo $FAKEROOT
+
+	# look up primary group name
+	PGROUP=`/usr/xpg4/bin/id -n -g`
+
+
+	cat >build_script.$$<<EOF
+	MAKE="$MAKE"
+	S_MAKEARGS="$S_MAKEARGS"
+	DESTTOP=$DESTTOP
+
+	if [[ "$nofakeroot" -ne 1 ]] ; then
+		chown -Rh root:bin $DESTTOP
+	fi
+
+	$MAKE $S_MAKEARGS
+
+	cd $DESTTOP/opt/csw
+
+	# Remove unneeded links. package should NOT include these
+	rm man info doc lib/locale
+	# Remove unneeded directories.
+	# If they ARE needed, rmdir will fail
+	rmdir share/man share/doc share/info share/locale 2>/dev/null
+	rmdir share bin sbin lib  2>/dev/null
+
+	(print 'i pkginfo'; print 'i copyright' ;print 'i depend' ; pkgproto . )>/tmp/proto.$$
+	cd ../..
+	# this sed works around bug in fakeroot on x86
+	# It forces root.bin owner/group for files that default to normal user
+	sed "s/${LOGNAME} ${PGROUP}$/root bin/" /tmp/proto.$$ >prototype
+	rm /tmp/proto.$$
+	cd ..
+EOF
+	$FAKEROOT ksh ./build_script.$$
+	#echo take a look at ./build_script.$$
+	rm build_script.$$
+
+}
+
+if [[ "$1" = "-a" ]] ; then
+	print Option -a detected
+	print Will create absolute-path package
+	absolute=1
+	shift
+fi
+
+if [[ "$1" = "-m" ]] ; then
+	print Option -m detected
+	print Will run as '"me"', $(/usr/xpg4/bin/id -n -u)
+	nofakeroot=1
+	shift
+fi
+
+if [[ -d $DESTTOP ]] ; then
+	print removing old staging area
+	rm -fr $DESTTOP
+fi
+
+print creating staging area $DESTTOP
+setupstage
+
+if [[ $# -gt 0 ]] ; then
+	S_MAKEARGS="$@"
+else
+	S_MAKEARGS="DESTDIR=$DESTTOP install"
+fi
+print using make arguments of "$S_MAKEARGS"
+
+export S_MAKEARGS
+
+
+if [[ $USER != "root" ]] && [[ $nofakeroot -ne 1 ]] ; then
+	FAKEROOT=fakeroot
+	print will use fakeroot to do install
+fi
+
+install_and_proto
+
+### Now need to figure out if package is REAALLY relocatable.
+# If there is anything with a hardcoded 'csw' in it, then it
+# cannot be relocatable
+
+print ""
+print Checking for relocatable capability...
+
+if [[ $absolute -eq 0 ]] ; then
+	find $DESTTOP -type f | xargs strings | grep csw
+	if [[ $? -eq 0 ]] ; then
+		print WARNING: MUST make an absolute package
+		absolute=1
+	fi
+fi
+
+if [[ $absolute -ne 0 ]] ; then
+	cd $DESTTOP
+	sed 's: none : none /opt/csw/:' prototype >prototype.new
+	mv prototype.new prototype
+	print Updated prototype file to use absolute paths
+	cd ..
+fi
+
+print ""
+print Stripping executables...
+
+
+find $DESTTOP | xargs file | grep 'not stripped' |
+   awk -F: '{print $1}' |xargs /usr/ccs/bin/strip
+
+
+
+print prototype file is now in $DESTTOP/prototype
+
+if [[ $absolute -eq 0 ]] ; then
+  print If you dont already have a prototype file, you should copy
+  print $DESTTOP/prototype
+  print to where you keep your pkginfo file, and edit it as appropriate. Next,
+  print '  cd ~/pkgs/[software] '
+  print You should then do EITHER
+  print "  createpkg -b $DESTTOP/opt/csw"
+  print OR if you want to do things the hard way
+  print "  pkgmk -b $DESTTOP/opt/csw \ "
+  print "        -f $DESTTOP/prototype \ "
+  print "         BASEDIR=/opt/csw"
+  print "  [and then all the other cleanup type stuff by hand]"
+else
+  print If you dont already have a prototype file, you should copy
+  print $DESTTOP/prototype
+  print to where you keep your pkginfo file, and edit it as appropriate. Next,
+  print '  cd  ~/pkgs/[software] '
+  print You should then do EITHER
+  print "  createpkg -r $DESTTOP"
+  print OR if you want to do things the hard way
+  print "  pkgmk -r $DESTTOP \ "
+  print "        -f $DESTTOP/prototype "
+  print "  [and then all the other cleanup type stuff by hand]"
+fi


Property changes on: csw/mgar/pkg/cswutils/trunk/files/stagepkg
___________________________________________________________________
Added: svn:executable
   + *

Added: csw/mgar/pkg/cswutils/trunk/files/stagepkg.8
===================================================================
--- csw/mgar/pkg/cswutils/trunk/files/stagepkg.8	                        (rev 0)
+++ csw/mgar/pkg/cswutils/trunk/files/stagepkg.8	2009-05-14 20:40:01 UTC (rev 4858)
@@ -0,0 +1,85 @@
+.TH stagepkg 8 "Feb 8, 2003" "CSW maintainers"
+.SH NAME
+\fBstagepkg\fP
+\- CSW utility program to 'make install' to a staging area
+.SH SYNOPSIS
+.br
+\fBstagepkg [-a] [-m] [make flags] \fP
+
+.SH OPTIONS
+-a  Absolute package
+
+-m  Run as "me". Do not try to use fakeroot or chown
+
+.SH DESCRIPTION
+\fBstagepkg\fP
+is used to create a virtual layout of /opt/csw, under 
+$PWD/cswstage, 
+for purposes of installing software, before making a package out of it.
+\fBstagepkg\fP will automatically create certain links like man -> share/man
+to ensure that software gets installed to the proper place.
+
+After installing the binaries to the staging tree, \fBstagepkg\fP will
+then attempt to determine if a package can be a relocatable one, or whether
+it needs to be an absolute-path one. You can force an absolute-path package
+with the -a option.
+
+It is then up to you to look over the generated prototype file, fix it up 
+as neccessary, and then call pkgmk with the appropriate options. 
+(Or use \fBcreatepkg\fP(8) instead of pkgmk)
+
+\fBstagepkg\fP will transparently use \fBfakeroot\fP to do the install,
+unless you already are root, or use the -m option.
+
+Note that this script \fBis not suitable\fP for multiarchitecture packages.
+That is to say, if you wish to provide binaries for sparcv8, sparcv8+, 
+and sparcv9, you will have to script something yourself.
+However, it may still be useful to run the script once for the "base" package,
+and then manually tweak the staging area and prototype file to match.
+
+By default, \fBstagepkg\fP will use standard Solaris make. If you wish
+to use gnu make, set your MAKE environment variable. For example,
+
+.LP
+MAKE=gmake stagepkg
+
+
+By default, \fBstagepkg\fP assumes that the target software Makefiles respect
+DESTDIR=/some/path to alter the virtual root destination. If you need to
+specify some other make varible, call stagepkg as if it were the make command
+directly. EG:
+
+.LP
+stagepkg BUILD_TOP=$PWD/cswstage install
+
+
+Since it is common to need to remake the package due to minor pkginfo changes,
+or dependancy changes, without any changes to the actual binaries,
+you are encouraged to keep your cswstage directory around, until you
+put together the next update for the software you maintain.
+
+.SH DUMMY RUN
+
+Even if you can't, or don't want to, use stagepkg to do the "make install"
+stage, it is still advisable for you to use it in a dummy run, so that it 
+makes the normal directory tree with special symbolic links for you,
+under cswstage. You will then have to create and fix up your own prototype file.
+
+To do a dummy run, you can call it with any variable that would be passed to
+"make". For example:
+
+.LP
+stagepkg FAKEVAR=dummy
+
+
+.SH SEE ALSO
+\fBcheckpkg\fP(8),
+\fBcreatepkg\fP(8),
+\fBfakeroot\fP(1)
+.br
+http://www.opencsw.org/standards/
+
+.SH AUTHORS
+Philip Brown
+.SH BUGS
+Cannot cover every possible package configuration issue automatically


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