Skip to content

Commit

Permalink
[DEVOPS-981] installers: Vary icon by cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jul 31, 2018
1 parent 6d02aaa commit d7b271b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
8 changes: 6 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ let
categories = "Application;Network;";
icon = "INSERT_ICON_PATH_HERE";
};
iconPath = ./installers/icons/1024x1024.png;
iconPath = {
mainnet = ./installers/icons/mainnet/1024x1024.png;
staging = ./installers/icons/staging/1024x1024.png;
testnet = ./installers/icons/testnet/1024x1024.png;
};
namespaceHelper = pkgs.writeScriptBin "namespaceHelper" ''
#!/usr/bin/env bash
Expand Down Expand Up @@ -94,7 +98,7 @@ let
echo "in post-install hook"
cp -f ${self.iconPath} $DAEDALUS_DIR/icon.png
cp -f ${self.iconPath.${cluster}} $DAEDALUS_DIR/icon.png
cp -Lf ${self.namespaceHelper}/bin/namespaceHelper $DAEDALUS_DIR/namespaceHelper
mkdir -pv ~/.local/bin ''${XDG_DATA_HOME}/applications
cp -Lf ${self.namespaceHelper}/bin/namespaceHelper ~/.local/bin/daedalus
Expand Down
12 changes: 8 additions & 4 deletions installers/common/MacInstaller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ main opts@Options{..} = do
ver <- getBackendVersion oBackend
exportBuildVars opts installerConfig ver

buildIcons oCluster
appRoot <- buildElectronApp darwinConfig
makeComponentRoot opts appRoot darwinConfig
daedalusVer <- getDaedalusVersion "../package.json"
Expand Down Expand Up @@ -105,16 +106,19 @@ makeScriptsDir Options{..} DarwinConfig{..} = case oBackend of
pure $ tt tempdir
Mantis -> pure "[DEVOPS-533]"

buildIcons :: Cluster -> IO ()
buildIcons cluster = do
let iconset = format ("icons/"%s%".iconset") (lshowText cluster)
echo "Creating icons ..."
procs "iconutil" ["--convert", "icns", "--output", "icons/electron.icns"
, iconset] mempty

-- | Builds the electron app with "npm package" and returns its
-- component root path.
-- NB: If webpack scripts are changed then this function may need to
-- be updated.
buildElectronApp :: DarwinConfig -> IO FilePath
buildElectronApp darwinConfig@DarwinConfig{..} = do
echo "Creating icons ..."
procs "iconutil" ["--convert", "icns", "--output", "icons/electron.icns"
, "icons/electron.iconset"] mempty

withDir ".." . sh $ npmPackage darwinConfig

let
Expand Down
18 changes: 11 additions & 7 deletions installers/common/WindowsInstaller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Prelude ((!!))
import qualified System.IO as IO
import Filesystem.Path (FilePath, (</>))
import Filesystem.Path.CurrentOS (encodeString, fromText)
import Turtle (Shell, Line, ExitCode (..), echo, proc, procs, inproc, shells, testfile, stdout, input, export, sed, strict, format, printf, fp, w, (%), need, writeTextFile, die)
import Turtle (Shell, Line, ExitCode (..), echo, proc, procs, inproc, shells, testfile, stdout, input, export, sed, strict, format, printf, fp, w, s, (%), need, writeTextFile, die)
import Turtle.Pattern (text, plus, noneOf, star, dot)
import AppVeyor
import qualified Codec.Archive.Zip as Zip
Expand Down Expand Up @@ -110,11 +110,11 @@ writeInstallerNSIS outName (Version fullVersion') installerConfig clusterName =

IO.writeFile "daedalus.nsi" $ nsis $ do
_ <- constantStr "Version" (str fullVersion)
_ <- constantStr "Cluster" (str $ unpack $ lshowText clusterName)
_ <- constantStr "Cluster" (str $ lshow clusterName)
_ <- constantStr "InstallDir" (str $ unpack $ installDirectory installerConfig)
name "$InstallDir ($Version)" -- The name of the installer
outFile $ str $ encodeString outName -- Where to produce the installer
unsafeInjectGlobal $ "!define MUI_ICON \"icons\\64x64.ico\""
unsafeInjectGlobal $ "!define MUI_ICON \"icons\\" ++ lshow clusterName ++ "\\64x64.ico\""
unsafeInjectGlobal $ "!define MUI_HEADERIMAGE"
unsafeInjectGlobal $ "!define MUI_HEADERIMAGE_BITMAP \"icons\\installBanner.bmp\""
unsafeInjectGlobal $ "!define MUI_HEADERIMAGE_RIGHT"
Expand Down Expand Up @@ -187,10 +187,14 @@ writeInstallerNSIS outName (Version fullVersion') installerConfig clusterName =
createShortcut "$SMPROGRAMS/$InstallDir/$InstallDir.lnk" daedalusShortcut
return ()

packageFrontend :: IO ()
packageFrontend = do
lshow :: Show a => a -> String
lshow = T.unpack . lshowText

packageFrontend :: Cluster -> IO ()
packageFrontend cluster = do
let icon = format ("installers/icons/"%s%"64x64") (lshowText cluster)
export "NODE_ENV" "production"
shells "npm run package -- --icon installers/icons/64x64" empty
shells ("npm run package -- --icon " <> icon) empty

main :: Options -> IO ()
main opts@Options{..} = do
Expand All @@ -205,7 +209,7 @@ main opts@Options{..} = do

echo "Packaging frontend"
exportBuildVars opts installerConfig ver
packageFrontend
packageFrontend oCluster

let fullName = packageFileName Win64 oCluster fullVersion oBackend ver oBuildJob

Expand Down

0 comments on commit d7b271b

Please sign in to comment.