[arch-commits] Commit in misfortune/trunk (PKGBUILD random-fu-0.3.patch)

Felix Yan felixonmars at gemini.archlinux.org
Sun Mar 6 23:04:48 UTC 2022


    Date: Sunday, March 6, 2022 @ 23:04:47
  Author: felixonmars
Revision: 1144030

upgpkg: misfortune 0.1.1.2-119: rebuild with rvar 0.3.0.0, random-fu 0.3.0.0

Added:
  misfortune/trunk/random-fu-0.3.patch
Modified:
  misfortune/trunk/PKGBUILD

---------------------+
 PKGBUILD            |   17 ++++++----
 random-fu-0.3.patch |   83 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+), 7 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2022-03-06 22:18:21 UTC (rev 1144029)
+++ PKGBUILD	2022-03-06 23:04:47 UTC (rev 1144030)
@@ -2,21 +2,24 @@
 
 pkgname=misfortune
 pkgver=0.1.1.2
-pkgrel=118
+pkgrel=119
 pkgdesc="fortune-mod clone"
 url="https://github.com/mokus0/misfortune"
 license=("custom:PublicDomain")
 arch=('x86_64')
-depends=('ghc-libs' 'haskell-cereal' 'haskell-knob' 'haskell-monad-loops' 'haskell-random-fu'
-         'haskell-regex-base' 'haskell-regex-pcre' 'haskell-utf8-string'
+depends=('ghc-libs' 'haskell-cereal' 'haskell-knob' 'haskell-monad-loops' 'haskell-random'
+         'haskell-random-fu' 'haskell-regex-base' 'haskell-regex-pcre' 'haskell-utf8-string'
          'haskell-vector')
-makedepends=('ghc')
-source=("https://hackage.haskell.org/packages/archive/$pkgname/$pkgver/$pkgname-$pkgver.tar.gz")
-sha256sums=('ae4b44215f811e7af6af756c813b9bd6e4161be555f30dd817324f8d1ffe2349')
+makedepends=('ghc' 'uusi')
+source=("https://hackage.haskell.org/packages/archive/$pkgname/$pkgver/$pkgname-$pkgver.tar.gz"
+        random-fu-0.3.patch)
+sha256sums=('ae4b44215f811e7af6af756c813b9bd6e4161be555f30dd817324f8d1ffe2349'
+            '954b412585a7406f4cff350dc63a45595864bb9d7ce874c922db3840a48c6e4e')
 
 prepare() {
   cd $pkgname-$pkgver
-  sed -i '/semigroups/d' $pkgname.cabal
+  patch -Np1 -i ../random-fu-0.3.patch
+  uusi -d semigroups $pkgname.cabal
 }
 
 build() {

Added: random-fu-0.3.patch
===================================================================
--- random-fu-0.3.patch	                        (rev 0)
+++ random-fu-0.3.patch	2022-03-06 23:04:47 UTC (rev 1144030)
@@ -0,0 +1,83 @@
+From 61b2b05b86e87a0a5c0795877024ff9449ba6cad Mon Sep 17 00:00:00 2001
+From: Felix Yan <felixonmars at archlinux.org>
+Date: Mon, 7 Mar 2022 00:57:28 +0200
+Subject: [PATCH] Fix compatibility for random-fu 0.3
+
+Fixes #4
+Many thanks to @berberman
+---
+ misfortune.cabal    | 6 ++----
+ src/Data/Fortune.hs | 6 ++++--
+ src/Fortune.hs      | 6 ++++--
+ 3 files changed, 10 insertions(+), 8 deletions(-)
+
+diff --git a/misfortune.cabal b/misfortune.cabal
+index b01ba69..f5f86cd 100644
+--- a/misfortune.cabal
++++ b/misfortune.cabal
+@@ -121,7 +121,8 @@ Library
+                         directory,
+                         filepath,
+                         knob,
+-                        random-fu >= 0.2.2,
++                        random,
++                        random-fu >= 0.3,
+                         semigroups,
+                         text,
+                         utf8-string,
+diff --git a/src/Data/Fortune.hs b/src/Data/Fortune.hs
+index 16d221e..ffbc970 100644
+--- a/src/Data/Fortune.hs
++++ b/src/Data/Fortune.hs
+@@ -64,6 +64,7 @@ import Paths_misfortune
+ import System.Directory
+ import System.Environment
+ import System.FilePath
++import System.Random.Stateful (newIOGenM, newStdGen)
+ 
+ -- |The number of fortune strings in the index
+ numFortunes :: S.FortuneStats -> Int
+@@ -233,9 +234,10 @@ randomFortune paths = withFortuneFiles '%' False paths $ \fs -> do
+ -- random fortune from that file (unformly).
+ randomFortuneFromRandomFile :: RVar FortuneFile -> IO String
+ randomFortuneFromRandomFile file = do
+-    f <- sample file
++    gen <- newStdGen >>= newIOGenM
++    f <- sampleFrom gen file
+     n <- getNumFortunes f
+-    i <- sample (uniform 0 (n-1))
++    i <- sampleFrom gen (uniform 0 (n-1))
+     T.unpack <$> getFortune f i
+ 
+ -- |Given a list of 'FortuneFile's, compute a distrubution over them weighted by the number
+diff --git a/src/Fortune.hs b/src/Fortune.hs
+index 5a27578..d6ffb74 100644
+--- a/src/Fortune.hs
++++ b/src/Fortune.hs
+@@ -21,6 +21,7 @@ import System.Environment
+ import System.Exit
+ import System.FilePath
+ import System.IO
++import System.Random.Stateful (newIOGenM, newStdGen)
+ import Text.Printf
+ import Text.Regex.Base
+ import Text.Regex.PCRE
+@@ -200,6 +201,7 @@ main = do
+     fortunes <- filterM (filterFile args) (fortuneFiles args)
+     
+     dist <- getDist args fortunes
++    gen <- newStdGen >>= newIOGenM
+     
+     when (numEvents dist == 0) $ do
+         hPutStrLn stderr "No fortunes matched the filter criteria"
+@@ -225,8 +227,8 @@ main = do
+             , let pctStr = printf "(%.2f%%)" (100 * weight / totalWeight dist) :: String
+             ]
+         else do
+-            (file, fortuneDist) <- sample dist
+-            fortune <- sample fortuneDist
++            (file, fortuneDist) <- sampleFrom gen dist
++            fortune <- sampleFrom gen fortuneDist
+             putStrLn . T.unpack =<< getFortune file fortune
+ 
+ getDist :: Args -> [FortuneFile] -> IO (Categorical Float (FortuneFile, Categorical Float Int))



More information about the arch-commits mailing list