diff options
-rw-r--r-- | Annex/Environment.hs | 1 | ||||
-rw-r--r-- | Assistant/Upgrade.hs | 1 | ||||
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | Git/CurrentRepo.hs | 1 | ||||
-rw-r--r-- | Git/Index.hs | 1 | ||||
-rw-r--r-- | Test.hs | 11 | ||||
-rw-r--r-- | Utility/Env.hs | 24 | ||||
-rw-r--r-- | Utility/Env/Set.hs | 40 | ||||
-rw-r--r-- | Utility/Gpg.hs | 1 | ||||
-rw-r--r-- | Utility/Lsof.hs | 2 | ||||
-rw-r--r-- | doc/bugs/Add_custom-setup_stanza_to_.cabal_file.mdwn | 3 | ||||
-rw-r--r-- | git-annex.cabal | 6 |
12 files changed, 62 insertions, 30 deletions
diff --git a/Annex/Environment.hs b/Annex/Environment.hs index 4f0fda986..0ddf9d2b7 100644 --- a/Annex/Environment.hs +++ b/Annex/Environment.hs @@ -14,6 +14,7 @@ import Utility.UserInfo import qualified Git.Config import Config import Utility.Env +import Utility.Env.Set {- Checks that the system's environment allows git to function. - Git requires a GECOS username, or suitable git configuration, or diff --git a/Assistant/Upgrade.hs b/Assistant/Upgrade.hs index 3b7b48833..c9084be53 100644 --- a/Assistant/Upgrade.hs +++ b/Assistant/Upgrade.hs @@ -15,6 +15,7 @@ import qualified Annex import Assistant.Alert import Assistant.DaemonStatus import Utility.Env +import Utility.Env.Set import Types.Distribution import Types.Transfer import Logs.Web @@ -5,6 +5,7 @@ git-annex (6.20171215) UNRELEASED; urgency=medium downloaded. * Fix bug introduced in version 6.20171018 that caused some commands to print out "ok" twice after processing a file. + * git-annex.cabal: Add back custom-setup stanza, so cabal new-build works. -- Joey Hess <id@joeyh.name> Wed, 20 Dec 2017 12:11:46 -0400 diff --git a/Git/CurrentRepo.hs b/Git/CurrentRepo.hs index 69a679ee3..df074cf8b 100644 --- a/Git/CurrentRepo.hs +++ b/Git/CurrentRepo.hs @@ -12,6 +12,7 @@ import Git.Types import Git.Construct import qualified Git.Config import Utility.Env +import Utility.Env.Set {- Gets the current git repository. - diff --git a/Git/Index.hs b/Git/Index.hs index 85ea480b5..0898569b4 100644 --- a/Git/Index.hs +++ b/Git/Index.hs @@ -10,6 +10,7 @@ module Git.Index where import Common import Git import Utility.Env +import Utility.Env.Set indexEnv :: String indexEnv = "GIT_INDEX_FILE" @@ -83,6 +83,7 @@ import qualified Utility.Process import qualified Utility.Misc import qualified Utility.InodeCache import qualified Utility.Env +import qualified Utility.Env.Set import qualified Utility.Matcher import qualified Utility.Exception import qualified Utility.Hash @@ -130,7 +131,7 @@ runner = Just go subenv = "GIT_ANNEX_TEST_SUBPROCESS" runsubprocesstests opts Nothing = do pp <- Annex.Path.programPath - Utility.Env.setEnv subenv "1" True + Utility.Env.Set.setEnv subenv "1" True ps <- getArgs (Nothing, Nothing, Nothing, pid) <-createProcess (proc pp ps) exitcode <- waitForProcess pid @@ -1919,9 +1920,9 @@ ensuretmpdir = do isolateGitConfig :: IO a -> IO a isolateGitConfig a = Utility.Tmp.withTmpDir "testhome" $ \tmphome -> do tmphomeabs <- absPath tmphome - Utility.Env.setEnv "HOME" tmphomeabs True - Utility.Env.setEnv "XDG_CONFIG_HOME" tmphomeabs True - Utility.Env.setEnv "GIT_CONFIG_NOSYSTEM" "1" True + Utility.Env.Set.setEnv "HOME" tmphomeabs True + Utility.Env.Set.setEnv "XDG_CONFIG_HOME" tmphomeabs True + Utility.Env.Set.setEnv "GIT_CONFIG_NOSYSTEM" "1" True a cleanup :: FilePath -> IO () @@ -2107,7 +2108,7 @@ setTestMode testmode = do currdir <- getCurrentDirectory p <- Utility.Env.getEnvDefault "PATH" "" - mapM_ (\(var, val) -> Utility.Env.setEnv var val True) + mapM_ (\(var, val) -> Utility.Env.Set.setEnv var val True) -- Ensure that the just-built git annex is used. [ ("PATH", currdir ++ [searchPathSeparator] ++ p) , ("TOPDIR", currdir) 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 diff --git a/doc/bugs/Add_custom-setup_stanza_to_.cabal_file.mdwn b/doc/bugs/Add_custom-setup_stanza_to_.cabal_file.mdwn index 51d4f189d..fcf9b6b3a 100644 --- a/doc/bugs/Add_custom-setup_stanza_to_.cabal_file.mdwn +++ b/doc/bugs/Add_custom-setup_stanza_to_.cabal_file.mdwn @@ -44,3 +44,6 @@ Use -v to see a list of the files searched for. Yeah, it's amazing! I've been using the version from the Debian repos and then wanted to try building the new version for youtube-dl support. + +> Revisited it and seem to have managed to add custom-setup back. [[done]] +> --[[Joey]] diff --git a/git-annex.cabal b/git-annex.cabal index 6b2fec439..95d39f592 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -302,6 +302,11 @@ source-repository head type: git location: git://git-annex.branchable.com/ +custom-setup + Setup-Depends: base (>= 4.5), hslogger, split, unix-compat, process, + filepath, exceptions, bytestring, directory, IfElse, data-default, + utf8-string, Cabal + Executable git-annex Main-Is: git-annex.hs Build-Depends: @@ -991,6 +996,7 @@ Executable git-annex Utility.Dot Utility.DottedVersion Utility.Env + Utility.Env.Set Utility.Exception Utility.ExternalSHA Utility.FileMode |