LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File nbd.spec of Package nbd (Project home:draht)

#
# spec file for package nbd
#
# Copyright (c) 2014 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:           nbd
BuildRequires:  doxygen
BuildRequires:  glib2-devel >= 2.26.0
PreReq:         %insserv_prereq coreutils
Version:        3.8
Release:        0
Source:         http://downloads.sourceforge.net/project/%{name}/%{name}/%{version}/%{name}-%{version}.tar.xz
Source2:        init.nbd-server
Source3:        config.example
Patch2:         nbd-2.9.25-close.diff
Patch3:         nbd-2.9.25-doxyfile.diff
Summary:        Network Block Device Server and Client Utilities
License:        GPL-2.0+
Group:          Productivity/Networking/Other
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
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

%build
export CFLAGS="$RPM_OPT_FLAGS -fstack-protector -fno-strict-aliasing"
./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 doc/Doxyfile.in

%install
make install DESTDIR=$RPM_BUILD_ROOT man_MANS='nbd-client.8 nbd-server.1 nbd-server.5 nbd-trdump.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
install %SOURCE3 $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) /usr/bin/nbd-trdump
%attr(0755,root,root) /etc/init.d/nbd-server
%attr(0755,root,root) /usr/bin/rcnbd-server
%{_mandir}/man1/nbd-server.1.gz
%{_mandir}/man1/nbd-trdump.1.gz
%{_mandir}/man5/nbd-server.5.gz
%{_mandir}/man8/nbd-client.8.gz
%doc README.md
#%%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
  grep -vE '^(#|[[:blank:]]*$)' /etc/nbd-server.conf |
  while read port file opts; do
    if test -z "$generic"; then
      echo > /etc/nbd-server/config
      echo "[generic]" >> /etc/nbd-server/config
      echo "	# No generic options yet" >> /etc/nbd-server/config
      echo >> /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
  mv /etc/nbd-server.conf /etc/nbd-server.conf.converted
fi

%postun
%{insserv_cleanup}
%restart_on_update nbd-server

%preun
%{stop_on_removal nbd-server}

%changelog