Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 20ab8e0

Browse files
author
Hiroto Shioi
committed
Disable console when update is running
1 parent cd154b0 commit 20ab8e0

File tree

1 file changed

+24
-18
lines changed
  • cardano-launcher/src/Cardano/Shell/Update

1 file changed

+24
-18
lines changed

cardano-launcher/src/Cardano/Shell/Update/Lib.hs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import Distribution.System (OS (..), buildOS)
2929
import Prelude (String)
3030

3131
import System.Directory (doesFileExist, removeFile)
32-
import System.Process (proc, waitForProcess, withCreateProcess)
32+
import System.Process (CreateProcess (..), StdStream (..), proc,
33+
waitForProcess, withCreateProcess)
3334

3435
#ifdef mingw32_HOST_OS
3536
import qualified Data.Text as T
@@ -52,14 +53,14 @@ import Cardano.Shell.Types (LoggingDependencies (..))
5253
-- | Runner path, what we use to run the update/installer,
5354
-- arguments for the runner, and the actual update path for the installer.
5455
data UpdaterData = UpdaterData
55-
{ udUpdaterPath :: !FilePath
56+
{ udUpdaterPath :: !FilePath
5657
-- ^ Path of the updater/installer runner. Examples:
5758
-- - /usr/bin/open
5859
-- - /bin/update-runner
5960
-- - Installer.bat (that we generate)
60-
, udArgs :: ![Text]
61+
, udArgs :: ![Text]
6162
-- ^ Arguments for the updater/installer.
62-
, udArchivePath :: !FilePath
63+
, udArchivePath :: !FilePath
6364
-- ^ The update path of the update file. Examples:
6465
-- - /../daedalus.pkg
6566
-- - /../installer.sh
@@ -74,13 +75,18 @@ data UpdateOSPlatform
7475

7576
-- | Conversion of the build OS to our definition.
7677
osToUpdateOSPlatform :: OS -> UpdateOSPlatform
77-
osToUpdateOSPlatform Windows = WinOS
78-
osToUpdateOSPlatform _ = UnixOS
78+
osToUpdateOSPlatform Windows = WinOS
79+
osToUpdateOSPlatform _ = UnixOS
7980

8081
-- | The way we should run the process normally.
8182
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
8490
$ \_in _out _err ph -> waitForProcess ph
8591

8692
-- The function for executing the update.
@@ -97,13 +103,13 @@ instance Arbitrary UpdaterExists where
97103

98104
-- | A simple isomorphic conversion from a more rich/descriptive type.
99105
updaterExistsToBool :: UpdaterExists -> Bool
100-
updaterExistsToBool UpdaterExists = True
101-
updaterExistsToBool UpdaterDoesntExist = False
106+
updaterExistsToBool UpdaterExists = True
107+
updaterExistsToBool UpdaterDoesntExist = False
102108

103109
-- | A simple isomorphic conversion to a more rich/descriptive type.
104110
boolToUpdaterExists :: Bool -> UpdaterExists
105-
boolToUpdaterExists True = UpdaterExists
106-
boolToUpdaterExists False = UpdaterDoesntExist
111+
boolToUpdaterExists True = UpdaterExists
112+
boolToUpdaterExists False = UpdaterDoesntExist
107113

108114
-- | The @Bool@ isomorphic type that signifies if we delete the archive/install
109115
-- file or not.
@@ -120,12 +126,12 @@ data UpdaterCommand
120126
deriving (Eq, Show)
121127

122128
isUpdaterRunOnWin :: UpdaterCommand -> Bool
123-
isUpdaterRunOnWin (WindowsRunUpdate _ _) = True
124-
isUpdaterRunOnWin _ = False
129+
isUpdaterRunOnWin (WindowsRunUpdate _ _) = True
130+
isUpdaterRunOnWin _ = False
125131

126132
isUpdaterRunOnUnix :: UpdaterCommand -> Bool
127-
isUpdaterRunOnUnix (UnixRunUpdate _ _) = True
128-
isUpdaterRunOnUnix _ = False
133+
isUpdaterRunOnUnix (UnixRunUpdate _ _) = True
134+
isUpdaterRunOnUnix _ = False
129135

130136
-- | Interpret the small language into the "real" semantics.
131137
evaluateUpdaterCmdExitCode :: RunCmdFunc -> UpdaterCommand -> IO ExitCode
@@ -214,8 +220,8 @@ executeUpdater buildOS' updaterExist updaterData = do
214220
if updaterExist == UpdaterExists
215221
then
216222
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)
219225
else UpdaterFileMissing
220226

221227
-- | Create @.bat@ file on given @FilePath@

0 commit comments

Comments
 (0)