From patchwork Thu May 17 09:37:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raphael Freudiger X-Patchwork-Id: 915268 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::23a; helo=mail-lf0-x23a.google.com; envelope-from=swupdate+bncbaabbvm26xlqkgqej7i54hi@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="AfGiArHX"; dkim-atps=neutral Received: from mail-lf0-x23a.google.com (mail-lf0-x23a.google.com [IPv6:2a00:1450:4010:c07::23a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40mmRs5dMZz9s1B for ; Thu, 17 May 2018 19:37:29 +1000 (AEST) Received: by mail-lf0-x23a.google.com with SMTP id 18-v6sf1738340lfy.22 for ; Thu, 17 May 2018 02:37:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1526549845; cv=pass; d=google.com; s=arc-20160816; b=N0Yr5unilwZVE10bI2UAtKlpK+ICcLboS7U1Ayg4RFfcfuZ+Yp8euMkG5M4nRm5ibI saNpnS6w9ZjNS8fpgScdXv/6g5ZgUwjL7QuB8KHZLRPi5aB/P59s34WDhRjV+2CH54sb EHgd76LAnrQibqYKzdWyGDE0NnmLYCt92kQvIT6eV1/ZbJDJAyCXPclInronT0jrdynl UwGrAam8RWFJArbCfyqWifBjoDZhc/JKfvKDjRkiRdMKjTuUd2jzWvIrUdh4xyQqsdW2 rgJYmcTWSeW6L3Fkib3aicdkSbY2o9GmWSHeR5QBl9rIsanfDC4kmCy9TqkjnjKWBT5C jM6Q== 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=G/JDl6eiMNwr5u2wHmH8iq1rc6eEvJd3gNGL/ocULqA=; b=K+2RkPAmqJdwBFgSr4G/PSmZ1A/G0B69El0w0vOR0EmhVW8NjNNaFcJoS813w2XbFA a0TY4i6ftod0yPjnvfXs6UcOqn6V3XqcovC0Ykzyiwaf5ilah6rxJvajWIEi6bKD96Pq gcjme9Zed9TIoAmus9trhVK9YL6HQAYk+8DR3KsV63jw5bnkktYgt87arJZYLiB1O2xF 6zDAEGdvkCK7VOZYVMthsMUzRahRs4PkmSaFmUAIyn4MsNXZrEMWT9s3ZrezQPuBoKM8 2Z50wdeJ9hv/ocY0GVwRJE7BsenqNJPkurP0NTGyVkonHBtGIxZqyDW/ASCvcVUXDjlI OrUw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.28 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=G/JDl6eiMNwr5u2wHmH8iq1rc6eEvJd3gNGL/ocULqA=; b=AfGiArHX4lMz88rcsrMAHRLGLIxNmaMPPuQ3ULG81t00H6rynP2Yn8fBKt0/nW8Nnb IqQLixCJXpfEvX4RHbM6EdTIs0xEbWXsQBJQZo2sA3y6fcp5JUevZa0+NUFtc6ctcLN9 iAoYMSxOh6okCqkvfaY+Pz4Dtvpf6cKT7pLdHJ8AkG+lsncME2Cc3AacZL48cAXw+lmN hwYKEyHH2+Fhh3KOrSiu9b4LljYUsSxPnJAb+Qy7Bs5ke+OSIk7W/JNj7o/3QCfJHG6I jiVeOuXz++JFwBi1/KFC4r8d8ZKylhUBVGItBryRknPAAoU/ZF49pbiJyw6bLzyHNRg7 j7/w== 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=G/JDl6eiMNwr5u2wHmH8iq1rc6eEvJd3gNGL/ocULqA=; b=O2lFc3HmvlFuTbtPLgWZfDqqMzMKO4eBljhpAucQSRKcRp+ViqgFpdNQvK4+Kovf5i DbzyGbQvTBw69bej2ekz9xA6MR11sF53AdxqBF8b7f/BflxoKZNMDvwfjpgpJOAbCOLq +kAVNN8CKHq9vnxR5vGsFQY1qVV0F3ec8OFYEo4BjPMFUyqrgDZZSzUPHadJcU/BH7bu 8NftV4aSlZIsKu+EdvKpLAzQsXcDhyQpVUHE6O49IGPESBkLOPgFCSrMPte1SjXVQG4D 51P8zuuFyG+cecMo7FRKCzvq2DjSrhtd7p1gKopGAXDMVoVF9CdAqknSdpkQ5HbFfBah ItDg== Sender: swupdate@googlegroups.com X-Gm-Message-State: ALKqPwcTx7R8DNNk42FL5wiAaiOZ3hfB5Q18KP6g6Ck7RkEf0bJCOrk1 S8iWIx0idxMa1jg7cLox3Zc= X-Google-Smtp-Source: AB8JxZrOxxyG3A7DDqeEG8G8IIwJqnKvdWxhAiv9eNh8LHnZwjW2wbEYxRscTEYJL8ZGyKxNYaTo5g== X-Received: by 2002:a2e:9790:: with SMTP id y16-v6mr15862lji.8.1526549845471; Thu, 17 May 2018 02:37:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:51d2:: with SMTP id g79-v6ls349903lfl.8.gmail; Thu, 17 May 2018 02:37:24 -0700 (PDT) X-Received: by 2002:a19:c793:: with SMTP id x141-v6mr1550198lff.33.1526549844917; Thu, 17 May 2018 02:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526549844; cv=none; d=google.com; s=arc-20160816; b=EMun2KXdUm+F5TgRE1jFQnUbdSJqlp6oVf8iD7fUIKMLN9p7EgkC/keQATo/VrRTk1 ZIa8rbPb0KJeiXQsf93E0OfEvmM5M3Nf1XTxBNfUTzx5bjYnlnu/lpY+5iI+2opLzDhy K9RoqfpJpyjeadzBqDqptolkLw27+G/MCfvnDuY2L8G+LyN0o5R00HcxwqUHXnZ6Tcus A4qlMeN++Sz8G3xjb8tTAHY0U55daDY+NJiDPct2FkMahtxfgKs+l+qs7uLW6bDBvpdW hU11alV69JVj4MNzK8zrubYxqTxTOvWu9rp3oPxFJ2L2jgpYpX0zERhfN9OCooFShJBG 3O8Q== 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=XKYojere6B/0cZ3sb3zd8UEKZCB4ViGJPXOttJ1Ee8U=; b=K0xFZ12Qc1wJLIWzGRHkBE1tCvzA5F3iHPpelp8+c2oiE27tskMdZAmZF8QCEmJ/0R v7dS0NRBzbcGGzgXzfbGmvrjvaxwcQ3ArGUMdKR88rf+bbACoBER1wNXfXGm5SvJRhz9 wc5Q9E9TuJWviTV2bs3KarR4SiqiVyv+3o4m07ZCqq1IXd0NVEGoksqsLK2A8KdrC9jC u3x7bps+hmRrkXNUh2ckeJviLpmzRqkEHaVMQx/Pcn6HqxTNz+1tgoIN36T5OVxjAbOx aoA45vkjF0AX44cyYvL1+UswmQV5gvmPQksJSJOplrpgPzpUdU/89bCERhwRSpTybCYg dcDw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=raphael.freudiger@siemens.com Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id b65-v6si194174ljb.1.2018.05.17.02.37.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 May 2018 02:37:24 -0700 (PDT) Received-SPF: pass (google.com: domain of raphael.freudiger@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w4H9bOJN029457 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 17 May 2018 11:37:24 +0200 Received: from dev.vm6.ccp.siemens.com ([167.87.2.66]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w4H9bN9a008504; Thu, 17 May 2018 11:37:23 +0200 Received: from dev.vm6.ccp.siemens.com (localhost [127.0.0.1]) by dev.vm6.ccp.siemens.com (Postfix) with ESMTP id 931B0343AEE3; Thu, 17 May 2018 11:37:23 +0200 (CEST) From: Raphael Freudiger To: swupdate@googlegroups.com Cc: Raphael Freudiger Subject: [swupdate] [meta-swupdate][PATCH v2 2/2] image_types_swupdate: add swu image type Date: Thu, 17 May 2018 11:37:10 +0200 Message-Id: <20180517093710.4155-2-raphael.freudiger@siemens.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180517093710.4155-1-raphael.freudiger@siemens.com> References: <20180517093710.4155-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.28 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: , Signed-off-by: Raphael Freudiger --- classes/image_types_swupdate.bbclass | 62 ++++++++++++++++++++++++++++++++++++ classes/swupdate-common.bbclass | 4 ++- classes/swupdate.bbclass | 3 +- 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 classes/image_types_swupdate.bbclass diff --git a/classes/image_types_swupdate.bbclass b/classes/image_types_swupdate.bbclass new file mode 100644 index 0000000..d86e936 --- /dev/null +++ b/classes/image_types_swupdate.bbclass @@ -0,0 +1,62 @@ +# Define swupdate image type that can be used in images. +# +# Example Usage: +# +# IMAGE_FSTYPES += "swu" +# IMAGE_TYPEDEP_swu = "ext4.gz" +# SWUPDATE_FILES += "${PN}-${MACHINE}.ext4.gz +inherit swupdate-common + + +SWUPDATE_FILES ?= " \ + sw-description \ + ${@ 'sw-description.sig' if d.getVar('SWUPDATE_SIGNING', True) else ''} \ + " + +IMAGE_CMD_swu () { + cd ${S} + for i in ${SWUPDATE_FILES} + do + echo $i + done | cpio -ov -H crc > ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.swu +} + +python do_prepare_swupdate() { + import shutil + s = d.getVar('S', True) + workdir = d.getVar('WORKDIR', True) + deploydir = d.getVar('DEPLOY_DIR_IMAGE', True) + imgdeploydir = d.getVar('IMGDEPLOYDIR', True) + + swupdate_files = (d.getVar('SWUPDATE_FILES', True) or '').split() + + list_for_cpio = [] + for file in swupdate_files: + imagename = os.path.basename(file) + src = os.path.join(workdir, imagename) + if not os.path.exists(src): + src = os.path.join(deploydir, imagename) + if not os.path.exists(src): + src = os.path.join(imgdeploydir, imagename) + if not os.path.exists(src): + bb.fatal("File %s does not exist in any of the directories %s, %s or %s." + % (imagename, workdir, deploydir, imgdeploydir)) + dst = os.path.join(s, imagename) + shutil.copyfile(src, dst) + list_for_cpio.append(imagename) + d.setVar('SWUPDATE_FILES', ' '.join(list_for_cpio)) + + prepare_sw_description(d) +} + +# The image type needs an additional preparation task, but it should only be executed when needed. +# Check that swu is in the IMAGE_FSTYPES before adding the task. +python () { + fstypes = (d.getVar('IMAGE_FSTYPES', True) or '').split() + dep = (d.getVar('IMAGE_TYPEDEP_swu', True) or '').split() + if 'swu' in fstypes: + # make sure dependencies are build before the preparation + after = ['do_rootfs'] + after += ['do_image_%s' % typ.split('.')[0] for typ in dep] + bb.build.addtask('do_prepare_swupdate', 'do_image_swu', ' '.join(after), d) +} diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass index f53c55f..3fa891c 100644 --- a/classes/swupdate-common.bbclass +++ b/classes/swupdate-common.bbclass @@ -29,7 +29,9 @@ def swupdate_write_sha256(s, filename, hash): for line in write_lines: f.write(line) -def prepare_sw_description(d, list_for_cpio): +def prepare_sw_description(d): + list_for_cpio = (d.getVar('SWUPDATE_FILES', True) or '').split() + s = d.getVar('S', True) for file in list_for_cpio: if file != 'sw-description' and swupdate_is_hash_needed(s, file): diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass index e24b387..df6b3e5 100644 --- a/classes/swupdate.bbclass +++ b/classes/swupdate.bbclass @@ -106,7 +106,8 @@ python do_swuimage () { shutil.copyfile(src, dst) list_for_cpio.append(imagename) - prepare_sw_description(d, list_for_cpio) + d.setVar('SWUPDATE_FILES', ' '.join(list_for_cpio)) + prepare_sw_description(d) 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)