Skip to content

Commit 2c36181

Browse files
authored
chore: stabilize hdiutil resize by using whole number byte size (#9135)
1 parent 8465768 commit 2c36181

File tree

4 files changed

+69
-83
lines changed

4 files changed

+69
-83
lines changed

.changeset/violet-zoos-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"dmg-builder": patch
3+
---
4+
5+
chore: stabilize hdiutil resize by using whole number byte size

packages/dmg-builder/src/dmg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class DmgTarget extends Target {
5252
// https://github.com/electron-userland/electron-builder/issues/2115
5353
const backgroundFile = specification.background == null ? null : await transformBackgroundFileIfNeed(specification.background, packager.info.tempDirManager)
5454
const finalSize = await computeAssetSize(packager.info.cancellationToken, tempDmg, specification, backgroundFile)
55-
const expandingFinalSize = finalSize * 0.1 + finalSize
55+
const expandingFinalSize = Math.ceil(finalSize * 0.1 + finalSize)
5656
await hdiUtil(["resize", "-size", expandingFinalSize.toString(), tempDmg])
5757

5858
const volumePath = path.join("/Volumes", volumeName)

test/snapshots/mac/dmgTest.js.snap

Lines changed: 51 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,14 @@ exports[`dmg > bundleShortVersion 1`] = `
226226
"mac": [
227227
{
228228
"arch": "x64",
229-
"file": "Bundle ShortVersion-2017.1-alpha5.dmg",
230-
"safeArtifactName": "Bundle-ShortVersion-2017.1-alpha5.dmg",
229+
"file": "Bundle-ShortVersion-2017.1-alpha5.dmg",
231230
"updateInfo": {
232231
"sha512": "@sha512",
233232
"size": "@size",
234233
},
235234
},
236235
{
237-
"file": "Bundle ShortVersion-2017.1-alpha5.dmg.blockmap",
238-
"safeArtifactName": "Bundle-ShortVersion-2017.1-alpha5.dmg.blockmap",
236+
"file": "Bundle-ShortVersion-2017.1-alpha5.dmg.blockmap",
239237
"updateInfo": {
240238
"sha512": "@sha512",
241239
"size": "@size",
@@ -247,12 +245,12 @@ exports[`dmg > bundleShortVersion 1`] = `
247245

248246
exports[`dmg > bundleShortVersion 2`] = `
249247
{
250-
"CFBundleDisplayName": "Bundle ShortVersion",
251-
"CFBundleExecutable": "Bundle ShortVersion",
248+
"CFBundleDisplayName": "Bundle-ShortVersion",
249+
"CFBundleExecutable": "Bundle-ShortVersion",
252250
"CFBundleIconFile": "icon.icns",
253251
"CFBundleIdentifier": "org.electron-builder.testApp",
254252
"CFBundleInfoDictionaryVersion": "6.0",
255-
"CFBundleName": "Bundle ShortVersion",
253+
"CFBundleName": "Bundle-ShortVersion",
256254
"CFBundlePackageType": "APPL",
257255
"CFBundleShortVersionString": "2017.1-alpha5",
258256
"ElectronAsarIntegrity": {
@@ -367,16 +365,15 @@ exports[`dmg > disable dmg icon (light), bundleVersion 1`] = `
367365
"mac": [
368366
{
369367
"arch": "x64",
370-
"file": "Disable Icon-1.1.0-mac.zip",
371-
"safeArtifactName": "Disable-Icon-1.1.0-mac.zip",
368+
"file": "Disable-Icon-1.1.0-mac.zip",
372369
"updateInfo": {
373370
"sha512": "@sha512",
374371
"size": "@size",
375372
},
376373
},
377374
{
378-
"file": "Disable Icon-1.1.0-mac.zip.blockmap",
379-
"safeArtifactName": "Disable Icon-1.1.0-mac.zip.blockmap",
375+
"file": "Disable-Icon-1.1.0-mac.zip.blockmap",
376+
"safeArtifactName": "Disable-Icon-1.1.0-mac.zip.blockmap",
380377
"updateInfo": {
381378
"sha512": "@sha512",
382379
"size": "@size",
@@ -388,12 +385,12 @@ exports[`dmg > disable dmg icon (light), bundleVersion 1`] = `
388385

389386
exports[`dmg > disable dmg icon (light), bundleVersion 2`] = `
390387
{
391-
"CFBundleDisplayName": "Disable Icon",
392-
"CFBundleExecutable": "Disable Icon",
388+
"CFBundleDisplayName": "Disable-Icon",
389+
"CFBundleExecutable": "Disable-Icon",
393390
"CFBundleIconFile": "icon.icns",
394391
"CFBundleIdentifier": "org.electron-builder.testApp",
395392
"CFBundleInfoDictionaryVersion": "6.0",
396-
"CFBundleName": "Disable Icon",
393+
"CFBundleName": "Disable-Icon",
397394
"CFBundlePackageType": "APPL",
398395
"CFBundleShortVersionString": "1.1.0",
399396
"ElectronAsarIntegrity": {
@@ -438,16 +435,14 @@ exports[`dmg > dmg 1`] = `
438435
"mac": [
439436
{
440437
"arch": "x64",
441-
"file": "Default Dmg-1.1.0.dmg",
442-
"safeArtifactName": "Default-Dmg-1.1.0.dmg",
438+
"file": "Default-Dmg-1.1.0.dmg",
443439
"updateInfo": {
444440
"sha512": "@sha512",
445441
"size": "@size",
446442
},
447443
},
448444
{
449-
"file": "Default Dmg-1.1.0.dmg.blockmap",
450-
"safeArtifactName": "Default-Dmg-1.1.0.dmg.blockmap",
445+
"file": "Default-Dmg-1.1.0.dmg.blockmap",
451446
"updateInfo": {
452447
"sha512": "@sha512",
453448
"size": "@size",
@@ -459,12 +454,12 @@ exports[`dmg > dmg 1`] = `
459454

460455
exports[`dmg > dmg 2`] = `
461456
{
462-
"CFBundleDisplayName": "Default Dmg",
463-
"CFBundleExecutable": "Default Dmg",
457+
"CFBundleDisplayName": "Default-Dmg",
458+
"CFBundleExecutable": "Default-Dmg",
464459
"CFBundleIconFile": "icon.icns",
465460
"CFBundleIdentifier": "org.electron-builder.testApp",
466461
"CFBundleInfoDictionaryVersion": "6.0",
467-
"CFBundleName": "Default Dmg",
462+
"CFBundleName": "Default-Dmg",
468463
"CFBundlePackageType": "APPL",
469464
"CFBundleShortVersionString": "1.1.0",
470465
"ElectronAsarIntegrity": {
@@ -567,16 +562,14 @@ exports[`dmg > license buttons config 2`] = `
567562
"mac": [
568563
{
569564
"arch": "x64",
570-
"file": "Foo 5-1.1.0.dmg",
571-
"safeArtifactName": "Foo-5-1.1.0.dmg",
565+
"file": "Foo-5-1.1.0.dmg",
572566
"updateInfo": {
573567
"sha512": "@sha512",
574568
"size": "@size",
575569
},
576570
},
577571
{
578-
"file": "Foo 5-1.1.0.dmg.blockmap",
579-
"safeArtifactName": "Foo-5-1.1.0.dmg.blockmap",
572+
"file": "Foo-5-1.1.0.dmg.blockmap",
580573
"updateInfo": {
581574
"sha512": "@sha512",
582575
"size": "@size",
@@ -588,12 +581,12 @@ exports[`dmg > license buttons config 2`] = `
588581

589582
exports[`dmg > license buttons config 3`] = `
590583
{
591-
"CFBundleDisplayName": "Foo 5",
592-
"CFBundleExecutable": "Foo 5",
584+
"CFBundleDisplayName": "Foo-5",
585+
"CFBundleExecutable": "Foo-5",
593586
"CFBundleIconFile": "icon.icns",
594587
"CFBundleIdentifier": "org.electron-builder.testApp",
595588
"CFBundleInfoDictionaryVersion": "6.0",
596-
"CFBundleName": "Foo 5",
589+
"CFBundleName": "Foo-5",
597590
"CFBundlePackageType": "APPL",
598591
"CFBundleShortVersionString": "1.1.0",
599592
"ElectronAsarIntegrity": {
@@ -638,16 +631,14 @@ exports[`dmg > license en 1`] = `
638631
"mac": [
639632
{
640633
"arch": "x64",
641-
"file": "Foo 3-1.1.0.dmg",
642-
"safeArtifactName": "Foo-3-1.1.0.dmg",
634+
"file": "Foo-3-1.1.0.dmg",
643635
"updateInfo": {
644636
"sha512": "@sha512",
645637
"size": "@size",
646638
},
647639
},
648640
{
649-
"file": "Foo 3-1.1.0.dmg.blockmap",
650-
"safeArtifactName": "Foo-3-1.1.0.dmg.blockmap",
641+
"file": "Foo-3-1.1.0.dmg.blockmap",
651642
"updateInfo": {
652643
"sha512": "@sha512",
653644
"size": "@size",
@@ -659,12 +650,12 @@ exports[`dmg > license en 1`] = `
659650

660651
exports[`dmg > license en 2`] = `
661652
{
662-
"CFBundleDisplayName": "Foo 3",
663-
"CFBundleExecutable": "Foo 3",
653+
"CFBundleDisplayName": "Foo-3",
654+
"CFBundleExecutable": "Foo-3",
664655
"CFBundleIconFile": "icon.icns",
665656
"CFBundleIdentifier": "org.electron-builder.testApp",
666657
"CFBundleInfoDictionaryVersion": "6.0",
667-
"CFBundleName": "Foo 3",
658+
"CFBundleName": "Foo-3",
668659
"CFBundlePackageType": "APPL",
669660
"CFBundleShortVersionString": "1.1.0",
670661
"ElectronAsarIntegrity": {
@@ -709,16 +700,14 @@ exports[`dmg > license ja 1`] = `
709700
"mac": [
710701
{
711702
"arch": "x64",
712-
"file": "Foo 2-1.1.0.dmg",
713-
"safeArtifactName": "Foo-2-1.1.0.dmg",
703+
"file": "Foo-2-1.1.0.dmg",
714704
"updateInfo": {
715705
"sha512": "@sha512",
716706
"size": "@size",
717707
},
718708
},
719709
{
720-
"file": "Foo 2-1.1.0.dmg.blockmap",
721-
"safeArtifactName": "Foo-2-1.1.0.dmg.blockmap",
710+
"file": "Foo-2-1.1.0.dmg.blockmap",
722711
"updateInfo": {
723712
"sha512": "@sha512",
724713
"size": "@size",
@@ -730,12 +719,12 @@ exports[`dmg > license ja 1`] = `
730719

731720
exports[`dmg > license ja 2`] = `
732721
{
733-
"CFBundleDisplayName": "Foo 2",
734-
"CFBundleExecutable": "Foo 2",
722+
"CFBundleDisplayName": "Foo-2",
723+
"CFBundleExecutable": "Foo-2",
735724
"CFBundleIconFile": "icon.icns",
736725
"CFBundleIdentifier": "org.electron-builder.testApp",
737726
"CFBundleInfoDictionaryVersion": "6.0",
738-
"CFBundleName": "Foo 2",
727+
"CFBundleName": "Foo-2",
739728
"CFBundlePackageType": "APPL",
740729
"CFBundleShortVersionString": "1.1.0",
741730
"ElectronAsarIntegrity": {
@@ -780,16 +769,14 @@ exports[`dmg > license rtf 1`] = `
780769
"mac": [
781770
{
782771
"arch": "x64",
783-
"file": "Foo 4-1.1.0.dmg",
784-
"safeArtifactName": "Foo-4-1.1.0.dmg",
772+
"file": "Foo-4-1.1.0.dmg",
785773
"updateInfo": {
786774
"sha512": "@sha512",
787775
"size": "@size",
788776
},
789777
},
790778
{
791-
"file": "Foo 4-1.1.0.dmg.blockmap",
792-
"safeArtifactName": "Foo-4-1.1.0.dmg.blockmap",
779+
"file": "Foo-4-1.1.0.dmg.blockmap",
793780
"updateInfo": {
794781
"sha512": "@sha512",
795782
"size": "@size",
@@ -801,12 +788,12 @@ exports[`dmg > license rtf 1`] = `
801788

802789
exports[`dmg > license rtf 2`] = `
803790
{
804-
"CFBundleDisplayName": "Foo 4",
805-
"CFBundleExecutable": "Foo 4",
791+
"CFBundleDisplayName": "Foo-4",
792+
"CFBundleExecutable": "Foo-4",
806793
"CFBundleIconFile": "icon.icns",
807794
"CFBundleIdentifier": "org.electron-builder.testApp",
808795
"CFBundleInfoDictionaryVersion": "6.0",
809-
"CFBundleName": "Foo 4",
796+
"CFBundleName": "Foo-4",
810797
"CFBundlePackageType": "APPL",
811798
"CFBundleShortVersionString": "1.1.0",
812799
"ElectronAsarIntegrity": {
@@ -851,16 +838,14 @@ exports[`dmg > multi language license 1`] = `
851838
"mac": [
852839
{
853840
"arch": "x64",
854-
"file": "Foo 1-1.1.0.dmg",
855-
"safeArtifactName": "Foo-1-1.1.0.dmg",
841+
"file": "Foo-1-1.1.0.dmg",
856842
"updateInfo": {
857843
"sha512": "@sha512",
858844
"size": "@size",
859845
},
860846
},
861847
{
862-
"file": "Foo 1-1.1.0.dmg.blockmap",
863-
"safeArtifactName": "Foo-1-1.1.0.dmg.blockmap",
848+
"file": "Foo-1-1.1.0.dmg.blockmap",
864849
"updateInfo": {
865850
"sha512": "@sha512",
866851
"size": "@size",
@@ -872,12 +857,12 @@ exports[`dmg > multi language license 1`] = `
872857

873858
exports[`dmg > multi language license 2`] = `
874859
{
875-
"CFBundleDisplayName": "Foo 1",
876-
"CFBundleExecutable": "Foo 1",
860+
"CFBundleDisplayName": "Foo-1",
861+
"CFBundleExecutable": "Foo-1",
877862
"CFBundleIconFile": "icon.icns",
878863
"CFBundleIdentifier": "org.electron-builder.testApp",
879864
"CFBundleInfoDictionaryVersion": "6.0",
880-
"CFBundleName": "Foo 1",
865+
"CFBundleName": "Foo-1",
881866
"CFBundlePackageType": "APPL",
882867
"CFBundleShortVersionString": "1.1.0",
883868
"ElectronAsarIntegrity": {
@@ -922,16 +907,14 @@ exports[`dmg > no background 1`] = `
922907
"mac": [
923908
{
924909
"arch": "x64",
925-
"file": "No Background-1.1.0.dmg",
926-
"safeArtifactName": "No-Background-1.1.0.dmg",
910+
"file": "No-Background-1.1.0.dmg",
927911
"updateInfo": {
928912
"sha512": "@sha512",
929913
"size": "@size",
930914
},
931915
},
932916
{
933-
"file": "No Background-1.1.0.dmg.blockmap",
934-
"safeArtifactName": "No-Background-1.1.0.dmg.blockmap",
917+
"file": "No-Background-1.1.0.dmg.blockmap",
935918
"updateInfo": {
936919
"sha512": "@sha512",
937920
"size": "@size",
@@ -943,12 +926,12 @@ exports[`dmg > no background 1`] = `
943926

944927
exports[`dmg > no background 2`] = `
945928
{
946-
"CFBundleDisplayName": "No Background",
947-
"CFBundleExecutable": "No Background",
929+
"CFBundleDisplayName": "No-Background",
930+
"CFBundleExecutable": "No-Background",
948931
"CFBundleIconFile": "icon.icns",
949932
"CFBundleIdentifier": "org.electron-builder.testApp",
950933
"CFBundleInfoDictionaryVersion": "6.0",
951-
"CFBundleName": "No Background",
934+
"CFBundleName": "No-Background",
952935
"CFBundlePackageType": "APPL",
953936
"CFBundleShortVersionString": "1.1.0",
954937
"ElectronAsarIntegrity": {
@@ -1147,16 +1130,14 @@ exports[`dmg > unset dmg icon 1`] = `
11471130
"mac": [
11481131
{
11491132
"arch": "x64",
1150-
"file": "Test ß No Volume Icon-1.1.0.dmg",
1151-
"safeArtifactName": "TestApp-1.1.0.dmg",
1133+
"file": "No_Volume_Icon-1.1.0.dmg",
11521134
"updateInfo": {
11531135
"sha512": "@sha512",
11541136
"size": "@size",
11551137
},
11561138
},
11571139
{
1158-
"file": "Test ß No Volume Icon-1.1.0.dmg.blockmap",
1159-
"safeArtifactName": "TestApp-1.1.0.dmg.blockmap",
1140+
"file": "No_Volume_Icon-1.1.0.dmg.blockmap",
11601141
"updateInfo": {
11611142
"sha512": "@sha512",
11621143
"size": "@size",
@@ -1168,12 +1149,12 @@ exports[`dmg > unset dmg icon 1`] = `
11681149

11691150
exports[`dmg > unset dmg icon 2`] = `
11701151
{
1171-
"CFBundleDisplayName": "Test ß No Volume Icon",
1172-
"CFBundleExecutable": "Test ß No Volume Icon",
1152+
"CFBundleDisplayName": "No_Volume_Icon",
1153+
"CFBundleExecutable": "No_Volume_Icon",
11731154
"CFBundleIconFile": "icon.icns",
11741155
"CFBundleIdentifier": "org.electron-builder.testApp",
11751156
"CFBundleInfoDictionaryVersion": "6.0",
1176-
"CFBundleName": "Test ß No Volume Icon",
1157+
"CFBundleName": "No_Volume_Icon",
11771158
"CFBundlePackageType": "APPL",
11781159
"CFBundleShortVersionString": "1.1.0",
11791160
"ElectronAsarIntegrity": {

0 commit comments

Comments
 (0)