[arch-commits] Commit in misfortune/repos (3 files)
Felix Yan
felixonmars at gemini.archlinux.org
Mon Mar 7 20:41:21 UTC 2022
Date: Monday, March 7, 2022 @ 20:41:21
Author: felixonmars
Revision: 1144998
archrelease: copy trunk to community-staging-x86_64
Added:
misfortune/repos/community-staging-x86_64/
misfortune/repos/community-staging-x86_64/PKGBUILD
(from rev 1144997, misfortune/trunk/PKGBUILD)
misfortune/repos/community-staging-x86_64/random-fu-0.3.patch
(from rev 1144997, misfortune/trunk/random-fu-0.3.patch)
---------------------+
PKGBUILD | 47 ++++++++++++++++++++++++++++
random-fu-0.3.patch | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 130 insertions(+)
Copied: misfortune/repos/community-staging-x86_64/PKGBUILD (from rev 1144997, misfortune/trunk/PKGBUILD)
===================================================================
--- community-staging-x86_64/PKGBUILD (rev 0)
+++ community-staging-x86_64/PKGBUILD 2022-03-07 20:41:21 UTC (rev 1144998)
@@ -0,0 +1,47 @@
+# Maintainer: Felix Yan <felixonmars at archlinux.org>
+
+pkgname=misfortune
+pkgver=0.1.1.2
+pkgrel=120
+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'
+ 'haskell-random-fu' 'haskell-regex-base' 'haskell-regex-pcre' 'haskell-utf8-string'
+ 'haskell-vector')
+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
+ patch -Np1 -i ../random-fu-0.3.patch
+ uusi -d semigroups $pkgname.cabal
+}
+
+build() {
+ cd $pkgname-$pkgver
+
+ runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
+ --prefix=/usr --docdir=/usr/share/doc/$pkgname --enable-tests \
+ --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
+ --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
+ --ghc-option='-pie'
+
+ runhaskell Setup build $MAKEFLAGS
+ runhaskell Setup register --gen-script
+ runhaskell Setup unregister --gen-script
+ sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
+ sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
+}
+
+package() {
+ cd $pkgname-$pkgver
+
+ install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
+ install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
+ runhaskell Setup copy --destdir="$pkgdir"
+}
Copied: misfortune/repos/community-staging-x86_64/random-fu-0.3.patch (from rev 1144997, misfortune/trunk/random-fu-0.3.patch)
===================================================================
--- community-staging-x86_64/random-fu-0.3.patch (rev 0)
+++ community-staging-x86_64/random-fu-0.3.patch 2022-03-07 20:41:21 UTC (rev 1144998)
@@ -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