Trochę zmian w apcupsd.spec

Zbigniew Bryczkowski kkalii w poczta.onet.pl
Czw, 8 Kwi 2004, 19:25:49 CEST


Witam

Załączam trochę zmian do ww. speca. Dodałem skrypt startowy, rozdzieliłem
pliki events i stats pierwszy ląduje w /var/log drugi w /var/lib/apcupsd,
dodałem rotację logów plus bcond with usb. Po szczegóły odsyłam do
załączników.

-- 
Zbychu
-------------- następna część ---------
diff -urN apcupsd-3.10.12.orig/autoconf/acconfig.h apcupsd-3.10.12.new/autoconf/acconfig.h
--- apcupsd-3.10.12.orig/autoconf/acconfig.h	2003-03-08 16:14:52.000000000 +0100
+++ apcupsd-3.10.12.new/autoconf/acconfig.h	2004-04-08 12:40:17.892974408 +0200
@@ -97,6 +97,9 @@
 /* Define the default "log" files directory. */
 #undef LOGDIR
 
+/* Define the default "status" files directory. */
+#undef STATDIR
+
 /* Define the default serial port lock directory */
 #undef LOCKDIR
 
diff -urN apcupsd-3.10.12.orig/autoconf/configure.in apcupsd-3.10.12.new/autoconf/configure.in
--- apcupsd-3.10.12.orig/autoconf/configure.in	2004-03-04 11:48:42.000000000 +0100
+++ apcupsd-3.10.12.new/autoconf/configure.in	2004-04-08 13:13:47.029539224 +0200
@@ -1176,10 +1176,19 @@
 	fi
 done
 
-# Find the default directory to put the apcupsd.events and apcupsd.status files
+# Find the default directory to put the apcupsd.events file
 for LOGDIR in "/var/log" "/etc/apcupsd"
 do
-	if test -d $LOGDIR 
+	if test -d $LOGDIR
+	then
+		break;
+	fi
+done
+
+# Find the default directory to put the apcupsd.status file
+for STATDIR in "/var/log" "/etc/apcupsd"
+do
+	if test -d $STATDIR
 	then
 		break;
 	fi
@@ -1479,11 +1488,18 @@
 )
 # now allow user to specify LOGDIR
 AC_ARG_WITH(log-dir,
-	[  --with-log-dir=DIR	   Specify EVENTS and STATUS directory (default is OS dependent)],
+	[  --with-log-dir=DIR	   Specify EVENTS directory (default is OS dependent)],
 	[
 		LOGDIR="$withval";
 	]
 )
+# now allow user to specify STATDIR
+AC_ARG_WITH(stat-dir,
+	[  --with-stat-dir=DIR	   Specify STATUS directory (default is OS dependent)],
+	[
+		STATDIR="$withval";
+	]
+)
 # now allow user to specify LOCKDIR
 AC_ARG_WITH(lock-dir,
 	[  --with-lock-dir=DIR	   Specify serial port lock directory (default is OS dependent)],
@@ -1549,6 +1565,8 @@
 AC_SUBST(PIDDIR)
 AC_DEFINE_UNQUOTED(LOGDIR, "$LOGDIR")
 AC_SUBST(LOGDIR)
+AC_DEFINE_UNQUOTED(STATDIR, "$STATDIR")
+AC_SUBST(STATDIR)
 AC_DEFINE_UNQUOTED(NOLOGDIR, "$nologdir")
 AC_SUBST(nologdir)
 AC_DEFINE_UNQUOTED(PWRFAILDIR, "$PWRFAILDIR")
@@ -1709,7 +1727,8 @@
   Install man files:	      ${mandir}
   Nologin file in:	      ${nologdir}
   PID directory:	      ${PIDDIR}
-  LOG dir (events, status)    ${LOGDIR}
+  LOG dir (events)            ${LOGDIR}
+  STATUS dir (status)         ${STATDIR}
   LOCK dir (for serial port)  ${LOCKDIR}
   Power Fail dir	      ${PWRFAILDIR}
   Compiler:		      ${CC} ${CCVERSION}
diff -urN apcupsd-3.10.12.orig/platforms/etc/apcupsd.conf.in apcupsd-3.10.12.new/platforms/etc/apcupsd.conf.in
--- apcupsd-3.10.12.orig/platforms/etc/apcupsd.conf.in	2003-11-26 16:54:47.000000000 +0100
+++ apcupsd-3.10.12.new/platforms/etc/apcupsd.conf.in	2004-04-08 13:27:59.542937488 +0200
@@ -217,7 +217,7 @@
 STATTIME 0
 #
 # Location of STATUS file (written to only if STATTIME is non-zero)
-STATFILE @LOGDIR@/apcupsd.status
+STATFILE @STATDIR@/apcupsd.status
 #
 #
 # LOGSTATS [ on | off ] on enables, off disables
-------------- następna część ---------
#! /bin/sh
#
# apcupsd      This shell script takes care of starting and stopping
#	       the apcupsd UPS monitoring daemon.
#
# chkconfig: 2345 60 99
# description: apcupsd monitors power and takes action if necessary

# Source function library
. /etc/rc.d/init.d/functions

# Get network config
. /etc/sysconfig/network

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down "UPS monitoring"
		exit 1
	fi
else
	exit 0
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	rm -f /etc/apcupsd/powerfail
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/apcupsd ]; then
		show "Starting APC UPS monitoring"
		daemon /usr/sbin/apcupsd -f /etc/apcupsd/apcupsd.conf
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/apcupsd
	else
		msg_already_running "APC UPS monitoring"
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/apcupsd ]; then
		msg_stopping "APC UPS monitoring"
		killproc apcupsd
		rm -f /var/lock/subsys/apcupsd
	else
		msg_not_running "APC UPS monitoring"
	fi
	;;
  restart)
	$0 stop
       	$0 start
	;;
  powerdown)
	if [ -f /etc/apcupsd/powerfail ]; then
		show "Switching the power off"
		/etc/apcupsd/apccontrol killpower
		sleep 60
		fail
	fi
	;;
  status)
	/usr/sbin/apcaccess status
	;;
  *)
	msg_usage "$0 {start|stop|restart|status|powerdown}"
	exit 3
esac

exit $RETVAL
-------------- następna część ---------
/var/log/apcupsd.events {
}
-------------- następna część ---------
--- apcupsd.spec	2004-04-08 18:48:04.123192864 +0200
+++ apcupsd.spec.new	2004-04-08 18:33:58.554738808 +0200
@@ -1,20 +1,20 @@
 # $Revision: 1.33 $, $Date: 2004/04/06 17:16:53 $
-# TODO:
-# - update paths and pld patches
-# - avoid messing in halt script in %post
+#
+# Conditional build:
+%bcond_with     usb            # with USB support
+#
 Summary:	Power management software for APC UPS hardware
 Summary(pl):	Oprogramowanie do zarządzania energią dla UPS-ów APC
 Name:		apcupsd
-Version:	3.10.10
+Version:	3.10.12
 Release:	0.1
 License:	GPL v2
 Group:		Networking/Daemons
 Source0:	http://dl.sourceforge.net/apcupsd/%{name}-%{version}.tar.gz
-# Source0-md5:	b69ccf4f4196582ab3e26bf6af937610
-Patch0:		%{name}-paths.patch
-Patch1:		%{name}-pld.patch
-#Patch1:	apcups-makefile.patch
-#Patch2:	%{name}-Makefile-fix.patch
+# Source0-md5:	4c35774d587c54276cf03926768ad551
+Source1:	%{name}.init
+Source2:	%{name}.logrotate
+Patch0:		%{name}-configure.patch
 URL:		http://www.apcupsd.com/
 Requires(post,preun):	/sbin/chkconfig
 Requires(post):	fileutils
@@ -38,60 +38,61 @@
 
 %prep
 %setup -q
-#%patch0 -p1	-- configure should be patched to move files from /var/log to /var/lib
-#%patch1 -p1	-- probably should be updated
-#%patch2 -p0
+%patch0 -p1
 
 %build
-%configure2_13
+cd autoconf
+%{__autoconf}
+cp -f ./configure ..
+cd ..
+%configure \
+	--with-log-dir=%{_var}/log \
+	--with-stat-dir=%{_var}/lib/apcupsd \
+%if %{with usb}
+	--enable-usb \
+	--with-serial-dev=/dev/usb/hiddev[0-15] \
+	--with-upstype=usb \
+	--with-upscable=usb
+%endif
+
 %{__make}
 
 %install
 rm -rf $RPM_BUILD_ROOT
-#install -d $RPM_BUILD_ROOT{/etc/rc.d/init.d,/var/log,/var/lib/apcupsd}
+install -d $RPM_BUILD_ROOT{/etc/rc.d/init.d,%{_var}/log,%{_var}/lib/apcupsd} \
+	$RPM_BUILD_ROOT/etc/logrotate.d
 
 %{__make} install \
 	DESTDIR=$RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
-install platforms/unknown/apcupsd $RPM_BUILD_ROOT/etc/rc.d/init.d/apcupsd
-#install platforms/pld/apcupsd  $RPM_BUILD_ROOT/etc/rc.d/init.d/apcupsd
-
-mkdir -p $RPM_BUILD_ROOT/var/log
-mkdir -p $RPM_BUILD_ROOT/var/lib/apcupsd
-touch $RPM_BUILD_ROOT/var/log/apcupsd.log
-touch $RPM_BUILD_ROOT/var/lib/apcupsd/apcupsd.status
-touch $RPM_BUILD_ROOT/var/lib/apcupsd/apcupsd.events
-mkdir -p $RPM_BUILD_ROOT/usr/share/doc/%{name}-%{version}
+
+install %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/apcupsd
+install %{SOURCE2} $RPM_BUILD_ROOT/etc/logrotate.d/apcupsd
+
+touch $RPM_BUILD_ROOT%{_var}/log/apcupsd.events
+touch $RPM_BUILD_ROOT%{_var}/lib/apcupsd/apcupsd.status
+
+cat > $RPM_BUILD_ROOT/etc/rc.d/init.d/halt << EOF
+#!/bin/sh
+/etc/rc.d/init.d/apcupsd powerdown
+EOF
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %post
 /sbin/chkconfig --add apcupsd
-
-#if !(grep /sbin/powersc /etc/rc.d/init.d/halt > /dev/null); then
-cp -f /etc/rc.d/init.d/halt /etc/rc.d/init.d/halt.rpmorig
-#sed -e '/# Now halt or reboot./i\' \
-#     -e '\
-# See if this is a powerfail situation.\
-
-echo '
-if [ -f /etc/apcupsd/powerfail ]; then\
-  echo "APCUPSD to the Rescue!"\
-  echo\
-  /etc/apcupsd/apccontrol killpower \
-  echo\
-  sleep 120\
-  exit 1\
-fi\
-' >  /etc/rc.d/init.d/halt
-#' /etc/rc.d/init.d/halt.rpmorig > /etc/rc.d/init.d/halt
-#fi
-chmod 754 /etc/rc.d/init.d/halt
+if [ -f /var/lock/subsys/apcupsd ]; then
+        /etc/rc.d/init.d/apcupsd restart >&2
+else
+	echo "Run \"/etc/rc.d/init.d/apcupsd start\" to start apcupsd daemon."
+fi
 
 %preun
 if [ "$1" = "0" ]; then
-	/sbin/chkconfig --del apcupsd
+	if [ -f /var/lock/subsys/apcupsd ]; then
+		/etc/rc.d/init.d/apcupsd stop >&2
+	fi
+/sbin/chkconfig --del apcupsd
 fi
 
 %files
@@ -99,12 +100,20 @@
 %doc ChangeLog Developers doc/{README.apcaccess,developers_manual,home-page,logo}
 %{_mandir}/man8/apcupsd.*
 %attr(755,root,root) %{_sbindir}/*
-#%attr(755,root,root) %config /sbin/powersc
 %attr(640,root,root) %config(noreplace) %{_sysconfdir}/apcupsd.conf
+%attr(754,root,root) %{_sysconfdir}/apccontrol
+%attr(754,root,root) %{_sysconfdir}/changeme
+%attr(754,root,root) %{_sysconfdir}/commfailure
+%attr(754,root,root) %{_sysconfdir}/commok
+%attr(754,root,root) %{_sysconfdir}/mainsback
+%attr(754,root,root) %{_sysconfdir}/masterconnect
+%attr(754,root,root) %{_sysconfdir}/mastertimeout
+%attr(754,root,root) %{_sysconfdir}/onbattery
 %attr(754,root,root) /etc/rc.d/init.d/apcupsd
-%ghost /var/log/apcupsd.log
-%ghost /var/lib/apcupsd/apcupsd.status
-%ghost /var/lib/apcupsd/apcupsd.events
+%attr(754,root,root) /etc/rc.d/init.d/halt
+%attr(640,root,root) /etc/logrotate.d/apcupsd
+%attr(640,root,root) %ghost %{_var}/lib/apcupsd/apcupsd.status
+%attr(640,root,root) %ghost %{_var}/log/apcupsd.events
 
 %define date	%(echo `LC_ALL="C" date +"%a %b %d %Y"`)
 %changelog


Więcej informacji o liście dyskusyjnej pld-devel-pl