From 3be6ed7d426b48fa66804a5c03d9937a95d51afb Mon Sep 17 00:00:00 2001 From: "jmcd@samba.org" <> Date: Sun, 27 May 2007 16:48:18 -0400 Subject: [PATCH] Inital rpm build files (This used to be ctdb commit 8830592b9202d6edab16af5c717608096597c517) --- ctdb/Makefile.in | 9 +- ctdb/packaging/RHEL/ctdb.spec | 120 +++++++++++++++++++++++ ctdb/packaging/RHEL/makerpms.sh | 81 +++++++++++++++ ctdb/packaging/RHEL/setup/ctdb.init | 105 ++++++++++++++++++++ ctdb/packaging/RHEL/setup/ctdb.sysconfig | 2 + 5 files changed, 313 insertions(+), 4 deletions(-) create mode 100644 ctdb/packaging/RHEL/ctdb.spec create mode 100755 ctdb/packaging/RHEL/makerpms.sh create mode 100755 ctdb/packaging/RHEL/setup/ctdb.init create mode 100644 ctdb/packaging/RHEL/setup/ctdb.sysconfig diff --git a/ctdb/Makefile.in b/ctdb/Makefile.in index a4a26c0b678..41839c7ed17 100644 --- a/ctdb/Makefile.in +++ b/ctdb/Makefile.in @@ -11,6 +11,7 @@ localstatedir = @localstatedir@ VPATH = @srcdir@:@tdbdir@:@tallocdir@:@libreplacedir@:@poptdir@ srcdir = @srcdir@ builddir = @builddir@ +DESTDIR = / EXTRA_OBJ=@EXTRA_OBJ@ POPT_LIBS = @POPT_LIBS@ @@ -110,10 +111,10 @@ distclean: clean rm -f Makefile install: all - mkdir -p $(bindir) - mkdir -p $(includedir) - rsync $(BINS) $(bindir) - rsync $(srcdir)/include/ctdb.h $(includedir) + mkdir -p $(DESTDIR)$(bindir) + mkdir -p $(DESTDIR)$(includedir) + rsync $(BINS) $(DESTDIR)$(bindir) + rsync $(srcdir)/include/ctdb.h $(DESTDIR)$(includedir) test: all tests/run_tests.sh diff --git a/ctdb/packaging/RHEL/ctdb.spec b/ctdb/packaging/RHEL/ctdb.spec new file mode 100644 index 00000000000..67564fa9304 --- /dev/null +++ b/ctdb/packaging/RHEL/ctdb.spec @@ -0,0 +1,120 @@ +%define initdir %{_sysconfdir}/rc.d/init.d + +Summary: Clustered TDB +Vendor: Samba Team +Packager: Samba Team +Name: ctdb +Version: 1.0 +Release: 1 +Epoch: 0 +License: GNU GPL version 2 +Group: System Environment/Daemons +URL: bzr://www.samba.org/~tridge/ctdb/ + +Source: ctdb-%{version}.tar.bz2 +Source999: setup.tar.bz2 + +Prereq: /sbin/chkconfig /bin/mktemp /usr/bin/killall +Prereq: fileutils sed /etc/init.d + +Requires: initscripts >= 5.54-1 +Provides: ctdb = %{version} + +Prefix: /usr +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +ctdb is the clustered database used by samba + + +####################################################################### + +%prep +%setup -q +# setup the init script and sysconfig file +%setup -T -D -a 999 -n ctdb-%{version} -q + +%build + +# RPM_OPT_FLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64" + +## check for ccache +# ccache -h 2>&1 > /dev/null +#if [ $? -eq 0 ]; then +# CC="ccache gcc" +#else + CC="gcc" +#fi + +## always run autogen.sh +./autogen.sh + +CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE" ./configure \ + --prefix=%{_prefix} \ + +make showflags + +make + + +%install +# Clean up in case there is trash left from a previous build +rm -rf $RPM_BUILD_ROOT + +# Create the target build directory hierarchy +mkdir -p $RPM_BUILD_ROOT%{_includedir} +mkdir -p $RPM_BUILD_ROOT{%{_libdir},%{_includedir}} +mkdir -p $RPM_BUILD_ROOT%{_prefix}/{bin,sbin} +mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d + +make DESTDIR=$RPM_BUILD_ROOT \ + install + +install -m644 setup/ctdb.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ctdb +install -m755 setup/ctdb.init $RPM_BUILD_ROOT%{initdir}/ctdb + +# Remove "*.old" files +find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \; + +%clean +rm -rf $RPM_BUILD_ROOT + +%post + +%preun +if [ $1 = 0 ] ; then + /sbin/chkconfig --del ctdb + /sbin/service ctdb stop >/dev/null 2>&1 +fi +exit 0 + +%postun +if [ "$1" -ge "1" ]; then + %{initdir}/ctdb restart >/dev/null 2>&1 +fi + + +####################################################################### +## Files section ## +####################################################################### + +%files +%defattr(-,root,root) + +%config(noreplace) %{_sysconfdir}/sysconfig/ctdb +%attr(755,root,root) %config %{initdir}/ctdb + +%{_bindir}/ctdbd +%{_bindir}/ctdb_test +%{_bindir}/ctdbd_test +%{_bindir}/ctdb_control +%{_bindir}/ctdb_bench +%{_bindir}/ctdb_fetch +%{_bindir}/ctdb_fetch1 +%{_bindir}/ctdb_messaging +%{_bindir}/lockwait +%{_includedir}/ctdb.h + + diff --git a/ctdb/packaging/RHEL/makerpms.sh b/ctdb/packaging/RHEL/makerpms.sh new file mode 100755 index 00000000000..8d847bbd51a --- /dev/null +++ b/ctdb/packaging/RHEL/makerpms.sh @@ -0,0 +1,81 @@ +#!/bin/sh +# Copyright (C) John H Terpstra 1998-2002 +# Gerald (Jerry) Carter 2003 +# Jim McDonough 2007 + +# The following allows environment variables to override the target directories +# the alternative is to have a file in your home directory calles .rpmmacros +# containing the following: +# %_topdir /home/mylogin/redhat +# +# Note: Under this directory rpm expects to find the same directories that are under the +# /usr/src/redhat directory +# + +EXTRA_OPTIONS="$1" + +SPECDIR=`rpm --eval %_specdir` +SRCDIR=`rpm --eval %_sourcedir` + +# At this point the SPECDIR and SRCDIR vaiables must have a value! + +USERID=`id -u` +GRPID=`id -g` +VERSION='1.0' +REVISION='' +SPECFILE="ctdb.spec" +RPMVER=`rpm --version | awk '{print $3}'` +RPM="rpmbuild" + +## +## Check the RPM version (paranoid) +## +case $RPMVER in + 4*) + echo "Supported RPM version [$RPMVER]" + ;; + *) + echo "Unknown RPM version: `rpm --version`" + exit 1 + ;; +esac + +pushd . +cd ../.. +if [ -f Makefile ]; then + make distclean +fi +popd + +pushd . +cd ../../../ +chown -R ${USERID}.${GRPID} ctdb +if [ ! -d ctdb-${VERSION} ]; then + ln -s ctdb ctdb-${VERSION} || exit 1 +fi +echo -n "Creating ctdb-${VERSION}.tar.bz2 ... " +tar --exclude=.bzr --exclude .bzrignore --exclude packaging -cf - ctdb-${VERSION}/. | bzip2 > ${SRCDIR}/ctdb-${VERSION}.tar.bz2 +echo "Done." +if [ $? -ne 0 ]; then + echo "Build failed!" + exit 1 +fi + +popd + + +## +## copy additional source files +## +tar --exclude=.svn -jcvf - setup > ${SRCDIR}/setup.tar.bz2 +cp -p ${SPECFILE} ${SPECDIR} + +## +## Build +## +echo "$(basename $0): Getting Ready to build release package" +cd ${SPECDIR} +${RPM} -ba --clean --rmsource $EXTRA_OPTIONS $SPECFILE + +echo "$(basename $0): Done." + diff --git a/ctdb/packaging/RHEL/setup/ctdb.init b/ctdb/packaging/RHEL/setup/ctdb.init new file mode 100755 index 00000000000..2ea65d1e117 --- /dev/null +++ b/ctdb/packaging/RHEL/setup/ctdb.init @@ -0,0 +1,105 @@ +#!/bin/sh +# +# chkconfig: - 91 35 +# description: Starts and stops the Samba smbd and nmbd daemons \ +# used to provide SMB network services. +# +# pidfile: /var/run/samba/smbd.pid +# pidfile: /var/run/samba/nmbd.pid +# config: /etc/samba/smb.conf + + +# Source function library. +if [ -f /etc/init.d/functions ] ; then + . /etc/init.d/functions +elif [ -f /etc/rc.d/init.d/functions ] ; then + . /etc/rc.d/init.d/functions +else + exit 0 +fi + +# Avoid using root's TMPDIR +unset TMPDIR + +# Source networking configuration. +. /etc/sysconfig/network + +if [ -f /etc/sysconfig/ctdb ]; then + . /etc/sysconfig/ctdb +fi + +# Check that networking is up. +[ ${NETWORKING} = "no" ] && exit 0 + +# Check that smb.conf exists. +[ -f /etc/samba/smb.conf ] || exit 0 + +RETVAL=0 + + +start() { + echo -n $"Starting ctdbd services: " + daemon ctdbd $CTDBDOPTIONS + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || \ + RETVAL=1 + return $RETVAL +} + +stop() { + echo -n $"Shutting down ctdbd services: " + killproc ctdbd + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb + echo "" + return $RETVAL +} + +restart() { + stop + start +} + +rhstatus() { + status ctdbd + if [ $? -ne 0 ] ; then + return 1 + fi +} + + +# Allow status as non-root. +if [ "$1" = status ]; then + rhstatus + exit $? +fi + +# Check that we can write to it... so non-root users stop here +[ -w /etc/samba/smb.conf ] || exit 0 + + + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + status) + rhstatus + ;; + condrestart) + [ -f /var/lock/subsys/ctdb ] && restart || : + ;; + *) + echo $"Usage: $0 {start|stop|restart|status|condrestart}" + exit 1 +esac + +exit $? diff --git a/ctdb/packaging/RHEL/setup/ctdb.sysconfig b/ctdb/packaging/RHEL/setup/ctdb.sysconfig new file mode 100644 index 00000000000..e9e5774a404 --- /dev/null +++ b/ctdb/packaging/RHEL/setup/ctdb.sysconfig @@ -0,0 +1,2 @@ +# Options to ctdbd +CTDBDOPTIONS="--nlist=/etc/samba/cluster_addresses.txt --dbdir=/var/lock/samba/ctdb --logfile=/var/log/samba/log.ctdb --public-addresses=/etc/samba/public_addresses.txt --public-interface=eth0" -- 2.47.3