on master help sign in
Merge branch 'master' into add-it-has
commitfc7365a4fa857bd64b88ce4cef6ddb081efea204 authorJens Petersen <juhpetersen@gmail.com> dateMon 18 May 2020, 22:37 (6 years ago) parent60b6ea8b70d9dd
2 files changed+63−5
build-constraints.yaml+8−5 etc/diskspace/remove-old-stack-work-libs.hs+55
build-constraints.yaml+8−5
@@ -466,7 +466,7 @@ packages:
466466
467467 "Li-yao Xia <lysxia@gmail.com> @Lysxia":
468468 - boltzmann-samplers
469− - first-class-families < 0.8.0.0
469+ - first-class-families
470470 - generic-data
471471 - generic-data-surgery < 0 # via generic-data
472472 - generic-random
@@ -862,7 +862,7 @@ packages:
862862 - compensated
863863 - compressed < 0
864864 - concurrent-supply
865− - constraints < 0.12 # https://github.com/commercialhaskell/stackage/issues/5124
865+ - constraints
866866 - contravariant
867867 - distributive
868868 - discrimination < 0
@@ -3865,10 +3865,10 @@ packages:
38653865 - map-syntax < 0 # GHC 8.4 via base-4.11.0.0
38663866 - heist < 0 # GHC 8.4 via map-syntax
38673867 - snap < 0 # GHC 8.4 via base-4.11.0.0
3868− - conferer
3868+ - conferer < 0.4.0.0 # https://github.com/commercialhaskell/stackage/issues/5374
38693869 # - conferer-snap # Because snap
3870− - conferer-warp
3871− - conferer-hspec
3870+ - conferer-warp < 0.4.0.0 # https://github.com/commercialhaskell/stackage/issues/5374
3871+ - conferer-hspec < 0.4.0.0 # https://github.com/commercialhaskell/stackage/issues/5374
38723872 - conferer-provider-json
38733873
38743874 "Tim Humphries <tim+stackage@utf8.me> @thumphries":
@@ -4245,6 +4245,9 @@ packages:
42454245 "Dobromir Nikolov <dnikolovv@hotmail.com> @dnikolovv":
42464246 - it-has
42474247
4248+ "Gabriele Sales <gbrsales@gmail.com> @gbrsales":
4249+ - cabal-appimage
4250+
42484251 "Grandfathered dependencies":
42494252 - network
42504253 - Boolean
etc/diskspace/remove-old-stack-work-libs.hsnew file+55
@@ -0,0 +1,55 @@
1+#!/usr/bin/env stack
2+-- stack --resolver lts-14 script
3+
4+-- Utility to remove old libs installed under .stack-work/ to save diskspace
5+
6+-- Should be run in:
7+-- work/*/unpack-dir/.stack-work/install/x86_64-linux/*/*/lib/x86_64-linux-ghc-*
8+
9+import Data.List
10+import System.Directory
11+
12+main = do
13+ files <- sort <$> listDirectory "."
14+ (libdirs,dynlibs) <- partitionM doesDirectoryExist files
15+ let pkglibdirs = groupBy samePkgLibDir libdirs
16+ pkgdynlibs = groupBy samePkgDynLib dynlibs
17+ mapM_ (removeOlder removeDirectoryRecursive) pkglibdirs
18+ mapM_ (removeOlder removeFile) pkgdynlibs
19+ where
20+ samePkgLibDir l1 l2 = pkgDirName l1 == pkgDirName l2
21+ where
22+ pkgDirName p =
23+ if countDashes p < 2
24+ then error $ p ++ " not in name-version-hash format"
25+ else (removeDashSegment . removeDashSegment) p
26+
27+ countDashes = length . filter (== '-')
28+
29+ removeDashSegment = init . dropWhileEnd (/= '-')
30+
31+ samePkgDynLib d1 d2 = pkgDynName d1 == pkgDynName d2
32+ where
33+ pkgDynName p =
34+ if countDashes p < 3
35+ then error $ p ++ " not in libname-version-hash-ghc*.so format"
36+ else (removeDashSegment . removeDashSegment . removeDashSegment) p
37+
38+ removeOlder remover files = do
39+ oldfiles <- drop 2 . reverse <$> sortByAge files
40+ mapM_ remover oldfiles
41+
42+ sortByAge files = do
43+ timestamps <- mapM getModificationTime files
44+ let fileTimes = zip files timestamps
45+ return $ map fst $ sortBy compareSnd fileTimes
46+
47+ compareSnd (_,t1) (_,t2) = compare t1 t2
48+
49+-- borrowed from Control.Monad.Extra
50+partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])
51+partitionM f [] = pure ([], [])
52+partitionM f (x:xs) = do
53+ res <- f x
54+ (as,bs) <- partitionM f xs
55+ pure ([x | res]++as, [x | not res]++bs)