fix: surface keytool errors and add keytool preflight check

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-11 04:29:45 -04:00
parent b8a4ddf4a0
commit ec21256ca5

View File

@@ -56,6 +56,11 @@ preflight_check() {
ok=false ok=false
fi fi
if ! command -v keytool &>/dev/null; then
error "keytool not found. It ships with the JDK — check your JAVA_HOME/PATH."
ok=false
fi
if [[ ! -x "./gradlew" ]]; then if [[ ! -x "./gradlew" ]]; then
error "Gradle wrapper not found or not executable." error "Gradle wrapper not found or not executable."
ok=false ok=false
@@ -133,6 +138,9 @@ create_keystore() {
info "Creating keystore..." info "Creating keystore..."
local keytool_err
keytool_err=$(mktemp)
keytool -genkeypair \ keytool -genkeypair \
-alias "$KEY_ALIAS" \ -alias "$KEY_ALIAS" \
-keyalg RSA \ -keyalg RSA \
@@ -142,9 +150,10 @@ create_keystore() {
-storepass "$password" \ -storepass "$password" \
-keypass "$password" \ -keypass "$password" \
-dname "$dname" \ -dname "$dname" \
2>/dev/null || true 2>"$keytool_err" || true
if [[ -f "$KEYSTORE_FILE" ]]; then if [[ -f "$KEYSTORE_FILE" ]]; then
rm -f "$keytool_err"
echo "" echo ""
success "Keystore created at ${BOLD}$KEYSTORE_FILE${NC}" success "Keystore created at ${BOLD}$KEYSTORE_FILE${NC}"
echo "" echo ""
@@ -153,6 +162,10 @@ create_keystore() {
warn "that already have this version installed." warn "that already have this version installed."
else else
error "Keystore creation failed." error "Keystore creation failed."
if [[ -s "$keytool_err" ]]; then
echo -e "${DIM}$(cat "$keytool_err")${NC}" >&2
fi
rm -f "$keytool_err"
return 1 return 1
fi fi
} }