From patchwork Mon Nov 20 11:10:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 839524 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:400c:c09::239; helo=mail-wm0-x239.google.com; envelope-from=swupdate+bncbcxploxj6ikrbppqzliakgqewdbew3i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="edGcPQFR"; dkim-atps=neutral Received: from mail-wm0-x239.google.com (mail-wm0-x239.google.com [IPv6:2a00:1450:400c:c09::239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ygQxr2pnfz9s4s for ; Mon, 20 Nov 2017 22:10:56 +1100 (AEDT) Received: by mail-wm0-x239.google.com with SMTP id v186sf6178261wma.9 for ; Mon, 20 Nov 2017 03:10:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1511176253; cv=pass; d=google.com; s=arc-20160816; b=AqIHLZhYzYxT5AtUbjFRaCZzRCg3oAs2PW4Ok+cXj1N6hFqDVDb1LksqgRG4wufe4t gdYkB1qfGtVf0vpkLOtWyiE9ZoVYefWjlGLAX/a2bZ7kTQOI2KvxpIMHr8GYYoMgrF06 SXEWc/1Uz2LiBs0hVYC/h1+oJippnnMHk2l/WC3eFIMYGTfFncnoyBK0r+awqJZ70k28 mR/xBqOZLu4OchISg46DvBF2dlgJ+7sttrphWL1kujhUobOPFghuHpLFMZ3t1XdtoWmb mKAyE9oS0bUcmPhHNV6sjLWKtmEc8gHimO9kdw5jjgAQoWiz0Fxysbw0gBcxRedvQu2r viFA== 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:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=rzI0Z2ojxgTZz0L0eeM/J4JhHfXl41iWWAQoCGa0uYM=; b=SL4P0MURK4KEYYYfr/v1pfFjzRy9Knr4CFQGpyZETANYYa2NAgmEpjxOP+botcrS5G xVjRGFnDvuxU88VLBTxYf2MNgHg0cMnA7fwwva1H8VrjeZTixthMO4F9V8hW1Fm1OZ7L nmj2iyvuqsUjX+CKfSM+WZmZ+56Y4sUA7UHc8pBWQ/3PaP2pUjvTkrZ6z4s1jBoN39BP QNX8TA1tSIEerd7Ydh4dHLgQEvlFddEKO5cc3K+XjDXb/iK7ECFhMCnDI4yt+QRz/0oT tO1it4oLQmzJyCiwQgDNbBFafXpvqzDGPPm0DKh5bX2CV6eLlrR/4oDkgxOpyrzcRDKQ 5Jgg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=rzI0Z2ojxgTZz0L0eeM/J4JhHfXl41iWWAQoCGa0uYM=; b=edGcPQFRHWxIP+MEi9s7ZyxVbjmUjF+FnSCbzSqdl7pG6TN5lMzJZ/uZJ+TQGFBJ6Z xMuv5w7IQnHjzQ4CYPCM4lywUaA7T1zsVv4ihO5TYLTuXj+vTV86haalE3Er2krVBI8E un015nQaNVEgIODebAiao55wrRHYcNj0SwAF1rP67gE40S8Eq1FuAPP2oKwQL8Y44BIr LP2+kEUrVJBNDXBwmZ2q5YN96CqYg0H55hodK+MeciQR0XhqS06T2kkROFMJ13a+wcjr FDk3xqBQyASnhGLeD4I7BaaSWRHUoOjrRu/f5sVwbQrrl8sI1Bir8d/BrOswoXLEi6Xh PHnA== 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: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=rzI0Z2ojxgTZz0L0eeM/J4JhHfXl41iWWAQoCGa0uYM=; b=HkyGGW9N1JYecz2Mi1/xKqQWDNYmRmIPNmnrREctr2SSKG9VfOfGOEpBfasoEFG076 jKy2YmEHgyFOyGpC9b4iy+rvVumI+pWJAM8FggzbViIt73Pv1fsLmpa8SFQDOZNhBHbh IempnqhWVWYS5+vfW1o6RLixisLQPUKBEGvzkBie5bCp3eZsOoxkfJQbpzN+6AEX9Ewq fjVDWeh2z9NC13GXaGraRiDrVl5bPeBr/mFxtRyHjMmgtRM7nBp+051PbdOFpUE0+ppG onNqjJMNwtAxPjXW7W50bSDQSQ5muBY2ukgJJUNAmJlX4D9sXjyaugQ3DaNR4t33JxCU nS5A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AJaThX7LogBIF2Dpd55SbYyg8d6IANmP7MFrBahRNQtSyIrYwZoQOwNX SdRYKvhUa635U3rGElkpJPQ= X-Google-Smtp-Source: AGs4zMY7omGoRXcZFY6VQUQeMOL4QMxQqmGkBrtKfeTRXepsJka+gTu97wO4CZuHt3jcapSJ44QQog== X-Received: by 10.28.147.75 with SMTP id v72mr143613wmd.2.1511176253570; Mon, 20 Nov 2017 03:10:53 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.139.130 with SMTP id n124ls888572wmd.10.canary-gmail; Mon, 20 Nov 2017 03:10:53 -0800 (PST) X-Received: by 10.28.184.216 with SMTP id i207mr1484561wmf.2.1511176253295; Mon, 20 Nov 2017 03:10:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511176253; cv=none; d=google.com; s=arc-20160816; b=qemW/xL4U/w4Byan53z2xkKeKd+upYsnsfut+9r2G084+6TntBqCMr5mSmmCKQVbzE hqQMENkrZf+umge30RfHYW4jSgyCmZRajLCu1+JwUhOB3A/WtFMIbvk/8mCjWlAKWKJ2 SeBGfBysv8OWo7HoBXlXvhIHuUCzvzPukYGNOpRDA++4ug4T+eRrilYwipGwuWeOA3YK laurJhzugbqarb2sWEfzBY5yxqnTdMrgtLLQ/xIEAPqr7ZrjClNnRk0qDPuNrXZgnOhS +0Ib7HJNtf6pFpGBhJw4ZyBPtompWGpBqnjEiqXSjXdIxBnQc4fFcw4egyWbHwsfr6S1 avDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=pX7uALBvNVELerhxQ6g63S5KoMmV354cn4R/5lqwOHE=; b=Ia2k6/i13Fl5cQtcRi53MWokScfAFVBC5vRhG/RAG+XCkP9n1yrzBpEXng4bM1vPkG jU3XB+srz/kTk8W2w2Sl0uKF8niySLbJXxF9CH82rFyPanyJ9dz7ll97WNcg9N7lO3VT ZA5RHsidjnhTKo212p59ek5LQNPmM3MfhmpDzJUSAJVM74SKtIYdLDtLU8j/K6EDKIfW 0XgJKyx2JwOqykKrNVunu2KXAHCWsryh9kOdJw80IroxcP3MFmxbYV3JjdF07ONUo6Vs vhQb1Mum9WJqfBPrrK2rUyZEGDJ3n921uTIPcftUiskqAZtyHJx3BpHGBttW3fCCXLjB DlIg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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.10]) by gmr-mx.google.com with ESMTPS id a2si467815wmg.0.2017.11.20.03.10.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 03:10:53 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3ygQxn0mN3z1qtFg; Mon, 20 Nov 2017 12:10:53 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 3ygQxn0cq6z1qqkZ; Mon, 20 Nov 2017 12:10:53 +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 MS5SVi6kgv8F; Mon, 20 Nov 2017 12:10:52 +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; Mon, 20 Nov 2017 12:10:52 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 9ACDD4540378; Mon, 20 Nov 2017 12:10:51 +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 Iw1ZOEoJR1_Z; Mon, 20 Nov 2017 12:10:45 +0100 (CET) Received: from papero.fritz.box (papero.fritz.box [192.168.178.132]) by babic.homelinux.org (Postfix) with ESMTP id 48BB445405A9; Mon, 20 Nov 2017 12:10:36 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH] core: simplify flow when installing from file Date: Mon, 20 Nov 2017 12:10:34 +0100 Message-Id: <1511176234-29040-1-git-send-email-sbabic@denx.de> X-Mailer: git-send-email 2.7.4 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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: , Signed-off-by: Stefano Babic --- core/swupdate.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/core/swupdate.c b/core/swupdate.c index 797ef72..514dc71 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -367,15 +367,14 @@ static int install_from_file(char *fname, int check) if (ret) { fprintf(stdout, "Software updated failed\n"); - bootloader_env_set("recovery_status", "failed"); - exit(1); + return EXIT_FAILURE; } bootloader_env_unset("recovery_status"); fprintf(stdout, "Software updated successfully\n"); fprintf(stdout, "Please reboot the device to start the new software\n"); - return 0; + return EXIT_SUCCESS; } static int parse_image_selector(const char *selector, struct swupdate_cfg *sw) @@ -535,6 +534,7 @@ int main(int argc, char **argv) char main_options[256]; unsigned int public_key_mandatory = 0; struct sigaction sa; + int result = EXIT_SUCCESS; #ifdef CONFIG_SURICATTA int opt_u = 0; char suricattaoptions[1024]; @@ -888,13 +888,19 @@ int main(int argc, char **argv) if (opt_i) { - install_from_file(fname, opt_c); - cleanup_files(&swcfg); - - notify(SUCCESS, 0, INFOLEVEL, NULL); - if (postupdate(&swcfg, NULL) != 0) { - ERROR("Post-update command execution failed."); + result = install_from_file(fname, opt_c); + switch (result) { + case EXIT_FAILURE: + bootloader_env_set("recovery_status", "failed"); + break; + case EXIT_SUCCESS: + notify(SUCCESS, 0, INFOLEVEL, NULL); + if (postupdate(&swcfg, NULL) != 0) { + ERROR("Post-update command execution failed."); + } + break; } + cleanup_files(&swcfg); } #ifdef CONFIG_SYSTEMD @@ -918,5 +924,5 @@ int main(int argc, char **argv) if (!opt_c && !opt_i) pthread_join(network_daemon, NULL); - return EXIT_SUCCESS; + return result; }