[Pkg-ganeti-devel] [ganeti] 05/13: Add patches for lens 4.4+ compatibility

Apollon Oikonomopoulos apoikos at moszumanska.debian.org
Fri Sep 18 11:03:55 UTC 2015


This is an automated email from the git hooks/post-receive script.

apoikos pushed a commit to branch debian/backports/wheezy
in repository ganeti.

commit 74ae9f06563302ae49e3408abe89788e8dfda7ed
Author: Apollon Oikonomopoulos <apoikos at debian.org>
Date:   Tue Feb 10 21:30:57 2015 +0200

    Add patches for lens 4.4+ compatibility
    
    Include patches by Petr Pudlak adding compatibility with the changed TH
    API of lens 4.4 and on.
---
 ...mple-CPP-macro-for-detecting-lens-version.patch | 150 +++++++++++++++++++++
 ...enses-correctly-for-different-lens-versio.patch |  42 ++++++
 debian/patches/series                              |   2 +
 3 files changed, 194 insertions(+)

diff --git a/debian/patches/0001-Create-a-simple-CPP-macro-for-detecting-lens-version.patch b/debian/patches/0001-Create-a-simple-CPP-macro-for-detecting-lens-version.patch
new file mode 100644
index 0000000..ab05b5c
--- /dev/null
+++ b/debian/patches/0001-Create-a-simple-CPP-macro-for-detecting-lens-version.patch
@@ -0,0 +1,150 @@
+From 9dfe2cf411500478b5954e93f99c4fb27a1637d1 Mon Sep 17 00:00:00 2001
+From: Petr Pudlak <pudlak at google.com>
+Date: Tue, 10 Feb 2015 13:11:44 +0100
+Subject: [PATCH 1/2] Create a simple CPP macro for detecting lens versions
+
+.. in Haskell code.
+
+This patch should be removed starting from 2.14, as there cabal provides
+proper macros for all packages.
+
+The macro in this patch is intentionally kept compatible with the cabal
+macros.
+
+Signed-off-by: Petr Pudlak <pudlak at google.com>
+---
+ Makefile.am        | 20 +++++++++++++-------
+ configure.ac       | 16 ++++++++++++++++
+ src/Ganeti/Lens.hs |  7 ++++++-
+ 3 files changed, 35 insertions(+), 8 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 2bd16e6..67368f3 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1171,14 +1171,14 @@ Makefile.ghc: $(HS_MAKEFILE_GHC_SRCS) Makefile \
+               | $(built_base_sources) $(HS_BUILT_SRCS)
+ 	$(GHC) -M -dep-makefile $@ -dep-suffix $(HPROF_SUFFIX) \
+ 		-dep-suffix $(HTEST_SUFFIX) $(HFLAGS) -itest/hs \
+-		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(HS_MAKEFILE_GHC_SRCS)
++		$(HS_PARALLEL3) $(HS_LENS) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(HS_MAKEFILE_GHC_SRCS)
+ 
+ @include_makefile_ghc@
+ 
+ %.o:
+ 	@echo '[GHC]: $@ <- $^'
+ 	@$(GHC) -c $(HFLAGS) \
+-		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(@:%.o=%.hs)
++		$(HS_PARALLEL3) $(HS_LENS) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(@:%.o=%.hs)
+ 
+ # For TH+profiling we need to compile twice: Once without profiling,
+ # and then once with profiling. See
+@@ -1188,14 +1188,15 @@ if HPROFILE
+ 	@echo '[GHC|prof]: $@ <- $^'
+ 	@$(GHC) -c $(HFLAGS) \
+ 	  $(HPROFFLAGS) \
+-		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) \
++		$(HS_PARALLEL3) $(HS_LENS) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) \
+ 		$(@:%.$(HPROF_SUFFIX)_o=%.hs)
+ endif
+ 
+ %.$(HTEST_SUFFIX)_o:
+ 	@echo '[GHC|test]: $@ <- $^'
+ 	@$(GHC) -c $(HTEST_FLAGS) \
+-		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) $(@:%.$(HTEST_SUFFIX)_o=%.hs)
++		$(HS_PARALLEL3) $(HS_LENS) $(HS_REGEX_PCRE) \
++		$(HEXTRA_COMBINED) $(@:%.$(HTEST_SUFFIX)_o=%.hs)
+ 
+ %.hi: %.o ;
+ %.$(HTEST_SUFFIX)_hi: %.$(HTEST_SUFFIX)_o ;
+@@ -1209,7 +1210,8 @@ endif
+ 	@echo '[GHC-link]: $@'
+ 	$(GHC) $(HFLAGS) \
+ 		$(HPROFFLAGS) \
+-		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) --make $(@:%=%.hs)
++		$(HS_PARALLEL3) $(HS_LENS) $(HS_REGEX_PCRE) \
++		$(HEXTRA_COMBINED) --make $(@:%=%.hs)
+ 	@rm -f $(notdir $@).tix
+ 	@touch "$@"
+ 
+@@ -1222,7 +1224,8 @@ $(HS_TEST_PROGS): %: %.$(HTEST_SUFFIX)_o \
+ 	fi
+ 	@echo '[GHC-link|test]: $@'
+ 	$(GHC) $(HTEST_FLAGS) \
+-		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA_COMBINED) --make $(@:%=%.hs)
++		$(HS_PARALLEL3) $(HS_LENS) $(HS_REGEX_PCRE) \
++		$(HEXTRA_COMBINED) --make $(@:%=%.hs)
+ 	@rm -f $(notdir $@).tix
+ 	@touch "$@"
+ 
+@@ -2556,6 +2559,9 @@ $(APIDOC_HS_DIR)/index.html: $(HS_LIBTESTBUILT_SRCS) Makefile
+ 	if [ "$(HS_PARALLEL3)" ]; \
+ 	then OPTGHC="$$OPTGHC --optghc=$(HS_PARALLEL3)"; \
+ 	fi; \
++	if [ "$(HS_LENS)" ]; \
++	then OPTGHC="$$OPTGHC $(addprefix --optghc=,$(HS_LENS))"; \
++	fi; \
+ 	if [ "$(HS_REGEX_PCRE)" ]; \
+ 	then OPTGHC="$$OPTGHC --optghc=$(HS_REGEX_PCRE)"; \
+ 	fi; \
+@@ -2580,7 +2586,7 @@ TAGS: $(GENERATED_FILES)
+ 		-osuf tags.o \
+ 		-hisuf tags.hi \
+     -lcurl \
+-	  $(HS_PARALLEL3) $(HS_REGEX_PCRE) \
++	  $(HS_PARALLEL3) $(HS_LENS) $(HS_REGEX_PCRE) \
+ 	  $(HS_LIBTEST_SRCS)
+ 	find . -path './lib/*.py' -o -path './scripts/gnt-*' -o \
+ 	  -path './daemons/ganeti-*' -o -path './tools/*' -o \
+diff --git a/configure.ac b/configure.ac
+index 0cf7019..114ba59 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -626,6 +626,22 @@ AC_GHC_PKG_CHECK([parallel-3.*], [HS_PARALLEL3=-DPARALLEL3],
+                  [AC_GHC_PKG_REQUIRE(parallel)], t)
+ AC_SUBST(HS_PARALLEL3)
+ 
++# check for lens versions; 0 means an unknown version;
++# this (and the corresponding code in Makefile.am) should be removed starting
++# from 2.14, as there cabal creates proper CPP macros to distinguish package
++# versions
++HS_LENS="-DLENS_MAJOR=0 -DLENS_MINOR=0"
++AC_GHC_PKG_CHECK([lens-3.*], [HS_LENS="-DLENS_MAJOR=3 -DLENS_MINOR=0"], [], t)
++AC_GHC_PKG_CHECK([lens-4.*], [HS_LENS="-DLENS_MAJOR=4 -DLENS_MINOR=7"], [], t)
++AC_GHC_PKG_CHECK([lens-4.0.*], [HS_LENS="-DLENS_MAJOR=4 -DLENS_MINOR=0"], [], t)
++AC_GHC_PKG_CHECK([lens-4.1.*], [HS_LENS="-DLENS_MAJOR=4 -DLENS_MINOR=1"], [], t)
++AC_GHC_PKG_CHECK([lens-4.2.*], [HS_LENS="-DLENS_MAJOR=4 -DLENS_MINOR=2"], [], t)
++AC_GHC_PKG_CHECK([lens-4.3.*], [HS_LENS="-DLENS_MAJOR=4 -DLENS_MINOR=3"], [], t)
++AC_GHC_PKG_CHECK([lens-4.4.*], [HS_LENS="-DLENS_MAJOR=4 -DLENS_MINOR=4"], [], t)
++AC_GHC_PKG_CHECK([lens-4.5.*], [HS_LENS="-DLENS_MAJOR=4 -DLENS_MINOR=5"], [], t)
++AC_GHC_PKG_CHECK([lens-4.6.*], [HS_LENS="-DLENS_MAJOR=4 -DLENS_MINOR=6"], [], t)
++AC_SUBST(HS_LENS)
++
+ # and now standard modules
+ AC_GHC_PKG_REQUIRE(curl)
+ AC_GHC_PKG_REQUIRE(json)
+diff --git a/src/Ganeti/Lens.hs b/src/Ganeti/Lens.hs
+index b3bd69f..8f9b976 100644
+--- a/src/Ganeti/Lens.hs
++++ b/src/Ganeti/Lens.hs
+@@ -1,4 +1,4 @@
+-{-# LANGUAGE RankNTypes #-}
++{-# LANGUAGE RankNTypes, CPP #-}
+ 
+ {-| Provides all lens-related functions.
+ 
+@@ -44,6 +44,11 @@ module Ganeti.Lens
+   , atSet
+   ) where
+ 
++-- The following macro is just a temporary solution for 2.12 and 2.13.
++-- Since 2.14 cabal creates proper macros for all dependencies.
++#define MIN_VERSION_lens(maj,min,rev) \
++  (((maj)<LENS_MAJOR)||(((maj)==LENS_MAJOR)&&((min)<=LENS_MINOR)))
++
+ import Control.Applicative ((<$>), WrappedMonad(..))
+ import Control.Lens
+ import Control.Monad
+-- 
+2.1.4
+
diff --git a/debian/patches/0002-Construct-lenses-correctly-for-different-lens-versio.patch b/debian/patches/0002-Construct-lenses-correctly-for-different-lens-versio.patch
new file mode 100644
index 0000000..9d89a34
--- /dev/null
+++ b/debian/patches/0002-Construct-lenses-correctly-for-different-lens-versio.patch
@@ -0,0 +1,42 @@
+From 1136f1cbf85444dcd0b942545e7f4000b81befbc Mon Sep 17 00:00:00 2001
+From: Petr Pudlak <pudlak at google.com>
+Date: Tue, 10 Feb 2015 13:18:00 +0100
+Subject: [PATCH 2/2] Construct lenses correctly for different 'lens' versions
+
+As the interface of the TH code for generating lenses changed twice in
+4.*, we need to differentiate between versions accordingly.
+
+Signed-off-by: Petr Pudlak <pudlak at google.com>
+---
+ src/Ganeti/Lens.hs | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/src/Ganeti/Lens.hs b/src/Ganeti/Lens.hs
+index 8f9b976..0299e1a 100644
+--- a/src/Ganeti/Lens.hs
++++ b/src/Ganeti/Lens.hs
+@@ -69,8 +69,19 @@ makeCustomLensesFiltered :: (String -> Bool) -> Name -> Q [Dec]
+ makeCustomLensesFiltered f = makeLensesWith customRules
+   where
+     customRules :: LensRules
+-    customRules = set lensField (fmap lensFieldName . mfilter f . Just)
+-                      defaultRules
++    customRules = set lensField nameFun lensRules
++#if MIN_VERSION_lens(4,5,0)
++    nameFun :: Name -> [Name] -> Name -> [DefName]
++    nameFun _ _ = liftM (TopName . mkName) . nameFilter . nameBase
++#elif MIN_VERSION_lens(4,4,0)
++    nameFun :: [Name] -> Name -> [DefName]
++    nameFun _ = liftM (TopName . mkName) . nameFilter . nameBase
++#else
++    nameFun :: String -> Maybe String
++    nameFun = nameFilter
++#endif
++    nameFilter :: (MonadPlus m) => String -> m String
++    nameFilter = liftM lensFieldName . mfilter f . return
+ 
+ -- | Create lenses for all fields of a given data type.
+ makeCustomLenses :: Name -> Q [Dec]
+-- 
+2.1.4
+
diff --git a/debian/patches/series b/debian/patches/series
index a1a5b54..cd4a168 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,5 @@ cfgupgrade12-remove-old-ssconf.patch
 0003-Disable-local-checks-during-build.patch
 do-not-backup-export-dir.patch
 fix-wconfd-metad
+0001-Create-a-simple-CPP-macro-for-detecting-lens-version.patch
+0002-Construct-lenses-correctly-for-different-lens-versio.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ganeti/ganeti.git



More information about the Pkg-ganeti-devel mailing list