From patchwork Tue Jan 25 16:10:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 1584160 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=VdIhA1pJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::237; helo=mail-lj1-x237.google.com; envelope-from=swupdate+bncbddmj4nl6ekrbfgcychqmgqedyuoycq@googlegroups.com; receiver=) Received: from mail-lj1-x237.google.com (mail-lj1-x237.google.com [IPv6:2a00:1450:4864:20::237]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjsKM4Cstz9t4b for ; Wed, 26 Jan 2022 03:11:03 +1100 (AEDT) Received: by mail-lj1-x237.google.com with SMTP id v9-20020a2e2f09000000b0023021c0c47asf2812372ljv.11 for ; Tue, 25 Jan 2022 08:11:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643127060; cv=pass; d=google.com; s=arc-20160816; b=rBCab7Pq8BWA7+avJTYDExHYa3oy0Y4ucHAZ3GAizRZCS9gaIudrrfHuvT/AvWh3IT dQjYd3JgMMIdzgV6rJBLr72enjHMcFmffr63LgKxFv9GnqpOt2JOZ+QBjsFeimKFt1cx kbGFZjGehxQhln6Hm1WxUzXTFTDlAFAvVu01Fntyp1FYnbuZrRoK2Xra1/6iHRExaMpk bIoxLaUyfsr1bICEhOt0dJjsJ1HIq5kBMaoAhVHI3BGymfpFEq/Rlt0NwpY53RMv4n/g Gama9vlqHYYpd3w/XC061Hu+mocSzzcmcZA2iI1MWuyvq3MV7MNWW+smKiE3RvKIk+PB 2A7Q== 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:content-disposition:mime-version :message-id:subject:to:from:date:sender:dkim-signature; bh=SzneqM7Ir5KoZL1qYhWrGaT475RrYUayXwA6ETWN5Lk=; b=NHvhaQpiP2C7/1eWO3KIShZMJTXnpf+IQMlT/wMhu+A1XIHIcTYJlJOMUfRrHzNQB5 H4gltbGUugDakLk7QjmOPe9GRh05vFvMIaiA1PbvoZ2EKtwdO9ZA1WLUpZxn7tlHyZhC 6+HdWfUscS/qX+sSbe7jgZHb4/30FOeFSEptoARwSCDy647triL4y0/3cDgff/+XiLpw /HErUycrG6vJA+Jfrl0fACVrT0+Edq9G9JlezLpkKFcUnvmJHa4qQPA5RtXPCNUsf4yg JsIzmy5sPA+a7VkCzqXj9EYtFMLWxl/QmGQIMZvTn7KnHhWtJ/GdolvoPQg8QugAjTB4 G86g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of ben@decadent.org.uk designates 95.217.213.242 as permitted sender) smtp.mailfrom=ben@decadent.org.uk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:date:from:to:subject:message-id:mime-version :content-disposition:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=SzneqM7Ir5KoZL1qYhWrGaT475RrYUayXwA6ETWN5Lk=; b=VdIhA1pJD17fV0jSI6Gd8xRNKxVTMBprNORx50O7SqyichRNxI/ZeSjKwArwtLCeOt 7OgoQxFCvMTkK/e7iH6729jm+E3uQYBEAOasySjWZM9PnJh00A0cqPtSmZpGtnjV/x+g +AoxxTGKOOgXvUQBP9XzbIwX5G8ixdXIckjQ+jvj1jNo8mK3W0wtsUXgw6Yt9fGZVm5b k1Gxi4JC6I/z67DbPG5zZWLpoAuNNt1bqZ3iFQBRycKHCmFgQon7Rjfjz1lAZym8XMxa 2vMlZAzxxQcOkDFnO9Av16VoAfhoX+RR8EtDjV8kwmOStIgjGZuJy2yYLmvNy96S38XU VxGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:date:from:to:subject:message-id :mime-version:content-disposition: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=SzneqM7Ir5KoZL1qYhWrGaT475RrYUayXwA6ETWN5Lk=; b=5k48MxJwXR6eFI274X7EIecTy/Kf9AK3kArSVQUIla2adbZhE7j3C79YCVmyyLckq7 dGNDDdEGTfTfsOttEz/6walxw1fVFZ1gJ3L1pTJRt5WNpRPPMN0urs3B7H8VcPFpHGR1 hYjJJE3NqJs5ckuBAPQYiKfU10GWdtskuS81keDj/O/vE0TotM39n4rnAffu+xZ4lzOj wf/H8mMOoTPBK37yZV043ULgV/YgECgXrAo9vvQ00fsH1a45WjhoWgRXOFzj1PZ96YmS JyOh+kwH8sMNqysYUJ+XZ8npjjsZ/kq3NgS4FkB9NEHXs4JneJiSph11eclfNZ9zGwfz 5sDQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533k11FqfYvGlZTfbbBsjJ0eqr+t6TcaKDbWz7FAQ2Vk8076URQo nmNlMVUZ8mbRAjtOOmnS6Lw= X-Google-Smtp-Source: ABdhPJwFIjJ4teUwQh01QffkG4bhRlRYAUuquaB+7LyGMqGiCl4FfvdA0VU3Kbi9c49VvVGK5NyQrg== X-Received: by 2002:a05:6512:3994:: with SMTP id j20mr10639361lfu.449.1643127060339; Tue, 25 Jan 2022 08:11:00 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3b90:: with SMTP id g16ls160228lfv.3.gmail; Tue, 25 Jan 2022 08:10:59 -0800 (PST) X-Received: by 2002:ac2:5dcf:: with SMTP id x15mr13731025lfq.164.1643127059233; Tue, 25 Jan 2022 08:10:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643127059; cv=none; d=google.com; s=arc-20160816; b=ldbR2ViPiMk5bNPLQk1OuhnyC9D2ogKVMC/JHAPeKlAiWXh/V83L+AcfNSwppJDhR8 DihtjBsqCEUKucIuVJF7MRiEyLuZfmrPGqwtqLthVQ/N19GsHZDdNorKikqZNEIXzbJB lH5IOLIk8BE2c6PxO3xAi7TfrSQ+Fu5y91hq9c+RZR5S1p29UxTemOSr7n42jh+kjAKm OjtwtVGrdLTm08sMSziwUF9qWqLNTs35ae7hC0w0WrO7CVmm4hFOHcoZhFidqEURZt6B xs7KOTyZkzGJEkzv8Lv6WQfZR3odCzRxEJC8XG4OvF3nwI/WvENIuizCBBJ0bkbrqsOD n2Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:message-id:subject:to:from:date; bh=QUB5y4HBqNp9V6aRLuK9LwQZEpU3AmWEKVaXawIvx5M=; b=XR75QB1wPupZRja0mNGrcAHl/Exov4K9UQBvTaODX5j9I0PSAXHkhiX6WqijP4Z3Ar LyDnFiq39wJTulRmaw7b/hRjMTrK2eqEuQKcVRZXOJP4cLaHFxLkPra0TAnGunzbYERo mqGWJdhPvJFUmlFqXZtQa0XvWLHii7Iq9OY2PGQMvRSm2QECddVKhTfFimnSEYf5A+06 /RjledyNPhPyAyYjzZUShxNYRcLZpWLh6/HJZPlPpovFufpBOurAsCIVpwSAY1piasxT +JANkDtKU/oNKBha5+iQW37cthHg2GoVTX/kt3qRT1mg0UjpjX6XsmSxy4FUIqYPavkq zY9g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ben@decadent.org.uk designates 95.217.213.242 as permitted sender) smtp.mailfrom=ben@decadent.org.uk Received: from maynard.decadent.org.uk (maynard.decadent.org.uk. [95.217.213.242]) by gmr-mx.google.com with ESMTPS id br32si155474lfb.11.2022.01.25.08.10.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 08:10:59 -0800 (PST) Received-SPF: pass (google.com: domain of ben@decadent.org.uk designates 95.217.213.242 as permitted sender) client-ip=95.217.213.242; Received: from 168.7-181-91.adsl-dyn.isp.belgacom.be ([91.181.7.168] helo=deadeye) by maynard with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nCOPK-0006yh-Ui; Tue, 25 Jan 2022 17:10:58 +0100 Received: from ben by deadeye with local (Exim 4.95) (envelope-from ) id 1nCOPK-00AN01-Fj; Tue, 25 Jan 2022 17:10:58 +0100 Date: Tue, 25 Jan 2022 17:10:58 +0100 From: Ben Hutchings To: swupdate@googlegroups.com Subject: [swupdate] [PATCH 1/2] installer: Rename extract_scripts() and update comments Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-SA-Exim-Connect-IP: 91.181.7.168 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on maynard); SAEximRunCond expanded to false X-Original-Sender: ben.hutchings_ext@softathome.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ben@decadent.org.uk designates 95.217.213.242 as permitted sender) smtp.mailfrom=ben@decadent.org.uk 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: , Scripts are now extracted by the cpio streaming loop, and this function only moveds them. Rename it to move_scripts() and update the comments to show what's actually going on. Signed-off-by: Ben Hutchings --- core/installer.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/installer.c b/core/installer.c index eb07f41..089f638 100644 --- a/core/installer.c +++ b/core/installer.c @@ -89,10 +89,9 @@ swupdate_file_t check_if_required(struct imglist *list, struct filehdr *pfdh, /* - * Extract all scripts from a list from the image - * and save them on the filesystem to be executed later + * Move all scripts from a list to the temporary scripts directory */ -static int extract_scripts(struct imglist *head) +static int move_scripts(struct imglist *head) { struct img_type *script; int fdout; @@ -258,10 +257,10 @@ int install_images(struct swupdate_cfg *sw) bool dry_run = sw->parms.dry_run; bool dropimg; - /* Extract all scripts, preinstall scripts must be run now */ + /* Move all scripts, preinstall scripts must be run now */ const char* tmpdir_scripts = get_tmpdirscripts(); - ret = extract_scripts(&sw->scripts); - ret |= extract_scripts(&sw->bootscripts); + ret = move_scripts(&sw->scripts); + ret |= move_scripts(&sw->bootscripts); if (ret) { ERROR("extracting script to %s failed", tmpdir_scripts); return ret; From patchwork Tue Jan 25 16:11:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 1584162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=FD6tpT9a; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::337; helo=mail-wm1-x337.google.com; envelope-from=swupdate+bncbddmj4nl6ekrbs6cychqmgqevdvhryi@googlegroups.com; receiver=) Received: from mail-wm1-x337.google.com (mail-wm1-x337.google.com [IPv6:2a00:1450:4864:20::337]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JjsLR65jcz9t4b for ; Wed, 26 Jan 2022 03:11:59 +1100 (AEDT) Received: by mail-wm1-x337.google.com with SMTP id d140-20020a1c1d92000000b0034edefd55casf1380943wmd.4 for ; Tue, 25 Jan 2022 08:11:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643127115; cv=pass; d=google.com; s=arc-20160816; b=lv1KHFe9scAFWJFhbTwI7IL1t3ZHgQTKiflWdDlVCWWrlgKa5Nv0eAUNFUHh52EbTh vxEkcFDCGNYKvr3UuJfEgdv0aoA1qc/JGsZTt5uQqccwwr/tEAD4AREGjF8BFu86SWzH ZHiQ2yi9loICe03zghDrLClf3N5T13KSWocBr4MS+uA73PLeulfocw4bjj9aYqTK4CSg WnBEbSS2gofjrsn4kUXcZpfjLuhGQ+qh2Or3pleT+3CglelCvyljMJDsSnnZ74Nm6czj EvPNSJQxC6N4ewsp3+ys7Q/odIidpe2J47OOB7EYPmnafxbJAhIVXXEAsbD1aQFWKudk D4kg== 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:in-reply-to:content-disposition :mime-version:message-id:subject:to:from:date:sender:dkim-signature; bh=Rv6V6y3ljwUZZi4+NOf+F3F6NXkb5/UTr2NOBZ5tRoc=; b=JpTITugkL1495yYbZ8bf3PR+tU/Za5tF3QJZ+SCr/C+3v3lJQiqVhZMdLxiLO2O6Db 9oRtoW4EPy0fO/U51i3q84R1VRa3Zl9XK3hL+yW3VIXYuG65QUzOE1zy6CmjIuJDeE2N B4owt/Ehs6ZqXlYObytMWUG4YemctEz1PpfaFPux0dTkbnvZpaXg1PzYu3shB9UaUZJO RDNohyrZllsuc+zJXHjkNTvDrOorQ+cCZRCfgNSoNR5KiG7VodE/JV2QkesoTSiFSng6 nDI3LYIv2JxmSPvK5G/CS+SFPfJdcpv69BfVkDb7mZ7KtlbG64Dj5y0lM4lNOo0OFn0n e5sQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of ben@decadent.org.uk designates 95.217.213.242 as permitted sender) smtp.mailfrom=ben@decadent.org.uk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:date:from:to:subject:message-id:mime-version :content-disposition:in-reply-to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=Rv6V6y3ljwUZZi4+NOf+F3F6NXkb5/UTr2NOBZ5tRoc=; b=FD6tpT9a1RU4gWyccNF0uVIgP5P0vG1xMDf1OpC6auj6XuEWA9q2Cqpx9KcPFFlIET zR+5tBGjeXl1cOcwf+V20eWmZB5za6hwYFJfnWHf0M4Je8jtTlYkLJsKiUaXwrCa9WWO 8Yy8W93+WR/JAjrJfk0xTEtja8ogfbbWGsOThqVKs5EMxZd3qZPGg+XT0wggjNLLjc/S lKr0vBh235Aw8QTeuBpJoWzK83J2WZcQuDGVUAn+KZba6+NpgU3Tbf9RYbRpJ/bAQIgc noVQmJhiPaquTxNO8v/Gx1NKjDCVkzmEDFU9mGI21HztaP/YVnQmftO8Vzuw8YuIHH3/ axlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:date:from:to:subject:message-id :mime-version:content-disposition:in-reply-to: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=Rv6V6y3ljwUZZi4+NOf+F3F6NXkb5/UTr2NOBZ5tRoc=; b=yryYpaAXVHV9BCKAtGmvZdf7EGDrsBEoMoB7fn5TE5tpZirREtBmd+D66LwD1mmGVX lhvCbRyCWkmYvDTpGZbjWJzI4L4NmSAsuwo5/S2sC5sydj81hxVkmV6A6C8zH1RMvDtB GGuCQeaT1xo9xeWNScbES46LTbWyQSqQVPC9GIvF4TrRv1PapjvQRnJYR9V32zmU6bNr EuVbs0Th00+28svp7tJRifWzddDUbwjgKMnkOmm7SMGg0O/eFblaEneMhzhLvz8a03Qf ZXaRU5L02w5NMj1db9zxWr5QsOIpU386vjJd4kf9L4BYsgh/O5dPjm0D6aiznk2iYzMC QZbg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5301Drfd1XNiN+b3USCW5IZOx1EvKSzssuBjwjzpj4xmBYJj1Ld4 bN9kfpMTLOEZZ0uOhINz0zs= X-Google-Smtp-Source: ABdhPJyiA1GcnRQ6RUvZa6h49O8kp1iU7SrhX8ftKU+1oKxZx8FCk5G6MkMLyx3/ND5bLs2JQEV8zQ== X-Received: by 2002:adf:d1ef:: with SMTP id g15mr12743107wrd.571.1643127115813; Tue, 25 Jan 2022 08:11:55 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:448f:: with SMTP id j15ls57249wrq.3.gmail; Tue, 25 Jan 2022 08:11:54 -0800 (PST) X-Received: by 2002:adf:d091:: with SMTP id y17mr18963843wrh.161.1643127114813; Tue, 25 Jan 2022 08:11:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643127114; cv=none; d=google.com; s=arc-20160816; b=fPVZa/fN39+jPbCSt13ZzpaV3mcX3CD3UtM0DZ/UYRDH0qUPGqTujAPH9ixUklY2Oi +awdWl5dE7LRRwAIsVMR9yzjCr5AGnU1Y3ig9tSHtJdxBcGjV7gzDEAw8OidnTWKnnA8 yfwi5heWbnRnLGUIh/dzadslrauhaj/U9gdql8Az2sP66/4raV/QHKuUXcXUXA+VnwrF LPAfhtkTIOHJOzkuUcB5fVg889/nBpOjagF5rUonVSx0s9Wq15CS805UW7E2qk4z0d2r Lm5SGxFS3qoj3JStMqvQbVLEFB0tdtn6YRRK01rmqXuVld/Djss/XoYuyteUL+wg0KPx LZ2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:message-id:subject:to :from:date; bh=GBraadCgM0qo2cGTQOUs8i4tkv2x660L7pBjd6LhEX0=; b=iO5bmcHhNL2S8kIvl+b0Mbzd9tFpCbroVrocaMV5GmYrd8Xmu+/zMx/Y+UuuhYtP0X m2iJvP6o232q4/AzUmNtk7g2JdNTgYcAmRXTbklUDEvY66t9x7rLGmcnPk7/xSSkia1U WZyaA05rMf0SNDMfMZMh6w4nwZIZwj6Qq+a5V6W9GTw05HSsQRIJZ6DJgj2syLKQTGbN 2syU8vuUYX9I+HSRg/sjGht0Rlq6Ygpf2UtYkqHI9l2LiokN3P4gVCLHM1HN2UC76gW4 pXmwqIPntcJsVmbd9UD7LBTghtepbo+0Q0VCt3bP2ClKQ+IgrLX7QmnUI+fuiBuIrLHX 9/SA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ben@decadent.org.uk designates 95.217.213.242 as permitted sender) smtp.mailfrom=ben@decadent.org.uk Received: from maynard.decadent.org.uk (maynard.decadent.org.uk. [95.217.213.242]) by gmr-mx.google.com with ESMTPS id d14si679942wrz.4.2022.01.25.08.11.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 08:11:54 -0800 (PST) Received-SPF: pass (google.com: domain of ben@decadent.org.uk designates 95.217.213.242 as permitted sender) client-ip=95.217.213.242; Received: from 168.7-181-91.adsl-dyn.isp.belgacom.be ([91.181.7.168] helo=deadeye) by maynard with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nCOQE-0006yp-6P; Tue, 25 Jan 2022 17:11:54 +0100 Received: from ben by deadeye with local (Exim 4.95) (envelope-from ) id 1nCOQD-00AN0R-O3; Tue, 25 Jan 2022 17:11:53 +0100 Date: Tue, 25 Jan 2022 17:11:53 +0100 From: Ben Hutchings To: swupdate@googlegroups.com Subject: [swupdate] [PATCH 2/2] Run preinstall scripts before installing an image directly Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 91.181.7.168 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on maynard); SAEximRunCond expanded to false X-Original-Sender: ben.hutchings_ext@softathome.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ben@decadent.org.uk designates 95.217.213.242 as permitted sender) smtp.mailfrom=ben@decadent.org.uk 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: , Currently preinstall scripts are run *after* updating any images that have the installed-directly flag set. This is a regression from SWUpdate 2020.11, at least when updating from a local file. * Split out the move and execution of preinstall scripts from install_images() into new function ensure_preinstall_scripts_done(). * Add a flag in swupdate_cfg and use it to make the function idempotent. * Call it from extract_files() before installing the first image directly. * Document the requirement on ordering of files in the cpio archive. Signed-off-by: Ben Hutchings --- core/installer.c | 46 +++++++++++++++++++++++++---------- core/stream_interface.c | 5 +++- doc/source/sw-description.rst | 5 +++- include/installer.h | 1 + include/swupdate.h | 1 + 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/core/installer.c b/core/installer.c index 089f638..2b3d1ab 100644 --- a/core/installer.c +++ b/core/installer.c @@ -241,21 +241,13 @@ int install_single_image(struct img_type *img, bool dry_run) return ret; } -/* - * streamfd: file descriptor if it is required to extract - * images from the stream (update from file) - * extract : boolean, true to enable extraction - */ - -int install_images(struct swupdate_cfg *sw) +int ensure_preinstall_scripts_done(struct swupdate_cfg *sw) { int ret; - struct img_type *img, *tmp; - char *filename; - struct stat buf; - const char* TMPDIR = get_tmpdir(); bool dry_run = sw->parms.dry_run; - bool dropimg; + + if (sw->preinstall_scripts_done) + return 0; /* Move all scripts, preinstall scripts must be run now */ const char* tmpdir_scripts = get_tmpdirscripts(); @@ -275,6 +267,34 @@ int install_images(struct swupdate_cfg *sw) } } + sw->preinstall_scripts_done = true; + return 0; +} + +/* + * streamfd: file descriptor if it is required to extract + * images from the stream (update from file) + * extract : boolean, true to enable extraction + */ + +int install_images(struct swupdate_cfg *sw) +{ + int ret; + struct img_type *img, *tmp; + char *filename; + struct stat buf; + const char* TMPDIR = get_tmpdir(); + bool dry_run = sw->parms.dry_run; + bool dropimg; + + /* + * Run preinstall scripts if they weren't already triggered a + * directly installed image. + */ + ret = ensure_preinstall_scripts_done(sw); + if (ret) + return ret; + LIST_FOREACH_SAFE(img, &sw->images, next, tmp) { dropimg = false; diff --git a/core/stream_interface.c b/core/stream_interface.c index 1c9853d..b721509 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -251,12 +251,15 @@ static int extract_files(int fd, struct swupdate_cfg *software) /* * If this is the first image to be directly installed, set transaction flag * to on to be checked if a power-off happens. Be sure to set the flag - * just once + * just once. Also run preinstall scripts, if there are any. */ if (!installed_directly) { if (!software->parms.dry_run && software->bootloader_transaction_marker) { bootloader_env_set(BOOTVAR_TRANSACTION, get_state_string(STATE_IN_PROGRESS)); } + if (ensure_preinstall_scripts_done(software)) { + return -1; + } installed_directly = true; } diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index 3de3636..b8f72b8 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -1334,7 +1334,10 @@ There are 4 main sections inside sw-description: | installed-\ | bool | images | flag to indicate that image is | | directly | | | streamed into the target without any | | | | | temporary copy. Not all handlers | - | | | | support streaming. | + | | | | support streaming. If this flag is | + | | | | set, all preinstall scripts used with | + | | | | the image must be placed before it in | + | | | | the cpio archive. | +-------------+----------+------------+---------------------------------------+ | name | string | bootenv | name of the bootloader variable to be | | | | | set. | diff --git a/include/installer.h b/include/installer.h index 80aa442..7d415b9 100644 --- a/include/installer.h +++ b/include/installer.h @@ -17,6 +17,7 @@ swupdate_file_t check_if_required(struct imglist *list, struct filehdr *pfdh, const char *destdir, struct img_type **pimg); +int ensure_preinstall_scripts_done(struct swupdate_cfg *sw); int install_images(struct swupdate_cfg *sw); int install_single_image(struct img_type *img, bool dry_run); int install_from_file(const char *filename, bool check); diff --git a/include/swupdate.h b/include/swupdate.h index 4cce892..9d350ca 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -150,6 +150,7 @@ struct swupdate_cfg { bool no_transaction_marker; bool no_state_marker; bool check_max_version; + bool preinstall_scripts_done; int verbose; int loglevel; int cert_purpose;