Skip to content

Commit c363044

Browse files
committed
[DDW-1083] Don’t use inputs.self.revCount (not available in Cicero)
1 parent 1e7ac3d commit c363044

File tree

13 files changed

+42
-24
lines changed

13 files changed

+42
-24
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"NETWORK": true,
102102
"BUILD_REV": true,
103103
"BUILD_REV_SHORT": true,
104-
"BUILD_REV_COUNT": true,
104+
"BUILD_COUNTER": true,
105105
"Process": true // TODO: remove after fix
106106
},
107107
"settings": {

installers/Installer.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ main = do
3333
BuildkiteCrossWin -> do
3434
fullVersion <- getAppVersion "../package.json"
3535
installerConfig <- decodeFileThrow "installer-config.json"
36-
let fullName = packageFileName (uglyName installerConfig) Win64 (oCluster options') fullVersion (oBackend options') (oBuildJob options') (oBuildRevCount options')
36+
let fullName = packageFileName (uglyName installerConfig) Win64 (oCluster options') fullVersion (oBackend options') (oBuildJob options') (oBuildCounter options')
3737
WindowsInstaller.writeInstallerNSIS fullName fullVersion installerConfig options' (oCluster options')
3838
WindowsInstaller.writeUninstallerNSIS fullVersion installerConfig
3939
-- | The contract of `genSignedInstaller` is not to produce unsigned installer binaries.

installers/common/Config.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ data Command
5959
data Options = Options
6060
{ oBackend :: Backend
6161
, oBuildJob :: Maybe BuildJob
62-
, oBuildRevCount :: Maybe BuildJob
62+
, oBuildCounter :: Maybe BuildJob
6363
, oOS :: OS
6464
, oCluster :: Cluster
6565
, oAppName :: AppName
@@ -85,7 +85,7 @@ optionsParser detectedOS = Options
8585
<*> (optional $
8686
(BuildJob <$> optText "build-rev-short" 'b' "CI Build Job/ID"))
8787
<*> (optional $
88-
(BuildJob <$> optText "build-rev-count" 'v' "‘inputs.self.sourceInfo.revCount’"))
88+
(BuildJob <$> optText "build-counter" 'v' "‘inputs.self.sourceInfo.revCount’"))
8989
<*> (fromMaybe detectedOS <$> (optional $
9090
optReadLower "os" 's' "OS, defaults to host OS. One of: linux64 macos64 win64"))
9191
<*> (fromMaybe Selfnode <$> (optional $

installers/common/MacInstaller.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ data DarwinConfig = DarwinConfig {
4242

4343
-- | The contract of `main` is not to produce unsigned installer binaries.
4444
main :: Options -> IO ()
45-
main opts@Options{oCodeSigningConfigPath,oAppRootOverride,oDontPkgbuild,oSigningConfigPath,oCluster,oBackend,oBuildJob,oBuildRevCount,oOutputDir,oTestInstaller} = do
45+
main opts@Options{oCodeSigningConfigPath,oAppRootOverride,oDontPkgbuild,oSigningConfigPath,oCluster,oBackend,oBuildJob,oBuildCounter,oOutputDir,oTestInstaller} = do
4646

4747
installerConfig <- decodeFileThrow "installer-config.json"
4848

@@ -77,7 +77,7 @@ main opts@Options{oCodeSigningConfigPath,oAppRootOverride,oDontPkgbuild,oSigning
7777
makeComponentRoot opts appRoot darwinConfig installerConfig
7878
daedalusVer <- getAppVersion "../package.json"
7979

80-
let pkg = packageFileName (uglyName installerConfig) Macos64 oCluster daedalusVer oBackend oBuildJob oBuildRevCount
80+
let pkg = packageFileName (uglyName installerConfig) Macos64 oCluster daedalusVer oBackend oBuildJob oBuildCounter
8181
opkg = oOutputDir </> pkg
8282

8383
print "appRoot:"

installers/common/Types.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ clusterNetwork Preprod = "preprod"
117117
clusterNetwork Preview = "preview"
118118

119119
packageFileName :: Text -> OS -> Cluster -> Version -> Backend -> Maybe BuildJob -> Maybe BuildJob -> FilePath
120-
packageFileName uglyName _os cluster ver backend buildJob buildRevCount = fromText name <.> ext
120+
packageFileName uglyName _os cluster ver backend buildJob buildCounter = fromText name <.> ext
121121
where
122122
name = T.intercalate "-" parts
123-
parts = [uglyName, fromVer ver <> buildRevCount', lshowText cluster] ++ buildJob' ++ [archOS]
123+
parts = [uglyName, fromVer ver <> buildCounter', lshowText cluster] ++ buildJob' ++ [archOS]
124124
_backend' = case backend of
125125
Cardano _ -> "cardano-wallet"
126126
ext = case _os of
@@ -139,7 +139,7 @@ packageFileName uglyName _os cluster ver backend buildJob buildRevCount = fromTe
139139
else "x86_64-darwin"
140140
Linux64 -> "x86_64-linux"
141141
buildJob' = maybe [] (\b -> [fromBuildJob b]) buildJob
142-
buildRevCount' = "." <> maybe "0" fromBuildJob buildRevCount
142+
buildCounter' = "." <> maybe "0" fromBuildJob buildCounter
143143

144144
instance FromJSON Version where
145145
parseJSON = withObject "Package" $ \o -> Version <$> o .: "version"

installers/common/WindowsInstaller.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ main opts@Options{..} = do
309309
echo "Packaging frontend"
310310
packageFrontend oCluster installerConfig
311311

312-
let fullName = packageFileName (uglyName installerConfig) Win64 oCluster fullVersion oBackend oBuildJob oBuildRevCount
312+
let fullName = packageFileName (uglyName installerConfig) Win64 oCluster fullVersion oBackend oBuildJob oBuildCounter
313313

314314
printf ("Building: "%fp%"\n") fullName
315315

nix/any-darwin.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let
1717

1818
archSuffix = if pkgs.system == "aarch64-darwin" then "arm64" else "x64";
1919
packageVersion = originalPackageJson.version;
20-
installerName = "daedalus-${packageVersion}.${toString sourceLib.buildRevCount}-${cluster}-${sourceLib.buildRevShort}-${pkgs.system}";
20+
installerName = "daedalus-${packageVersion}.${toString sourceLib.buildCounter}-${cluster}-${sourceLib.buildRevShort}-${pkgs.system}";
2121

2222
in rec {
2323

@@ -124,7 +124,7 @@ in rec {
124124
NETWORK = cluster;
125125
BUILD_REV = sourceLib.buildRev;
126126
BUILD_REV_SHORT = sourceLib.buildRevShort;
127-
BUILD_REV_COUNT = sourceLib.buildRevCount;
127+
BUILD_COUNTER = sourceLib.buildCounter;
128128
CARDANO_WALLET_VERSION = cardanoWalletVersion;
129129
CARDANO_NODE_VERSION = cardanoNodeVersion;
130130
configurePhase = newCommon.setupCacheAndGypDirs + darwinSpecificCaches + ''
@@ -147,7 +147,7 @@ in rec {
147147
148148
make-installer --cardano ${daedalus-bridge} \
149149
--build-rev-short ${sourceLib.buildRevShort} \
150-
--build-rev-count ${toString sourceLib.buildRevCount} \
150+
--build-counter ${toString sourceLib.buildCounter} \
151151
--cluster ${cluster} \
152152
--out-dir doesnt-matter \
153153
--dont-pkgbuild

nix/source-lib.nix

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,26 @@ in rec {
2323

2424
forEachCluster = forEach allClusters;
2525

26-
buildRev = if inputs.self ? revCount then inputs.self.rev else "0000000000000000000000000000000000000000";
27-
buildRevShort = if inputs.self ? revCount then builtins.substring 0 9 buildRev else "dirty";
28-
buildRevCount = inputs.self.revCount or 0;
26+
# When did the project start? → `git show --no-patch --date=unix $(git rev-list --max-parents=0 HEAD)`
27+
daedalusEpoch = 1475675335;
28+
29+
# In `std`, we don’t get `inputs.self.sourceInfo`. Instead, when Git
30+
# status is dirty, we get only `.rev = "not-a-commit"`. When clean,
31+
# we get all normal attributes. Cf.
32+
# <https://github.com/divnix/std/blob/d2bde49f82331db61ebabf7d0b7441a31364908a/src/grow.nix#L184>.
33+
34+
buildRev =
35+
if inputs.self ? shortRev
36+
then inputs.self.rev
37+
else "0000000000000000000000000000000000000000";
38+
buildRevShort =
39+
if inputs.self ? shortRev
40+
then builtins.substring 0 9 buildRev
41+
else "dirty";
42+
# XXX: inputs.self.revCount is not available in Cicero, let’s use a counter incrementing every hour:
43+
buildCounter =
44+
if inputs.self ? shortRev
45+
then (inputs.self.lastModified - daedalusEpoch) / (60 * 60)
46+
else 0;
2947

3048
}

nix/x86_64-linux.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ in rec {
8989
NETWORK = oldCode.launcherConfigs.launcherConfig.networkName;
9090
BUILD_REV = sourceLib.buildRev;
9191
BUILD_REV_SHORT = sourceLib.buildRevShort;
92-
BUILD_REV_COUNT = sourceLib.buildRevCount;
92+
BUILD_COUNTER = sourceLib.buildCounter;
9393
NODE_ENV = "production";
9494
BUILDTYPE = "Release";
9595
configurePhase = newCommon.setupCacheAndGypDirs + linuxSpecificCaches + ''
@@ -283,7 +283,7 @@ in rec {
283283

284284
wrappedBundle = let
285285
version = (builtins.fromJSON (builtins.readFile ../package.json)).version;
286-
fn = "daedalus-${version}.${toString sourceLib.buildRevCount}-${linuxClusterBinName}-${sourceLib.buildRevShort}-x86_64-linux.bin";
286+
fn = "daedalus-${version}.${toString sourceLib.buildCounter}-${linuxClusterBinName}-${sourceLib.buildRevShort}-x86_64-linux.bin";
287287
in pkgs.runCommand fn {} ''
288288
mkdir -p $out
289289
cp ${newBundle} $out/${fn}

nix/x86_64-windows.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ in rec {
5151
NETWORK = launcherConfigs.launcherConfig.networkName;
5252
BUILD_REV = sourceLib.buildRev;
5353
BUILD_REV_SHORT = sourceLib.buildRevShort;
54-
BUILD_REV_COUNT = sourceLib.buildRevCount;
54+
BUILD_COUNTER = sourceLib.buildCounter;
5555
NODE_ENV = "production";
5656
BUILDTYPE = "Release";
5757
configurePhase = newCommon.setupCacheAndGypDirs + ''
@@ -228,7 +228,7 @@ in rec {
228228
-o $out \
229229
--cluster ${cluster} \
230230
--build-rev-short ${sourceLib.buildRevShort} \
231-
--build-rev-count ${toString sourceLib.buildRevCount} \
231+
--build-counter ${toString sourceLib.buildCounter} \
232232
buildkite-cross
233233
234234
mkdir $out
@@ -330,7 +330,7 @@ in rec {
330330
signed-windows-installer = let
331331
backend_version = oldCode.cardanoWalletVersion;
332332
frontend_version = (builtins.fromJSON (builtins.readFile ../package.json)).version;
333-
fullName = "daedalus-${frontend_version}.${toString sourceLib.buildRevCount}-${cluster}-${sourceLib.buildRevShort}-x86_64-windows.exe"; # must match to packageFileName in make-installer
333+
fullName = "daedalus-${frontend_version}.${toString sourceLib.buildCounter}-${cluster}-${sourceLib.buildRevShort}-x86_64-windows.exe"; # must match to packageFileName in make-installer
334334
in pkgs.runCommand "signed-windows-installer-${cluster}" {} ''
335335
mkdir $out
336336
cp -v ${signFile "${unsigned-windows-installer}/${fullName}"} $out/${fullName}

0 commit comments

Comments
 (0)