[Replicant] [vendor_replicant][PATCH] sign-build.sh: fix unexpected operator with multiple TARGET_FILES

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Sun Feb 23 12:37:29 UTC 2020


sign-build sometimes fails when there is multiple files
matching the *-target_files-*.zip pattern for TARGET_FILES:
when checking if TARGET_FILES is a file with
[ -f $TARGET_FILES ], it can fail because -f expects ai
single path.

When it happens the failure looks like that:
  vendor/replicant/sign-build: 111: [:
  [...]/out/target/product/maguro/obj/PACKAGING/target_files_intermediates/replicant_maguro-target_files-3c9b1e0289.zip:
  unexpected operator

The TARGET_FILES files we are sigining in sign-build.sh
have their build rules in build/core/Makefile where the
resulting path of the file is defined in this way:
  BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
name is in turn defined like this:
  name := $(name)-target_files-$(FILE_NAME_TAG)
and FILE_NAME_TAG like this:
  FILE_NAME_TAG := $(BUILD_NUMBER)

Since we have access to the device name and the
BUILD_NUMBER that is used to construct the FILE_NAME_TAG,
we can use them to find out the name of the file to sign
instead of relying on fragile glob ('*') patterns.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 sign-build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sign-build b/sign-build
index d9aa0a8a..7b955d93 100755
--- a/sign-build
+++ b/sign-build
@@ -40,7 +40,8 @@ else
 fi
 
 TARGET_DIR=$OUT_DIR/target/product/$DEVICE
-TARGET_FILES=$TARGET_DIR/obj/PACKAGING/target_files_intermediates/*-target_files-*.zip
+TARGET_FILES=$TARGET_DIR/obj/PACKAGING/target_files_intermediates/replicant_${DEVICE}-target_files-${BUILD_NUMBER}.zip
+
 DIST_OUT_DIR=$OUT_DIR/"dist"/$DEVICE
 RELEASE=replicant-6.0-0004-rc1
 
-- 
2.25.1



More information about the Replicant mailing list