mdist: Ensure correct format for sha256sum.

We conform to the format described at
<https://www.gnu.org/software/coreutils/manual/html_node/md5sum-invocation.html>.
and compatible with busybox and Perl's shasum utility.
This commit is contained in:
Aman Verma 2020-12-19 18:43:55 -05:00 committed by Eli Schwartz
parent d6ef5b2024
commit 1f7c8ec7e2
1 changed files with 3 additions and 1 deletions

View File

@ -48,7 +48,9 @@ def create_hash(fname):
m = hashlib.sha256()
m.update(open(fname, 'rb').read())
with open(hashname, 'w') as f:
f.write('{} {}\n'.format(m.hexdigest(), os.path.basename(fname)))
# A space and an asterisk because that is the format defined by GNU coreutils
# and accepted by busybox and the Perl shasum tool.
f.write('{} *{}\n'.format(m.hexdigest(), os.path.basename(fname)))
print(os.path.relpath(fname), m.hexdigest())