@@ -22,7 +22,7 @@ use std::env;
2222use std:: fs:: { self , File } ;
2323use std:: io:: { Read , Write } ;
2424use std:: path:: { PathBuf , Path } ;
25- use std:: process:: Command ;
25+ use std:: process:: { Command , Stdio } ;
2626
2727use build_helper:: output;
2828
@@ -876,3 +876,34 @@ fn add_env(build: &Build, cmd: &mut Command, target: &str) {
876876 cmd. env ( "CFG_PLATFORM" , "x86" ) ;
877877 }
878878}
879+
880+ pub fn hash_and_sign ( build : & Build ) {
881+ let compiler = Compiler :: new ( 0 , & build. config . build ) ;
882+ let mut cmd = build. tool_cmd ( & compiler, "build-manifest" ) ;
883+ let sign = build. config . dist_sign_folder . as_ref ( ) . unwrap_or_else ( || {
884+ panic ! ( "\n \n failed to specify `dist.sign-folder` in `config.toml`\n \n " )
885+ } ) ;
886+ let addr = build. config . dist_upload_addr . as_ref ( ) . unwrap_or_else ( || {
887+ panic ! ( "\n \n failed to specify `dist.upload-addr` in `config.toml`\n \n " )
888+ } ) ;
889+ let file = build. config . dist_gpg_password_file . as_ref ( ) . unwrap_or_else ( || {
890+ panic ! ( "\n \n failed to specify `dist.gpg-password-file` in `config.toml`\n \n " )
891+ } ) ;
892+ let mut pass = String :: new ( ) ;
893+ t ! ( t!( File :: open( & file) ) . read_to_string( & mut pass) ) ;
894+
895+ let today = output ( Command :: new ( "date" ) . arg ( "+%Y-%m-%d" ) ) ;
896+
897+ cmd. arg ( sign) ;
898+ cmd. arg ( distdir ( build) ) ;
899+ cmd. arg ( today. trim ( ) ) ;
900+ cmd. arg ( package_vers ( build) ) ;
901+ cmd. arg ( addr) ;
902+
903+ t ! ( fs:: create_dir_all( distdir( build) ) ) ;
904+
905+ let mut child = t ! ( cmd. stdin( Stdio :: piped( ) ) . spawn( ) ) ;
906+ t ! ( child. stdin. take( ) . unwrap( ) . write_all( pass. as_bytes( ) ) ) ;
907+ let status = t ! ( child. wait( ) ) ;
908+ assert ! ( status. success( ) ) ;
909+ }
0 commit comments