From 7fc4f1cc40f79772b08b37a1d40d3d36cbcf2671 Mon Sep 17 00:00:00 2001 From: Pete Fotheringham Date: Sat, 22 Jun 2024 16:21:00 +0100 Subject: [PATCH] Move BUILD file generation out of key generation loop Fix indentation --- src/init.sh | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/init.sh b/src/init.sh index 424cc19..de645c8 100755 --- a/src/init.sh +++ b/src/init.sh @@ -34,30 +34,13 @@ fi git config --global user.name "$USER_NAME" git config --global user.email "$USER_MAIL" - if [ "$SIGN_BUILDS" = true ]; then - for c in bluetooth cyngn-app media networkstack nfc platform releasekey sdk_sandbox shared testcert testkey verity ; do - if [ ! -f "$KEYS_DIR/$c.pk8" ]; then - echo ">> [$(date)] Generating $c..." - /root/make_key "$KEYS_DIR/$c" "$KEYS_SUBJECT" <<< '' &> /dev/null - fi - done - fi - - # Android 14 requires to set a BUILD file for bazel to avoid errors: - cat > "$KEYS_DIR"/BUILD << _EOB -# adding an empty BUILD file fixes the A14 build error: -# "ERROR: no such package 'keys': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package." -# adding the filegroup "android_certificate_directory" fixes the A14 build error: -# "no such target '//keys:android_certificate_directory': target 'android_certificate_directory' not declared in package 'keys'" -filegroup( -name = "android_certificate_directory", -srcs = glob([ - "*.pk8", - "*.pem", -]), -visibility = ["//visibility:public"], -) -_EOB +if [ "$SIGN_BUILDS" = true ]; then + for c in bluetooth cyngn-app media networkstack nfc platform releasekey sdk_sandbox shared testcert testkey verity ; do + if [ ! -f "$KEYS_DIR/$c.pk8" ]; then + echo ">> [$(date)] Generating $c..." + /root/make_key "$KEYS_DIR/$c" "$KEYS_SUBJECT" <<< '' &> /dev/null + fi + done for c in cyngn{-priv,}-app testkey; do for e in pk8 x509.pem; do @@ -66,6 +49,22 @@ _EOB done fi +# Android 14 requires to set a BUILD file for bazel to avoid errors: +cat > "$KEYS_DIR"/BUILD << _EOB +# adding an empty BUILD file fixes the A14 build error: +# "ERROR: no such package 'keys': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package." +# adding the filegroup "android_certificate_directory" fixes the A14 build error: +# "no such target '//keys:android_certificate_directory': target 'android_certificate_directory' not declared in package 'keys'" +filegroup( +name = "android_certificate_directory", +srcs = glob([ +"*.pk8", +"*.pem", +]), +visibility = ["//visibility:public"], +) +_EOB + if [ "$CRONTAB_TIME" = "now" ]; then /root/build.sh else