|
|
@@ -65,22 +65,22 @@ def swupdate_getdepends(d):
|
|
|
|
|
|
return depstr
|
|
|
|
|
|
-def swupdate_write_sha256(s):
|
|
|
+def swupdate_write_sha256(workdir):
|
|
|
import re
|
|
|
write_lines = []
|
|
|
- with open(os.path.join(s, "sw-description"), 'r') as f:
|
|
|
+ with open(os.path.join(workdir, "sw-description"), 'r') as f:
|
|
|
for line in f:
|
|
|
shastr = r"sha256.+=.+@(.+\")"
|
|
|
m = re.match(r"^(?P<before_placeholder>.+)(sha256|version).+[=:].*(?P<quote>[\'\"])@(?P<filename>.*)(?P=quote)", line)
|
|
|
if m:
|
|
|
filename = m.group('filename')
|
|
|
bb.warn("Syntax for sha256 changed, please use $swupdate_get_sha256(%s)" % filename)
|
|
|
- hash = swupdate_get_sha256(None, s, filename)
|
|
|
+ hash = swupdate_get_sha256(None, workdir, filename)
|
|
|
write_lines.append(line.replace("@%s" % (filename), hash))
|
|
|
else:
|
|
|
write_lines.append(line)
|
|
|
|
|
|
- with open(os.path.join(s, "sw-description"), 'w+') as f:
|
|
|
+ with open(os.path.join(workdir, "sw-description"), 'w+') as f:
|
|
|
for line in write_lines:
|
|
|
f.write(line)
|
|
|
|
|
|
@@ -96,7 +96,7 @@ def swupdate_exec_functions(d, s, write_lines):
|
|
|
write_lines[index] = line
|
|
|
|
|
|
|
|
|
-def swupdate_expand_bitbake_variables(d, s):
|
|
|
+def swupdate_expand_bitbake_variables(d, s, workdir):
|
|
|
write_lines = []
|
|
|
|
|
|
with open(os.path.join(s, "sw-description"), 'r') as f:
|
|
|
@@ -128,9 +128,9 @@ def swupdate_expand_bitbake_variables(d, s):
|
|
|
|
|
|
write_lines.append(line)
|
|
|
|
|
|
- swupdate_exec_functions(d, s, write_lines)
|
|
|
+ swupdate_exec_functions(d, workdir, write_lines)
|
|
|
|
|
|
- with open(os.path.join(s, "sw-description"), 'w+') as f:
|
|
|
+ with open(os.path.join(workdir, "sw-description"), 'w+') as f:
|
|
|
for line in write_lines:
|
|
|
f.write(line)
|
|
|
|
|
|
@@ -172,17 +172,18 @@ def prepare_sw_description(d):
|
|
|
import subprocess
|
|
|
|
|
|
s = d.getVar('S')
|
|
|
- swupdate_expand_bitbake_variables(d, s)
|
|
|
+ workdir = d.getVar('WORKDIR')
|
|
|
+ swupdate_expand_bitbake_variables(d, s, workdir)
|
|
|
|
|
|
- swupdate_write_sha256(s)
|
|
|
+ swupdate_write_sha256(workdir)
|
|
|
|
|
|
encrypt = d.getVar('SWUPDATE_ENCRYPT_SWDESC')
|
|
|
if encrypt:
|
|
|
bb.note("Encryption of sw-description")
|
|
|
- shutil.copyfile(os.path.join(s, 'sw-description'), os.path.join(s, 'sw-description.plain'))
|
|
|
+ shutil.copyfile(os.path.join(workdir, 'sw-description'), os.path.join(workdir, 'sw-description.plain'))
|
|
|
key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE'))
|
|
|
- iv = swupdate_get_IV(d, s, 'sw-description')
|
|
|
- swupdate_encrypt_file(os.path.join(s, 'sw-description.plain'), os.path.join(s, 'sw-description'), key, iv)
|
|
|
+ iv = swupdate_get_IV(d, workdir, 'sw-description')
|
|
|
+ swupdate_encrypt_file(os.path.join(workdir, 'sw-description.plain'), os.path.join(workdir, 'sw-description'), key, iv)
|
|
|
|
|
|
signing = d.getVar('SWUPDATE_SIGNING')
|
|
|
if signing == "1":
|
|
|
@@ -190,8 +191,8 @@ def prepare_sw_description(d):
|
|
|
signing = "RSA"
|
|
|
if signing:
|
|
|
|
|
|
- sw_desc_sig = os.path.join(s, 'sw-description.sig')
|
|
|
- sw_desc = os.path.join(s, 'sw-description.plain' if encrypt else 'sw-description')
|
|
|
+ sw_desc_sig = os.path.join(workdir, 'sw-description.sig')
|
|
|
+ sw_desc = os.path.join(workdir, 'sw-description.plain' if encrypt else 'sw-description')
|
|
|
|
|
|
if signing == "CUSTOM":
|
|
|
signcmd = []
|
|
|
@@ -239,7 +240,7 @@ def prepare_sw_description(d):
|
|
|
def swupdate_add_src_uri(d, list_for_cpio):
|
|
|
import shutil
|
|
|
|
|
|
- s = d.getVar('S')
|
|
|
+ workdir = d.getVar('WORKDIR')
|
|
|
exclude = (d.getVar("SWUPDATE_SRC_URI_EXCLUDE") or "").split()
|
|
|
|
|
|
fetch = bb.fetch2.Fetch([], d)
|
|
|
@@ -255,12 +256,12 @@ def swupdate_add_src_uri(d, list_for_cpio):
|
|
|
key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE'))
|
|
|
if (filename != 'sw-description') and (os.path.isfile(local)):
|
|
|
encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename) or "")
|
|
|
- dst = os.path.join(s, "%s" % filename )
|
|
|
+ dst = os.path.join(workdir, "%s" % filename )
|
|
|
if encrypted == '1':
|
|
|
bb.note("Encryption requested for %s" %(filename))
|
|
|
if not key or not iv:
|
|
|
bb.fatal("Encryption required, but no key found")
|
|
|
- iv = swupdate_get_IV(d, s, filename)
|
|
|
+ iv = swupdate_get_IV(d, workdir, filename)
|
|
|
swupdate_encrypt_file(local, dst, key, iv)
|
|
|
else:
|
|
|
shutil.copyfile(local, dst)
|
|
|
@@ -290,7 +291,7 @@ def swupdate_add_artifacts(d, list_for_cpio):
|
|
|
images = (d.getVar('SWUPDATE_IMAGES') or "").split()
|
|
|
deploydir = d.getVar('DEPLOY_DIR_IMAGE')
|
|
|
imgdeploydir = d.getVar('SWUDEPLOYDIR')
|
|
|
- s = d.getVar('S')
|
|
|
+ workdir = d.getVar('WORKDIR')
|
|
|
for image in images:
|
|
|
fstypes = (d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image) or "").split()
|
|
|
encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", image) or "")
|
|
|
@@ -305,19 +306,19 @@ def swupdate_add_artifacts(d, list_for_cpio):
|
|
|
for fstype in fstypes:
|
|
|
image_found = False
|
|
|
for imagebase in imagebases:
|
|
|
- image_found = add_image_to_swu(d, deploydir, imagebase + fstype, s, encrypted, list_for_cpio)
|
|
|
+ image_found = add_image_to_swu(d, deploydir, imagebase + fstype, workdir, encrypted, list_for_cpio)
|
|
|
if image_found:
|
|
|
break
|
|
|
if not image_found:
|
|
|
bb.fatal("swupdate cannot find image file: %s" % os.path.join(deploydir, imagebase + fstype))
|
|
|
else: # Allow also complete entries like "image.ext4.gz" in SWUPDATE_IMAGES
|
|
|
- if not add_image_to_swu(d, deploydir, image, s, encrypted, list_for_cpio):
|
|
|
+ if not add_image_to_swu(d, deploydir, image, workdir, encrypted, list_for_cpio):
|
|
|
bb.fatal("swupdate cannot find %s image file" % image)
|
|
|
|
|
|
|
|
|
def swupdate_create_cpio(d, swudeploydir, list_for_cpio):
|
|
|
- s = d.getVar('S')
|
|
|
- os.chdir(s)
|
|
|
+ workdir = d.getVar('WORKDIR')
|
|
|
+ os.chdir(workdir)
|
|
|
updateimage = d.getVar('IMAGE_NAME') + '.swu'
|
|
|
line = 'for i in ' + ' '.join(list_for_cpio) + '; do echo $i;done | cpio -ov -H crc --reproducible > ' + os.path.join(swudeploydir, updateimage)
|
|
|
os.system(line)
|