From patchwork Sun Nov 22 10:01:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1404462 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::438; helo=mail-wr1-x438.google.com; envelope-from=swupdate+bncbcxploxj6ikrb27n5d6qkgqehzy4ofq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de 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=hZgL4mEE; dkim-atps=neutral Received: from mail-wr1-x438.google.com (mail-wr1-x438.google.com [IPv6:2a00:1450:4864:20::438]) (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 4Cf5Qp6YLqz9s1l for ; Sun, 22 Nov 2020 21:01:20 +1100 (AEDT) Received: by mail-wr1-x438.google.com with SMTP id g5sf4937712wrp.5 for ; Sun, 22 Nov 2020 02:01:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1606039276; cv=pass; d=google.com; s=arc-20160816; b=eoaOetJtzLQCQxzkFqniFCA4g+6+PedrEL7eZQrQ7qUAH5zotrqWXZVPhhS+4hZLMZ QQE6w8WMaCh5oai4dI+RumBALmZnvl4VvIDv569rB6nhcstVAiwK6YhCp/jxeScGwr3l Xq3OC/l+SG1I4iIj7U/L8nnSh46FCuGetzInKbJbpgnTVeFaiho2eqqb9SgZExglgKPD 9RSaBBPgEnC03VL4zFgoA/RUwfkWHRyocrMdFiBxscCxSzSKhlfTck0CNwmzkNpi99ET HyAXgNHfeoVsrRYZw18dnMzYtQMzvyvkERDxNUWKbKMqGuSiVDaFMf7BYQYft55UQ9XI CdQA== 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=ojHtcSP9eM1Ag34P2bNOcHCC7Tx3o0iGR0Rg9vjJ1bU=; b=C95I2RJbZ2EmOF4JHuXRAGXIDt7EWy8U4Bd92bXnk2hGChHZbMqpFZSk7dXOlGW9SA O4i9HRGzYcg9I9VAyW0bcBd5V+/dgj4G/vQnroIh5gI3mJ+z4fzFY+V83heh1WaIhUFS /g0toRFQEdsMukzDkv6U2vnJS+APiChvCc9cFKtNyDNBUXzGEXbPLrLdwRv8PgVf+Ld5 7ZO0a5w1lr2WQgV3WguPQ5LWu/pDQe8HjVQmsAtBLNKtHVYeVCsTQTPKoGD8kTq+HRq3 nQ12LcOgsakwtZy2Kn258Jd70/M2dtyHC31qcLms9SQVGhzwGVEIkrqlnIKqHrBvwtzs RxjA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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=ojHtcSP9eM1Ag34P2bNOcHCC7Tx3o0iGR0Rg9vjJ1bU=; b=hZgL4mEENVoX7tAPmMt057nmktm94ScMrkXAAv8CQWkDQPFL2o1PEqg9yFI1ABh1ox J71SX5er9k2Dle91QFPKWl8tX1tLz7xaf0HVK83aoxIqFdOLF2dXmpxPLSytFBuqI+c5 wbvKaY7OSrr5JwO7xVQSF3Vx/mHSUq/PbgXEX6bvsG6tfLsSDNGY3FIomnx9sgy3sWv9 OAdjzdPL7SCLlzFGf4PS4MdGWDwMvhO4Y3IQzEmL4mzOUUOf5eFgPR72O0xoufsvtek+ bi+UtIhdtzwA6arLDkTAb8F36qlcJPjkWhnLEm/q5ZVMlblevU2sw+p6onPxL09824uX Nwhg== 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=ojHtcSP9eM1Ag34P2bNOcHCC7Tx3o0iGR0Rg9vjJ1bU=; b=a9vP3+3pm22sYk1D/RjEtvAC9tC25qOAU2O9yZmUpxcQyPrXr/enMTN4ira8ExpplF ZFYmYKk9Zn1iwgZWs80d11cIUbuPeGSXNVWldkgluP9ZzLix/AUTk07Lz+jj2S5cTSs2 kbV/FXaLSYd3Xkfy0LLa2zPi9+yf4IYzwCROgiLmKrQj+H0//vyO5f0msP7SX7XRbT3U IAcGm5kmxQf6bWF9UleSgTNNGvEsYnT9fmOd8MVXNe15hWj7/6HTEfp9lJw6ewslU+h+ LNqKzm5Fck6mhzEi6TdqqU0//pbCdzYYgjBR/Cr6ld4nTtan0pGbLyBBX7RxtXYqFYdb RKIw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533rVgdSXJNBq1h9aFDrv8G8nvCOpmRwctdbRI0ostsTABUColHn mw1nCsPeVkviB2Ur8aTc5s4= X-Google-Smtp-Source: ABdhPJxC7ubwfhmQ6vNODqaACQQIJBIycDu3hT2JodKe9Jmpd7PNtDEsRsgeAn+TK+/sCf+m9QZF8A== X-Received: by 2002:a05:600c:4112:: with SMTP id j18mr19565360wmi.152.1606039275959; Sun, 22 Nov 2020 02:01:15 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:f70d:: with SMTP id r13ls3928430wrp.1.gmail; Sun, 22 Nov 2020 02:01:15 -0800 (PST) X-Received: by 2002:a5d:44d1:: with SMTP id z17mr26392830wrr.423.1606039274932; Sun, 22 Nov 2020 02:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606039274; cv=none; d=google.com; s=arc-20160816; b=BDd+txbkcdZBK28cm9P5qB5u+txcNGkyK8ABep928R+dQ+HYqp7W37gKHa4X0TE/FE I7sXSrkVAgy2Jf2hBl7KYXe8w6fVhpT4fC2AXkmy0P6UICVuOVkjxbFKYorSyOCk1TPs AG9u4StZg1OiZp61wsgPmKfUgMPGz18pHUh+IpaKXbt4w3Jso/fpHAriHGEPMyOpyR0O be94ONwukeG/Ee+PFw+bUQAUsE0Jcxgr0G1CAOwb8pKUvhvI5Jt+3BTGEYDbOvbRTQCN s5UK+yn4TI3w8JdFi8KeRg4zOrQFT4dz8rr+lDvpduwJtIs1aJ8y7Ib3BjK24II+WGZ7 Vwow== 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=Tkfs/0jd73GqSaeto4hWBv+fHOz/aiB73iSY/nQcpoI=; b=Mw+xF66WsLLcDzm6O/0sIH5zbMa//icIw1zM/P3Xmr+zgH4l76eIxzTwjU+tOfp4q6 l8aXpFa97lDUvc+H3elfsggOz8dsBiNf8cmpq8tBcDoIX46F3nBCzsOi1PFocCoh176U 95qiCYogtsrGlG5oxxWe58c6eJpHdLOvdIyUszZ70KpQw4hzUX9r7jsYUNv8+PpnNV34 szigLKrL+Kr9vPIYP5Q8YENz05sCCsShdspZpbjb3Lgsq+bsYbFHPkPVrkbAFlo9bATR uqPXP8cHW1M3a26C765q6Wq8PpSlwPFtskDSIblzWkiYtw2p++3lT9RPKQJ2Z4Wp39DY L10w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id j199si397435wmj.0.2020.11.22.02.01.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Nov 2020 02:01:14 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Cf5Qf4vRdz1qs10; Sun, 22 Nov 2020 11:01:14 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Cf5Qf4Zh8z1qwl4; Sun, 22 Nov 2020 11:01:14 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 7b-VD_tYzKYM; Sun, 22 Nov 2020 11:01:13 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Sun, 22 Nov 2020 11:01:13 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 752B74540445; Sun, 22 Nov 2020 11:01:13 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jB_3tIQROVAy; Sun, 22 Nov 2020 11:01:11 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 339044540210; Sun, 22 Nov 2020 11:01:11 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Christian Storm , Stefano Babic Subject: [swupdate] [PATCH V2] Don't set (persistent) state in dry run mode Date: Sun, 22 Nov 2020 11:01:09 +0100 Message-Id: <20201122100109.80111-1-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: , From: Christian Storm Signed-off-by: Christian Storm Signed-off-by: Stefano Babic --- Changes since V1: - do not use dry_run from request because this is evaluated and can overwrite the default at start-up. Use the result stored in globals.dry_run core/stream_interface.c | 12 ++++++------ core/swupdate.c | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/stream_interface.c b/core/stream_interface.c index 39fa64e..0752e5c 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -243,7 +243,7 @@ static int extract_files(int fd, struct swupdate_cfg *software) * just once */ if (!installed_directly) { - if (software->bootloader_transaction_marker) { + if (!software->globals.dry_run && software->bootloader_transaction_marker) { save_state_string((char*)BOOTVAR_TRANSACTION, STATE_IN_PROGRESS); } installed_directly = true; @@ -572,19 +572,19 @@ void *network_initializer(void *data) * must be successful. Set we have * initiated an update */ - if (software->bootloader_transaction_marker) { + if (!software->globals.dry_run && software->bootloader_transaction_marker) { save_state_string((char*)BOOTVAR_TRANSACTION, STATE_IN_PROGRESS); } notify(RUN, RECOVERY_NO_ERROR, INFOLEVEL, "Installation in progress"); ret = install_images(software, 0, 0); if (ret != 0) { - if (software->bootloader_transaction_marker) { + if (!software->globals.dry_run && software->bootloader_transaction_marker) { save_state_string((char*)BOOTVAR_TRANSACTION, STATE_FAILED); } notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Installation failed !"); inst.last_install = FAILURE; - if (save_state((char *)STATE_KEY, STATE_FAILED) != SERVER_OK) { + if (!software->globals.dry_run && save_state((char *)STATE_KEY, STATE_FAILED) != SERVER_OK) { WARN("Cannot persistently store FAILED update state."); } } else { @@ -592,10 +592,10 @@ void *network_initializer(void *data) * Clear the recovery variable to indicate to bootloader * that it is not required to start recovery again */ - if (software->bootloader_transaction_marker) { + if (!software->globals.dry_run && software->bootloader_transaction_marker) { unset_state((char*)BOOTVAR_TRANSACTION); } - if (save_state((char *)STATE_KEY, STATE_INSTALLED) != SERVER_OK) { + if (!software->globals.dry_run && 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 0684de4..56e6c96 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -386,7 +386,7 @@ static int install_from_file(char *fname, int check) /* * Set "recovery_status" as begin of the transaction" */ - if (swcfg.bootloader_transaction_marker) { + if (!swcfg.globals.dry_run && swcfg.bootloader_transaction_marker) { save_state_string((char*)BOOTVAR_TRANSACTION, STATE_IN_PROGRESS); } @@ -402,7 +402,7 @@ static int install_from_file(char *fname, int check) return EXIT_FAILURE; } - if (swcfg.bootloader_transaction_marker) { + if (!swcfg.globals.dry_run && swcfg.bootloader_transaction_marker) { unset_state((char*)BOOTVAR_TRANSACTION); } fprintf(stdout, "Software updated successfully\n"); @@ -1069,7 +1069,7 @@ int main(int argc, char **argv) result = install_from_file(fname, opt_c); switch (result) { case EXIT_FAILURE: - if (swcfg.bootloader_transaction_marker) { + if (!swcfg.globals.dry_run && swcfg.bootloader_transaction_marker) { save_state_string((char*)BOOTVAR_TRANSACTION, STATE_FAILED); } break;