From patchwork Tue Jan 23 13:55:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 864791 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+bncbdn7dbh5yqibb5p5ttjqkgqe4ljjpiq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="WO7S9C2P"; 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 3zQqZw0B4Yz9sQm for ; Wed, 24 Jan 2018 00:56:07 +1100 (AEDT) Received: by mail-wm0-x239.google.com with SMTP id b195sf467801wmb.1 for ; Tue, 23 Jan 2018 05:56:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1516715765; cv=pass; d=google.com; s=arc-20160816; b=kHd17Uj0phPV8WeqpPZoTQzjpNOUeHc/3I3BgKGtWKoAFuEaIFZpMKbCnDWfRgX5O3 UY5reIrtMwkFais5jm9t6daFqNqX0A0zENJGc6nTYwglc6T6sUlJiuMacF3C0DGdLFsb Bga9UTuAyxLh54rCqFpAKbdd2X23kMV1luHbwrI2K6K1HvRMQvXjvc7+8THnZu0jejwf YJjwRHki6/paaKOvD90q6L+7AOunJ2cqXOvX1orA/jNorJPB6r+j0mHSzcX7GdcXzED4 oUw3hYnBHAwneRtjGUCwSwl0Z99kekysUvt7F6m5ERjtdhnf1AQMCYn8ksitdIBNI906 NTMQ== 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=cVGblsd59l1enUbRft/ooQLUiAyaT/EgKTS8405E4tk=; b=R2qPY2KVTAhnXPep/LJfPdpJpYKCa1n1fSoGYcmBpAjwA5PDrWJlqEnzkt6/ohDdsN HwRyBBxKN8wHecaDEPwgDxGGuNvQVh5IzgGomcY51CI4oC8z/KZsZqmCXzhmOE/rGBtz 9k37sUmmmOXOWkYXr4HdbBu1xdZNJ9ih43zLitwuK1n+j1AIuiK+506gF0wnlCqW1zYB cicHo6CSTVh3IOe+zLd9VElAjBczxtGMilUIeMsUdg9IqpM6RRJy2K7uhmnDxWJ6DsEu nQ4VGdzgLNE6E19hzZCx6LCAVDl1kAG2nsySSvA9ZG7UCAiSr6Hoo38nuXXtJiWHgaxu g5DQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net 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=cVGblsd59l1enUbRft/ooQLUiAyaT/EgKTS8405E4tk=; b=WO7S9C2Pni1pOCKUjF17zkSuDCi2aHimKsnqGpmAY24X5rafzMZ69xDXF4soPt6czz RIxSjv3bM5de4z6iuNo4xvruSwiAL8djlY9HZXu6C2XWQ5Tw/N0eWThA/A/2zYN3vi4B M1SImjtwsP+dByqpH3RF4z7TfvUJwI8/DipN1yD7dSQOyAr0BnPaum9Es/6HtNtnlel7 mqNwZ+k3/XyvdkWNBydRKwzKBQsxbeAZdGpybbs3dVG3sEoLv0/VzVD5fMCG36ew0jLx buJJHknu8/1ueuC+labx7i1SYmFvivCC8cq+kcRQtjhJHoSaT6P8IsQRcCCx2EisSgiJ s6xA== 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=cVGblsd59l1enUbRft/ooQLUiAyaT/EgKTS8405E4tk=; b=QC7pTXSMKeogFIwLTxS+tGLeKXrrJ4k9ohXHRelwTVho73aMGkDss42i0SG8QvNKGX nvdDy/Lkfhqr7a721O5DWmnc2ogFMwpH4HdEf3ajzoJo91XltN2QgQ5KW0jxi0jOgjez GfQ6ZiZ61J/OfZaeHZ24GdKKfSDoMi/eCuYMKrWz1R+Yl2A5RM+lwjUmKNR4oaW8ZHUF jiw44RFwobuj4lY9gVeYuXC6Vlu8mRiRr7kLpjOGVslvQ61g8e31ybm50m8k1pmASM3A e1mjDM1ma9AG11WkRMKxBYgFOoIpKgkHIFg5nmLuzib9dh3SVpMTbrYxV6zC1wyxSM2T z23A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxyteTfPS2x6sjskvbq1ullD1vkLjJ+tJeiIgNXgMnJmoMJeim9Mc/ usliF/zu83cmxtixToh3IN0= X-Google-Smtp-Source: AH8x2279tq5nORKUIBthFRg/TPMPhFo1Rmn516opKZQrZAp9n4hE6Gk3RF/ZYPuP8zgwDVO76C3Dlw== X-Received: by 10.28.54.133 with SMTP id y5mr28332wmh.7.1516715765312; Tue, 23 Jan 2018 05:56:05 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.129.141 with SMTP id c135ls2134176wmd.11.canary-gmail; Tue, 23 Jan 2018 05:56:04 -0800 (PST) X-Received: by 10.223.151.40 with SMTP id r37mr299797wrb.27.1516715764721; Tue, 23 Jan 2018 05:56:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516715764; cv=none; d=google.com; s=arc-20160816; b=hiW+rW5qQEyaEc3ioKVf0LH4ijdYQD3TPiVJ3DoNYu9M1QM1k9Z4ar7ya7QJ/mfIga xd1KhTHlpHJn0J2zDntRk4/+6WkK/dSbzI0CZGVD5NoAM11sqBbWsBSNSOgLJijVjjDb ivrG6qrAk6ngsb6vtQlCemDyNRW3E8xFYyZD/esZSu7+JC2wEks4NxHFyAyba553TxoX gY6qHZopRRsSl0UGz8e3nXBzKfaHKaAGOM7sALJGi9uqaETwwV97squ0S7sKjuH7tGJt hMsAggFjRXIvNCuJAIq35JZ9RYtGOAhhtu1eA3VialoRU/07mw//ZhseiIusfeLU7ZBK pMjQ== 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=4l98zgxn0IyPLrYNjqdSLcI0+sb8cVPk2GpQ2nZ5Cig=; b=NN47Lm1o8WEKvWJA4nD7J7ZchSFmB7ywVHp1yD0MDU0VCdzw4+OdC7QZsSGKcmf4y9 WOHCdJ65Bz2cPU8R2VxqPwudaV77PxQvYDCAqS1ygEOAwrdc1oYKu4quzznFTlS8AgpW ARKGW+OVWeT6E0535u5ZV3EOkuQefBJTJ/9wfieLhW7joCeulvOcAgTQN1IxHU9Dhftb PGhcXdFeunOCw6npMnLu+cQHfeo43JhAAk93erInEiWifTjpPtE1FppAT6JGa2Gshucb URfhP3sbC9k6+H8bMiKKctiw9CEcMkqYTJfVcpSkBKEqJwg8M2l6nkGIkWao05REYzD2 Qiuw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net Received: from dd41138.kasserver.com (dd41138.kasserver.com. [85.13.157.12]) by gmr-mx.google.com with ESMTPS id 44si63940wrk.0.2018.01.23.05.56.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 05:56:04 -0800 (PST) Received-SPF: neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) client-ip=85.13.157.12; Received: from WS08941.weidmueller.com (unknown [217.244.7.16]) by dd41138.kasserver.com (Postfix) with ESMTPSA id 3639F11A05ED; Tue, 23 Jan 2018 14:56:04 +0100 (CET) From: stefan@herbrechtsmeier.net To: swupdate@googlegroups.com Cc: Stefan Herbrechtsmeier Subject: [swupdate] [PATCH 1/5] parser: Check image version after parsing to remove skipped images Date: Tue, 23 Jan 2018 14:55:57 +0100 Message-Id: <1516715761-3043-1-git-send-email-stefan@herbrechtsmeier.net> X-Mailer: git-send-email 2.7.4 X-Original-Sender: stefan@herbrechtsmeier.net X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net 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: Stefan Herbrechtsmeier Remove skipped images after parsing because they are removed anyway. Signed-off-by: Stefan Herbrechtsmeier Acked-by: Stefano Babic --- core/parser.c | 47 +++++++++++++++++++++++++++++++++++++++++++ corelib/installer.c | 50 ---------------------------------------------- corelib/stream_interface.c | 2 -- include/installer.h | 1 - 4 files changed, 47 insertions(+), 53 deletions(-) diff --git a/core/parser.c b/core/parser.c index 0df960f..0edbe1b 100644 --- a/core/parser.c +++ b/core/parser.c @@ -130,6 +130,51 @@ static int check_handler_list(struct imglist *list, return 0; } +static int is_image_installed(struct swver *sw_ver_list, + struct img_type *img) +{ + struct sw_version *swver; + + if (!sw_ver_list) + return false; + + if (!strlen(img->id.name) || !strlen(img->id.version) || + !img->id.install_if_different) + return false; + + LIST_FOREACH(swver, sw_ver_list, next) { + /* + * Check if name and version are identical + */ + if (!strncmp(img->id.name, swver->name, sizeof(img->id.name)) && + !strncmp(img->id.version, swver->version, sizeof(img->id.version))) { + TRACE("%s(%s) already installed, skipping...", + img->id.name, + img->id.version); + + return true; + } + } + + return false; +} + +/* + * Remove the image if the same version is already installed + */ +static void remove_installed_image_list(struct imglist *img_list, + struct swver *sw_ver_list) +{ + struct img_type *img; + + LIST_FOREACH(img, img_list, next) { + if (is_image_installed(sw_ver_list, img)) { + LIST_REMOVE(img, next); + free(img); + } + } +} + int parse(struct swupdate_cfg *sw, const char *descfile) { int ret = -1; @@ -204,6 +249,8 @@ int parse(struct swupdate_cfg *sw, const char *descfile) #endif #endif + remove_installed_image_list(&sw->images, &sw->installed_sw_list); + /* * Compute the total number of installer * to initialize the progress bar diff --git a/corelib/installer.c b/corelib/installer.c index f92ade9..c630b9d 100644 --- a/corelib/installer.c +++ b/corelib/installer.c @@ -32,34 +32,6 @@ #include "bootloader.h" #include "progress.h" -static int isImageInstalled(struct swver *sw_ver_list, - struct img_type *img) -{ - struct sw_version *swver; - - if (!sw_ver_list) - return false; - - if (!strlen(img->id.name) || !strlen(img->id.version) || - !img->id.install_if_different) - return false; - - LIST_FOREACH(swver, sw_ver_list, next) { - /* - * Check if name and version are identical - */ - if (!strncmp(img->id.name, swver->name, sizeof(img->id.name)) && - !strncmp(img->id.version, swver->version, sizeof(img->id.version))) { - TRACE("%s(%s) already installed, skipping...", - img->id.name, - img->id.version); - return true; - } - } - - return false; -} - /* * function returns: * 0 = do not skip the file, it must be installed @@ -68,7 +40,6 @@ static int isImageInstalled(struct swver *sw_ver_list, * -1= error found */ int check_if_required(struct imglist *list, struct filehdr *pfdh, - struct swver *sw_ver_list, const char *destdir, struct img_type **pimg) { @@ -82,20 +53,6 @@ int check_if_required(struct imglist *list, struct filehdr *pfdh, LIST_FOREACH(img, list, next) { if (strcmp(pfdh->filename, img->fname) == 0) { - - /* - * Check the version. If this artifact is - * installed in the same version on the system, - * skip it - */ - if (isImageInstalled(sw_ver_list, img)) { - /* - * drop this from the list of images to be installed - */ - LIST_REMOVE(img, next); - continue; - } - skip = COPY_FILE; img->provided = 1; img->size = (unsigned int)pfdh->size; @@ -362,13 +319,6 @@ int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile) img->size = fdh.size; img->checksum = fdh.chksum; img->fdin = fdsw; - - /* - * Skip if the image in the same version is already - * installed - */ - if (isImageInstalled(&sw->installed_sw_list, img)) - continue; } if ((strlen(img->path) > 0) && diff --git a/corelib/stream_interface.c b/corelib/stream_interface.c index a5fd4a1..91f523f 100644 --- a/corelib/stream_interface.c +++ b/corelib/stream_interface.c @@ -179,8 +179,6 @@ static int extract_files(int fd, struct swupdate_cfg *software) for (unsigned int i = 0; i < ARRAY_SIZE(list); i++) { skip = check_if_required(list[i], &fdh, - (list[i] == &software->images) ? - &software->installed_sw_list : NULL, get_tmpdir(), &img); diff --git a/include/installer.h b/include/installer.h index fc31c52..ab83691 100644 --- a/include/installer.h +++ b/include/installer.h @@ -14,7 +14,6 @@ #include "cpiohdr.h" int check_if_required(struct imglist *list, struct filehdr *pfdh, - struct swver *sw_ver_list, const char *destdir, struct img_type **pimg); int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile);