From patchwork Mon May 7 12:12:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raphael Freudiger X-Patchwork-Id: 909716 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c0c::23e; helo=mail-wr0-x23e.google.com; envelope-from=swupdate+bncbaabbuufyhlqkgqe3h3ebbi@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="I+fFDvv0"; dkim-atps=neutral Received: from mail-wr0-x23e.google.com (mail-wr0-x23e.google.com [IPv6:2a00:1450:400c:c0c::23e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40fhN66cS7z9s34 for ; Mon, 7 May 2018 22:13:09 +1000 (AEST) Received: by mail-wr0-x23e.google.com with SMTP id f23-v6sf19498932wra.20 for ; Mon, 07 May 2018 05:13:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1525695187; cv=pass; d=google.com; s=arc-20160816; b=Uq5aB4B9gExD/FXUTkdF+BS8xQSpKCWpSe85BOk6+0uWz5YNDHZz93QbXFgPRjjzhY 8wKH3xBpflsjZE88AtB6AO2E76KzdgfoDnifzMwF4/MYsvUUIq6L7U5XX4Koi6nZhdT6 d/QT/0e/9/HODoJpYIrD6CUj92ySbpYlk1qrLgsIsH4v45XEmSoC6FUZr0a8BFf1imDw JMerBNYxCFMSi7t7PJdWl4VZ3io6myIglZaJSUBcEas9jXe6hByGTM5utBeEAE0GCyNK wz5bgRH7bQs9KrRqgk+F2rNtkleaO9k2NPI164mUwVF56ckhoJ2PmTpBUmluHUieoEtr r63Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=U20G6SPISUmCQtJUMVhCLWwWg2mGaPuhojg4pOErGpY=; b=abfz47VYhoFEVG8uLdrUtd9zrO0K62P8aEQ0c7W40aXdnnBSpe74B4fkzM+yIRKNOr BSrQgADxKlbYPkFuo9Ypqjn/SPI/LgmLwL74CgHz6R2Ym6s02RZ7Jl2XV1aNcFKz8Vh/ c5/G043/TWwbpqpIdL1VctH3MoefF4nNhwrXqDlL1pYZ9GtCZtvKBrWRosJNqZpiUXdz 9SPGe5uqHOPXaOxxfDp5pkmbMft+Sh4pOCfAhju0a9xI5u7jIToL6iar2WbF5bG04ePQ cmFPDLB1sstM+6C64WFFGABpnRwRBwTwBatAKwzhJXpxs25qsGZ3gPBWKKzs1zOOvUso FmEg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=raphael.freudiger@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=U20G6SPISUmCQtJUMVhCLWwWg2mGaPuhojg4pOErGpY=; b=I+fFDvv04kcwsNzI4dcb+y6J/34IXab9i0N16pf3VVi9QEYEcmpWmZAvzcWhw6luRS vu6eHdqAPWEH3EIexTaYsS1V6NQJ8gGddTm8ySZZgGhiPUVV8HozFe5OjiiF94l/Batn VSoSkLAbH+kfXGYc1SQnawBU5Z7E3HQB6vROMY1vLTZ2m6RicrhlRtwsqiQyOdSqyj9o RAvm8npqTFxUFvtnBHVR1dgm7HRMcrNPPbJjv+3k4DEE3PAUwdWCCgI2ap88jai5MSj8 ijHQcsd5Uy2WdFtKLWEj9iq6/zXtC/02Fqcp089tiaF0utVWOP8jy/dIKlhcTQJKXKZq EVgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=U20G6SPISUmCQtJUMVhCLWwWg2mGaPuhojg4pOErGpY=; b=ltS79AUg/cr1U3u5JvGrjM+USsx/FzBkEM/FXp7bAxpabx/qrX6l0roHCfvL7UkWUe 7qYhBZra3GkKFvMmMP9Gze46nNwPm1ICJGN85VO8lB+BXxt61m8wyk4UYqTHhYhVZdYA AEenz4MsO9P1nf/idSqnpXgRqVjW3T9AlutBetMcbxFcrh3DeB5gAJFs8H66LILzFwsn iuB6r/DEZ+REq1eJvHYup2jmzqPxvRQg0DHMg2vfFNpTHFoezpq5w9qOOGQLNO2rvH85 iFn+xdinTSifnLhOKCuoO9AnMtsjK5hgYaFdcpSr4VY2tnn1FvPApdPz7wdYTvPx0Tu0 e8lQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: ALQs6tB3l/Y8feuhO3ndzbxUnJ0sws5uC5SiTDpSnWmqPVru0/cPcA5Q XnakiR8rYTzMTOAnTVQeOz4= X-Google-Smtp-Source: AB8JxZqlrulNQ5cndIoGoIGOC18TLxe0S5MF69arCL0y4q2zO330yXA4WBheVewNEyiMTrmImUgL7g== X-Received: by 10.28.247.18 with SMTP id v18mr8866wmh.2.1525695187074; Mon, 07 May 2018 05:13:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a50:c441:: with SMTP id w1-v6ls8144802edf.1.gmail; Mon, 07 May 2018 05:13:06 -0700 (PDT) X-Received: by 2002:aa7:d40f:: with SMTP id z15-v6mr11571650edq.9.1525695186413; Mon, 07 May 2018 05:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525695186; cv=none; d=google.com; s=arc-20160816; b=Ixz0JS/35Gsl9XoKN+/6xql71qdX2swRWdWOHO0Lyikcnw7IYW5yll0iG5aiyRTtst 9ftnycFDSmPBA3dBouQXkdC/WSQY61Q9aEoGbAPGCmeB+8KPtiNQhuvzUIRvUXi5Ds6H E9ESJrPZ41pifb9hF2imWwdue0ppB0lUfmIdUkSuzwnU14YLjJvQcSIVepr9+Otmg7uF RbSiuBy3ElKhEXdHbI9mLjNth7ubdRMfTSX3GhS6n8rleLEsk3UK9WfvbTvojXExiqhs H55Wihsb1owM2dhlOYAqqXHbHcmCxpMPFlx23f+4ACM45n9WsGCQo5xhds4MzcO2pESY WtYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=v/d35hTRqmi1tTYPZZagz1tQxljATdflIXcd2du2VEI=; b=AsN/pja00OqPEzmfjA71PKsqKrdRufD8YYpY0xxxZQ5aO5W9JbVfI4TTr/YCiAz+Cb 95KEeX3RK5wjMh7UGHBAsUxEquJ6/2gFi1+4B9CddLHB5AaLHz+AACxKU1A05AZm3fHw id9kAbKAJq7J+2t3HMC6FF3gDpVKtSKICL3l/ukuVlxkjB8tn8RPHZIWNur5lQipwcwD myX8CGbIt6cAqPTcTRaktonJDA9O/zIF6q9qUIFG+bOy/1KmkJ3GO2ew3I4FQPlcH198 31MRb46gUuX62HpZiQnXF1mC0dMmI0fyok7/CobHC/u1NayXLxHHmjxuz5lGjFiJBJJF HuGQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=raphael.freudiger@siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id u9-v6si953488edp.3.2018.05.07.05.13.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 05:13:05 -0700 (PDT) Received-SPF: pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w47CD5M8018847 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 7 May 2018 14:13:05 +0200 Received: from dev.vm6.ccp.siemens.com (MD1AT2FC.ad001.siemens.net [139.16.79.173]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id w47CD5ld004404; Mon, 7 May 2018 14:13:05 +0200 Received: from dev.vm6.ccp.siemens.com (localhost [127.0.0.1]) by dev.vm6.ccp.siemens.com (Postfix) with ESMTP id E9052343AEE3; Mon, 7 May 2018 14:13:04 +0200 (CEST) From: Raphael Freudiger To: swupdate@googlegroups.com Cc: Raphael Freudiger Subject: [swupdate] [meta-swupdate][PATCH 1/3] swupdate_class: split out a base class Date: Mon, 7 May 2018 14:12:49 +0200 Message-Id: <20180507121251.13088-1-raphael.freudiger@siemens.com> X-Mailer: git-send-email 2.11.0 X-Original-Sender: raphael.freudiger@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=raphael.freudiger@siemens.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , The base class can be used in images directly instead of a separate update image. This is useful when only files from one image are used anyway. Signed-off-by: Raphael Freudiger --- classes/swupdate-base.bbclass | 177 ++++++++++++++++++++++++++++++++++++++++++ classes/swupdate.bbclass | 158 +------------------------------------ 2 files changed, 178 insertions(+), 157 deletions(-) create mode 100644 classes/swupdate-base.bbclass diff --git a/classes/swupdate-base.bbclass b/classes/swupdate-base.bbclass new file mode 100644 index 0000000..d46375d --- /dev/null +++ b/classes/swupdate-base.bbclass @@ -0,0 +1,177 @@ +# Copyright (C) 2015 Stefano Babic +# +# Some parts from the patch class +# +# swupdate allows to generate a compound image for the +# in the "swupdate" format, used for updating the targets +# in field. +# See also http://sbabic.github.io/swupdate/ +# +# +# To use, add swupdate to the inherit clause and set +# set the images (all of them must be found in deploy directory) +# that are part of the compound image. + +DEPENDS += "${@ 'openssl-native' if d.getVar('SWUPDATE_SIGNING', True) else ''}" +SWUPDATE_DIR ?= "${IMGDEPLOYDIR}" + +def swupdate_is_hash_needed(s, filename): + with open(os.path.join(s, "sw-description"), 'r') as f: + for line in f: + if line.find("@%s" % (filename)) != -1: + return True + return False + +def swupdate_get_sha256(s, filename): + import hashlib + + m = hashlib.sha256() + + with open(os.path.join(s, filename), 'rb') as f: + while True: + data = f.read(1024) + if not data: + break + m.update(data) + return m.hexdigest() + +def swupdate_write_sha256(s, filename, hash): + write_lines = [] + + with open(os.path.join(s, "sw-description"), 'r') as f: + for line in f: + write_lines.append(line.replace("@%s" % (filename), hash)) + + with open(os.path.join(s, "sw-description"), 'w+') as f: + for line in write_lines: + f.write(line) + +def swupdate_getdepends(d): + def adddep(depstr, deps): + for i in (depstr or "").split(): + if i not in deps: + deps.append(i) + + deps = [] + images = (d.getVar('IMAGE_DEPENDS', True) or "").split() + for image in images: + adddep(image , deps) + + depstr = "" + for dep in deps: + depstr += " " + dep + ":do_build" + return depstr + +python do_swuimage () { + import shutil + + workdir = d.getVar('WORKDIR', True) + images = (d.getVar('SWUPDATE_IMAGES', True) or "").split() + s = d.getVar('S', True) + shutil.copyfile(os.path.join(workdir, "sw-description"), os.path.join(s, "sw-description")) + fetch = bb.fetch2.Fetch([], d) + list_for_cpio = ["sw-description"] + + if d.getVar('SWUPDATE_SIGNING', True): + list_for_cpio.append('sw-description.sig') + + for url in fetch.urls: + local = fetch.localpath(url) + filename = os.path.basename(local) + if (filename != 'sw-description'): + shutil.copyfile(local, os.path.join(s, "%s" % filename )) + list_for_cpio.append(filename) + +# SWUPDATE_IMAGES refers to images in the DEPLOY directory +# If they are not there, additional file can be added +# by fetching from URLs + deploydir = d.getVar('DEPLOY_DIR_IMAGE', True) + imgdeploydir = d.getVar('IMGDEPLOYDIR', True) + swupdate_dir = d.getVar('SWUPDATE_DIR', True) + + for image in images: + fstypes = (d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image, True) or "").split() + if not fstypes: + fstypes = [""] + + for fstype in fstypes: + + appendmachine = d.getVarFlag("SWUPDATE_IMAGES_NOAPPEND_MACHINE", image, True) + if appendmachine == None: + imagebase = image + '-' + d.getVar('MACHINE', True) + else: + imagebase = image + + imagename = imagebase + fstype + src = os.path.join(imgdeploydir, "%s" % imagename) + if not os.path.exists(src): + src = os.path.join(deploydir, "%s" % imagename) + if not os.path.exists(src): + bb.fatal("File %s could not be found" % imagename) + dst = os.path.join(s, "%s" % imagename) + shutil.copyfile(src, dst) + list_for_cpio.append(imagename) + + for file in list_for_cpio: + if file != 'sw-description' and swupdate_is_hash_needed(s, file): + hash = swupdate_get_sha256(s, file) + swupdate_write_sha256(s, file, hash) + + signing = d.getVar('SWUPDATE_SIGNING', True) + if signing == "1": + bb.warn('SWUPDATE_SIGNING = "1" is deprecated, falling back to "RSA". It is advised to set it to "RSA" if using RSA signing.') + signing = "RSA" + if signing: + if signing == "CUSTOM": + sign_tool = d.getVar('SWUPDATE_SIGN_TOOL', True) + if sign_tool: + ret = os.system(sign_tool) + if ret != 0: + bb.fatal("Failed to sign with %s" % (sign_tool)) + else: + bb.fatal("Custom SWUPDATE_SIGN_TOOL is not given") + elif signing == "RSA": + privkey = d.getVar('SWUPDATE_PRIVATE_KEY', True) + if not privkey: + bb.fatal("SWUPDATE_PRIVATE_KEY isn't set") + if not os.path.exists(privkey): + bb.fatal("SWUPDATE_PRIVATE_KEY %s doesn't exist" % (privkey)) + passout = d.getVar('SWUPDATE_PASSWORD_FILE', True) + if passout: + passout = "-passin file:'%s' " % (passout) + else: + passout = "" + signcmd = "openssl dgst -sha256 -sign '%s' %s -out '%s' '%s'" % ( + privkey, + passout, + os.path.join(s, 'sw-description.sig'), + os.path.join(s, 'sw-description')) + if os.system(signcmd) != 0: + bb.fatal("Failed to sign sw-description with %s" % (privkey)) + elif signing == "CMS": + cms_cert = d.getVar('SWUPDATE_CMS_CERT', True) + if not cms_cert: + bb.fatal("SWUPDATE_CMS_CERT is not set") + if not os.path.exists(cms_cert): + bb.fatal("SWUPDATE_CMS_CERT %s doesn't exist" % (cms_cert)) + cms_key = d.getVar('SWUPDATE_CMS_KEY', True) + if not cms_key: + bb.fatal("SWUPDATE_CMS_KEY isn't set") + if not os.path.exists(cms_key): + bb.fatal("SWUPDATE_CMS_KEY %s doesn't exist" % (cms_key)) + signcmd = "openssl cms -sign -in '%s' -out '%s' -signer '%s' -inkey '%s' -outform DER -nosmimecap -binary" % ( + os.path.join(s, 'sw-description'), + os.path.join(s, 'sw-description.sig'), + cms_cert, + cms_key) + if os.system(signcmd) != 0: + bb.fatal("Failed to sign sw-description with %s" % (privkey)) + else: + bb.fatal("Unrecognized SWUPDATE_SIGNING mechanism."); + + line = 'for i in ' + ' '.join(list_for_cpio) + '; do echo $i;done | cpio -ov -H crc >' + os.path.join(swupdate_dir,d.getVar('IMAGE_NAME', True) + '.swu') + os.system("cd " + s + ";" + line) + + line = 'ln -sf ' + d.getVar('IMAGE_NAME', True) + '.swu ' + d.getVar('IMAGE_LINK_NAME', True) + '.swu' + os.system("cd " + swupdate_dir + "; " + line) +} diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass index 02db631..6ad16d4 100644 --- a/classes/swupdate.bbclass +++ b/classes/swupdate.bbclass @@ -11,59 +11,12 @@ # To use, add swupdate to the inherit clause and set # set the images (all of them must be found in deploy directory) # that are part of the compound image. +inherit swupdate-base S = "${WORKDIR}/${PN}" -DEPENDS += "${@ 'openssl-native' if d.getVar('SWUPDATE_SIGNING', True) else ''}" IMAGE_DEPENDS ?= "" -def swupdate_is_hash_needed(s, filename): - with open(os.path.join(s, "sw-description"), 'r') as f: - for line in f: - if line.find("@%s" % (filename)) != -1: - return True - return False - -def swupdate_get_sha256(s, filename): - import hashlib - - m = hashlib.sha256() - - with open(os.path.join(s, filename), 'rb') as f: - while True: - data = f.read(1024) - if not data: - break - m.update(data) - return m.hexdigest() - -def swupdate_write_sha256(s, filename, hash): - write_lines = [] - - with open(os.path.join(s, "sw-description"), 'r') as f: - for line in f: - write_lines.append(line.replace("@%s" % (filename), hash)) - - with open(os.path.join(s, "sw-description"), 'w+') as f: - for line in write_lines: - f.write(line) - -def swupdate_getdepends(d): - def adddep(depstr, deps): - for i in (depstr or "").split(): - if i not in deps: - deps.append(i) - - deps = [] - images = (d.getVar('IMAGE_DEPENDS', True) or "").split() - for image in images: - adddep(image , deps) - - depstr = "" - for dep in deps: - depstr += " " + dep + ":do_build" - return depstr - IMGDEPLOYDIR = "${WORKDIR}/deploy-${PN}-swuimage" do_swuimage[dirs] = "${TOPDIR}" @@ -91,115 +44,6 @@ python () { d.appendVarFlag('do_swuimage', 'depends', deps) } -python do_swuimage () { - import shutil - - workdir = d.getVar('WORKDIR', True) - images = (d.getVar('SWUPDATE_IMAGES', True) or "").split() - s = d.getVar('S', True) - shutil.copyfile(os.path.join(workdir, "sw-description"), os.path.join(s, "sw-description")) - fetch = bb.fetch2.Fetch([], d) - list_for_cpio = ["sw-description"] - - if d.getVar('SWUPDATE_SIGNING', True): - list_for_cpio.append('sw-description.sig') - - for url in fetch.urls: - local = fetch.localpath(url) - filename = os.path.basename(local) - if (filename != 'sw-description'): - shutil.copyfile(local, os.path.join(s, "%s" % filename )) - list_for_cpio.append(filename) - -# SWUPDATE_IMAGES refers to images in the DEPLOY directory -# If they are not there, additional file can be added -# by fetching from URLs - deploydir = d.getVar('DEPLOY_DIR_IMAGE', True) - imgdeploydir = d.getVar('IMGDEPLOYDIR', True) - - for image in images: - fstypes = (d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image, True) or "").split() - if not fstypes: - fstypes = [""] - - for fstype in fstypes: - - appendmachine = d.getVarFlag("SWUPDATE_IMAGES_NOAPPEND_MACHINE", image, True) - if appendmachine == None: - imagebase = image + '-' + d.getVar('MACHINE', True) - else: - imagebase = image - - imagename = imagebase + fstype - src = os.path.join(deploydir, "%s" % imagename) - dst = os.path.join(s, "%s" % imagename) - shutil.copyfile(src, dst) - list_for_cpio.append(imagename) - - for file in list_for_cpio: - if file != 'sw-description' and swupdate_is_hash_needed(s, file): - hash = swupdate_get_sha256(s, file) - swupdate_write_sha256(s, file, hash) - - signing = d.getVar('SWUPDATE_SIGNING', True) - if signing == "1": - bb.warn('SWUPDATE_SIGNING = "1" is deprecated, falling back to "RSA". It is advised to set it to "RSA" if using RSA signing.') - signing = "RSA" - if signing: - if signing == "CUSTOM": - sign_tool = d.getVar('SWUPDATE_SIGN_TOOL', True) - if sign_tool: - ret = os.system(sign_tool) - if ret != 0: - bb.fatal("Failed to sign with %s" % (sign_tool)) - else: - bb.fatal("Custom SWUPDATE_SIGN_TOOL is not given") - elif signing == "RSA": - privkey = d.getVar('SWUPDATE_PRIVATE_KEY', True) - if not privkey: - bb.fatal("SWUPDATE_PRIVATE_KEY isn't set") - if not os.path.exists(privkey): - bb.fatal("SWUPDATE_PRIVATE_KEY %s doesn't exist" % (privkey)) - passout = d.getVar('SWUPDATE_PASSWORD_FILE', True) - if passout: - passout = "-passin file:'%s' " % (passout) - else: - passout = "" - signcmd = "openssl dgst -sha256 -sign '%s' %s -out '%s' '%s'" % ( - privkey, - passout, - os.path.join(s, 'sw-description.sig'), - os.path.join(s, 'sw-description')) - if os.system(signcmd) != 0: - bb.fatal("Failed to sign sw-description with %s" % (privkey)) - elif signing == "CMS": - cms_cert = d.getVar('SWUPDATE_CMS_CERT', True) - if not cms_cert: - bb.fatal("SWUPDATE_CMS_CERT is not set") - if not os.path.exists(cms_cert): - bb.fatal("SWUPDATE_CMS_CERT %s doesn't exist" % (cms_cert)) - cms_key = d.getVar('SWUPDATE_CMS_KEY', True) - if not cms_key: - bb.fatal("SWUPDATE_CMS_KEY isn't set") - if not os.path.exists(cms_key): - bb.fatal("SWUPDATE_CMS_KEY %s doesn't exist" % (cms_key)) - signcmd = "openssl cms -sign -in '%s' -out '%s' -signer '%s' -inkey '%s' -outform DER -nosmimecap -binary" % ( - os.path.join(s, 'sw-description'), - os.path.join(s, 'sw-description.sig'), - cms_cert, - cms_key) - if os.system(signcmd) != 0: - bb.fatal("Failed to sign sw-description with %s" % (privkey)) - else: - bb.fatal("Unrecognized SWUPDATE_SIGNING mechanism."); - - line = 'for i in ' + ' '.join(list_for_cpio) + '; do echo $i;done | cpio -ov -H crc >' + os.path.join(imgdeploydir,d.getVar('IMAGE_NAME', True) + '.swu') - os.system("cd " + s + ";" + line) - - line = 'ln -sf ' + d.getVar('IMAGE_NAME', True) + '.swu ' + d.getVar('IMAGE_LINK_NAME', True) + '.swu' - os.system("cd " + imgdeploydir + "; " + line) -} - COMPRESSIONTYPES = "" PACKAGE_ARCH = "${MACHINE_ARCH}" From patchwork Mon May 7 12:12:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raphael Freudiger X-Patchwork-Id: 909718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4010:c07::23f; helo=mail-lf0-x23f.google.com; envelope-from=swupdate+bncbaabbw4fyhlqkgqeroiijky@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="tST+etLp"; dkim-atps=neutral Received: from mail-lf0-x23f.google.com (mail-lf0-x23f.google.com [IPv6:2a00:1450:4010:c07::23f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40fhNG65hJz9s34 for ; Mon, 7 May 2018 22:13:18 +1000 (AEST) Received: by mail-lf0-x23f.google.com with SMTP id o98-v6sf3829224lfg.2 for ; Mon, 07 May 2018 05:13:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1525695195; cv=pass; d=google.com; s=arc-20160816; b=VZUeYzZzZmX2uXUwOmRqqXxuX7ObY73PcVE8sz83bLvR3RXuimxh1eKovGzd+LNoFR 1iHmRbqNZQO/XkzHj/kjftt1degfP/0M4iudLC9Xa97+f7JVzfeo41H6/KnarUAMP2WJ 1WANcTHYIJtRaAJTwK8rbtsaBD6rEIkipnrvE4RLUVAzEaYJA7oJnN5wuaof4BT5B9dp JZcdZ5l2tOFfsxpBfheZtmxN2dQmiwKmGYtDcXRLkx2aUOlpEeR4wIC9Y9bPcQCGC4oh yzTgD+E3wQ5l7IWt+xb0RkvGwGTz1SSzKYt2H3UHeLaf/EcTEuRfZfYRt4qdNtQdyJKJ UGww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=HB32dpDW3ud3CypnjtF4y1lqLV8txD05o07FFkLO+9M=; b=o+OIrlmHp+fJCIfVu4m9gvvVFumpEfQQabwZp4JXhSI1/fWFnJ0wz/RjIox+KRYU4O 9eA02VCqF2v9z/8/Px+nu2rVfYmoX6KisiUJFaUlJRUSBLw/q2kUXlo7nDhuCyTi/W3e Gghuvxd4gc0sbyqdkFh9biyq3eUevqIuFSjTXjnhhAIE6V2GOwuR0qUilDUro5iwHC2x x3cBOwWk3zDOu8txy10JdvvlzJspzxaIt4lP4nU5pipch6V9J3rrVXPdkU9t5RkC0RF5 Ng3B61qZbXsqvJ6QLVxhpCMf8jeWVb4lLICFaUrVOCT8NFOEl4CTRLXLdCsAoUqpJS58 7luA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=raphael.freudiger@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=HB32dpDW3ud3CypnjtF4y1lqLV8txD05o07FFkLO+9M=; b=tST+etLpnNNaZRnaG251k7XyokValO6CMmzUX+/JKaNmRyjU1k2IULuFhX43q/pCkp ww7mQ8sSREAxa25i1h/fIGtt+zqNKLD64OlMlW68aZ0nwPmh+atGoWnkZAmcy6TD7N6c OTBcJIBlLVvFXtWCUIVPFJ14+08a5TBkCb8wlmSaE/O+Vbu1Z4O94FPtM2esxcTe0/uo 8RPam33IqQy/eZUiG7Jr8BuJT0C1HJKtHSnkqOxGSf/De7UsG1KTQD3WJrQtJvIwewaA Hw+4K42ehWm/cYbvf4GuvmV2CUKX39IBUHLveJb9PrBAFf93gLkVFI4xLKPIhXWedWVX y4BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=HB32dpDW3ud3CypnjtF4y1lqLV8txD05o07FFkLO+9M=; b=KTS8UlIIm/sO9PDs0H3mSuV7MPYUhtCOuVIlaReMA22+DkhLOAEnGdrmX0jBZINjfz fcEH2J/eHxAeR7GgKKV0zWfBuvbZaNd1sVMf06JwacVzg3kHislMlL3XCWyyPHYs6Cp3 N+fR+jHMyGeVnDhxDEmFR8jB8UT2MulbY3gbzUgEFZwfasHDw2Hke0Mtitnrh4fnJ87M njn7OY2QryDKyvXZG64Kw30kw79BPn1KyPp7cQis5eqqSgLYdDTdxYgiBCpLSrLpYqim GFx7Op2zg2N2An40LRIF5zepeuxKxTnLPSQ2LqcgP0Nlip8x3oOrjmMj3DtIKW7MRW9J fKRw== Sender: swupdate@googlegroups.com X-Gm-Message-State: ALQs6tD18TViEkUS5jEJREzKsubhnOUJkcVfg+ScDIrXBtUZ1CQbHLzj mT1y8iq72/oN9yZ9IlyDlXQ= X-Google-Smtp-Source: AB8JxZqhgUS+vWUKrAJ8Cu3FTJLNQhCw3l4Svk9ND47cK2Yt3tWubgazL2HiO91nm8k8qtib9OwOeQ== X-Received: by 2002:a2e:9f03:: with SMTP id u3-v6mr34456ljk.0.1525695195675; Mon, 07 May 2018 05:13:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:db9d:: with SMTP id t29-v6ls1267591lfi.7.gmail; Mon, 07 May 2018 05:13:15 -0700 (PDT) X-Received: by 2002:a19:93d6:: with SMTP id w83-v6mr1281608lfk.16.1525695195145; Mon, 07 May 2018 05:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525695195; cv=none; d=google.com; s=arc-20160816; b=BwqQkvLRQilwXsLs4RwSQKDoGSxC/zde1KyCs1P2eYNb0TDRqUajt6TLffV06Hq6UC cxxJ/CaKONZrloabSPlh7sUSyXB+goHM/d14aUgccLkgsnG10GFeDz8AcC4sXOCn06RS 7dgwmyMWbsUdWIbsULd0Ei7E6zNTOuSoyBKkaPjoI/TiCtaN5RGzcGjYOtgFYc/HI5/d ABU0Le8wJhdvmVwMcxwogdu71isHhKwd+7G8uJkyT0iCLmRIu5PwYzbQa/Yt3AZszhhd tbM5M2fBuPSIZUMJ8jscIUB4dr4j7OCpd8IlEzyBwCMfsT41MXfED8c/Y2kF/iBQjEC2 +zEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/oN0NSxq8NupYZawRZpp9BdmTNF2DeUruhnAaUzGrvQ=; b=PDQNhAASEZ+Iy+lZaz+C+UAX0o8qn6h5oQngJdiA2hmy5D+Ac4/jPozqIermrF4ZoO qLWOsk9R6Fq7q7oOZfQiUsjYeYEvwG3eSVOd96KAPzr+c+zr7cCXUIWxoP9pj0dR83qc MZKtXyNjW6lp6Ko+b9gxJZFTnGDbZ4tjeAmRlaBNawD78MXMwduPs3kq79tiO1bN4+jl BTq5a0m39LhFjLSNXo7LmFzoansVw/6semlA1fti9R5QOo64OdDmnPKtvxatImo3zbbK 9iybnugy6eF9lRWQg3uE4el3avRDNjveM2y6dNOAaBsNOjp6QK5jI5VUTjFtYo0TX0Fc Rw3A== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=raphael.freudiger@siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id b65-v6si795300ljb.1.2018.05.07.05.13.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 05:13:15 -0700 (PDT) Received-SPF: pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w47CDE0G019052 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 7 May 2018 14:13:14 +0200 Received: from dev.vm6.ccp.siemens.com (MD1AT2FC.ad001.siemens.net [139.16.79.173]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w47CDDrR018943; Mon, 7 May 2018 14:13:14 +0200 Received: from dev.vm6.ccp.siemens.com (localhost [127.0.0.1]) by dev.vm6.ccp.siemens.com (Postfix) with ESMTP id CAECB343AEE3; Mon, 7 May 2018 14:13:13 +0200 (CEST) From: Raphael Freudiger To: swupdate@googlegroups.com Cc: Raphael Freudiger Subject: [swupdate] [meta-swupdate][PATCH 2/3] swupdate_class: do not add all files that are fetched Date: Mon, 7 May 2018 14:12:50 +0200 Message-Id: <20180507121251.13088-2-raphael.freudiger@siemens.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180507121251.13088-1-raphael.freudiger@siemens.com> References: <20180507121251.13088-1-raphael.freudiger@siemens.com> X-Original-Sender: raphael.freudiger@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=raphael.freudiger@siemens.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , If swupdate is used in an image it will add all files that are fetched to the swupdate file. Let bitbake do the fetching and only add to the image what is explicitly listed. Signed-off-by: Raphael Freudiger --- classes/swupdate-base.bbclass | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/classes/swupdate-base.bbclass b/classes/swupdate-base.bbclass index d46375d..29cfe5f 100644 --- a/classes/swupdate-base.bbclass +++ b/classes/swupdate-base.bbclass @@ -67,24 +67,17 @@ python do_swuimage () { workdir = d.getVar('WORKDIR', True) images = (d.getVar('SWUPDATE_IMAGES', True) or "").split() + extra_images = (d.getVar('SWUPDATE_EXTRA_IMAGES', True) or "").split() s = d.getVar('S', True) shutil.copyfile(os.path.join(workdir, "sw-description"), os.path.join(s, "sw-description")) - fetch = bb.fetch2.Fetch([], d) list_for_cpio = ["sw-description"] if d.getVar('SWUPDATE_SIGNING', True): list_for_cpio.append('sw-description.sig') - for url in fetch.urls: - local = fetch.localpath(url) - filename = os.path.basename(local) - if (filename != 'sw-description'): - shutil.copyfile(local, os.path.join(s, "%s" % filename )) - list_for_cpio.append(filename) - # SWUPDATE_IMAGES refers to images in the DEPLOY directory # If they are not there, additional file can be added -# by fetching from URLs +# by fetching from URLs and adding them to SWUPDATE_EXTRA_IMAGES deploydir = d.getVar('DEPLOY_DIR_IMAGE', True) imgdeploydir = d.getVar('IMGDEPLOYDIR', True) swupdate_dir = d.getVar('SWUPDATE_DIR', True) @@ -112,6 +105,8 @@ python do_swuimage () { shutil.copyfile(src, dst) list_for_cpio.append(imagename) + list_for_cpio += extra_images + for file in list_for_cpio: if file != 'sw-description' and swupdate_is_hash_needed(s, file): hash = swupdate_get_sha256(s, file) From patchwork Mon May 7 12:12:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raphael Freudiger X-Patchwork-Id: 909717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c09::23d; helo=mail-wm0-x23d.google.com; envelope-from=swupdate+bncbaabbxefyhlqkgqec2klk5i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=siemens.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="PUOAmq8e"; dkim-atps=neutral Received: from mail-wm0-x23d.google.com (mail-wm0-x23d.google.com [IPv6:2a00:1450:400c:c09::23d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40fhNH3QYbz9s37 for ; Mon, 7 May 2018 22:13:19 +1000 (AEST) Received: by mail-wm0-x23d.google.com with SMTP id 70sf2227027wmb.2 for ; Mon, 07 May 2018 05:13:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1525695196; cv=pass; d=google.com; s=arc-20160816; b=cYvPnS/LCXeDzoS/t70K662fOSLC0/TFyIv69X4NcCcKx+NfJuBwoaGkAl2dfKLQR/ vxHsHgoZLEFtzZOFFVAT+HLUwzH+Rms0tbdQlyHpjZ8pStYNpTV1VAgRew48ukgj7XlG oodrdDZuZ2shMLkgG0Sg9l5pZxAGPXkhaxY5SEQSqv+3N3rwhapapc7IlUsJWloSeDE8 SsD4ngNqycDd9Ai/A2u8ZwwbgZLLB7D2EEmTTDT5JBEac+WVrHI2Ar6oQa7r5zAQyIda ADvcEghYtBQ85O4/GvoIQ+GEOPFRF4xswITRvNZtPladC30AhLm5sCxEz8O1PeE5NcZ6 MGNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=Ub4Kj9SJs0CrKsHpUMQvR+cAo6sZ+SkXyo9p6cTeNac=; b=SpcDvr1K5PO8WhTHL1Gf9gxHJD6B8OHibiawip9xcctbd7AorOOk3qbR7DSzN+3De3 zzg72W6M+81ueVvpDqcCvURYUMPdMs7iSC10a+uawr5H0DynW8GTCprRthQcMWKLHSoE lU/v8LbzbGP8jDClxMNFsmkolqDFToXhYXEtpXnOLX4EWJ4V5ZNG58f+NrtKZIZQL1V8 tp8yJWOfn+dtoisSXYZAumNoYCyr6AASGG9flPtXxU7d/AKQayGlQmNyS3ShAyB5qnWT V2Fj0/OlkCxMdoHHW/kO+Puqq4vn6PtpJr5tdnQCYPLdL/I1ZeLOQ9JUJ0roXSsAUAw5 Q4JA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=raphael.freudiger@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Ub4Kj9SJs0CrKsHpUMQvR+cAo6sZ+SkXyo9p6cTeNac=; b=PUOAmq8eirIgN7y/O2HubmEpx0rFYzbAsyXpvJMfQ0iaZf/i0x86Y96i2v7w7o9fPJ jNECBf2nFzdi6z/tWxFG8J9GgjAoRcPeJiorLBWMnTKMWy7e2U7Nn+xZuAkZABwShHpr VUS8z3lz4ox+r19IDQB5T6RWzEfs3QNk3GJ1U2dXLJjg+oFTR9W6G/1jJksPvYqXx7EI bpyl5QbHjzpLIxKRtKwXYyI+hkg/e8AYfCA9Ur+WYsAh5XHY1y5lRiXAf8jJcMURE10E 923itoiLUJ8SKJzz4or6PR/AyjzIoAe5uZbAo56HKMTSIKst0XdnuzUGxgIKnP9csJAd IpbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Ub4Kj9SJs0CrKsHpUMQvR+cAo6sZ+SkXyo9p6cTeNac=; b=kHpKTG+gXxY6C3e2eyiQng4wk+ZgEfBJwGnTwrpSAW95m2agNPNlJNdRzz0YNSN6rB A/l9Os2Qsd+bxE5AB53rkDlAM82yDLX6WizWCJkVIW+C7psX3DT4nsdc5R1xDUBTLgfJ KNJDE4kRGwKX8VhJaeZL5eKaArS1fu3jv0U5zvT0UIi7uGK57Z/mzvXznsP+TXPGJC+9 /22Xt2+4IRJnCe7u1er0nM2MNabAOBffKE+F3f19+N/RTiv3St4XqxYsXtEFFs4kIm/c ZTR23CTaqS9uv5Mmg+Ozjl5/2DePz3ZrCZ9AAN5nmmWPfnPMM1BTfOb35HyTQfPEKHT8 2D+Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: ALKqPwdYpNnJcvBo8mezxnCp/2h0ZJImcIn5saTbzszBVsQtafZBbXdZ CQ4+QCQOskBsuhLKu2HIZoo= X-Google-Smtp-Source: AB8JxZo7LBuvf+ATgMLqOq1jjd9ub3ROebqzQYxOGub4cZH23hqPzoqm8FX3nob/l880npOsC/9Hyw== X-Received: by 2002:a1c:9e15:: with SMTP id h21-v6mr8136wme.5.1525695196708; Mon, 07 May 2018 05:13:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:9a4f:: with SMTP id z73-v6ls6943377wrb.12.gmail; Mon, 07 May 2018 05:13:16 -0700 (PDT) X-Received: by 2002:adf:e544:: with SMTP id z4-v6mr3159001wrm.6.1525695196248; Mon, 07 May 2018 05:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525695196; cv=none; d=google.com; s=arc-20160816; b=WwZbV5JLqfVefD1PnEM3Y/nXDS9zrc8TPc+J+iyTbib4PGY78tjRr8kZnLBgiddQYZ iDW0Ri957H1q96hQ5rUJs057pF6lSsjCC7CGp99ucn2TooI1gJiW0tZ9t5cDfxIYoAon LRsMYdR0p14s6PebBIeCE/fha+IdUNHy636UdpughYuD3rEejsOFqtDZh7uOXKUfXohG uroFqC82T7NkZIw90CmM+s+e+VVkl/xdR9AXT/S0IdfCQVs3T/wr5520xco/e/BCmQU/ S+I0q6s5nkpmliWFEeXlFhfdTojW8ZzKnvYdYMFoEGK/rgzFry37o3WCs4hifgGXw06H Ujgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=SO9Th3njw6ZOIQeEVaTXaVAOHThNC/uqyQ0ubS7eqzk=; b=CE/etvdQahTlKwyNcG7DjwwFlMYtUjU5BE74RNG9LXygL+GohzgY2DkkVWLn0KJlO+ 1cwdNj12y8yzNytWhwgz/BPZOKEML1QDogVK5LqL+u1YyQ+py8ayZ3w67vZ6cKdqhiSF P7bb+vba+RM2vineRsMLS7cOFxSS5Kn3DOC34TqLH/g0KimjXdCRM16YROANRp8Ip46j U63c6TxNBvV9NceDveU7txsAXbWaA3XADYrR6LkxymkwEN0KXQuI4b79q0K9GtX7T5wQ Z5B8dWvIx+0OR8m31PP0DgsrfM0B17pI449rUcUVeJ6JkB7u/1MH/lSNlLw7v/EiW60v NkXw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=raphael.freudiger@siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id y144-v6si380369wmd.3.2018.05.07.05.13.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 05:13:16 -0700 (PDT) Received-SPF: pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id w47CDFBa019547 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 7 May 2018 14:13:15 +0200 Received: from dev.vm6.ccp.siemens.com (MD1AT2FC.ad001.siemens.net [139.16.79.173]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w47CDFNn019075; Mon, 7 May 2018 14:13:15 +0200 Received: from dev.vm6.ccp.siemens.com (localhost [127.0.0.1]) by dev.vm6.ccp.siemens.com (Postfix) with ESMTP id 9DCDE343AEE3; Mon, 7 May 2018 14:13:15 +0200 (CEST) From: Raphael Freudiger To: swupdate@googlegroups.com Cc: Raphael Freudiger Subject: [swupdate] [meta-swupdate][PATCH 3/3] swupdate_class: use shell function to create swupdate file Date: Mon, 7 May 2018 14:12:51 +0200 Message-Id: <20180507121251.13088-3-raphael.freudiger@siemens.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180507121251.13088-1-raphael.freudiger@siemens.com> References: <20180507121251.13088-1-raphael.freudiger@siemens.com> X-Original-Sender: raphael.freudiger@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=raphael.freudiger@siemens.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Having a separate shell function is better readable and maintainable than the string passed to os.system. Signed-off-by: Raphael Freudiger --- classes/swupdate-base.bbclass | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/classes/swupdate-base.bbclass b/classes/swupdate-base.bbclass index 29cfe5f..46e87a4 100644 --- a/classes/swupdate-base.bbclass +++ b/classes/swupdate-base.bbclass @@ -164,9 +164,16 @@ python do_swuimage () { else: bb.fatal("Unrecognized SWUPDATE_SIGNING mechanism."); - line = 'for i in ' + ' '.join(list_for_cpio) + '; do echo $i;done | cpio -ov -H crc >' + os.path.join(swupdate_dir,d.getVar('IMAGE_NAME', True) + '.swu') - os.system("cd " + s + ";" + line) + d.setVar("LIST_FOR_CPIO", ' '.join(list_for_cpio)) + bb.build.exec_func("create_swu", d) +} + +create_swu() { + cd ${S} + for i in ${LIST_FOR_CPIO} + do + echo $i + done | cpio -ov -H crc > ${SWUPDATE_DIR}/${IMAGE_NAME}.swu - line = 'ln -sf ' + d.getVar('IMAGE_NAME', True) + '.swu ' + d.getVar('IMAGE_LINK_NAME', True) + '.swu' - os.system("cd " + swupdate_dir + "; " + line) + ln -sf ${IMAGE_NAME}.swu ${SWUPDATE_DIR}/${IMAGE_LINK_NAME}.swu }