From patchwork Wed Oct 23 21:10:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Freihofer, Adrian" X-Patchwork-Id: 1182486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13f; helo=mail-lf1-x13f.google.com; envelope-from=swupdate+bncbaabb34dypwqkgqeithh2gi@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (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="dEmKe6GW"; dkim-atps=neutral Received: from mail-lf1-x13f.google.com (mail-lf1-x13f.google.com [IPv6:2a00:1450:4864:20::13f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46z32Z4wDFz9sPZ for ; Thu, 24 Oct 2019 08:11:17 +1100 (AEDT) Received: by mail-lf1-x13f.google.com with SMTP id k30sf1429304lfj.5 for ; Wed, 23 Oct 2019 14:11:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1571865071; cv=pass; d=google.com; s=arc-20160816; b=WiquJkZfh6+f9ZpzMawbr8fBaWPrjmWq+/kZTa12tpkm0uZszVAXfjJ498DhQ0nfFR US9tvG0woCFn3B0K1bRuhQzCL9KqrZ1zxociv+lTfOk+1hk3oAXS2M4JMDwsp5diIT7n OAPqQqr6m25QxPMiT9cKedlWT6zUCWNd2vNNvFf5Z46lBsAeOsCB8HFJpifTMn6N5KfH +hfBI21v6Wcq1M6cAIs5/5zyomjvXhh/ggbgP2u65JAquDZlm2HPE11zi51bqVZbVbJ1 TOo7Fskmvdjbg3Dlp0noneUok5KzJwvGx81Lq+2GuLWv03Ge4rMwiUZ57crwEQKqjylC l1jg== 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:mime-version:sender:dkim-signature; bh=ISNBnCjMPPdrDKesl5XmPDvA9z1wPW8Jj9Xsq2GvQIg=; b=B34OftdwljnV62L91tl4NZycpC0qTCjih30Oj4z36OhitJya7QQf4WVAnJ/J83fFRv f/pjcXbiCPyYMUUvGU7vlDx6MxAfZFJ7wKvSXJdHvXQ3HxNVKbl+XUWpvh7jTYebbc0X 7saUlhmbWIzx1MTYbDAZGWKehapwLGknfkkI4y6y9Coo3gs04OYrei4mU2pxw0IAHLcs oTbQbCKaxTtMIJKDjgtIyyiQP/R+kSrIJaPD6JI6rjxJCT8RlrewfSUrJHGr5UMerBIl /IhYOh1ChmPbfegVW5K9a/J6bID3MoIt5SydMsqkDyM0gFL72/moRqFzzp2gdpdcmx5e POdw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of adrian.freihofer@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=adrian.freihofer@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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=ISNBnCjMPPdrDKesl5XmPDvA9z1wPW8Jj9Xsq2GvQIg=; b=dEmKe6GWy0TgYh09favwfDO8Rm7/TAZ8+c9bOH/Xxwt76pEYbMMsV04Is2+GEeva68 /Jv3HZbGMFKE6Nd4DCArqAFNimzC06GvnxXDgzib2GAHuMpdld9jNDfghoLrY28wbydS dMITpwvY8VcBLb7vLV2zX9iH2gRTUmoXBZG32ltzrJBjtFsAB8n/fq1KtujNsJD9WoRs HHg45MwgEKo14/n8R6oGSfsrlNGSfp0oolrCzGhb5xNBypQd8jktTbzw/CB9O+6kJ3PA zzPS93ZbOmg7RNRjsYr5ZSKZihPN3w4I9ESZYMTCBGc4bry3i3/W+gFscpLR+8AiZNdz p9gQ== 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=ISNBnCjMPPdrDKesl5XmPDvA9z1wPW8Jj9Xsq2GvQIg=; b=iCqxcb7bZ+t5OiD6XXzMc1RE9NDprgrNN315cJiE2baDMmTIjPelxgtOkBDZ1B1+rv Q0HSdKbHKAorl0pmmWpYqT/+8Kbljho0KYCH4K+1oU21kNdyaPwx/VFuM3xonTs7PrSP SLN2Fu+1JGJQxM0dg4ymtmYQ0T6QwdOOylq/bbyfw31t4PX67/rcTsNKTJX1lvx5lhuM bZ8lrghSJcgorQEAzO1yFqW/dRKdBUAItfE4A0DCbAHw5aYroGRaHcTYPZTawGD75vdG tb1qhGNnBlC1RrVGoKk9jNXvDfVLDAs3l8sTF6GF3xIx7TnfLcf49UHyBnrohTbTxHXq QiMg== Sender: swupdate@googlegroups.com X-Gm-Message-State: APjAAAV7QxGzyUDCwSJ1orD4BpA2K8DvEGiNRmmaTdYRRV0jY1xMZquz yHfLa+88NLnt+DndvlzH9dU= X-Google-Smtp-Source: APXvYqx/dx/wGSZXCVPiIeFfqa4lCulErj625NjxIgm1V3zCjI6H51Wvpeo7Fkrivj6MzPfrLPMCeg== X-Received: by 2002:a2e:8310:: with SMTP id a16mr24247785ljh.48.1571865071299; Wed, 23 Oct 2019 14:11:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:93:: with SMTP id 141ls349301lfa.12.gmail; Wed, 23 Oct 2019 14:11:10 -0700 (PDT) X-Received: by 2002:a05:6512:142:: with SMTP id m2mr16861430lfo.126.1571865070883; Wed, 23 Oct 2019 14:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571865070; cv=none; d=google.com; s=arc-20160816; b=hPGkBimrIP0Ai0imalybtY3smrQAri/zv0x3mdRIcqHBT4FraPrREVSoEhSiVp1cdM W/XedGndZ8lgr8MxaSTwlnQU6FY/ZgZ0DWJMCCTMdoY62glHSAx0d64kh0l1DPGAP5/Q WbvLV7qOu/W0MgwL6zQCtgbzmqfHrnXvy56XQ5RlnLME8UsqTNlvzJto8YN3ZzNSPwLX XyXOwJbSiECe41voZkvrkveLtYGyygLYzCTb5zGogqWzOMLp8fIENbU3nKMvibkdGf3I 7ow8l5TnJn5rWvOGOQXzZ0Kjq1YCKCFxUN6q/comHuvSP2/3hYIv6BiKPALHBKG8vqi2 jc4Q== 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; bh=rBRkaXlkI7idc5ty1rxDEsY9R+6q1WOcSp1UNz6tmL4=; b=A0dowrqrhC/KF1EhKwwg9CfXuHt5ioO7qDK3cCDHtG12rX7q0EXSHUBUm+2LUGDXIQ I1pHcdNGN/UrJW+KIboErMjL5A+6XpgDlkM4XtHIEPMhBOFfBuNuNi9XpFTUvJ1ZMTVU zRPoUlrmVnn6Ws94qSurJHnLFa8jE2EqkwYm8QcuEi34B6sVf3RKQb8iDKb075L1bpKk 42fPhe6TLJ9x3Y3wgHasReNwDUUSVsLKxdNXJXU6CZsKyGvVjWC8Y4K9dTjY7msdsMNL wKJmQhCaX0GyJ1+/0PRYNG+GrRgycSNlFXSbGcGXlMjx4rGsf7jkoadAWJD+exZQFx5g zJnw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of adrian.freihofer@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=adrian.freihofer@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id q25si1279086ljg.5.2019.10.23.14.11.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Oct 2019 14:11:10 -0700 (PDT) Received-SPF: pass (google.com: domain of adrian.freihofer@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Received: from mail2.siemens.de (mail2.siemens.de [139.25.208.11]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id x9NLBAVU007382 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 23 Oct 2019 23:11:10 +0200 Received: from dev.vm6.ccp.siemens.com ([167.87.32.70]) by mail2.siemens.de (8.15.2/8.15.2) with ESMTP id x9NLB8Yj012709; Wed, 23 Oct 2019 23:11:09 +0200 Received: from dev.localdomain (localhost [127.0.0.1]) by dev.vm6.ccp.siemens.com (Postfix) with ESMTP id 24F782353A53; Wed, 23 Oct 2019 23:11:08 +0200 (CEST) From: Adrian Freihofer To: swupdate@googlegroups.com Cc: Adrian Freihofer Subject: [swupdate] [meta-swupdate][PATCH 02/12] swupdate: ensure scripts are added before images Date: Wed, 23 Oct 2019 23:10:51 +0200 Message-Id: <20191023211101.16591-3-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023211101.16591-1-adrian.freihofer@siemens.com> References: <20191023211101.16591-1-adrian.freihofer@siemens.com> X-Original-Sender: adrian.freihofer@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of adrian.freihofer@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=adrian.freihofer@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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: , In case of streamed images, it is essential to add scripts before images to the swu archive. Otherwise the preinstall script function arrives after the image installation step. Signed-off-by: Adrian Freihofer --- classes/swupdate.bbclass | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass index 79c9aae..cb1122c 100644 --- a/classes/swupdate.bbclass +++ b/classes/swupdate.bbclass @@ -90,17 +90,31 @@ python do_swuimage () { shutil.copyfile(os.path.join(workdir, "sw-description"), os.path.join(s, "sw-description")) fetch = bb.fetch2.Fetch([], d) list_for_cpio = ["sw-description"] + list_for_cpio_scripts = [] # scripts: pre-scripts must arive before streamed images + list_for_cpio_images = [] if d.getVar('SWUPDATE_SIGNING', True): list_for_cpio.append('sw-description.sig') + def is_script(filename): + try: + with open(filename, 'r') as fh: + if fh.read(2) == '#!': + return True + except UnicodeDecodeError: + pass + return False + # Add files listed in SRC_URI to the swu file 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) + if is_script(local): + list_for_cpio_scripts.append(filename) + else: + list_for_cpio_images.append(filename) def add_image_to_swu(deploydir, imagename, s): src = os.path.join(deploydir, imagename) @@ -109,7 +123,10 @@ python do_swuimage () { target_imagename = os.path.basename(imagename) # allow images in subfolders of DEPLOY_DIR_IMAGE dst = os.path.join(s, target_imagename) shutil.copyfile(src, dst) - list_for_cpio.append(target_imagename) + if is_script(dst): + list_for_cpio_scripts.append(target_imagename) + else: + list_for_cpio_images.append(target_imagename) return True # Search for images listed in SWUPDATE_IMAGES in the DEPLOY directory. @@ -137,6 +154,8 @@ python do_swuimage () { if not add_image_to_swu(deploydir, image, s): bb.fatal("swupdate cannot find %s image file" % image) + list_for_cpio = list_for_cpio + list_for_cpio_scripts + list_for_cpio_images + prepare_sw_description(d, s, list_for_cpio) 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')