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

theferret at users.sourceforge.net theferret at users.sourceforge.net
Tue Aug 24 00:37:01 CEST 2010


Revision: 10802
          http://gar.svn.sourceforge.net/gar/?rev=10802&view=rev
Author:   theferret
Date:     2010-08-23 22:37:00 +0000 (Mon, 23 Aug 2010)

Log Message:
-----------
cswclassutils: Added support for CSWDESTDIR to cswpreserveconf

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

Modified: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswpreserveconf
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswpreserveconf	2010-08-23 17:40:20 UTC (rev 10801)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.i.cswpreserveconf	2010-08-23 22:37:00 UTC (rev 10802)
@@ -10,12 +10,30 @@
 # May be used/copied freely
 #
 
+# extra checks and warnings to help people run this manually
+if [ "$PKG" = "" ] ; then
+	echo ERROR: PKG env variable must be set
+	exit 1
+fi
 
 while read src dest ; do
 	cp $src $dest
-
+	if [ $? -ne 0 ] ; then
+		# It's technically "okay" if the copy fails in some situations.
+		# For example, if we have shared root and the file is already
+		# there. Except I dont think we would be run in that case
+		# anyway. erm..
+		if [ ! -f $src ] ; then
+			echo ERROR: src $src does not exist
+			exit 1
+		fi
+	fi
 	# reminder: $dest will already have $PKG_INSTALL_ROOT prepended for us
 
+	# We always copy to $dest. However, the purpose of this script
+	# is to make a second copy of this "sample" config,
+	# to the "real" location
+
 	case $dest in
 		*.csw)
 			confdest=`echo $dest |sed 's/.csw$//'`
@@ -28,10 +46,17 @@
 			exit 1
 			;;
 	esac
+
 	preservedir=$PKG_INSTALL_ROOT/etc/opt/csw/preserve/$PKG
 	confbasename=`basename $confdest`
 	preservedconf=$preservedir/$confbasename
 
+	overridedir=`sed -n  's/.*CSWDESTDIR=\([^ ]*\).*/\1/p' $src`
+	if [ "$overridedir" != "" ] ; then
+		# basename will not change so dont need to reset that
+		confdest=$PKG_INSTALL_ROOT/$overridedir/$basename
+	fi
+
 	if [ -f $preservedconf ] ; then
 		echo Restoring $preservedconf
 		cp -p $preservedconf $confdest
@@ -55,7 +80,16 @@
 			chown $user:$group $confdest
 		fi
 	fi
+	copied="done"
 done
 
+if [ "$copied"  = "" ] ; then
+	echo WARNING: we were called, but no filenames were given.
+	echo "You may have to manually run this script ( $0 )"
+	echo "and pass it the name of the config files in the package."
+	echo "Or, copy over the appropriate config files by hand yourself,"
+	echo "to their proper destinations .
+fi
+
 echo ""
 

Modified: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswpreserveconf
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswpreserveconf	2010-08-23 17:40:20 UTC (rev 10801)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswpreserveconf	2010-08-23 22:37:00 UTC (rev 10802)
@@ -4,6 +4,12 @@
 # May be used/copied freely
 #
 
+# extra checks and warnings to help people run this manually
+if [ "$PKG" = "" ] ; then
+	echo ERROR: PKG env variable must be set
+	exit 1
+fi
+
 while read dest ; do
 	# reminder: $dest will already have $PKG_INSTALL_ROOT prepended for us
 
@@ -24,6 +30,12 @@
 	confbasename=`basename $confdest`
 	preservedconf=$preservedir/$confbasename
 
+	overridedir=`sed -n  's/.*CSWDESTDIR=\([^ ]*\).*/\1/p' $src`
+	if [ "$overridedir" != "" ] ; then
+		# basename will not change so dont need to reset that
+		confdest=$PKG_INSTALL_ROOT/$overridedir/$basename
+	fi
+
 	if [ -f $confdest ] ; then
 		if cmp $confdest $dest >/dev/null ; then
 			echo $confdest is identical to sample config file $dest


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