@@ -14,18 +14,36 @@ fn main() {
1414 out. push_str ( & format ! ( "{:x} {}\n " , hash, path) ) ;
1515 } ) ;
1616
17- let sums_path = PathBuf :: from ( "./gen/SHA256SUMS" ) ;
17+ let target_dir = target_dir ( ) ;
18+ let sums_path = target_dir. join ( "SHA256SUMS" ) ;
1819 std:: fs:: write ( & sums_path, out) . unwrap ( ) ;
1920
2021 if !cfg ! ( debug_assertions) {
2122 sign_sha256sums ( & sums_path) ;
2223 } else {
23- std:: fs:: write ( "./gen/SHA256SUMS.sig" , "NOT SIGNED NEEDED FOR DEBUG" ) . unwrap ( ) ;
24+ std:: fs:: write (
25+ sums_path. with_extension ( ".sig" ) ,
26+ "NOT SIGNED NEEDED FOR DEBUG" ,
27+ )
28+ . unwrap ( ) ;
2429 }
2530
2631 tauri_build:: build ( ) ;
2732}
2833
34+ fn target_dir ( ) -> PathBuf {
35+ let out_dir = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
36+ // see <https://github.com/rust-lang/cargo/issues/5457>
37+ out_dir
38+ . parent ( )
39+ . unwrap ( )
40+ . parent ( )
41+ . unwrap ( )
42+ . parent ( )
43+ . unwrap ( )
44+ . to_path_buf ( )
45+ }
46+
2947fn read_folder_recursive < F > ( path : PathBuf , cb : & mut F )
3048where
3149 F : FnMut ( PathBuf ) ,
@@ -48,21 +66,15 @@ fn sign_sha256sums(path: &PathBuf) {
4866
4967 let key_base64 =
5068 std:: env:: var ( "TAURI_SIGNING_PRIVATE_KEY" ) . expect ( "TAURI_SIGNING_PRIVATE_KEY missing" ) ;
51-
5269 let password = std:: env:: var ( "TAURI_SIGNING_PRIVATE_KEY_PASSWORD" )
5370 . expect ( "TAURI_SIGNING_PRIVATE_KEY_PASSWORD missing" ) ;
5471
55- // Decode the private key from base64 (following Tauri's pattern)
5672 let key_bytes = base64:: engine:: general_purpose:: STANDARD
5773 . decode ( & key_base64)
5874 . expect ( "Failed to decode base64 secret key" ) ;
59-
6075 let key_str = String :: from_utf8 ( key_bytes) . expect ( "Secret key is not valid UTF-8" ) ;
6176
62- // Load the secret key box from the string representation
6377 let sk_box = SecretKeyBox :: from_string ( & key_str) . expect ( "Invalid secret key format" ) ;
64-
65- // Decrypt the secret key using the password
6678 let secret_key = sk_box
6779 . into_secret_key ( Some ( password) )
6880 . expect ( "Failed to decrypt secret key - invalid password" ) ;
@@ -76,11 +88,8 @@ fn sign_sha256sums(path: &PathBuf) {
7688 minisign:: sign ( None , & secret_key, data_reader, None , None ) . expect ( "Failed to sign data" ) ;
7789
7890 // Write the signature to a .sig file
79- let mut sig_path = path. clone ( ) ;
80- sig_path. set_extension ( "sig" ) ;
81-
91+ let sig_path = path. with_extension ( "sig" ) ;
8292 let mut file = std:: fs:: File :: create ( & sig_path) . expect ( "Failed to create signature file" ) ;
83-
8493 file. write_all ( signature_box. to_string ( ) . as_bytes ( ) )
8594 . expect ( "Failed to write signature" ) ;
8695
0 commit comments