commit 52c43cd53d874887718f0dbe0d13ad4b42c905cc83893166c789355482980ff1 Author: James Fehlig Date: Wed Jan 18 22:10:06 2012 +0000 Initial sanlock package for openSUSE OBS-URL: https://build.opensuse.org/package/show/Virtualization/sanlock?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/sanlock-1.9.tar.gz b/sanlock-1.9.tar.gz new file mode 100644 index 0000000..b35c441 --- /dev/null +++ b/sanlock-1.9.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01b3e8a0f9466e42b841fb9d64574ae6b0fb4527cd94f18d45c22031b2f61504 +size 119767 diff --git a/sanlock-SCHED_RESET_ON_FORK-undefined.patch b/sanlock-SCHED_RESET_ON_FORK-undefined.patch new file mode 100644 index 0000000..9b63ca3 --- /dev/null +++ b/sanlock-SCHED_RESET_ON_FORK-undefined.patch @@ -0,0 +1,30 @@ +Index: src/main.c +=================================================================== +--- src/main.c.orig ++++ src/main.c +@@ -50,6 +50,10 @@ + #include "client_cmd.h" + #include "cmd.h" + ++#ifndef SCHED_RESET_ON_FORK ++#define SCHED_RESET_ON_FORK 0 ++#endif ++ + struct thread_pool { + int num_workers; + int max_workers; +Index: wdmd/main.c +=================================================================== +--- wdmd/main.c.orig ++++ wdmd/main.c +@@ -43,6 +43,10 @@ + + #define RELEASE_VERSION "1.9" + ++#ifndef SCHED_RESET_ON_FORK ++#define SCHED_RESET_ON_FORK 0 ++#endif ++ + #define DEFAULT_TEST_INTERVAL 10 + #define DEFAULT_FIRE_TIMEOUT 60 + #define DEFAULT_HIGH_PRIORITY 1 diff --git a/sanlock-old_blkid.patch b/sanlock-old_blkid.patch new file mode 100644 index 0000000..d4883ab --- /dev/null +++ b/sanlock-old_blkid.patch @@ -0,0 +1,24 @@ +Index: src/diskio.c +=================================================================== +--- src/diskio.c.orig ++++ src/diskio.c +@@ -33,6 +33,7 @@ + + static int set_disk_properties(struct sync_disk *disk) + { ++#ifdef BLKID_VERSION + blkid_probe probe; + blkid_topology topo; + uint32_t sector_size, ss_logical, ss_physical; +@@ -64,7 +65,10 @@ static int set_disk_properties(struct sy + ss_physical, disk->path); + return -1; + } +- ++#else ++ /* HACK, should really read this from sysfs */ ++ uint32_t sector_size = 512; ++#endif + disk->sector_size = sector_size; + return 0; + } diff --git a/sanlock-python-prefix.patch b/sanlock-python-prefix.patch new file mode 100644 index 0000000..9effe38 --- /dev/null +++ b/sanlock-python-prefix.patch @@ -0,0 +1,13 @@ +Index: python/Makefile +=================================================================== +--- python/Makefile.orig ++++ python/Makefile +@@ -8,7 +8,7 @@ all: + python setup.py build + + install: +- python setup.py install --root=$(DESTDIR) ++ python setup.py install --root=$(DESTDIR) --prefix=$(PREFIX) + + clean: + rm -rf build diff --git a/sanlock.changes b/sanlock.changes new file mode 100644 index 0000000..820fcbb --- /dev/null +++ b/sanlock.changes @@ -0,0 +1,11 @@ +------------------------------------------------------------------- +Wed Jan 18 10:17:57 MST 2012 - jfehlig@suse.com + +- Update to sanlock 1.9 +- Add SUSE init script for sanlock and wdmd + +------------------------------------------------------------------- +Thu Dec 22 01:15:39 CET 2011 - ro@suse.de + +- initial package based on package from openstack + diff --git a/sanlock.init b/sanlock.init new file mode 100644 index 0000000..269b488 --- /dev/null +++ b/sanlock.init @@ -0,0 +1,73 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: sanlock +# Required-Start: $time $syslog wdmd $remote_fs +# Required-Stop: $syslog +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts and stops sanlock daemon +# Description: starts and stops sanlock daemon +### END INIT INFO + +SANLOCK_BIN=/usr/sbin/sanlock +SANLOCK_PIDFILE=/var/run/sanlock/sanlock.pid +test -x $SANLOCK_BIN || { echo "$SANLOCK_BIN not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + +[ -f /etc/sysconfig/sanlock ] && . /etc/sysconfig/sanlock + +. /etc/rc.status +rc_reset + + +case "$1" in + start) + if [ -e $SANLOCK_PIDFILE ]; then + if checkproc $SANLOCK_BIN ; then + echo -n "sanlock is already running." + rc_status -v + exit + else + echo "Removing stale PID file $SANLOCK_PIDFILE." + rm -f $SANLOCK_PIDFILE + fi + fi + echo -n "Starting sanlock " + startproc $SANLOCK_BIN daemon $SANLOCKOPTS + rc_status -v + ;; + stop) + echo -n "Shutting down sanlock " + killproc -TERM $SANLOCK_BIN > /dev/null 2>&1 + rm -f $SANLOCK_PIDFILE + rc_status -v + ;; + try-restart) + $0 status >/dev/null && $0 restart + rc_status + ;; + restart) + $0 stop + $0 start + rc_status + ;; + reload) + killproc -HUP $SANLOCK_BIN + rc_status -v + ;; + status) + echo -n "Checking status of sanlock " + checkproc $SANLOCK_BIN + rc_status -v + ;; + *) + echo "Usage: $0 {start|stop|restart|try-restart|reload|status}" + rc_failed 2 + rc_exit + ;; +esac +rc_exit diff --git a/sanlock.spec b/sanlock.spec new file mode 100644 index 0000000..0d2dbdb --- /dev/null +++ b/sanlock.spec @@ -0,0 +1,162 @@ +# +# spec file for package sanlock +# +# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +Name: sanlock +Version: 1.9 +Release: 1%{?dist} +Summary: A shared disk lock manager + +Group: System Environment/Base +License: GPLv2, GPLv2+, LGPLv2+ +URL: https://fedorahosted.org/sanlock/ +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: libblkid-devel libaio-devel python python-devel +Requires: %{name}-lib = %{version}-%{release} +Source0: https://fedorahosted.org/releases/s/a/sanlock/%{name}-%{version}.tar.gz +Source1: sanlock.init +Source2: wdmd.init +Patch0: sanlock-SCHED_RESET_ON_FORK-undefined.patch +Patch1: sanlock-python-prefix.patch +Patch2: sanlock-old_blkid.patch + +%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} + +%description +sanlock uses disk paxos to manage leases on shared storage. +Hosts connected to a common SAN can use this to synchronize their +access to the shared disks. + +%prep +%setup -q +%patch0 +%patch1 +%patch2 + +%build +# upstream does not require configure +# upstream does not support _smp_mflags +CFLAGS=$RPM_OPT_FLAGS make -C wdmd +CFLAGS=$RPM_OPT_FLAGS make -C src +CFLAGS=$RPM_OPT_FLAGS make -C python + +%install +make -C src \ + install LIBDIR=%{_libdir} \ + DESTDIR=$RPM_BUILD_ROOT +make -C wdmd \ + install LIBDIR=%{_libdir} \ + DESTDIR=$RPM_BUILD_ROOT +make -C python \ + install LIBDIR=%{_libdir} \ + DESTDIR=$RPM_BUILD_ROOT PREFIX=%_prefix +install -D -m 755 %SOURCE1 $RPM_BUILD_ROOT/etc/init.d/sanlock +install -D -m 755 %SOURCE2 $RPM_BUILD_ROOT/etc/init.d/wdmd + +%clean +rm -rf $RPM_BUILD_ROOT + +%pre +/usr/sbin/useradd -u 179 -g 179 -c "sanlock" -s /sbin/nologin -r \ + -d /var/run/sanlock sanlock 2> /dev/null || : + +##%post +##/sbin/chkconfig --add sanlock +##/sbin/chkconfig --add wdmd + +%preun +%{stop_on_removal sanlock} +%{stop_on_removal wdmd} +##if [ $1 = 0 ]; then +## /sbin/service sanlock stop > /dev/null 2>&1 +## /sbin/service wdmd stop > /dev/null 2>&1 +## /sbin/chkconfig --del sanlock +## /sbin/chkconfig --del wdmd +##fi + +%postun +%{insserv_cleanup} +#/sbin/service sanlock condrestart >/dev/null 2>&1 || : +#/sbin/service wdmd condrestart >/dev/null 2>&1 || : + +%files +%defattr(-,root,root,-) +/etc/init.d/sanlock +/etc/init.d/wdmd +%{_sbindir}/sanlock +%{_sbindir}/wdmd +%{_mandir}/man8/wdmd* +%{_mandir}/man8/sanlock* + +%package -n libsanlock1 +Provides: sanlock-lib +Summary: A shared disk lock manager library +Group: System Environment/Libraries + +%description -n libsanlock1 +The %{name}-lib package contains the runtime libraries for sanlock, +a shared disk lock manager. +Hosts connected to a common SAN can use this to synchronize their +access to the shared disks. + +%post -n libsanlock1 -p /sbin/ldconfig + +%postun -n libsanlock1 -p /sbin/ldconfig + +%files -n libsanlock1 +%defattr(-,root,root,-) +%{_libdir}/libsanlock.so.* +%{_libdir}/libsanlock_client.so.* +%{_libdir}/libwdmd.so.* + +%package -n python-%name +Provides: sanlock-python +Summary: Python bindings for the sanlock library +Group: Development/Libraries +Requires: %{name}-lib = %{version}-%{release} + +%description -n python-%name +The %{name}-python package contains a module that permits applications +written in the Python programming language to use the interface +supplied by the sanlock library. + +%files -n python-%name +%defattr(-,root,root,-) +%{python_sitearch}/Sanlock-1.0-py*.egg-info +%{python_sitearch}/sanlock.so + +%package devel +Summary: Development files for %{name} +Group: Development/Libraries +Requires: %{name}-lib = %{version}-%{release} + +%description devel +The %{name}-devel package contains libraries and header files for +developing applications that use %{name}. + +%files devel +%defattr(-,root,root,-) +%{_libdir}/libwdmd.so +%{_includedir}/wdmd.h +%{_libdir}/libsanlock.so +%{_libdir}/libsanlock_client.so +%{_includedir}/sanlock.h +%{_includedir}/sanlock_rv.h +%{_includedir}/sanlock_admin.h +%{_includedir}/sanlock_resource.h +%{_includedir}/sanlock_direct.h + +%changelog diff --git a/wdmd.init b/wdmd.init new file mode 100644 index 0000000..3ac5bf8 --- /dev/null +++ b/wdmd.init @@ -0,0 +1,81 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: wdmd +# Required-Start: $time $syslog +# Required-Stop: $syslog +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts and stops wdmd daemon +# Description: starts and stops wdmd daemon +### END INIT INFO + +WDMD_BIN=/usr/sbin/wdmd +WDMD_PIDFILE=/var/run/wdmd/wdmd.pid + +WDMDGROUP="sanlock" +WDMDOPTS="-G $WDMDGROUP" + +test -x $WDMD_BIN || { echo "$WDMD_BIN not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + +[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +. /etc/rc.status +rc_reset + + +case "$1" in + start) + if [ ! -d /var/run/$prog ]; then + mkdir -p /var/run/$prog + fi + + if [ -e $WDMD_PIDFILE ]; then + if checkproc $WDMD_BIN ; then + echo -n "wdmd is already running." + rc_status -v + exit + else + echo "Removing stale PID file $WDMD_PIDFILE." + rm -f $WDMD_PIDFILE + fi + fi + echo -n "Starting wdmd " + startproc $WDMD_BIN + rc_status -v + ;; + stop) + echo -n "Shutting down wdmd " + killproc -TERM $WDMD_BIN > /dev/null 2>&1 + rm -f $WDMD_PIDFILE + rc_status -v + ;; + try-restart) + $0 status >/dev/null && $0 restart + rc_status + ;; + restart) + $0 stop + $0 start + rc_status + ;; + reload) + killproc -HUP $WDMD_BIN + rc_status -v + ;; + status) + echo -n "Checking status of wdmd " + checkproc $WDMD_BIN + rc_status -v + ;; + *) + echo "Usage: $0 {start|stop|restart|try-restart|reload|status}" + rc_failed 2 + rc_exit + ;; +esac +rc_exit