From cbb7f306b8f8f2672ea34b040a0010739f722310 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 31 Dec 2017 14:09:41 -0400 Subject: Revert "git-annex.cabal: Add back custom-setup stanza, so cabal new-build works." This reverts commit c7c745d28868c8cd646d3e31dd8ba6a0b763f611. No, still doesn't work when built with cabal. It did with stack; stack must somehow make the unix package implicitly available. With cabal, System.Posix.Process and System.Posix.Env are both missing. --- Utility/Env.hs | 24 ++++++++++++++++++++++++ Utility/Env/Set.hs | 40 ---------------------------------------- Utility/Gpg.hs | 1 - Utility/Lsof.hs | 2 +- 4 files changed, 25 insertions(+), 42 deletions(-) delete mode 100644 Utility/Env/Set.hs (limited to 'Utility') diff --git a/Utility/Env.hs b/Utility/Env.hs index dfebd9868..c56f4ec23 100644 --- a/Utility/Env.hs +++ b/Utility/Env.hs @@ -16,6 +16,7 @@ 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 @@ -41,6 +42,29 @@ 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 deleted file mode 100644 index fd8d5140d..000000000 --- a/Utility/Env/Set.hs +++ /dev/null @@ -1,40 +0,0 @@ -{- portable environment variables - - - - Copyright 2013 Joey Hess - - - - 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 fff40454d..4af0067bb 100644 --- a/Utility/Gpg.hs +++ b/Utility/Gpg.hs @@ -15,7 +15,6 @@ 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 7cab8d98a..ab80258b7 100644 --- a/Utility/Lsof.hs +++ b/Utility/Lsof.hs @@ -11,7 +11,7 @@ module Utility.Lsof where import Common import BuildInfo -import Utility.Env.Set +import Utility.Env import System.Posix.Types -- cgit v1.2.3