# @configure_input@

#%global mirror http://hakodate/mirrors/fedora/10/Fedora/x86_64/os/

Summary:     Access and modify virtual machine disk images
Name:        libguestfs
Version:     @VERSION@
Release:     1%{?dist}
License:     LGPLv2+
Group:       Development/Libraries
URL:         http://et.redhat.com/~rjones/libguestfs/
Source0:     http://et.redhat.com/~rjones/libguestfs/files/%{name}-%{version}.tar.gz
BuildRoot:   %{_tmppath}/%{name}-%{version}-%{release}-root

# Basic build requirements:
BuildRequires: /usr/bin/pod2man
BuildRequires: /usr/bin/pod2text
BuildRequires: febootstrap >= 1.5
BuildRequires: augeas-devel

# If you want to build the bindings for different languages:
BuildRequires: ocaml
BuildRequires: perl-devel
BuildRequires: perl-Test-Pod
BuildRequires: perl-Test-Pod-Coverage
BuildRequires: perl-ExtUtils-MakeMaker
# BuildRequires: python-devel

# Runtime requires:
Requires:    qemu


%description
Libguestfs is a library for accessing and modifying guest disk images.
Amongst the things this is good for: making batch configuration
changes to guests, getting disk used/free statistics (see also:
virt-df), migrating between virtualization systems (see also:
virt-p2v), performing partial backups, performing partial guest
clones, cloning guests and changing registry/UUID/hostname info, and
much else besides.

Libguestfs uses Linux kernel and qemu code, and can access any type of
guest filesystem that Linux and qemu can, including but not limited
to: ext2/3/4, btrfs, FAT and NTFS, LVM, many different disk partition
schemes, qcow, qcow2, vmdk.

Libguestfs provides ways to enumerate guest storage (eg. partitions,
LVs, what filesystem is in each LV, etc.).  It can also run commands
in the context of the guest.  Also you can access filesystems over FTP.

Libguestfs is a library that can be linked with C and C++ management
programs.

See also the 'guestfish' package for shell scripting and command line
access.


%package devel
Summary:     Development tools and libraries for %{name}
Group:       Development/Libraries
Requires:    %{name} = %{version}-%{release}


%description devel
%{name}-devel contains development tools and libraries
for %{name}.


%package -n guestfish
Summary:     Shell for accessing and modifying virtual machine disk images
Group:       Development/Tools
License:     GPLv2+
Requires:    %{name} = %{version}-%{release}
Requires:    /usr/bin/pod2text


%description -n guestfish
Guestfish is the Filesystem Interactive SHell, for accessing and
modifying virtual machine disk images from the command line and shell
scripts.


%package ocaml
Summary:     OCaml bindings for %{name}
Group:       Development/Libraries
Requires:    %{name} = %{version}-%{release}


%description ocaml
%{name}-ocaml contains OCaml bindings for %{name}.

This is for toplevel and scripting access only.  To compile OCaml
programs which use %{name} you will also need %{name}-ocaml-devel.


%package ocaml-devel
Summary:     OCaml bindings for %{name}
Group:       Development/Libraries
Requires:    %{name}-ocaml = %{version}-%{release}


%description ocaml-devel
%{name}-ocaml-devel contains development libraries
required to use the OCaml bindings for %{name}.


%package perl
Summary:     Perl bindings for %{name}
Group:       Development/Libraries
Requires:    %{name} = %{version}-%{release}
Requires:    perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))


%description perl
%{name}-perl contains Perl bindings for %{name}.


# %package python
# Summary:     Python bindings for %{name}
# Group:       Development/Libraries
# Requires:    %{name} = %{version}-%{release}


# %description python
# %{name}-python contains Python bindings for %{name}.


%prep
%setup -q


%build
#%configure --with-mirror=%{mirror}
%configure

# 'INSTALLDIRS' ensures that perl libs are installed in the vendor dir
# not the site dir.
make INSTALLDIRS=vendor


%check
make check


%install
rm -rf $RPM_BUILD_ROOT

make DESTDIR=$RPM_BUILD_ROOT install

rm $RPM_BUILD_ROOT%{_libdir}/libguestfs.a
rm $RPM_BUILD_ROOT%{_libdir}/libguestfs.la

# Clean up the examples/ directory which will get installed in %doc.
# Note we can't delete the original examples/Makefile because that
# will be needed by the check section later in the RPM build.
cp -a examples ex
pushd ex
make clean
rm Makefile*
rm -rf .deps .libs
popd

# Same for ocaml/examples.
cp -a ocaml/examples ocaml-ex
pushd ocaml-ex
make clean
rm Makefile*
popd

find $RPM_BUILD_ROOT -name perllocal.pod -delete
find $RPM_BUILD_ROOT -name .packlist -delete


%clean
rm -rf $RPM_BUILD_ROOT


%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


%files
%defattr(-,root,root,-)
%doc COPYING
%{_libdir}/guestfs/
%{_libdir}/libguestfs.so.*


%files devel
%defattr(-,root,root,-)
%doc HACKING README ex html/guestfs.3.html html/pod.css
%{_libdir}/libguestfs.so
%{_mandir}/man3/guestfs.3*
%{_includedir}/guestfs.h
%{_includedir}/guestfs-actions.h
%{_includedir}/guestfs-structs.h


%files -n guestfish
%defattr(-,root,root,-)
%doc html/guestfish.1.html html/pod.css
%{_bindir}/guestfish
%{_mandir}/man1/guestfish.1*


%files ocaml
%defattr(-,root,root,-)
%{_libdir}/ocaml/guestfs
%exclude %{_libdir}/ocaml/guestfs/*.a
%exclude %{_libdir}/ocaml/guestfs/*.cmxa
%exclude %{_libdir}/ocaml/guestfs/*.cmx
%exclude %{_libdir}/ocaml/guestfs/*.mli
%{_libdir}/ocaml/stublibs/*.so
%{_libdir}/ocaml/stublibs/*.so.owner


%files ocaml-devel
%defattr(-,root,root,-)
%doc ocaml-ex
%{_libdir}/ocaml/guestfs/*.a
%{_libdir}/ocaml/guestfs/*.cmxa
%{_libdir}/ocaml/guestfs/*.cmx
%{_libdir}/ocaml/guestfs/*.mli


%files perl
%defattr(-,root,root,-)
%doc perl/examples
%{perl_vendorarch}/*
%{_mandir}/man3/Sys::Guestfs.3pm*


# %files python
# %defattr(-,root,root,-)


%changelog
* Sat Apr  4 2009 Richard Jones <rjones@redhat.com> - @VERSION@-1
- Initial build.