@@ -29,7 +29,8 @@ import Distribution.System (OS (..), buildOS)
29
29
import Prelude (String )
30
30
31
31
import System.Directory (doesFileExist , removeFile )
32
- import System.Process (proc , waitForProcess , withCreateProcess )
32
+ import System.Process (CreateProcess (.. ), StdStream (.. ), proc ,
33
+ waitForProcess , withCreateProcess )
33
34
34
35
#ifdef mingw32_HOST_OS
35
36
import qualified Data.Text as T
@@ -52,14 +53,14 @@ import Cardano.Shell.Types (LoggingDependencies (..))
52
53
-- | Runner path, what we use to run the update/installer,
53
54
-- arguments for the runner, and the actual update path for the installer.
54
55
data UpdaterData = UpdaterData
55
- { udUpdaterPath :: ! FilePath
56
+ { udUpdaterPath :: ! FilePath
56
57
-- ^ Path of the updater/installer runner. Examples:
57
58
-- - /usr/bin/open
58
59
-- - /bin/update-runner
59
60
-- - Installer.bat (that we generate)
60
- , udArgs :: ! [Text ]
61
+ , udArgs :: ! [Text ]
61
62
-- ^ Arguments for the updater/installer.
62
- , udArchivePath :: ! FilePath
63
+ , udArchivePath :: ! FilePath
63
64
-- ^ The update path of the update file. Examples:
64
65
-- - /../daedalus.pkg
65
66
-- - /../installer.sh
@@ -74,13 +75,18 @@ data UpdateOSPlatform
74
75
75
76
-- | Conversion of the build OS to our definition.
76
77
osToUpdateOSPlatform :: OS -> UpdateOSPlatform
77
- osToUpdateOSPlatform Windows = WinOS
78
- osToUpdateOSPlatform _ = UnixOS
78
+ osToUpdateOSPlatform Windows = WinOS
79
+ osToUpdateOSPlatform _ = UnixOS
79
80
80
81
-- | The way we should run the process normally.
81
82
runDefaultUpdateProcess :: FilePath -> [String ] -> IO ExitCode
82
- runDefaultUpdateProcess path args =
83
- withCreateProcess (proc path args)
83
+ runDefaultUpdateProcess path args = do
84
+ let process = (proc path args)
85
+ { std_in = CreatePipe
86
+ , std_out = CreatePipe
87
+ , std_err = CreatePipe
88
+ }
89
+ withCreateProcess process
84
90
$ \ _in _out _err ph -> waitForProcess ph
85
91
86
92
-- The function for executing the update.
@@ -97,13 +103,13 @@ instance Arbitrary UpdaterExists where
97
103
98
104
-- | A simple isomorphic conversion from a more rich/descriptive type.
99
105
updaterExistsToBool :: UpdaterExists -> Bool
100
- updaterExistsToBool UpdaterExists = True
101
- updaterExistsToBool UpdaterDoesntExist = False
106
+ updaterExistsToBool UpdaterExists = True
107
+ updaterExistsToBool UpdaterDoesntExist = False
102
108
103
109
-- | A simple isomorphic conversion to a more rich/descriptive type.
104
110
boolToUpdaterExists :: Bool -> UpdaterExists
105
- boolToUpdaterExists True = UpdaterExists
106
- boolToUpdaterExists False = UpdaterDoesntExist
111
+ boolToUpdaterExists True = UpdaterExists
112
+ boolToUpdaterExists False = UpdaterDoesntExist
107
113
108
114
-- | The @Bool@ isomorphic type that signifies if we delete the archive/install
109
115
-- file or not.
@@ -120,12 +126,12 @@ data UpdaterCommand
120
126
deriving (Eq , Show )
121
127
122
128
isUpdaterRunOnWin :: UpdaterCommand -> Bool
123
- isUpdaterRunOnWin (WindowsRunUpdate _ _) = True
124
- isUpdaterRunOnWin _ = False
129
+ isUpdaterRunOnWin (WindowsRunUpdate _ _) = True
130
+ isUpdaterRunOnWin _ = False
125
131
126
132
isUpdaterRunOnUnix :: UpdaterCommand -> Bool
127
- isUpdaterRunOnUnix (UnixRunUpdate _ _) = True
128
- isUpdaterRunOnUnix _ = False
133
+ isUpdaterRunOnUnix (UnixRunUpdate _ _) = True
134
+ isUpdaterRunOnUnix _ = False
129
135
130
136
-- | Interpret the small language into the "real" semantics.
131
137
evaluateUpdaterCmdExitCode :: RunCmdFunc -> UpdaterCommand -> IO ExitCode
@@ -214,8 +220,8 @@ executeUpdater buildOS' updaterExist updaterData = do
214
220
if updaterExist == UpdaterExists
215
221
then
216
222
case buildOS' of
217
- WinOS -> WindowsRunUpdate updaterPath (toS archivePath: args)
218
- UnixOS -> UnixRunUpdate updaterPath (toS archivePath: args)
223
+ WinOS -> WindowsRunUpdate updaterPath (toS archivePath: args)
224
+ UnixOS -> UnixRunUpdate updaterPath (toS archivePath: args)
219
225
else UpdaterFileMissing
220
226
221
227
-- | Create @.bat@ file on given @FilePath@
0 commit comments