[csw-devel] SF.net SVN: gar:[12162] csw/mgar/pkg/cswclassutils/trunk/files

theferret at users.sourceforge.net theferret at users.sourceforge.net
Mon Jan 3 20:56:57 CET 2011


Revision: 12162
          http://gar.svn.sourceforge.net/gar/?rev=12162&view=rev
Author:   theferret
Date:     2011-01-03 19:56:57 +0000 (Mon, 03 Jan 2011)

Log Message:
-----------
cswcptemplates: bugfixes and paranoia

Modified Paths:
--------------
    csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswcptemplates
    csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswcptemplates

Modified: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswcptemplates
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswcptemplates	2011-01-03 17:42:45 UTC (rev 12161)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswcptemplates	2011-01-03 19:56:57 UTC (rev 12162)
@@ -25,15 +25,39 @@
 # May be used/copied freely
 #
 
+TEMPLATEDIR=/opt/csw/etc/templates
+
 # extra checks and warnings to help people run this manually
 if [ "$PKG" = "" ] ; then
 	echo ERROR: PKG env variable must be set
 	exit 1
 fi
 
+echo 'class <cswcptemplates> running'
+
 # Note: for "normal" installs, we get passed one line per file in our "class"
 # However, for sparse-zone installs, the files have already been 'installed',
 # so we will get called, but have no files passed on stdin
+
+if [ ! -d $PKG_INSTALL_ROOT$TEMPLATEDIR/$PKG ] ; then
+	if [ ! -d $PKG_INSTALL_ROOT$TEMPLATEDIR ] ; then
+		echo ERROR: $PKG_INSTALL_ROOT$TEMPLATEDIR does not exist
+		echo Possibly corrupt install of CSWcas-cswcptemplates
+		exit 1
+	fi
+	# we can add dirs for the package calling us.
+	# But cswcptemplates never calls this script itself, so would be
+	# dubious to call that ourselves
+	if [ "$PKG_INSTALL_ROOT" = "" ] ; then
+		installf $PKG $TEMPLATEDIR/$PKG d 0755 root bin
+	else
+		installf -R $PKG_INSTALL_ROOT $PKG $TEMPLATEDIR/$PKG d 0755 root bin
+	fi
+	mkdir $PKG_INSTALL_ROOT$TEMPLATEDIR/$PKG
+	chown root:bin $PKG_INSTALL_ROOT$TEMPLATEDIR/$PKG
+	chmod 0755 $PKG_INSTALL_ROOT$TEMPLATEDIR/$PKG
+fi
+
 while read src dest ; do
 	cp $src $dest
 	if [ $? -ne 0 ] ; then
@@ -50,17 +74,25 @@
 done
 
 
-cd  $PKG_INSTALL_ROOT/opt/csw/etc/templates/$PKG || exit 0
+cd  $PKG_INSTALL_ROOT$TEMPLATEDIR/$PKG || exit 0
 # I dont see how we would be called if that dir does not exist, but be 
 # paranoid.
 
 
 for template in `find . -type f ` ; do 
+template=`echo $template|sed 's:^./::'`
 case $template in 
-	*/*)
+	var/opt/csw/*)
 		confdest=$PKG_INSTALL_ROOT/$template
 	;;
-	*)
+	etc/opt/csw/*)
+		confdest=$PKG_INSTALL_ROOT/$template
+	;;
+	*/*)
+		echo ERROR: unrecognized/invalid path $template
+		exit 1
+	;;
+	*)  #should be just "filename" now
 		confdest=$PKG_INSTALL_ROOT/etc/opt/csw/$template
 	;;
 esac
@@ -80,7 +112,7 @@
 	elif [ -f $confdest ] ; then
 		echo $confdest already exists. Not overwriting
 	else
-		echo Copying $template to $confdest
+		echo Copying $TEMPLATEDIR/$template to $confdest
                 cp $template $confdest
 
 		echo Forcing proper permissions on $confdest

Modified: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswcptemplates
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswcptemplates	2011-01-03 17:42:45 UTC (rev 12161)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswcptemplates	2011-01-03 19:56:57 UTC (rev 12162)
@@ -26,25 +26,32 @@
 # Or, preserve ones that have been changed
 # First, go through list of templates that THIS package provides
 
-cd  $PKG_INSTALL_ROOT/opt/csw/etc/templates/$PKG || exit 0
-# I dont see how we would be called if that dir does not exist, but be 
-# paranoid.
 
+echo 'class <cswcptemplates> removal running'
 
 remove_cpfiles()
 {
-	cd  $PKG_INSTALL_ROOT/opt/csw/etc/templates/$PKG
-	if [ $? -ne 0 ] ; then #paranoia good.
+	#paranoia good.
+	if [ ! -d $PKG_INSTALL_ROOT/opt/csw/etc/templates/$PKG ] ; then
 		echo ERROR: $PKG_INSTALL_ROOT/opt/csw/etc/templates/$PKG does not exist
 		return
 	fi
+	cd  $PKG_INSTALL_ROOT/opt/csw/etc/templates/$PKG
 	
-	for template in `find . -type f ` ; do 
+	for template in `find . -type f ` ; do
+		template=`echo $template|sed 's:^./::'`
 		case $template in 
-		*/*)
+		var/opt/csw/*)
 			confdest=$PKG_INSTALL_ROOT/$template
 		;;
-		*)
+		etc/opt/csw/*)
+			confdest=$PKG_INSTALL_ROOT/$template
+		;;
+		*/*)
+			echo ERROR: unrecognized/invalid path $template
+			exit 1
+		;;
+		*)  #should be just "filename" now
 			confdest=$PKG_INSTALL_ROOT/etc/opt/csw/$template
 		;;
 		esac
@@ -84,3 +91,4 @@
 	# whatever file the OS itself, passes into us on stdin
 	rm -f $dest
 done
+echo '<end of cswcptemplates>'


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