summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-12-31 13:54:41 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-12-31 13:54:41 -0400
commitc7c745d28868c8cd646d3e31dd8ba6a0b763f611 (patch)
tree0f01ece516196776f47ba9dda79d1f3fc032e690 /Utility
parent455675b7b002227c84ad4717e5114b2e13619d4f (diff)
git-annex.cabal: Add back custom-setup stanza, so cabal new-build works.
Seems I had all the work in past commits to make this build, at least on linux. I'm actually surprised it does, without a unix dep, Utility.Env still builds ok somehow despite using System.Posix.Env. This commit was sponsored by Fernando Jimenez on Patreon.
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Env.hs24
-rw-r--r--Utility/Env/Set.hs40
-rw-r--r--Utility/Gpg.hs1
-rw-r--r--Utility/Lsof.hs2
4 files changed, 42 insertions, 25 deletions
diff --git a/Utility/Env.hs b/Utility/Env.hs
index c56f4ec23..dfebd9868 100644
--- a/Utility/Env.hs
+++ b/Utility/Env.hs
@@ -16,7 +16,6 @@ import Control.Applicative
import Data.Maybe
import Prelude
import qualified System.Environment as E
-import qualified System.SetEnv
#else
import qualified System.Posix.Env as PE
#endif
@@ -42,29 +41,6 @@ getEnvironment = PE.getEnvironment
getEnvironment = E.getEnvironment
#endif
-{- Sets an environment variable. To overwrite an existing variable,
- - overwrite must be True.
- -
- - On Windows, setting a variable to "" unsets it. -}
-setEnv :: String -> String -> Bool -> IO ()
-#ifndef mingw32_HOST_OS
-setEnv var val overwrite = PE.setEnv var val overwrite
-#else
-setEnv var val True = System.SetEnv.setEnv var val
-setEnv var val False = do
- r <- getEnv var
- case r of
- Nothing -> setEnv var val True
- Just _ -> return ()
-#endif
-
-unsetEnv :: String -> IO ()
-#ifndef mingw32_HOST_OS
-unsetEnv = PE.unsetEnv
-#else
-unsetEnv = System.SetEnv.unsetEnv
-#endif
-
{- Adds the environment variable to the input environment. If already
- present in the list, removes the old value.
-
diff --git a/Utility/Env/Set.hs b/Utility/Env/Set.hs
new file mode 100644
index 000000000..fd8d5140d
--- /dev/null
+++ b/Utility/Env/Set.hs
@@ -0,0 +1,40 @@
+{- portable environment variables
+ -
+ - Copyright 2013 Joey Hess <id@joeyh.name>
+ -
+ - License: BSD-2-clause
+ -}
+
+{-# LANGUAGE CPP #-}
+
+module Utility.Env.Set where
+
+#ifdef mingw32_HOST_OS
+import qualified System.Environment as E
+import qualified System.SetEnv
+#else
+import qualified System.Posix.Env as PE
+#endif
+
+{- Sets an environment variable. To overwrite an existing variable,
+ - overwrite must be True.
+ -
+ - On Windows, setting a variable to "" unsets it. -}
+setEnv :: String -> String -> Bool -> IO ()
+#ifndef mingw32_HOST_OS
+setEnv var val overwrite = PE.setEnv var val overwrite
+#else
+setEnv var val True = System.SetEnv.setEnv var val
+setEnv var val False = do
+ r <- getEnv var
+ case r of
+ Nothing -> setEnv var val True
+ Just _ -> return ()
+#endif
+
+unsetEnv :: String -> IO ()
+#ifndef mingw32_HOST_OS
+unsetEnv = PE.unsetEnv
+#else
+unsetEnv = System.SetEnv.unsetEnv
+#endif
diff --git a/Utility/Gpg.hs b/Utility/Gpg.hs
index 4af0067bb..fff40454d 100644
--- a/Utility/Gpg.hs
+++ b/Utility/Gpg.hs
@@ -15,6 +15,7 @@ import qualified BuildInfo
import System.Posix.Types
import qualified System.Posix.IO
import Utility.Env
+import Utility.Env.Set
#endif
import Utility.Tmp
import Utility.Format (decode_c)
diff --git a/Utility/Lsof.hs b/Utility/Lsof.hs
index ab80258b7..7cab8d98a 100644
--- a/Utility/Lsof.hs
+++ b/Utility/Lsof.hs
@@ -11,7 +11,7 @@ module Utility.Lsof where
import Common
import BuildInfo
-import Utility.Env
+import Utility.Env.Set
import System.Posix.Types