Commit b09406e3 authored by Oliver Pinter's avatar Oliver Pinter
Browse files

HBSD: add basic error handling



Signed-off-by: default avatarOliver Pinter <oliver.pinter@hardenedbsd.org>
parent cfa32540
......@@ -5,11 +5,21 @@ import os.path
cwd = os.path.basename(os.getcwd())
with open("CHECKSUM.SHA512", "r") as f:
checksum = f.read()
with open("CHECKSUM.SHA512.asc", "r") as f:
signature = f.read()
try:
with open("CHECKSUM.SHA512", "r") as f:
checksum = f.read()
update_checksum = True
except:
print("missing CHECKSUM.SHA512 file!")
update_checksum = False
try:
with open("CHECKSUM.SHA512.asc", "r") as f:
signature = f.read()
update_signature = True
except:
print("missing CHECKSUM.SHA512.asc file!")
update_signature = False
with open("drupal-{version}.template".format(version=cwd), "r") as f:
drupal_template = f.read()
......@@ -34,17 +44,17 @@ github_text = "\n".join(github_formatted_lines)
drupal_text = "\n".join(drupal_formatted_lines)
with open("drupal-{version}.txt".format(version=cwd), "w+") as f:
drupal = (drupal_template
.replace("%%NOTES%%", drupal_text)
.replace("%%CHECKSUM%%", checksum)
.replace("%%SIGNATURE%%", signature)
)
drupal = drupal_template.replace("%%NOTES%%", drupal_text)
if update_checksum:
drupal = drupal.replace("%%CHECKSUM%%", checksum)
if update_signature:
drupal = drupal.replace("%%SIGNATURE%%", signature)
f.write(drupal)
with open("github-{version}.txt".format(version=cwd), "w+") as f:
github = (github_template
.replace("%%NOTES%%", github_text)
.replace("%%CHECKSUM%%", checksum)
.replace("%%SIGNATURE%%", signature)
)
github = github_template.replace("%%NOTES%%", github_text)
if update_checksum:
github = github.replace("%%CHECKSUM%%", checksum)
if update_signature:
github = github.replace("%%SIGNATURE%%", signature)
f.write(github)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment