Skip to content

Commit

Permalink
Move signature files to subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
photron committed Jul 11, 2024
1 parent 1bb1cd2 commit b57b938
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions software/merge_firmware_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ def check_call(*args): # hide subprocess.check_call return value
), f"Merging firmware.bin -> build/{firmware_basename}_merged.bin")
)

if os.path.exists(env.subst("$PROJECT_DIR/signature_secret_key_v1.json")):
if os.path.exists(env.subst("$PROJECT_DIR/signature/secret_key_v1.json")):
signed_firmware_basename = firmware_basename.replace('-UNSIGNED', '')

env.AddPostAction(
"$BUILD_DIR/${PROGNAME}.bin",
env.VerboseAction(lambda env, **kwargs: check_call(
env.subst('$PYTHONEXE'),
"-u",
env.subst("$PROJECT_DIR/signature_sign.py"),
env.subst("$PROJECT_DIR/signature/sign.py"),
"build/{}_merged.bin".format(firmware_basename),
"build/{}_merged.bin".format(signed_firmware_basename)
), f"Signing merged firmware.bin -> build/{signed_firmware_basename}_merged.bin")
Expand Down
2 changes: 1 addition & 1 deletion software/pio_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def main():

firmware_basename = '{}_firmware-UNSIGNED{}{}{}_{}_{:x}{}'.format(
name,
"-NONVERIFYING" if not os.path.exists("signature_public_key_v1.json") else "",
"-NONVERIFYING" if not os.path.exists("signature/public_key_v1.json") else "",
"-NIGHTLY" if nightly else "",
"-WITH-WIFI-PASSPHRASE-DO-NOT-DISTRIBUTE" if not_for_distribution else "",
"{}_{}_{}{}".format(*version[:3], f"_beta_{version[3]}" if version[3] != "255" else ""),
Expand Down
4 changes: 2 additions & 2 deletions software/signature_keygen.py → software/signature/keygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def main():
args = parser.parse_args()

directory = os.path.dirname(__file__)
public_key_filename = os.path.relpath(os.path.join(directory, 'signature_public_key_v1.json'))
secret_key_filename = os.path.relpath(os.path.join(directory, 'signature_secret_key_v1.json'))
public_key_filename = os.path.relpath(os.path.join(directory, 'public_key_v1.json'))
secret_key_filename = os.path.relpath(os.path.join(directory, 'secret_key_v1.json'))

if os.path.exists(public_key_filename):
if args.force:
Expand Down
2 changes: 1 addition & 1 deletion software/signature_sign.py → software/signature/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def main():
return 1

directory = os.path.dirname(__file__)
secret_key_filename = os.path.relpath(os.path.join(directory, 'signature_secret_key_v1.json'))
secret_key_filename = os.path.relpath(os.path.join(directory, 'secret_key_v1.json'))

try:
with open(secret_key_filename, 'r', encoding='utf-8') as f:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def main():

args = parser.parse_args()
directory = os.path.dirname(__file__)
public_key_filename = os.path.relpath(os.path.join(directory, 'signature_public_key_v1.json'))
public_key_filename = os.path.relpath(os.path.join(directory, 'public_key_v1.json'))

try:
with open(public_key_filename, 'r', encoding='utf-8') as f:
Expand Down
2 changes: 1 addition & 1 deletion software/src/modules/firmware_update/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from software import util

try:
with open('../../../signature_public_key_v1.json', 'r', encoding='utf-8') as f:
with open('../../../signature/public_key_v1.json', 'r', encoding='utf-8') as f:
signature_public_key_json = json.loads(f.read())

signature_publisher = repr(signature_public_key_json['publisher'].encode('utf-8'))[2:-1].replace('"', '\\"')
Expand Down

0 comments on commit b57b938

Please sign in to comment.