From patchwork Tue Jan 26 13:05:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1431664 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::239; helo=mail-lj1-x239.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbqfgycaamgqeq4ctchy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=ME9RaUGg; dkim-atps=neutral Received: from mail-lj1-x239.google.com (mail-lj1-x239.google.com [IPv6:2a00:1450:4864:20::239]) (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 4DQ6Ph1jfqz9sRR for ; Wed, 27 Jan 2021 00:04:05 +1100 (AEDT) Received: by mail-lj1-x239.google.com with SMTP id f20sf8038147ljj.15 for ; Tue, 26 Jan 2021 05:04:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1611666241; cv=pass; d=google.com; s=arc-20160816; b=LXlJzJXQre/IpzfTBnmWGOXZGqjdZLivjU7lA/2/Xq9FnwB9dLGh6kNSLL4JQW6mRp 3A+V6KjsqI2FWTiIeymLlfpk2btRgUXjoMXo60AZ6Fd7f0doIu4R0sbh+OHJQhBf2bfC L8EdmzByceLlI3U4vLrXAXZkph6Ej4UeW+3e6iQgJr+IvASHg64LooByIX0+iYv+atVB dULAvx6H8ELyXu8BCM9eNfVN59wrSxpXSwbOkYilRh47f7+42v7odBqwUiqo16R9g+0H EYA1Q6wQty5zo/lwS7SfSV6XOVsHaDb8VsPoFIYHFRJV3XGV64o1EKJjua86KBOlxxmK V12Q== 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:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=2G4Eba89G8QbZSOw124d1H8j5RhzFs+oKXlmJJY1h2o=; b=Ux4sSxFU9drE9Q/+oFoHfhlU0V1xfE+OJAXJWFLgC8o3Up56uVbxpKtNi4hi8FERr7 fP2NxGlWYzGki2FNDkgolvHPXkZkg8CRv6iM3GjI1BhP+cgKql/LGZbRWhdx8f4ZsDgK BGXy3RnJztwQBGk42POjII2nPV3K9fSRuZHCVYJ8YLKywbnJuq+kRETU4ZRtUtmVqyrs 9SxZP7YnGs+wpCaIbkhiAqQ1gcu5/bxDbnJwI4AmbuNgpAAV3erxTFe6HKGnTuU2+/QN ck1+bOKKsx6XoDq59nuty7Hpqm5/t5a95gbNpMV3bq08qAStmcG4fxAxrlr+hFcxFiTq 0mVA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@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:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=2G4Eba89G8QbZSOw124d1H8j5RhzFs+oKXlmJJY1h2o=; b=ME9RaUGg6k/gytBnSIfqf85JQfBqPAfkTF8+5IfKNhwkCahl6ElvBpcvTCrnH6Qsy1 rJRZXnUTyzH7K6wmVWAgQsMXxoYBHbDROgXAsTCZ4BeOcXsBSoBJvOT9KN55oetthr/k vxl3Mpej4vKdXEelQ0YrtnmucORxsFqEdAArynmTOR3fPvDm0V0NYSz63jkgsEwWogNS bJstgPIaz+0GZp2Tr1l0WSfr8tPlBqO1hg0YDliohdvhmvGM2T67Ptv/RW17XJ+g4w2G J0rDqhL5zopY5Ny/rVX2irc2z3pV2ZfTkiuMkE3/he9DD6K8z99ORABJq8LTaxWH+/JS 6edg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version: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=2G4Eba89G8QbZSOw124d1H8j5RhzFs+oKXlmJJY1h2o=; b=IKzwFnIgsx/cwBJ3Wm8fKe8Yf8C1ceUZgZqflKilQyRfMqGuOBedxf6cU/5gOtPZAX +NsiP/7+9IN2uBqWDm0pCFL/HNrA+RUTGb3XqBpkWA0jIexsw42TEmNnl6Tt891rSU2N P5+28ikuz38W6amJNYWogmq3HaSPc/6+cmTwuFTPdcXSw+uOLccJbiG4Fvpq0Be5ZZMt PCvhlk/gbrtsvj1lyNHp+Q+TWiWnUux4LkwG13N9JQIsMZZAwe0NGFeSt+938CJoCeIv p3ig0dkZQ0Dbbri9ZhCjf0J0xt8gllJbpljFvLBzOKzt1y83sh9euvrpgQ/eX/ZVGvLA ffhA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM53092wx588geXfLqJb+r1s4H9/SdIkb5c6o44YMrWiWlA7wBBvoS l65lysA3E5dL6xjH8/NqlbM= X-Google-Smtp-Source: ABdhPJx+jh2fvdcONxN/lzc2iydFm1VYMP4sH1uehSMcMDIQ4HxA6K4sjisb+DYZ32uVSNG9cROp8A== X-Received: by 2002:a2e:b0ee:: with SMTP id h14mr2976605ljl.31.1611666240694; Tue, 26 Jan 2021 05:04:00 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3993:: with SMTP id j19ls475194lfu.3.gmail; Tue, 26 Jan 2021 05:03:59 -0800 (PST) X-Received: by 2002:a19:410:: with SMTP id 16mr1318573lfe.264.1611666239551; Tue, 26 Jan 2021 05:03:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611666239; cv=none; d=google.com; s=arc-20160816; b=ZES/IqlKk3WJfOWzA9pM+W2EFCb4CsTxZTyTbYzGGqyAcBpaGbJRHUk6CsCImxuZjS Ef4kHrmOv9bnJi+qG0dWnK1NVRE4IQAByCUoYcJUFIImr+Zqk7KmtNqlDOChSIM6D5t8 Qb/To1ieHWzo88LSATYfWuFqK/Ab2oMTGM/9dhBrQUmV6Hye0Q3jf2ZDHHqqrJIVWS6I pf+F3+RbZxDz+KWlJA+VwUEbwiW+6cOiaIt/rOv5sfKb0/sy1dharQhQBrNGf6+p/Vtd 3JME4VClHwUcLj8/4FzEEhaL4xNkscdPebQPAKXIcBdlHSYcEtwku7UoZ9CdrVp0s2fR ns1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=unypLvDFg/8f7Nrx2laFPuJJk/W297xoiXuvkf6c4FI=; b=XWgGGkY1jwDNYhF9gepF5Beg7iJnPH05JEGOit6N2JajYScyAfuSlk0aIHATgr4mWz x+zi+pFSB0qF0Em15fSiqlNqRp0eYeSWDs13lrneztHTU+RKXbOYUbJfHD1q+3iKAiTi d9n8zNV12POmzgfmmP78Cd5lhOCNS26bxRkwWBu8ctw8/FWEroYiZUXbasW37SsJ44RO 8Fo/3wdyOdSYR70t9gX1Tlh9fXaeGgv+M2rQLDktga2ZV9aGc0Dc+3QCcZyn+UN30Wd3 jvjzWbA/VC9ohXPVQN10w9PZEZhjjA6lMa4jdcnumagaZS2cPsRGYaC2wwNA/PJrcLUV otPg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id d7si523657ljj.6.2021.01.26.05.03.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jan 2021 05:03:59 -0800 (PST) Received-SPF: pass (google.com: domain of christian.storm@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 10QD3wQW023512 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 26 Jan 2021 14:03:58 +0100 Received: from MD1ZFJVC.ad001.siemens.net ([167.87.7.200]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id 10QD3wns024845; Tue, 26 Jan 2021 14:03:58 +0100 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH] state: Optionally disable setting ustate marker Date: Tue, 26 Jan 2021 14:05:56 +0100 Message-Id: <20210126130556.21616-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christian.storm@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=christian.storm@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: , Analogously to the bootloader_transaction_marker, introduce a bootloader_state_marker that allows to disable setting ustate. This is useful if the installed update does not require persistent state handling at all like, e.g., applications, or when using a single-copy setup. Signed-off-by: Christian Storm --- core/stream_interface.c | 8 ++++++-- core/swupdate.c | 8 +++++++- doc/source/sw-description.rst | 13 ++++++++++--- doc/source/swupdate.rst | 3 +++ include/swupdate.h | 2 ++ parser/parser.c | 11 +++++++++++ 6 files changed, 39 insertions(+), 6 deletions(-) diff --git a/core/stream_interface.c b/core/stream_interface.c index 0205866..3907ade 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -603,7 +603,9 @@ void *network_initializer(void *data) } notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Installation failed !"); inst.last_install = FAILURE; - if (!software->globals.dry_run && save_state((char *)STATE_KEY, STATE_FAILED) != SERVER_OK) { + if (!software->globals.dry_run + && software->bootloader_state_marker + && save_state((char *)STATE_KEY, STATE_FAILED) != SERVER_OK) { WARN("Cannot persistently store FAILED update state."); } } else { @@ -614,7 +616,9 @@ void *network_initializer(void *data) if (!software->globals.dry_run && software->bootloader_transaction_marker) { bootloader_env_unset(BOOTVAR_TRANSACTION); } - if (!software->globals.dry_run && save_state((char *)STATE_KEY, STATE_INSTALLED) != SERVER_OK) { + if (!software->globals.dry_run + && software->bootloader_state_marker + && save_state((char *)STATE_KEY, STATE_INSTALLED) != SERVER_OK) { ERROR("Cannot persistently store INSTALLED update state."); notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Installation failed !"); inst.last_install = FAILURE; diff --git a/core/swupdate.c b/core/swupdate.c index 4f008e0..62fc085 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -83,6 +83,7 @@ static struct option long_options[] = { {"no-downgrading", required_argument, NULL, 'N'}, {"no-reinstalling", required_argument, NULL, 'R'}, {"no-transaction-marker", no_argument, NULL, 'M'}, + {"no-state-marker", no_argument, NULL, 'm'}, #ifdef CONFIG_SIGNED_IMAGES {"key", required_argument, NULL, 'k'}, {"ca-path", required_argument, NULL, 'k'}, @@ -153,6 +154,7 @@ static void usage(char *programname) " -N, --no-downgrading : not install a release older as \n" " -R, --no-reinstalling : not install a release same as \n" " -M, --no-transaction-marker : disable setting bootloader transaction marker\n" + " -m, --no-state-marker : disable setting update state in bootloader\n" " -o, --output : saves the incoming stream\n" " -v, --verbose : be verbose, set maximum loglevel\n" " --version : print SWUpdate version and exit\n" @@ -470,7 +472,7 @@ int main(int argc, char **argv) #endif memset(main_options, 0, sizeof(main_options)); memset(image_url, 0, sizeof(image_url)); - strcpy(main_options, "vhni:e:q:l:Lcf:p:P:o:N:R:M"); + strcpy(main_options, "vhni:e:q:l:Lcf:p:P:o:N:R:Mm"); #ifdef CONFIG_MTD strcat(main_options, "b:"); #endif @@ -640,6 +642,10 @@ int main(int argc, char **argv) swcfg.globals.no_transaction_marker = 1; TRACE("transaction_marker globally disabled"); break; + case 'm': + swcfg.globals.no_state_marker = 1; + TRACE("state_marker globally disabled"); + break; case 'e': software_select = optarg; opt_e = 1; diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index 63be19f..fd8bd11 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -832,8 +832,8 @@ SWUpdate scans for all scripts and calls them after installing the images. If the data attribute is defined, its value is passed as the last argument(s) to the script. -Update Transaction Marker -------------------------- +Update Transaction and Status Marker +------------------------------------ By default, SWUpdate sets the bootloader environment variable "recovery_status" to "in_progress" prior to an update operation and either unsets it or sets it to @@ -861,7 +861,14 @@ transaction marker: It is also possible to disable setting of the transaction marker entirely (and independently of the setting in `sw-description`) by -starting swupdate with the `-M` option. +starting SWUpdate with the `-M` option. + + +The same applies to setting the update state in the bootloader via its +environment variable "ustate" (default) to `STATE_INSTALLED=1` or +`STATE_FAILED=3` after an installation. This behavior can be turned off +globally via the `-m` option to SWUpdate or per `sw-description` via the +boolean switch "bootloader_state_marker". bootloader ---------- diff --git a/doc/source/swupdate.rst b/doc/source/swupdate.rst index a8144d1..22d135a 100644 --- a/doc/source/swupdate.rst +++ b/doc/source/swupdate.rst @@ -518,6 +518,9 @@ Command line parameters | -M | - | Disable setting the bootloader transaction | | | | marker. | +-------------+----------+--------------------------------------------+ +| -m | - | Disable setting the update state in the | +| | | bootloader. | ++-------------+----------+--------------------------------------------+ | -w | string | Available if CONFIG_WEBSERVER is set. | | | | Start internal webserver and pass to it | | | | a command line string. | diff --git a/include/swupdate.h b/include/swupdate.h index 137d8f2..e607ed6 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -131,6 +131,7 @@ struct swupdate_global_cfg { int no_downgrading; int no_reinstalling; int no_transaction_marker; + int no_state_marker; char publickeyfname[SWUPDATE_GENERAL_STRING_SIZE]; char aeskeyfname[SWUPDATE_GENERAL_STRING_SIZE]; char postupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; @@ -149,6 +150,7 @@ struct swupdate_cfg { char description[SWUPDATE_UPDATE_DESCRIPTION_STRING_SIZE]; char version[SWUPDATE_GENERAL_STRING_SIZE]; bool bootloader_transaction_marker; + bool bootloader_state_marker; char software_set[SWUPDATE_GENERAL_STRING_SIZE]; char running_mode[SWUPDATE_GENERAL_STRING_SIZE]; char output[SWUPDATE_GENERAL_STRING_SIZE]; diff --git a/parser/parser.c b/parser/parser.c index c2fe175..d3efde5 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -148,6 +148,17 @@ static bool get_common_fields(parsertype p, void *cfg, struct swupdate_cfg *swcf TRACE("Description %s", swcfg->description); } + if(swcfg->globals.no_state_marker) { + swcfg->bootloader_state_marker = false; + } else { + swcfg->bootloader_state_marker = true; + if((setting = find_node(p, cfg, "bootloader_state_marker", swcfg)) != NULL) { + get_field(p, setting, NULL, &swcfg->bootloader_state_marker); + TRACE("Setting bootloader state marker: %s", + swcfg->bootloader_state_marker == true ? "true" : "false"); + } + } + if(swcfg->globals.no_transaction_marker) { swcfg->bootloader_transaction_marker = false; } else {