[csw-devel] SF.net SVN: gar:[12154] csw/mgar/pkg/cswclassutils/trunk/files/ CSWcswclassutils.r.cswcptemplates
theferret at users.sourceforge.net
theferret at users.sourceforge.net
Mon Jan 3 01:48:50 CET 2011
Revision: 12154
http://gar.svn.sourceforge.net/gar/?rev=12154&view=rev
Author: theferret
Date: 2011-01-03 00:48:49 +0000 (Mon, 03 Jan 2011)
Log Message:
-----------
cswcptemplates: other half
Added Paths:
-----------
csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswcptemplates
Added: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswcptemplates
===================================================================
--- csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswcptemplates (rev 0)
+++ csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswcptemplates 2011-01-03 00:48:49 UTC (rev 12154)
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# See i.cswcptemplates for more detailed comments.
+#
+# Author: Philip Brown 2010
+# 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
+
+# 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
+# erm.. I think. True of INSTALL, but havent explicitly tested for pkgrm
+
+# Either way, we actually do work based on
+# "All files under /opt/csw/etc/templates/$PKG"
+
+
+#we remove all templated files that are unchanged.
+# 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.
+
+
+remove_cpfiles()
+{
+ cd $PKG_INSTALL_ROOT/opt/csw/etc/templates/$PKG
+ if [ $? -ne 0 ] ; then #paranoia good.
+ echo ERROR: $PKG_INSTALL_ROOT/opt/csw/etc/templates/$PKG does not exist
+ return
+ fi
+
+ for template in `find . -type f ` ; do
+ case $template in
+ */*)
+ confdest=$PKG_INSTALL_ROOT/$template
+ ;;
+ *)
+ confdest=$PKG_INSTALL_ROOT/etc/opt/csw/$template
+ ;;
+ esac
+
+
+ preservedir=$PKG_INSTALL_ROOT/etc/opt/csw/preserve/$PKG
+ confbasename=`basename $confdest`
+ preservedconf=$preservedir/$confbasename
+
+ if [ -f $confdest ] ; then
+ if cmp $confdest $template >/dev/null ; then
+ echo $confdest is identical to sample config file $template
+ echo Removing $confdest
+ rm -f $confdest
+ else
+ echo "preserving $confdest to $preservedconf"
+ mkdir -p $preservedir 2>/dev/null
+ # note: for safety, do this way, not "mv"
+ cp -p $confdest $preservedconf && rm $confdest
+ fi
+ fi
+
+ done
+}
+
+
+#remove files cp'd from templates
+remove_cpfiles
+
+
+# Lastly, remove pkg templates as per SVR4 pkg spec requirements
+while read dest ; do
+ # reminder: $dest will already have $PKG_INSTALL_ROOT prepended for us
+
+
+ # Any way it shakes out, we always remove the "sample conf", or
+ # whatever file the OS itself, passes into us on stdin
+ rm -f $dest
+done
Property changes on: csw/mgar/pkg/cswclassutils/trunk/files/CSWcswclassutils.r.cswcptemplates
___________________________________________________________________
Added: svn:executable
+ *
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