Skip to content

Commit 92a3313

Browse files
committed
Potentially better fix for keystore generation on Windows
1 parent 944bf20 commit 92a3313

2 files changed

Lines changed: 12 additions & 36 deletions

File tree

src/default.keystore

-2.51 KB
Binary file not shown.

src/renutil.rs

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ use tar::Archive;
2222
use trauma::download::Download;
2323
use trauma::downloader::DownloaderBuilder;
2424

25-
// default keystore created with the usual settings (as defined below) on 2025-05-19
26-
const DEFAULT_KEYSTORE: &'static [u8] = include_bytes!("default.keystore");
27-
28-
fn write_default_keystore(path: &Path) -> Result<()> {
29-
let mut file = fs::File::create(path)?;
30-
file.write_all(DEFAULT_KEYSTORE)?;
31-
Ok(())
32-
}
33-
3425
pub trait InstanceState {}
3526

3627
pub struct Local;
@@ -628,20 +619,18 @@ pub async fn install(
628619
}
629620
}
630621

631-
let original_dir = env::current_dir()?;
632-
env::set_current_dir(base_path.join("rapt"))?;
633-
634622
let keytool = java_home.join("bin").join("keytool");
635623

636-
let android_keystore = Path::new("android.keystore");
624+
let android_keystore = base_path.join("rapt").join("android.keystore");
625+
let android_keystore_str = android_keystore.to_str().unwrap();
637626
if !android_keystore.exists() {
638627
println!("Generating Android keystore");
639628

640629
let mut cmd = Command::new(&keytool);
641630
cmd.args([
642631
"-genkey",
643632
"-keystore",
644-
"android.keystore",
633+
android_keystore_str,
645634
"-alias",
646635
"android",
647636
"-keyalg",
@@ -662,34 +651,29 @@ pub async fn install(
662651
if !status.success() {
663652
match status.code() {
664653
Some(code) => {
665-
println!(
666-
"Unable to generate Android keystore: Exit code {code}\nCommand: {cmd:?}\nWriting default keystore."
654+
anyhow::bail!(
655+
"Unable to generate Android keystore: Exit code {code}\nCommand: {cmd:?}"
667656
);
668-
write_default_keystore(android_keystore)?;
669657
}
670658
None => {
671-
println!(
672-
"Unable to generate Android keystore: Terminated by signal\nCommand: {cmd:?}\nWriting default keystore."
659+
anyhow::bail!(
660+
"Unable to generate Android keystore: Terminated by signal\nCommand: {cmd:?}"
673661
);
674-
write_default_keystore(android_keystore)?;
675662
}
676663
}
677664
};
678665
}
679666
Err(e) => {
680-
println!(
681-
"Unable to generate Android keystore: {e}\nCommand: {cmd:?}\nWriting default keystore."
682-
);
683-
write_default_keystore(android_keystore)?;
667+
anyhow::bail!("Unable to generate Android keystore: {e}\nCommand: {cmd:?}");
684668
}
685669
};
686670
}
687671

688-
let bundle_keystore = Path::new("bundle.keystore");
672+
let bundle_keystore = base_path.join("rapt").join("android.keystore");
689673
if !bundle_keystore.exists() {
690674
println!("Generating Bundle keystore (reusing Android keystore)");
691675

692-
fs::copy("android.keystore", "bundle.keystore")?;
676+
fs::copy(android_keystore, bundle_keystore)?;
693677
}
694678

695679
println!("Patching SSL issue in RAPT");
@@ -731,23 +715,15 @@ pub async fn install(
731715

732716
unsafe { env::set_var("RAPT_NO_TERMS", "1") };
733717

718+
let android_py = base_path.join("rapt/android.py");
734719
let mut cmd = Command::new(&python);
735-
cmd.args(["-EO", "android.py", "installsdk"]);
736-
737-
println!("Command: {cmd:?}");
738-
739-
println!("Environment");
740-
for (k, v) in std::env::vars() {
741-
println!("{k} = {v}");
742-
}
720+
cmd.args(["-EO", android_py.to_str().unwrap(), "installsdk"]);
743721

744722
let status = cmd.status()?;
745723
if !status.success() {
746724
anyhow::bail!("Unable to install Android SDK.");
747725
}
748726

749-
env::set_current_dir(original_dir)?;
750-
751727
println!("Increasing Gradle RAM limit to 8Gb");
752728
let paths = [
753729
base_path.join("rapt/prototype/gradle.properties"),

0 commit comments

Comments
 (0)