Commit 3acc6aa9 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Fix the permission that we give wrapper scripts

parent 8dac63fc
......@@ -102,6 +102,7 @@ Library
Other-Modules:
Distribution.GetOpt,
Distribution.Compat.Exception,
Distribution.Compat.Permissions,
Distribution.Compat.TempFile,
Distribution.Simple.GHC.Makefile,
Distribution.Simple.GHC.IPI641,
......
-- #hide
module Distribution.Compat.Permissions (copyPermissions) where
import Foreign
import Foreign.C
import System.Posix.Internals
copyPermissions :: FilePath -> FilePath -> IO ()
copyPermissions source dest = do
allocaBytes sizeof_stat $ \ p_stat -> do
withCString source $ \p_source -> do
withCString dest $ \p_dest -> do
throwErrnoIfMinus1_ "copyPermissions" $ c_stat p_source p_stat
mode <- st_mode p_stat
throwErrnoIfMinus1_ "copyPermissions" $ c_chmod p_dest mode
......@@ -120,13 +120,12 @@ import Data.List ( nub )
import Data.Maybe ( catMaybes )
import System.Directory ( removeFile, renameFile,
getDirectoryContents, doesFileExist,
getTemporaryDirectory,
Permissions(..),
getPermissions, setPermissions )
getTemporaryDirectory )
import System.FilePath ( (</>), (<.>), takeExtension,
takeDirectory, replaceExtension, splitExtension )
import System.IO (openFile, IOMode(WriteMode), hClose, hPutStrLn)
import Distribution.Compat.Exception (catchExit, catchIO)
import Distribution.Compat.Permissions (copyPermissions)
-- -----------------------------------------------------------------------------
-- Configuring
......@@ -878,6 +877,7 @@ installExe flags lbi installDirs pretendInstallDirs buildPref (progprefix, progs
: fullPathTemplateEnv myPkgId myCompilerId
pretendInstallDirs
createDirectoryIfMissingVerbose verbosity True libExecDir
installBinary absExeFileName
-- XXX Should probably look somewhere more sensible
-- than just . for wrappers
wrapperTemplate <- readFile (e <.> "wrapper")
......@@ -885,10 +885,7 @@ installExe flags lbi installDirs pretendInstallDirs buildPref (progprefix, progs
$ substPathTemplate env
$ toPathTemplate wrapperTemplate
writeFileAtomic wrapperFileName wrapper
perms <- getPermissions wrapperFileName
let perms' = perms {executable = True}
setPermissions wrapperFileName perms'
installBinary absExeFileName
copyPermissions absExeFileName wrapperFileName
else do
let absExeFileName =
binDir </> fixedExeBaseName <.> exeExtension
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment