@@ -8,7 +8,7 @@ use serde::Deserialize;
8
8
use crate :: {
9
9
config:: {
10
10
self , CiStyle , CompressionImpl , Config , DistMetadata , HostingStyle , InstallPathStrategy ,
11
- InstallerStyle , PublishStyle , ZipStyle ,
11
+ InstallerStyle , MacPkgConfig , PublishStyle , ZipStyle ,
12
12
} ,
13
13
do_generate,
14
14
errors:: { DistError , DistResult } ,
@@ -665,7 +665,6 @@ fn get_new_dist_metadata(
665
665
InstallerStyle :: Npm ,
666
666
InstallerStyle :: Homebrew ,
667
667
InstallerStyle :: Msi ,
668
- InstallerStyle :: Pkg ,
669
668
]
670
669
} else {
671
670
eprintln ! ( "{notice} no CI backends enabled, most installers have been hidden" ) ;
@@ -782,66 +781,6 @@ fn get_new_dist_metadata(
782
781
}
783
782
}
784
783
785
- // Special handling of the pkg installer
786
- if meta
787
- . installers
788
- . as_deref ( )
789
- . unwrap_or_default ( )
790
- . contains ( & InstallerStyle :: Pkg )
791
- {
792
- let pkg_is_new = !orig_meta
793
- . installers
794
- . as_deref ( )
795
- . unwrap_or_default ( )
796
- . contains ( & InstallerStyle :: Pkg ) ;
797
-
798
- if pkg_is_new && orig_meta. mac_pkg_config . is_none ( ) {
799
- let prompt = r#"you've enabled a Mac .pkg installer. This requires a unique bundle ID;
800
- please enter one now. This is in reverse-domain name format.
801
- For more information, consult the Apple documentation:
802
- https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1"# ;
803
- let default = "" . to_string ( ) ;
804
-
805
- let identifier: String = if args. yes {
806
- default
807
- } else {
808
- let res = Input :: with_theme ( & theme)
809
- . with_prompt ( prompt)
810
- . allow_empty ( true )
811
- . interact_text ( ) ?;
812
- eprintln ! ( ) ;
813
- res
814
- } ;
815
- let identifier = identifier. trim ( ) ;
816
- if identifier. is_empty ( ) {
817
- return Err ( DistError :: MacPkgBundleIdentifierMissing { } ) ;
818
- }
819
-
820
- let prompt = r#"Please enter the installation prefix this .pkg should use."# ;
821
- let prefix = if args. yes {
822
- None
823
- } else {
824
- let res: String = Input :: with_theme ( & theme)
825
- . with_prompt ( prompt)
826
- . allow_empty ( true )
827
- . interact_text ( ) ?;
828
- eprintln ! ( ) ;
829
-
830
- let trimmed = res. trim ( ) ;
831
- if trimmed. is_empty ( ) {
832
- None
833
- } else {
834
- Some ( trimmed. to_owned ( ) )
835
- }
836
- } ;
837
-
838
- meta. mac_pkg_config = Some ( config:: MacPkgConfig {
839
- identifier : identifier. to_owned ( ) ,
840
- install_location : prefix,
841
- } )
842
- }
843
- }
844
-
845
784
meta. publish_jobs = if publish_jobs. is_empty ( ) {
846
785
None
847
786
} else {
@@ -1034,14 +973,14 @@ fn apply_dist_to_metadata(metadata: &mut toml_edit::Item, meta: &DistMetadata) {
1034
973
github_release,
1035
974
package_libraries,
1036
975
install_libraries,
976
+ mac_pkg_config,
1037
977
// These settings are complex enough that we don't support editing them in init
1038
978
extra_artifacts : _,
1039
979
github_custom_runners : _,
1040
980
github_custom_job_permissions : _,
1041
981
bin_aliases : _,
1042
982
system_dependencies : _,
1043
983
github_build_setup : _,
1044
- mac_pkg_config : _,
1045
984
} = & meta;
1046
985
1047
986
// Forcibly inline the default install_path if not specified,
@@ -1083,6 +1022,13 @@ fn apply_dist_to_metadata(metadata: &mut toml_edit::Item, meta: &DistMetadata) {
1083
1022
installers. as_ref ( ) ,
1084
1023
) ;
1085
1024
1025
+ apply_optional_mac_pkg (
1026
+ table,
1027
+ "mac-pkg-config" ,
1028
+ "\n # Configuration for the Mac .pkg installer\n " ,
1029
+ mac_pkg_config. as_ref ( ) ,
1030
+ ) ;
1031
+
1086
1032
apply_optional_value (
1087
1033
table,
1088
1034
"tap" ,
@@ -1494,3 +1440,39 @@ where
1494
1440
table. remove ( key) ;
1495
1441
}
1496
1442
}
1443
+
1444
+ /// Similar to [`apply_optional_value`][] but specialized to `MacPkgConfig`, since we're not able to work with structs dynamically
1445
+ fn apply_optional_mac_pkg (
1446
+ table : & mut toml_edit:: Table ,
1447
+ key : & str ,
1448
+ desc : & str ,
1449
+ val : Option < & MacPkgConfig > ,
1450
+ ) {
1451
+ if let Some ( mac_pkg_config) = val {
1452
+ let MacPkgConfig {
1453
+ identifier,
1454
+ install_location,
1455
+ } = mac_pkg_config;
1456
+
1457
+ let new_item = & mut table[ key] ;
1458
+ let mut new_table = toml_edit:: table ( ) ;
1459
+ if let Some ( new_table) = new_table. as_table_mut ( ) {
1460
+ apply_optional_value (
1461
+ new_table,
1462
+ "identifier" ,
1463
+ "# A unique identifier, in tld.domain.package format\n " ,
1464
+ Some ( identifier) ,
1465
+ ) ;
1466
+ apply_optional_value (
1467
+ new_table,
1468
+ "install-location" ,
1469
+ "# The location to which the software should be installed\n " ,
1470
+ install_location. as_ref ( ) ,
1471
+ ) ;
1472
+ new_table. decor_mut ( ) . set_prefix ( desc) ;
1473
+ }
1474
+ new_item. or_insert ( new_table) ;
1475
+ } else {
1476
+ table. remove ( key) ;
1477
+ }
1478
+ }
0 commit comments