[csw-devel] SF.net SVN: gar:[6814] csw/mgar/pkg
bdwalton at users.sourceforge.net
bdwalton at users.sourceforge.net
Sat Oct 10 05:06:54 CEST 2009
Revision: 6814
http://gar.svn.sourceforge.net/gar/?rev=6814&view=rev
Author: bdwalton
Date: 2009-10-10 03:06:54 +0000 (Sat, 10 Oct 2009)
Log Message:
-----------
cswpkglogger: initial commit of hooks to syslog package actions
Added Paths:
-----------
csw/mgar/pkg/cswpkglogger/
csw/mgar/pkg/cswpkglogger/branches/
csw/mgar/pkg/cswpkglogger/tags/
csw/mgar/pkg/cswpkglogger/trunk/
csw/mgar/pkg/cswpkglogger/trunk/Makefile
csw/mgar/pkg/cswpkglogger/trunk/checksums
csw/mgar/pkg/cswpkglogger/trunk/files/
csw/mgar/pkg/cswpkglogger/trunk/files/01-CSWcswpkglogger-postupgrade
csw/mgar/pkg/cswpkglogger/trunk/files/01-CSWcswpkglogger-preupgrade
Property changes on: csw/mgar/pkg/cswpkglogger/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/cswpkglogger/trunk/Makefile
===================================================================
--- csw/mgar/pkg/cswpkglogger/trunk/Makefile (rev 0)
+++ csw/mgar/pkg/cswpkglogger/trunk/Makefile 2009-10-10 03:06:54 UTC (rev 6814)
@@ -0,0 +1,34 @@
+GARNAME = cswpkglogger
+GARVERSION = 1.0
+CATEGORIES = utils
+
+DESCRIPTION = Hook scripts to log package maintenance actions
+define BLURB
+This set of hook scripts will log package maintenance actions to syslog.
+It is dependent on the use of a CSW package tool that is 'hook aware.'
+endef
+
+MASTER_SITES =
+DISTFILES =
+
+ARCHALL = 1
+
+CONFIGURE_SCRIPTS =
+BUILD_SCRIPTS =
+TEST_SCRIPTS =
+INSTALL_SCRIPTS = custom
+
+include gar/category.mk
+
+HOOKDIR=$(DESTDIR)/etc/opt/csw/pkg-hooks
+POSTHOOKS = postinstall postupgrade postremove
+PREHOOKS = preupgrade
+HOOKS = $(PREHOOKS) $(POSTHOOKS)
+
+install-custom:
+ @echo Installing CSWcswpkglogger files...
+ @( ginstall -m 0755 -d $(HOOKDIR) $(addprefix $(HOOKDIR)/,$(addsuffix .d,$(HOOKS))); \
+ ginstall -m 0755 $(FILEDIR)/01-CSWcswpkglogger-postupgrade $(HOOKDIR)/postupgrade.d/; \
+ ln $(HOOKDIR)/postupgrade.d/01-CSWcswpkglogger-postupgrade $(HOOKDIR)/postinstall.d/01-CSWcswpkglogger-postinstall; \
+ ln $(HOOKDIR)/postupgrade.d/01-CSWcswpkglogger-postupgrade $(HOOKDIR)/postremove.d/01-CSWcswpkglogger-postremove; \
+ ginstall -m 0755 $(FILEDIR)/01-CSWcswpkglogger-preupgrade $(HOOKDIR)/preupgrade.d/;)
Added: csw/mgar/pkg/cswpkglogger/trunk/files/01-CSWcswpkglogger-postupgrade
===================================================================
--- csw/mgar/pkg/cswpkglogger/trunk/files/01-CSWcswpkglogger-postupgrade (rev 0)
+++ csw/mgar/pkg/cswpkglogger/trunk/files/01-CSWcswpkglogger-postupgrade 2009-10-10 03:06:54 UTC (rev 6814)
@@ -0,0 +1,62 @@
+#!/opt/csw/bin/bash
+
+script=$0
+
+set -- ${1/-/ }
+PKG=$1
+VER=$2
+
+function logdie() {
+ logger -t "CSW Package Logger" "$1"
+ exit 0
+}
+
+function success() {
+ case ${script} in
+ *install) MSG="installed ${PKG} ${VER}";;
+ *upgrade) MSG="upgraded ${PKG} to ${VER} (from: $1)";;
+ *remove) MSG="removed ${PKG} ${VER}";;
+ esac
+
+ logdie "${MSG}"
+}
+
+function failure() {
+ case ${script} in
+ *install) MSG="Failed to install ${PKG} ${VER}";;
+ *upgrade) MSG="Failed to upgrade ${PKG} ${VER} (current: $1)";;
+ *remove) MSG="Failed to remove ${PKG} ${VER}";;
+ esac
+
+ logdie "${MSG}"
+}
+
+if [ -d /var/sadm/pkg/${PKG} ]; then
+ SYSTEMVER=$(pkgparam ${PKG} VERSION 2>/dev/null)
+ pf=/var/opt/csw/pkg-hooks/CSWpkglogger.upgrade.${PKG}
+ if [ -f ${pf} ]; then
+ PREVVER=$(cat ${pf} 2>/dev/null)
+ rm -f ${pf}
+ fi
+
+ case ${script} in
+ *remove)
+ failure
+ ;;
+ *install|*upgrade)
+ case "${VER}" in
+ ${SYSTEMVER}) success ${PREVVER};;
+ *) failure ${SYSTEMVER};;
+ esac
+ ;;
+ esac
+else
+ case ${script} in
+ *remove)
+ success
+ ;;
+ *install|*upgrade)
+ failure
+ ;;
+ esac
+fi
Property changes on: csw/mgar/pkg/cswpkglogger/trunk/files/01-CSWcswpkglogger-postupgrade
___________________________________________________________________
Added: svn:executable
+ *
Added: csw/mgar/pkg/cswpkglogger/trunk/files/01-CSWcswpkglogger-preupgrade
===================================================================
--- csw/mgar/pkg/cswpkglogger/trunk/files/01-CSWcswpkglogger-preupgrade (rev 0)
+++ csw/mgar/pkg/cswpkglogger/trunk/files/01-CSWcswpkglogger-preupgrade 2009-10-10 03:06:54 UTC (rev 6814)
@@ -0,0 +1,11 @@
+#!/opt/csw/bin/bash
+
+set -- ${1/-/ }
+
+PKG=$1
+VER=$2
+
+SYSTEMVER=$(pkgparam ${PKG} VERSION)
+
+# store previous version so we can log smarter things if upgrade fails.
+echo ${SYSTEMVER} > /var/opt/csw/pkg-hooks/CSWpkglogger.upgrade.${PKG}
Property changes on: csw/mgar/pkg/cswpkglogger/trunk/files/01-CSWcswpkglogger-preupgrade
___________________________________________________________________
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