Hello community,

here is the log from the commit of package ghc for openSUSE:Factory checked in 
at 2015-10-06 13:27:28
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc (Old)
 and      /work/SRC/openSUSE:Factory/.ghc.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc/ghc.changes  2015-09-24 06:15:20.000000000 
+0200
+++ /work/SRC/openSUSE:Factory/.ghc.new/ghc.changes     2015-10-06 
13:27:39.000000000 +0200
@@ -1,0 +2,13 @@
+Sat Oct  3 18:50:28 UTC 2015 - sbahl...@suse.com
+
+- Remove ncurses6.patch - it's not so easy ;)
+- Add remove-cur_term-usage.patch to remove the need to access the
+  cur_term global which isn't available in the openSUSE ncurses6
+  build.
+
+-------------------------------------------------------------------
+Sat Oct  3 15:59:19 UTC 2015 - mimi...@gmail.com
+
+- Add choice for libffi in openSUSE:Leap:42.1 
+
+-------------------------------------------------------------------
@@ -6 +19 @@
-  Tomas Cech - sleep_wal...@opensuse.org
+  Tomas Cech sleep_wal...@opensuse.org

Old:
----
  ncurses6.patch

New:
----
  remove-cur_term-usage.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc.spec ++++++
--- /var/tmp/diff_new_pack.BVFzUO/_old  2015-10-06 13:27:40.000000000 +0200
+++ /var/tmp/diff_new_pack.BVFzUO/_new  2015-10-06 13:27:40.000000000 +0200
@@ -33,7 +33,12 @@
 BuildRequires:  glibc-devel
 BuildRequires:  gmp-devel
 BuildRequires:  libelf-devel
+#Fix for openSUSE:Leap:42.1
+%if 0%{?suse_version} == 1315
+BuildRequires:  libffi48-devel
+%else
 BuildRequires:  libffi-devel
+%endif
 #TODO ghc-7.10.2 supports only llvm-3.5, need talk with llvm packagers about 
 # versioned build of llvm
 #%%ifnarch ppc aarch64
@@ -65,8 +70,8 @@
 Patch19:        0001-implement-native-code-generator-for-ppc64.patch
 # PATCH-FIX-UPSTREAM peter.tromm...@ohm-hochschule.de -- GNU ld does not work 
with ghc on aarch64 so use Gold. Adapted from Fedora patch 24.
 Patch23:        ghc-7.8-arm-use-ld-gold.patch
-# PATCH-FIX-OPENSUSE tc...@suse.cz -- ncurses6 doesn't export cur_term function
-Patch24:           ncurses6.patch
+# PATCH-FIX-OPENSUSE sbahl...@suse.com -- remove-cur_term-usage.patch 
openSUSE's ncurses6 doesn't export cur_term function
+Patch24:        remove-cur_term-usage.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 
@@ -157,9 +162,7 @@
 %prep
 %setup -q
 %patch19 -p1
-%if 0%{?suse_version} > 1320
 %patch24 -p1
-%endif 
 
 #%%ifarch armv7hl aarch64
 #%%patch23 -p1 -b .24~

++++++ remove-cur_term-usage.patch ++++++
Subject: Remove use of cur_term global struct
From: Scott Bahling sbahl...@suse.com
Date: 2015-10-04

With the move to ncurses6, it has been decided by the openSUSE
developer to build the library in threaded mode only. In threaded
mode, the global variables are protected and not exported.

ghc-terminfo was accessing (reading and writing) the cur_term
global so it doesn't work with the openSUSE threaded ncurses6
library. This is an attempt to remove the need to access cur_term
and rely only on the low-level functions.

First, cur_term was being set to a null pointer in order to force
ncurses setupterm() to return new struct instead of a copy of the
current when the terminal name is the same. Actually (and unfortunately)
setupterm() does not return the struct but rather set the global cur_term.
Reading the ncurses code, and the NEWS file, it appears that the
behavior of setupterm() had been changed quite some time ago, and no
longer returns a copy of the struct (internal 'reuse' option) (NEWS 20041127).
The code seems to confirm this, so setting cur_term to a null pointer
shouldn't really be required - we remove poke cur_term!

That's great, but the we still have the problem that setupterm() doesn't
return the terminal struct that is required later to setup the
cleanup routine of the Terminal type (del_curterm cterm). The only
function that appears to return the cur_term pointer is set_curterm()
which has the side effect of overwriting the current pointer in the
process :/  So, we call set_curterm() with a null pointer, retrieving
the former, cur_term pointer for our use in the cterm instance, and
then call set_curterm() again with the former pointer to set it
back again.... whew! Having looked at the ncurses set_curterm() code
it seems it handles a null pointer in the way we would need.

Later in the withCurTerm function we use virtually the same trick
to relieve the need to peek into the cur_term global. I'm not so
sure if this is Haskell correct code though.

Someone with more Haskell programming knowledge than me should review
this patch. It still needs to be tested as well.

---
diff -Nrup a/libraries/terminfo/System/Console/Terminfo/Base.hs 
b/libraries/terminfo/System/Console/Terminfo/Base.hs
--- a/libraries/terminfo/System/Console/Terminfo/Base.hs        2015-02-25 
06:13:15.000000000 +0100
+++ b/libraries/terminfo/System/Console/Terminfo/Base.hs        2015-10-03 
21:40:09.106028237 +0200
@@ -63,7 +63,6 @@ import Data.Typeable
 data TERMINAL
 newtype Terminal = Terminal (ForeignPtr TERMINAL)
 
-foreign import ccall "&" cur_term :: Ptr (Ptr TERMINAL)
 foreign import ccall set_curterm :: Ptr TERMINAL -> IO (Ptr TERMINAL)
 foreign import ccall "&" del_curterm :: FunPtr (Ptr TERMINAL -> IO ())
 
@@ -73,19 +72,12 @@ foreign import ccall setupterm :: CStrin
 -- 
 -- Throws a 'SetupTermError' if the terminfo database could not be read.
 setupTerm :: String -> IO Terminal
-setupTerm term = bracket (peek cur_term) (poke cur_term) $ \_ -> 
-    withCString term $ \c_term ->
+setupTerm term = withCString term $ \c_term ->
     with 0 $ \ret_ptr -> do
         -- NOTE: I believe that for the way we use terminfo
         -- (i.e. custom output function)
         -- this parameter does not affect anything.
         let stdOutput = 1
-        {-- Force ncurses to return a new struct rather than
-        a copy of the current one (which it would do if the
-        terminal names are the same).  This prevents problems
-        when calling del_term on a struct shared by more than one
-        Terminal. --}
-        poke cur_term nullPtr
         -- Call setupterm and check the return value.
         setupterm c_term stdOutput ret_ptr
         ret <- peek ret_ptr
@@ -93,7 +85,12 @@ setupTerm term = bracket (peek cur_term)
             then throwIO $ SetupTermError
                 $ "Couldn't look up terminfo entry " ++ show term
             else do
-                cterm <- peek cur_term
+                -- There is no function to simply return the cur_term pointer.
+                -- We call set_curterm with nullPtr which will give us
+                -- the value of the old cur_term and then we set it back
+                -- again.
+                cterm <- set_curterm nullPtr
+                set_curterm cterm
                 fmap Terminal $ newForeignPtr del_curterm cterm
 
 data SetupTermError = SetupTermError String
@@ -120,15 +117,10 @@ setupTermFromEnv = do
 -- TODO: this isn't really thread-safe...
 withCurTerm :: Terminal -> IO a -> IO a
 withCurTerm (Terminal term) f = withForeignPtr term $ \cterm -> do
-        old_term <- peek cur_term
-        if old_term /= cterm
-            then do
-                    _ <- set_curterm cterm
-                    x <- f
-                    _ <- set_curterm old_term
-                    return x
-            else f
-
+        old_term <- set_curterm cterm
+        x <- f
+        set_curterm old_term
+        return x
 
 ----------------------
 

Reply via email to