@@ -216,9 +216,23 @@ struct Builder {
216216 rustfmt_git_commit_hash : Option < String > ,
217217 llvm_tools_git_commit_hash : Option < String > ,
218218 lldb_git_commit_hash : Option < String > ,
219+
220+ should_sign : bool ,
219221}
220222
221223fn main ( ) {
224+ // Avoid signing packages while manually testing
225+ // Do NOT set this envvar in CI
226+ let should_sign = env:: var ( "BUILD_MANIFEST_DISABLE_SIGNING" ) . is_err ( ) ;
227+
228+ // Safety check to ensure signing is always enabled on CI
229+ // The CI environment variable is set by both Travis and AppVeyor
230+ if !should_sign && env:: var ( "CI" ) . is_ok ( ) {
231+ println ! ( "The 'BUILD_MANIFEST_DISABLE_SIGNING' env var can't be enabled on CI." ) ;
232+ println ! ( "If you're not running this on CI, unset the 'CI' env var." ) ;
233+ panic ! ( ) ;
234+ }
235+
222236 let mut args = env:: args ( ) . skip ( 1 ) ;
223237 let input = PathBuf :: from ( args. next ( ) . unwrap ( ) ) ;
224238 let output = PathBuf :: from ( args. next ( ) . unwrap ( ) ) ;
@@ -231,8 +245,12 @@ fn main() {
231245 let llvm_tools_release = args. next ( ) . unwrap ( ) ;
232246 let lldb_release = args. next ( ) . unwrap ( ) ;
233247 let s3_address = args. next ( ) . unwrap ( ) ;
248+
249+ // Do not ask for a passphrase while manually testing
234250 let mut passphrase = String :: new ( ) ;
235- t ! ( io:: stdin( ) . read_to_string( & mut passphrase) ) ;
251+ if should_sign {
252+ t ! ( io:: stdin( ) . read_to_string( & mut passphrase) ) ;
253+ }
236254
237255 Builder {
238256 rust_release,
@@ -265,6 +283,8 @@ fn main() {
265283 rustfmt_git_commit_hash : None ,
266284 llvm_tools_git_commit_hash : None ,
267285 lldb_git_commit_hash : None ,
286+
287+ should_sign,
268288 } . build ( ) ;
269289}
270290
@@ -588,6 +608,10 @@ impl Builder {
588608 }
589609
590610 fn sign ( & self , path : & Path ) {
611+ if !self . should_sign {
612+ return ;
613+ }
614+
591615 let filename = path. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
592616 let asc = self . output . join ( format ! ( "{}.asc" , filename) ) ;
593617 println ! ( "signing: {:?}" , path) ;
0 commit comments