Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jul 2010 05:42:49 +0000 (UTC)
From:      Doug Barton <dougb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r210399 - user/dougb/portmaster
Message-ID:  <201007230542.o6N5gnlq092466@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dougb
Date: Fri Jul 23 05:42:49 2010
New Revision: 210399
URL: http://svn.freebsd.org/changeset/base/210399

Log:
  Add an option to log actions after the run is complete. To enable it
  define PM_LOG in your rc file as the path of the file you want to log
  to. If using PM_SU_CMD make sure that the directory or file is writable
  by the unprivileged user.

Modified:
  user/dougb/portmaster/portmaster

Modified: user/dougb/portmaster/portmaster
==============================================================================
--- user/dougb/portmaster/portmaster	Thu Jul 22 23:30:24 2010	(r210398)
+++ user/dougb/portmaster/portmaster	Fri Jul 23 05:42:49 2010	(r210399)
@@ -180,16 +180,31 @@ parent_exit () {
 	if [ -n "$INSTALLED_LIST" ]; then
 		if [ -n "$UPDATE_ALL" -o -n "$PM_MULTI_PORTS" ]; then
 			show_list=all
-		else
+		elif [ -z "$show_list" ]; then
 			case "$INSTALLED_LIST" in
 			*\\n\\t*)	show_list=all ;;
 			*\\n)		show_list=one ;;
 			esac
 		fi
+		if [ -n "$PM_LOG" ]; then
+			if [ -f "$PM_LOG" ]; then
+				echo '' >> $PM_LOG
+			elif [ -e "$PM_LOG" -o -L "$PM_LOG" ]; then
+				echo "===>>> Warning: $PM_LOG exists, but is not a regular file"
+			else
+				local new_pm_log
+
+				new_pm_log=`pm_mktemp pm_log` &&
+					mv $new_pm_log $PM_LOG
+			fi
+			date >> $PM_LOG
+		fi
 		case "$show_list" in
 		all)	echo "===>>> The following actions were performed:"
-			echo -e $INSTALLED_LIST ;;
-		one)	echo "===>>> $ilist complete" ; echo '' ;;
+			echo -e $INSTALLED_LIST
+			[ -n "$PM_LOG" ] && echo -e $INSTALLED_LIST >> $PM_LOG ;;
+		one)	echo "===>>> $ilist complete" ; echo ''
+			[ -n "$PM_LOG" ] && echo "	$ilist" >> $PM_LOG ;;
 		esac
 	fi
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007230542.o6N5gnlq092466>