#3 Add breezy plugin on Fedora 31+
Merged 4 years ago by thm. Opened 4 years ago by churchyard.
rpms/ churchyard/etckeeper breezy  into  master

@@ -0,0 +1,52 @@ 

+ From b5919d7919dda614c3c3c76ba126f45e205494bd Mon Sep 17 00:00:00 2001

+ From: Dimitri John Ledkov <xnox@ubuntu.com>

+ Date: Mon, 29 Apr 2019 14:11:09 +0100

+ Subject: [PATCH 1/3] Add breezy python3 plugin

+ 

+ ---

+  Makefile                  |  3 +++

+  debian/changelog          |  6 ++++++

+  debian/control            |  6 +++---

+  etckeeper-brz/__init__.py | 34 ++++++++++++++++++++++++++++++++++

+  4 files changed, 46 insertions(+), 3 deletions(-)

+  create mode 100644 etckeeper-brz/__init__.py

+ 

+ Index: etckeeper-1.18.10/etckeeper-brz/__init__.py

+ ===================================================================

+ --- /dev/null

+ +++ etckeeper-1.18.10/etckeeper-brz/__init__.py

+ @@ -0,0 +1,34 @@

+ +#

+ +# Breezy plugin that runs etckeeper pre-commit when necessary

+ +

+ +"""Runs etckeeper pre-commit when necessary."""

+ +

+ +from breezy.errors import BzrError

+ +import os

+ +

+ +def etckeeper_startcommit_hook(tree):

+ +    abspath = getattr(tree, "abspath", None)

+ +    if abspath is None or not os.path.exists(abspath(".etckeeper")):

+ +        # Only run the commit hook when this is an etckeeper branch

+ +        return

+ +    import subprocess

+ +    ret = subprocess.call(["etckeeper", "pre-commit", abspath(".")])

+ +    if ret != 0:

+ +        raise BzrError("etckeeper pre-commit failed")

+ +

+ +try:

+ +    from breezy.hooks import install_lazy_named_hook

+ +except ImportError:

+ +    from breezy.mutabletree import MutableTree

+ +    MutableTree.hooks.install_named_hook('start_commit',

+ +        etckeeper_startcommit_hook, 'etckeeper')

+ +else:

+ +    install_lazy_named_hook(

+ +        "breezy.mutabletree", "MutableTree.hooks",

+ +        'start_commit', etckeeper_startcommit_hook, 'etckeeper')

+ +

+ +if __name__ == "__main__":

+ +    from distutils.core import setup

+ +    setup(name="brz-etckeeper",

+ +          packages=["breezy.plugins.etckeeper"],

+ +          package_dir={"breezy.plugins.etckeeper":"etckeeper-brz"})

file modified
+57 -3
@@ -1,9 +1,17 @@ 

  %{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}}

  

- %if 0%{?fedora} || (0%{?rhel} && 0%{?rhel} <= 7)

+ %if (0%{?fedora} && 0%{?fedora} < 32) || (0%{?rhel} && 0%{?rhel} <= 7)

  %global with_bzr 1

  %endif

  

+ %if 0%{?fedora} >= 31

+ %global with_brz 1

+ # this is used to mention the correct package in descriptions

+ %global bazaar brz

+ %else

+ %global bazaar bzr

+ %endif

+ 

  %if (0%{?fedora} && 0%{?fedora} <= 30) || (0%{?rhel} && 0%{?rhel} <= 7)

  %global with_yum 1

  %endif
@@ -25,7 +33,7 @@ 

  

  Name:      etckeeper

  Version:   1.18.10

- Release:   4%{?dist}

+ Release:   5%{?dist}

  Summary:   Store /etc in a SCM system (git, mercurial, bzr or darcs)

  License:   GPLv2+

  URL:       https://etckeeper.branchable.com/
@@ -34,6 +42,8 @@ 

  Patch0:    etckeeper-makefile-remove-python-plugins.patch

  Patch1:    etckeeper-1.18.7-fix-rpm-ignores.patch

  Patch2:    etckeeper-1.18.7-fix-hg-warnings.patch

+ # From https://bugs.launchpad.net/ubuntu/+source/etckeeper/+bug/1826855

+ Patch3:    etckeeper-add-breezy-python3-plugin.patch

  BuildArch: noarch

  BuildRequires: %{__markdown}

  Requires:  git >= 1.6.1
@@ -63,7 +73,7 @@ 

  

  The default backend is git, if want to use a another backend please

  install the appropriate tool (mercurial, darcs or bzr).

- To use bzr as backend, please also install the %{name}-bzr package.

+ To use bzr as backend, please also install the %{name}-%{bazaar} package.

  

  To start using the package please read %{_pkgdocdir}/README.

  
@@ -82,6 +92,20 @@ 

  %endif # with_bzr

  

  

+ %if 0%{?with_brz}

+ %package brz

+ Summary:  Support for bzr with etckeeper (via breezy)

+ BuildRequires: python3-devel

+ BuildRequires: brz

+ Requires: %{name} = %{version}-%{release}

+ Requires: brz

+ 

+ %description brz

+ This package provides a brz (breezy) backend for etckeeper, if you want to use

+ etckeeper with (bzr) bazaar repositories, install this package.

+ %endif # with_brz

+ 

+ 

  %if 0%{?with_dnf}

  %package dnf

  Summary:  DNF plugin for etckeeper support
@@ -107,6 +131,7 @@ 

  %patch0 -p1

  %patch1 -p1

  %patch2 -p1

+ %patch3 -p1

  %if 0%{?with_yum}

  # we set yum here, so the yum plugin gets built, and change that to

  # dnf later, if needed
@@ -131,6 +156,7 @@ 

  # move each plugin in its own subdirectory, so each has its own build/

  # directory

  mkdir bzr-plugin ; mv etckeeper-bzr bzr-plugin

+ mkdir brz-plugin ; mv etckeeper-brz brz-plugin

  mkdir dnf-plugin ; mv etckeeper-dnf dnf-plugin

  cp -av %{SOURCE1} .

  
@@ -144,6 +170,12 @@ 

  popd

  %endif # with_bzr

  

+ %if 0%{?with_brz}

+ pushd brz-plugin

+ %{__python3} etckeeper-brz/__init__.py build

+ popd

+ %endif # with_brz

+ 

  %if 0%{?with_dnf}

  pushd dnf-plugin

  %if 0%{?dnf_uses_python3}
@@ -166,6 +198,12 @@ 

  popd

  %endif # with_bzr

  

+ %if 0%{?with_brz}

+ pushd brz-plugin

+ %{__python3} etckeeper-brz/__init__.py install -O1 --skip-build --root %{buildroot}

+ popd

+ %endif # with_brz

+ 

  %if 0%{?with_dnf}

  pushd dnf-plugin

  %if 0%{?dnf_uses_python3}
@@ -261,6 +299,17 @@ 

  %endif # with_bzr

  

  

+ %if 0%{?with_brz}

+ %files brz

+ # co-own the plugins directories

+ # breezy installs to sitearch

+ %dir %{python3_sitelib}/breezy/

+ %dir %{python3_sitelib}/breezy/plugins/

+ %{python3_sitelib}/breezy/plugins/%{name}/

+ %{python3_sitelib}/brz_%{name}-*.egg-info

+ %endif # with_brz

+ 

+ 

  %if 0%{?with_dnf}

  %files dnf

  %if 0%{?dnf_uses_python3}
@@ -278,6 +327,11 @@ 

  

  

  %changelog

+ * Fri Nov 01 2019 Miro Hrončok <mhroncok@redhat.com> - 1.18.10-5

+ - Add breezy plugin on Fedora 31+

+ - Remove bazaar plugin on Fedora 32+

+ - https://fedoraproject.org/wiki/Changes/ReplaceBazaarWithBreezy

+ 

  * Fri Oct  4 2019 Thomas Moschny <thomas.moschny@gmx.de> - 1.18.10-4

  - Package fixes for CentOS8.

  - Build dnf plugin on CentOS7.

This builds, but I haven't really tried to use it.

Thank you very much for putting this together!

Pull-Request has been merged by thm

4 years ago