File nbd.spec of Package nbd

#
# spec file for package nbd (Version 2.9.11)
#
# Copyright (c) 2008 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/
#

# norootforbuild


Name:           nbd
BuildRequires:  doxygen glib2-devel
PreReq:         %insserv_prereq coreutils
Version:        2.9.11
Release:        1
License:        GPL v2 or later
Group:          Productivity/Networking/Other
AutoReqProv:    on
Source:         %{name}-%{version}.tar.bz2
Source2:        init.nbd-server
Patch2:         nbd-2.9.5-warn.diff
Patch3:         nbd-2.9.5-doc.diff
Summary:        Network Block Device Server and Client Utilities
Url:            http://nbd.sourceforge.net/
Prefix:         /usr
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Suggests:       nbd-doc

%description
This package contains nbd-server. It is the server backend for the nbd
network block device driver that's in the Linux kernel.

nbd can be used to have a filesystem stored on another machine. It does
provide a block device, not a file system; so unless you put a
clustering filesystem on top of it, you can't access it simultaneously
from more than one client. Use NFS or a real cluster FS (such as 
ocfs2) if you want to do this. nbd-server can export a file (which may
contain a filesystem image) or a partition. Swapping over nbd is
possible as well, though it's said not to be safe against OOM and
should not be used for that case. nbd-server also has a copy-on-write
mode where changes are saved to a separate file and thrown away when
the connection closes.

The package also contains the nbd-client tools, which you need to
configure the nbd devices on the client side.



Authors:
--------
    Wouter Verhelst <wouter@debian.org>
    Anton Altaparmakov <aia21@cam.ac.uk>
    Pavel Machek <pavel@ucw.cz>
    Paul Clements <Paul.Clements@steeleye.com>

%package doc
License:        GPL v2 or later
Summary:        Network Block Device Server and Client Utilities
Group:          Productivity/Networking/Other
Requires:       nbd = %{version}

%description doc
This package contains the HTML documentation for the network block
device (nbd) utilities.

nbd can be used to have a filesystem stored on another machine. It does
provide a block device, not a file system; so unless you put a
clustering filesystem on top of it, you can't access it simultaneously
from more than one client. Use NFS or a real cluster FS (such as 
ocfs2) if you want to do this. nbd-server can export a file (which may
contain a filesystem image) or a partition. Swapping over nbd is
possible as well, though it's said not to be safe against OOM and
should not be used for that case. nbd-server also has a copy-on-write
mode where changes are saved to a separate file and thrown away when
the connection closes.



Authors:
--------
    Wouter Verhelst <wouter@debian.org>
    Anton Altaparmakov <aia21@cam.ac.uk>
    Pavel Machek <pavel@ucw.cz>
    Paul Clements <Paul.Clements@steeleye.com>

%prep
%setup
%patch2 -p1
%patch3 -p1
touch nbd-client.8

%build
autoreconf --force --install
export CFLAGS="$RPM_OPT_FLAGS -fstack-protector"
#export CFLAGS="$RPM_OPT_FLAGS"
./configure --with-gnu-ld --prefix=/usr --mandir=%{_mandir} \
	--infodir=%{_infodir} --libdir=%{_libdir} --libexecdir=%{_libdir} \
	--program-prefix="" --sysconfdir=/etc --build=%{_target_cpu}-suse-linux
make
doxygen

%install
make install DESTDIR=$RPM_BUILD_ROOT man_MANS='nbd-client.8 nbd-server.1'
mkdir -p $RPM_BUILD_ROOT/etc/init.d
install %SOURCE2 $RPM_BUILD_ROOT/etc/init.d/nbd-server
mkdir -p $RPM_BUILD_ROOT/usr/bin
ln -s ../../etc/init.d/nbd-server $RPM_BUILD_ROOT/usr/bin/rcnbd-server
#echo "#Port	file	options" > $RPM_BUILD_ROOT/etc/nbd-server.conf
mkdir -p $RPM_BUILD_ROOT/etc/nbd-server
touch $RPM_BUILD_ROOT/etc/nbd-server/config
touch $RPM_BUILD_ROOT/etc/nbd-server/allow
grep -A16 -B1 '^\[generic\]' README > $RPM_BUILD_ROOT/etc/nbd-server/config.example

%files
%defattr(-,root,root)
%attr(0755,root,root) /usr/sbin/nbd-client
%attr(0755,root,root) /usr/bin/nbd-server
%attr(0755,root,root) /etc/init.d/nbd-server
%attr(0755,root,root) /usr/bin/rcnbd-server
%{_mandir}/man1/nbd-server.1.gz
%{_mandir}/man8/nbd-client.8.gz
%doc README
#%config(noreplace) /etc/nbd-server.conf
%dir /etc/nbd-server
%ghost %config(noreplace) /etc/nbd-server/config
%ghost %config(noreplace) /etc/nbd-server/allow
%config /etc/nbd-server/config.example

%files doc
%defattr(-,root,root)
%doc doc/html

%post
%{fillup_and_insserv -f nbd-server}
if test -e /etc/nbd-server.conf; then
  # Do we have to create a generic section?
  unset generic
  if test -e /etc/nbd-server/config; then generic=1; fi
  while read port file opts; do
    if test -z "$port"; then continue; fi
    if test "${port:0:1}" = "#"; then continue; fi
    if test -z "$generic"; then
      echo -e "[generic]\n\t# No generic options yet\n" > /etc/nbd-server/config
      generic=1
    fi
    FN=${file%/*}
    nm="cvt.$port.${FN##*/}.${file##*/}"
    echo " ... convert $port $file $opts -> $nm"
    /usr/bin/nbd-server $port $file $opts -o "$nm" >> /etc/nbd-server/config
  done < /etc/nbd-server.conf
  mv /etc/nbd-server.conf /etc/nbd-server.conf.converted
fi

%postun
%{insserv_cleanup}

%preun
%{stop_on_removal nbd-server}

%changelog
* Wed Aug 20 2008 garloff@suse.de
- Update to nbd-2.9.11:
  * nbd-client: new option -c to check for connection, -d to
  drop connection, -persist to infinitely retry connections
  dropped by server. timeout= setting
  * nbd-server: drop autoreadonly option
* Thu Nov 15 2007 garloff@suse.de
- Update to nbd-2.9.9:
  * Document -C option of nbd-server.
  * Fix name of /var/run/ file.
* Thu Nov 08 2007 garloff@suse.de
- Split nbd into nbd and nbd-doc packages.
- Update to nbd-2.9.8:
  * nbd-server can now setuid to specified user and group.
  * prerun and postrun scripts can be specified.
  * IP address to bind to (listenaddress) can be configured.
  * Socket Direct Protocol (sdp) -- not enabled.
  * server exits now after connection has gone (oops!).
  * nbd-client: timeout parameter.
* Mon Jul 30 2007 garloff@suse.de
- Convert options from old nbd-server.conf to new nbd-server/config
  on update and drop support for old config file syntax.
- Fix daemonize(0) segfault and pid filename.
- Fix compiler warnings.
- Fix /dev filename docu.
- Use startproc, killproc, checkproc in init script
- nbd-server does not support SIGHUP, fix init script accordingly.
* Tue Jul 17 2007 garloff@suse.de
- Update to nbd-2.9.5:
  * Support for more platforms, pkgconfig, debug build.
  * -o option to convert cmdline options to config file.
  * Fix duplication in handling nonblocking server socket.
* Tue Mar 13 2007 garloff@suse.de
- Update to 2.9.2:
  * make child socket nonblocking
  * Reintegrate fix for 64bit on looking for file size.
  * Fix cross-compiling
  * Search for libraries to allow linking on Solaris
- Update to 2.9.1:
  * A fix for a piece of code following a null pointer, and one
  for a memory leak (if only minor).
- Update to 2.9.0:
  * * Configuration file support
  * The ability to server multiple nbd-server exports from one server
  * Better multiple-file support (files can now be of any random size)
  * Better support for virtualizing servers (in addition to replacing
  %%s with the client's IP address, it is now also possible to use
  other options which allow for hashed directories)
  * Support for changing uid and gid after startup
  * The ability to do the copy-on-write stuff with a sparse file rather
  than a mapped file (specified by a config file option), which may be
  slightly faster.
* Sat Nov 18 2006 garloff@suse.de
- Add nbd-server init script (parses /etc/nbd-server.conf).
* Thu Oct 19 2006 garloff@suse.de
- Update to nbd-2.8.7:
  * A fix for build against nbd.h for kernel 2.6.18 (and above,
  presumably)
* Fri Oct 13 2006 ro@suse.de
- include linux/types.h before linux/nbd.h
* Mon Aug 07 2006 garloff@suse.de
- Update to nbd-2.8.6:
  * performance/reliability improvements: Use select() rather than
  accept() and waitpid() with WNOHANG rather than wait().
- Update to nbd-2.8.5:
  * -persist option.
  * Add export verification.
  * Make sure queue is empty for write requests to read-only export.
- Update to nbd-2.8.4:
  * Includes the previous fix (closing server socket)
* Mon Mar 06 2006 garloff@suse.de
- Make sure children quit when they finish serving, rather than
  trying to do stuff with a server socket that they've closed
  already in a loop. Whoops. (Fix from nbd-2.8.4.)
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Mon Jan 23 2006 garloff@suse.de
- Enable -fstack-protector.
* Mon Jan 09 2006 garloff@suse.de
- Update to nbd-2.8.3:
  * CVE-2005-3534.
  * A fix for 64bit systems regarding the BLKGETSIZE ioctl().
  * Better handling of SIGCHLD.
* Tue Dec 20 2005 garloff@suse.de
- Update to nbd-2.8.2:
  * Enable LFS by default.
* Thu Nov 03 2005 dmueller@suse.de
- don't build as root
* Fri Oct 28 2005 garloff@suse.de
- Update to version 2.8.1.
- Documentation added.
* Mon Jul 04 2005 garloff@suse.de
- Initial creation of package.
openSUSE Build Service is sponsored by