Reimplemented md5sum with python functions.

This commit is contained in:
emiliano.vavassori 2023-12-01 21:42:52 +01:00
parent 62248d862c
commit 49e0ab5593
1 changed files with 11 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import re
import shlex
import tempfile
import urllib.request
import hashlib
from lxml import etree
import loaih
@ -424,13 +425,22 @@ class Build(loaih.RemoteBuild):
def __create_checksum__(self, file):
"""Internal function to create checksum file."""
retval = hashlib.md5()
with open(file, 'rb') as rawfile:
while True:
buf = rawfile.read(2**20)
if not buf:
break
retval.update(buf)
checksum = subprocess.run(f"md5sum {file}", shell=True,
capture_output=True, text=True, encoding='utf-8', check=True,
cwd=self.appnamedir)
if checksum.stdout:
with open(f"{file}.md5", 'w', encoding='utf-8') as checkfile:
checkfile.write(checksum.stdout)
checkfile.write(f"{retval.hexdigest()} {os.path.basename(file)}")
def publish(self):