mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 12:39:02 +02:00
Record sha256sum of other distro source files
If a source points to a local file, get the sha256sum of it and save it into the field we just added. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
44aa397fbe
commit
c32fdd8c9e
|
@ -292,6 +292,12 @@ def update_recipe_file(path, recipe, repodir, raiseexceptions=False):
|
|||
existing_ids = list(recipe.source_set.values_list('id', flat=True))
|
||||
for src in sources:
|
||||
srcobj, _ = Source.objects.get_or_create(recipe=recipe, url=src)
|
||||
if not '://' in src:
|
||||
sourcepath = os.path.join(os.path.dirname(path), src)
|
||||
if os.path.exists(sourcepath):
|
||||
srcobj.sha256sum = utils.sha256_file(sourcepath)
|
||||
else:
|
||||
srcobj.sha256sum = ''
|
||||
srcobj.save()
|
||||
if srcobj.id in existing_ids:
|
||||
existing_ids.remove(srcobj.id)
|
||||
|
|
|
@ -469,6 +469,14 @@ def sanitise_html(html):
|
|||
def squashspaces(string):
|
||||
return re.sub("\s+", " ", string).strip()
|
||||
|
||||
def sha256_file(ifn):
|
||||
import hashlib
|
||||
shash = hashlib.sha256()
|
||||
with open(ifn, 'rb') as f:
|
||||
for line in f:
|
||||
shash.update(line)
|
||||
return shash.hexdigest()
|
||||
|
||||
def timesince2(date, date2=None):
|
||||
# Based on http://www.didfinishlaunchingwithoptions.com/a-better-timesince-template-filter-for-django/
|
||||
if date2 is None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user