Skip to content

Commit 68f5a3d

Browse files
earlephilhowerdevyte
authored andcommitted
Keep signing commands in platform.txt on release (#5491)
* Keep signing commands in platform.txt on release The boards packager was deleting what was at the time it was written unused lines in fht platform.txt file before deploying to Arduino. One of these lines is now needed for signing to work, so don't delete it. Also, explicitly call "python signing.py" because it looks like Arduino is sanitizing/removing executable bits on files when extracting from boards manager installations. Fixes #5483 * Create the build subdir, if needed, for autosign If the temporary build/core directory isn't available, make it in order that Updater.cpp will see the generated signing header and not the one in the main core.
1 parent 20f07ec commit 68f5a3d

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Diff for: package/build_boards_manager_package.sh

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ $SED 's/runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}\/tools\/
8686
$SED 's/runtime.tools.esptool.path={runtime.platform.path}\/tools\/esptool//g' | \
8787
$SED 's/tools.esptool.path={runtime.platform.path}\/tools\/esptool/tools.esptool.path=\{runtime.tools.esptool.path\}/g' | \
8888
$SED 's/tools.mkspiffs.path={runtime.platform.path}\/tools\/mkspiffs/tools.mkspiffs.path=\{runtime.tools.mkspiffs.path\}/g' |\
89-
$SED 's/recipe.hooks.core.prebuild.1.pattern.*//g' |\
9089
$SED 's/recipe.hooks.core.prebuild.2.pattern.*//g' |\
9190
$SED 's/recipe.hooks.core.prebuild.3.pattern.*//g' |\
9291
$SED "s/version=.*/version=$ver/g" |\

Diff for: platform.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ compiler.elf2hex.extra_flags=
7676

7777
## generate file with git version number
7878
## needs bash, git, and echo
79-
recipe.hooks.core.prebuild.1.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_VER 0x`git --git-dir {runtime.platform.path}/.git rev-parse --short=8 HEAD 2>/dev/null || echo ffffffff` >{build.path}/core/core_version.h"
80-
recipe.hooks.core.prebuild.2.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_DESC `cd "{runtime.platform.path}"; git describe --tags 2>/dev/null || echo unix-{version}` >>{build.path}/core/core_version.h"
81-
recipe.hooks.core.prebuild.3.pattern="{runtime.tools.signing}" --mode header --publickey "{build.source.path}/public.key" --out "{build.path}/core/Updater_Signing.h"
79+
recipe.hooks.core.prebuild.1.pattern=python "{runtime.tools.signing}" --mode header --publickey "{build.source.path}/public.key" --out "{build.path}/core/Updater_Signing.h"
80+
recipe.hooks.core.prebuild.2.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_VER 0x`git --git-dir {runtime.platform.path}/.git rev-parse --short=8 HEAD 2>/dev/null || echo ffffffff` >{build.path}/core/core_version.h"
81+
recipe.hooks.core.prebuild.3.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_DESC `cd "{runtime.platform.path}"; git describe --tags 2>/dev/null || echo unix-{version}` >>{build.path}/core/core_version.h"
8282

8383
## windows-compatible version without git
84-
recipe.hooks.core.prebuild.1.pattern.windows=cmd.exe /c mkdir {build.path}\core & (echo #define ARDUINO_ESP8266_GIT_VER 0x00000000 & echo #define ARDUINO_ESP8266_GIT_DESC win-{version} ) > {build.path}\core\core_version.h
85-
recipe.hooks.core.prebuild.2.pattern.windows=cmd.exe /c if exist {build.source.path}\public.key echo #error Cannot automatically build signed binaries on Windows > {build.path}\core\Updater_Signing.h
86-
recipe.hooks.core.prebuild.3.pattern.windows=
84+
recipe.hooks.core.prebuild.1.pattern.windows=cmd.exe /c rem cannot sign on windows
85+
recipe.hooks.core.prebuild.2.pattern.windows=cmd.exe /c mkdir {build.path}\core & (echo #define ARDUINO_ESP8266_GIT_VER 0x00000000 & echo #define ARDUINO_ESP8266_GIT_DESC win-{version} ) > {build.path}\core\core_version.h
86+
recipe.hooks.core.prebuild.3.pattern.windows=cmd.exe /c if exist {build.source.path}\public.key echo #error Cannot automatically build signed binaries on Windows > {build.path}\core\Updater_Signing.h
8787

8888
## Build the app.ld linker file
8989
recipe.hooks.linking.prelink.1.pattern="{compiler.path}{compiler.c.cmd}" -CC -E -P {build.vtable_flags} "{runtime.platform.path}/tools/sdk/ld/eagle.app.v6.common.ld.h" -o "{build.path}/local.eagle.app.v6.common.ld"
@@ -110,7 +110,7 @@ recipe.objcopy.eep.pattern=
110110
#recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
111111

112112
recipe.objcopy.hex.1.pattern="{runtime.tools.esptool.path}/{compiler.esptool.cmd}" -eo "{runtime.platform.path}/bootloaders/eboot/eboot.elf" -bo "{build.path}/{build.project_name}.bin" -bm {build.flash_mode} -bf {build.flash_freq} -bz {build.flash_size} -bs .text -bp 4096 -ec -eo "{build.path}/{build.project_name}.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
113-
recipe.objcopy.hex.2.pattern="{runtime.tools.signing}" --mode sign --privatekey "{build.source.path}/private.key" --bin "{build.path}/{build.project_name}.bin" --out "{build.path}/{build.project_name}.bin.signed"
113+
recipe.objcopy.hex.2.pattern=python "{runtime.tools.signing}" --mode sign --privatekey "{build.source.path}/private.key" --bin "{build.path}/{build.project_name}.bin" --out "{build.path}/{build.project_name}.bin.signed"
114114

115115
# No signing on Windows
116116
recipe.objcopy.hex.1.pattern.windows="{runtime.tools.esptool.path}/{compiler.esptool.cmd}" -eo "{runtime.platform.path}/bootloaders/eboot/eboot.elf" -bo "{build.path}/{build.project_name}.bin" -bm {build.flash_mode} -bf {build.flash_freq} -bz {build.flash_size} -bs .text -bp 4096 -ec -eo "{build.path}/{build.project_name}.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec

Diff for: tools/signing.py

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def main():
3838
# and they can check for the positive acknowledgement above.
3939
# sys.stderr.write("Not enabling binary signing\n")
4040
val += "#define ARDUINO_SIGNING 0\n"
41+
outdir = os.path.dirname(args.out)
42+
if not os.path.exists(outdir):
43+
os.makedirs(outdir)
4144
with open(args.out, "w") as f:
4245
f.write(val)
4346
return 0

0 commit comments

Comments
 (0)