From dc76a1b20fed94b3d76bfc07e7e83561eb5f5f45 Mon Sep 17 00:00:00 2001
From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Thu, 10 Oct 2002 20:17:46 +0000
Subject: [PATCH] Added RPM spec file; modified Makefile for arbitrary
 $(DESTDIR)

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@16 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/Makefile           | 27 +++++++++------
 sm5/smartmontools.spec | 79 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+), 10 deletions(-)
 create mode 100644 sm5/smartmontools.spec

diff --git a/sm5/Makefile b/sm5/Makefile
index 58ecd39ae..f030149ed 100644
--- a/sm5/Makefile
+++ b/sm5/Makefile
@@ -1,6 +1,6 @@
 # Makefile for smartmontools
 #
-# $Id: Makefile,v 1.5 2002/10/10 13:21:14 ballen4705 Exp $
+# $Id: Makefile,v 1.6 2002/10/10 20:17:46 ballen4705 Exp $
 #
 # Copyright (C) 2002 Bruce Allen <ballen@uwm.edu>
 # 
@@ -14,7 +14,8 @@
 # Mass Ave, Cambridge, MA 02139, USA.
 
 CC	= gcc
-CFLAGS	= -fsigned-char -Wall -g 
+# CFLAGS = -fsigned-char -Wall -g 
+CFLAGS	= -fsigned-char -Wall -O2
 
 all: smartd smartctl
 
@@ -37,15 +38,16 @@ scsicmds.o: scsicmds.h scsicmds.c
 	${CC} ${CFLAGS} -c scsicmds.c
 
 clean:
-	rm -f *.o smartctl smartd *~ smartmontools*.tar.gz
+	rm -f *.o smartctl smartd *~ smartmontools*.tar.gz smartmontools*.rpm
 
 install: smartctl smartd smartctl.8 smartd.8 smartd.initd
-	install -m 755 -o root -g root smartctl /usr/sbin
-	install -m 755 -o root -g root smartd /usr/sbin
-	install -m 644 -o root -g root smartctl.8 /usr/share/man/man8
-	install -m 644 -o root -g root smartd.8 /usr/share/man/man8
-	install -m 755 -o root -g root smartd.initd /etc/rc.d/init.d/smartd
-	/sbin/chkconfig --add smartd
+	install -m 755 -o root -g root -D smartctl $(DESTDIR)/usr/sbin/smartctl
+	install -m 755 -o root -g root -D smartd $(DESTDIR)/usr/sbin/smartd
+	install -m 644 -o root -g root -D smartctl.8 $(DESTDIR)/usr/share/man/man8/smartctl.8
+	install -m 644 -o root -g root -D smartd.8 $(DESTDIR)/usr/share/man/man8/smartd.8
+	install -m 755 -o root -g root -D smartd.initd $(DESTDIR)/etc/rc.d/init.d/smartd
+	echo "To manually start smartd on bootup, run etc/rc.d/init.d/smartd start"
+	echo "To Automatically start smartd on bootup, run /sbin/chkconfig --add smartd"
 
 uninstall:
 	rm -f /usr/sbin/smartctl /usr/sbin/smartd /usr/share/man/man8/smartctl.8 /usr/share/man/man8/smartd.8  /usr/share/man/man8/smartctl.8.gz /usr/share/man/man8/smartd.8.gz
@@ -55,7 +57,7 @@ uninstall:
 
 releasefiles=atacmds.c atacmds.h ataprint.c ataprint.h CHANGELOG COPYING extern.h Makefile\
   README scsicmds.c scsicmds.h scsiprint.c scsiprint.h smartctl.8 smartctl.c smartctl.h\
-  smartd.8 smartd.c smartd.h smartd.initd
+  smartd.8 smartd.c smartd.h smartd.initd TODO
 
 pkgname=smartmontools-5.0
 workdir=$(pkgname)
@@ -66,4 +68,9 @@ release: $(releasefiles)
 	cp -a $(releasefiles) $(workdir)
 	tar zcvf $(pkgname).tar.gz $(workdir)
 	rm -rf $(workdir)
+	cp $(pkgname).tar.gz /usr/src/redhat/SOURCES
+	rpm -ba smartmontools.spec
+	mv /usr/src/redhat/RPMS/i386/$(pkgname)*.rpm .
+	mv /usr/src/redhat/SRPMS/$(pkgname)*rpm .
+	rm -f /usr/src/redhat/SOURCES/$(pkgname).tar.gz
 
diff --git a/sm5/smartmontools.spec b/sm5/smartmontools.spec
new file mode 100644
index 000000000..1d1f5993e
--- /dev/null
+++ b/sm5/smartmontools.spec
@@ -0,0 +1,79 @@
+Summary:	SMARTmontools - for monitoring S.M.A.R.T. disks and devices
+Name:		smartmontools
+Version:	5.0
+Release:	1
+License:	GPL
+Group:		Applications/System
+Source0:	http://prdownloads.sourceforge.net/%{name}-%{version}.tar.gz
+URL:            http://smartmontools.sourceforge.net/
+Prereq:		/sbin/chkconfig
+BuildRoot:	%{_builddir}/%{name}-%{version}-root
+Obsoletes:	smartctl
+Obsoletes:      smartd
+Obsoletes:	ucsc-smartsuite
+Obsoletes:      smartsuite
+
+%description 
+SMARTmontools controls and monitors storage devices using the
+Self-Monitoring, Analysis and Reporting Technology System (S.M.A.R.T.)
+build into ATA and SCSI Hard Drives. This is used to check the
+reliability of the hard drive and predict drive failures. The suite
+contents two utilities.  The first, smartctl, is a command line
+utility designed to perform simple S.M.A.R.T. tasks. The second,
+smartd, is a daemon that periodically monitors smart status and
+reports errors to syslog.  The package is compatible with the
+ATA/ATAPI-5 specification.  Future releases will be compatible with
+the ATA/ATAPI-6 andATA/ATAPI-7 specifications.  The package is
+intended to incorporate as much "vendor specific" and "reserved"
+information as possible about disk drives.  man smartctl and man
+smartd will provide more information.
+
+# The following sections are executed by the SRPM file
+%prep
+
+%setup -q
+
+%build
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make DESTDIR=$RPM_BUILD_ROOT install
+
+
+%files
+%defattr(-,root,root)
+/usr/sbin/smartd
+/usr/sbin/smartctl
+/etc/rc.d/init.d/smartd
+%doc %attr(644,root,root) /usr/share/man/man8/smartctl.8.gz
+%doc %attr(644,root,root) /usr/share/man/man8/smartd.8.gz
+%doc CHANGELOG COPYING TODO README
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+rm -rf 
+
+# The following are executed only by the binary RPM at install/uninstall
+
+%post
+if [ -f /var/lock/subsys/smartd ]; then
+        /etc/rc.d/init.d/smartd restart 1>&2
+	echo "Restarted smartd services"
+else
+        echo "Run \"/etc/rc.d/init.d/smartd start\" to start smartd service now."
+	echo "Run \"/sbin/chkconfig --add smartd\", to start smartd service on system boot"
+fi
+
+%preun
+if [ -f /var/lock/subsys/smartd ]; then
+        /etc/rc.d/init.d/smartd stop 1>&2
+	echo "Stopping smartd services"
+fi
+/sbin/chkconfig --del smartd
+
+%define date	%(echo `LC_ALL="C" date +"%a %b %d %Y"`)
+%changelog
+* %{date} Bruce Allen ballen@uwm.edu
+Initial release.  Code is derived from smartsuite, and is
+   intended to be compatible with the ATA/ATAPI-5 specifications.
-- 
GitLab