Skip to content

Commit 1b7f9c1

Browse files
committed
Allow passing keystore password other than android
1 parent 7726bec commit 1b7f9c1

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

providers/providers.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ StarlarkApkInfo = provider(
4444
keystore = "Keystore used to sign the APK. Deprecated, prefer signing_keys.",
4545
signing_keys = "List of keys used to sign the APK",
4646
signing_lineage = "Optional sigining lineage file",
47+
keystore_signing_password = "Keystore password (defaults to android)",
4748
signed_apk = "Signed APK",
4849
unsigned_apk = "Unsigned APK",
4950
),
@@ -190,6 +191,7 @@ ApkInfo = provider(
190191
signed_apk = "Returns a signed APK built from the target.",
191192
signing_keys = "Returns a list of signing keystores that were used to sign the APK.",
192193
signing_min_v3_rotation_api_version = "Returns the minimum API version for signing the APK with key rotation.",
194+
keystore_signing_password = "Returns the keystore password (defaults to android)",
193195
),
194196
)
195197

rules/android_binary/attrs.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ ATTRS = _attrs.replace(
175175
""",
176176
cfg = android_platforms_transition,
177177
),
178+
keystore_signing_password = attr.string(
179+
doc = """
180+
The password for the KeyStore that contains the signer's key and certificate.
181+
""",
182+
default = "android",
183+
),
178184
key_rotation_min_sdk = attr.string(
179185
doc = """
180186
Sets the minimum Android platform version (API Level) for which an APK's

rules/android_binary/impl.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,7 @@ def _process_apk_packaging(ctx, packaged_resources_ctx, native_libs_ctx, dex_ctx
984984
signing_keys = signing_keys,
985985
signing_lineage = ctx.file.debug_signing_lineage_file,
986986
signing_key_rotation_min_sdk = ctx.attr.key_rotation_min_sdk,
987+
keystore_signing_password = ctx.attr.keystore_signing_password,
987988
deterministic_signing = False,
988989
java_toolchain = common.get_java_toolchain(ctx),
989990
deploy_info_writer = get_android_toolchain(ctx).deploy_info_writer.files_to_run,

rules/apk_packaging.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def _process(
5454
signing_keys = [],
5555
signing_lineage = None,
5656
signing_key_rotation_min_sdk = None,
57+
keystore_signing_password = "android",
5758
stamp_signing_key = None,
5859
deterministic_signing = False,
5960
java_toolchain = None,
@@ -84,6 +85,7 @@ def _process(
8485
signing_keys: Sequence of Files. The keystores to be used to sign the APK.
8586
signing_lineage: File. The signing lineage for signing_keys.
8687
signing_key_rotation_min_sdk: The minimum API version for signing the APK with key rotation.
88+
signing_password: String. The password for the signing keystores. Defaults to "android".
8789
stamp_signing_key: File. The keystore to be used to sign the APK with stamp signing.
8890
deterministic_signing: Boolean. Whether to enable deterministic DSA signing.
8991
java_toolchain: The JavaToolchain target.
@@ -136,6 +138,7 @@ def _process(
136138
out_apk = signed_apk,
137139
in_apk = zipaligned_apk,
138140
signing_keys = signing_keys,
141+
keystore_signing_password = keystore_signing_password,
139142
stamp_signing_key = stamp_signing_key,
140143
deterministic_signing = deterministic_signing,
141144
signing_lineage = signing_lineage,
@@ -320,6 +323,7 @@ def _sign_apk(
320323
out_apk,
321324
in_apk,
322325
signing_keys = [],
326+
keystore_signing_password = "android",
323327
stamp_signing_key = None,
324328
deterministic_signing = True,
325329
signing_lineage = None,
@@ -351,7 +355,7 @@ def _sign_apk(
351355
if i > 0:
352356
args.add("--next-signer")
353357
args.add("--ks", signing_keys[i])
354-
args.add("--ks-pass", "pass:android")
358+
args.add("--ks-pass", "pass:{keystore_signing_password}".format(keystore_signing_password = keystore_signing_password))
355359

356360
args.add("--v1-signing-enabled", ctx.fragments.android.apk_signing_method_v1)
357361
args.add("--v1-signer-name", "CERT")
@@ -371,7 +375,7 @@ def _sign_apk(
371375
inputs.append(stamp_signing_key)
372376
args.add("--stamp-signer")
373377
args.add("--ks", stamp_signing_key)
374-
args.add("--ks-pass", "pass:android")
378+
args.add("--ks-pass", "pass:{keystore_signing_password}".format(keystore_signing_password = keystore_signing_password))
375379

376380
args.add("--out", out_apk)
377381
args.add(in_apk)

0 commit comments

Comments
 (0)