%global with_bzr 0

%global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")

Summary: Store /etc in a SCM system (git, mercurial or darcs)
Summary(ja): /etc をバージョン管理システム(git,mercurialなど)で管理するツール

Name:      etckeeper
Version:   0.62
Release:   1%{?_dist_release}
Group:     Applications/System
License:   GPLv2+
URL:       http://kitenet.net/~joey/code/etckeeper/

Source0:   http://ftp.debian.org/debian/pool/main/e/etckeeper/%{name}_%{version}.tar.gz
Source1:   README.Vine
Source2:   README.Vine.en

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch
Requires:  git
Requires:  perl

%description
The etckeeper program is a tool to let /etc be stored in a git,
mercurial, bzr or darcs repository. It hooks into yum to automatically
commit changes made to /etc during package upgrades. It tracks file
metadata that version control systems do not normally support, but that
is important for /etc, such as the permissions of /etc/shadow. It's
quite modular and configurable, while also being simple to use if you
understand the basics of working with version control.

The default backend is git, if want to use a another backend please
install the appropriate tool (mercurial, darcs).
%if %{with_bzr}
To use bzr as backend, please also install the %{name}-bzr package.
%endif

To start using the package please read %{_docdir}/%{name}-%{version}/README

%if %{with_bzr}
%package bzr
Summary:  Support for bzr with etckeeper
Summary(ja):  Support for bzr with etckeeper
Group:    Applications/System
Requires: %{name} = %{version}-%{release} bzr
BuildRequires: bzr
BuildRequires: python-devel

%description bzr
This package provides a bzr backend for etckeeper, if you want to use
etckeeper with bzr backend, install this package.
%endif

%prep
%setup -q -n %{name}
%{__perl} -pi -e '
    s|LOWLEVEL_PACKAGE_MANAGER=dpkg|LOWLEVEL_PACKAGE_MANAGER=rpm|;
    ' etckeeper.conf
cp -av %{SOURCE1} %{SOURCE2} .

%build
make %{?_smp_mflags}

%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot} INSTALL="%{__install} -p"
%{__install} -D -p debian/cron.daily %{buildroot}%{_sysconfdir}/cron.daily/%{name}
%{__install} -d  %{buildroot}%{_localstatedir}/cache/%{name}
%if %{with_bzr}
%{__sed} -i -e '1d' %{buildroot}%{python_sitelib}/bzrlib/plugins/%{name}/__init__.py
%endif

mv %{buildroot}%{_sysconfdir}/apt/apt.conf.d/05etckeeper \
   %{buildroot}%{_sysconfdir}/apt/apt.conf.d/05etckeeper.conf

%clean
rm -rf %{buildroot}

%post
if [ $1 == 1 ] ; then
  if [ ! -d /etc/.git ] ; then
    %{_bindir}/%{name} init
    ( cd /etc; git commit -m 'initial commit' )
  fi
fi
if [ $1 -gt 1 ] ; then
  %{_bindir}/%{name} update-ignore
fi

%files
%defattr(-, root, root, -)
%doc GPL TODO README README.Vine README.Vine.en
%{_bindir}/%{name}
%{_mandir}/man8/%{name}.8*
%dir %{_sysconfdir}/%{name}
%{_sysconfdir}/%{name}/*.d
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%{_sysconfdir}/cron.daily/%{name}
%dir %{_sysconfdir}/bash_completion.d
%config(noreplace) %{_sysconfdir}/bash_completion.d/%{name}
%{_localstatedir}/cache/%{name}
%config(noreplace) %{_sysconfdir}/apt/apt.conf.d/05etckeeper.conf
%config(noreplace) %{_sysconfdir}/cruft/filters-unex/etckeeper
     
%if %{with_bzr}
%files bzr
%defattr(-, root, root, -)
%doc GPL
%{python_sitelib}/bzrlib/plugins/%{name}
%{python_sitelib}/bzr_%{name}-*.egg-info
%endif

%changelog
* Mon May 28 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 0.62-1
- initial build for Vine Linux
- disable bzr support by default
- run etckeeper initialize and first commit on first install.

* Tue Mar 13 2012 Thomas Moschny <thomas.moschny@gmx.de> - 0.62-2
- Add missing dependency on perl (bz 798563).

* Tue Mar 13 2012 Thomas Moschny <thomas.moschny@gmx.de> - 0.62-1
- Update to 0.62.

* Tue Jan 17 2012 Thomas Moschny <thomas.moschny@gmx.de> - 0.61-1
- Update to 0.61.

* Fri Jan 13 2012 Thomas Moschny <thomas.moschny@gmx.de> - 0.60-1
- Update to 0.60.

* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.58-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Thu Dec  1 2011 Thomas Moschny <thomas.moschny@gmx.de> - 0.58-1
- Update to 0.58.

* Wed Nov  9 2011 Thomas Moschny <thomas.moschny@gmx.de> - 0.57-1
- Update to 0.57.

* Wed Aug 17 2011 Thomas Moschny <thomas.moschny@gmx.de> - 0.56-2
- Rebuilt for trailing slash bug of rpm-4.9.1

* Thu Jul 21 2011 Thomas Moschny <thomas.moschny@gmx.de> - 0.56-1
- Update to 0.56.

* Fri Jun 24 2011 Thomas Moschny <thomas.moschny@gmx.de> - 0.55-1
- Update to 0.55.

* Wed Jun  1 2011 Thomas Moschny <thomas.moschny@gmx.de> - 0.54-1
- Update to 0.54.
- Add patch for bz 709487.

* Mon Mar 28 2011 Thomas Moschny <thomas.moschny@gmx.de> - 0.53-1
- Update to 0.53.
- Run update-ignore on package upgrade (bz 680632).

* Wed Feb  9 2011 Thomas Moschny <thomas.moschny@gmx.de> - 0.52-1
- Update to 0.52.
- Include a README.fedora (bz 670934).

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.51-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Mon Jan  3 2011 Thomas Moschny <thomas.moschny@gmx.de> - 0.51-1
- Update to 0.51.
- etckeeper has been moved out of sbin.

* Sat Dec 11 2010 Thomas Moschny <thomas.moschny@gmx.de> - 0.50-2
- Don't package INSTALL.

* Wed Oct 27 2010 Thomas Moschny <thomas.moschny@gmx.de> - 0.50-1
- Update to 0.50.
- Change %%define -> %%global.

* Fri Sep 17 2010 Thomas Moschny <thomas.moschny@gmx.de> - 0.49-2
- Adjust minimum required version of GIT.
- egg-info files are not created automatically on RHEL5.

* Wed Sep 15 2010 Thomas Moschny <thomas.moschny@gmx.de> - 0.49-1
- Update to 0.49.
- Remove obsolete patch.

* Fri Sep  3 2010 Thomas Moschny <thomas.moschny@gmx.de> - 0.48-1
- Update to 0.48.
- Don't list /etc/etckeeper/*.d directories twice in %%files.
- Add patch from upstream that fixes bz 588086.

* Wed Jul 21 2010 David Malcolm <dmalcolm@redhat.com> - 0.41-2
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild

* Sat Sep 12 2009 Bernie Innocenti <bernie@codewiz.org> - 0.41-1
- Update to 0.41
- Add missing directory ownerships

* Sat Sep 12 2009 Bernie Innocenti <bernie@codewiz.org> - 0.40-3
- Make the bzr subpackage builddepend on python-devel

* Wed Sep 09 2009 Terje Rosten <terje.rosten@ntnu.no> - 0.40-2
- Package is noarch
- Rpmlint clean
- Random cleanup
- Ship cache dir in package
- bzr subpackage
- Add bzr to buildreq

* Sat Sep 05 2009 Bernie Innocenti <bernie@codewiz.org> - 0.40-1
- Update to 0.40

* Sun Jun 14 2009 Bernie Innocenti <bernie@codewiz.org> - 0.37-1
- Update to 0.37
- Change license tag to GPLv2+

* Fri Feb 27 2009 Jimmy Tang <jtang@tchpc.tcd.ie> - 0.33-4
- fix up initial install to make directory in /var/cache/etckeeper
- install the etckeeper daily cron job
- define some config files that shouldn't be replaced, should the hooks
in commit.d, init.d etc... saved and not blown away? if so they can
defined as config files. etckeeper should record the changes anyway.

* Wed Feb 25 2009 Jimmy Tang <jtang@tchpc.tcd.ie> - 0.32-1
- yum etckeeper plugin is now apart of this package

* Tue Feb 24 2009 Jimmy Tang <jtang@tchpc.tcd.ie> - 0.31-1
- initial package
