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); From patchwork Tue Jan 23 13:55:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 864792 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::237; helo=mail-wm0-x237.google.com; envelope-from=swupdate+bncbdn7dbh5yqibb7h5ttjqkgqejm7tqqa@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="IdUDqXqQ"; dkim-atps=neutral Received: from mail-wm0-x237.google.com (mail-wm0-x237.google.com [IPv6:2a00:1450:400c:c09::237]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zQqb26lHNz9s1h for ; Wed, 24 Jan 2018 00:56:14 +1100 (AEDT) Received: by mail-wm0-x237.google.com with SMTP id e195sf454344wmd.9 for ; Tue, 23 Jan 2018 05:56:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1516715772; cv=pass; d=google.com; s=arc-20160816; b=IxzU4ebeq6Qr/K62y9Br3D1/Ut01+0fZNvtbACijKWk8fOMXw3SJttmNlCzJuMajuh FSXlOFuhpJ/A/OBe0GM4ZnLfUWKaxItVLYAoVGE6DfGsnPzDNLiEtZGyfa+GGjbJR5ex NLbf/ZY7FG3pQbcVQfmsMI7vub45dnMbOfn4BGzFW0jpcqK1jOJLG7wR+lKY2Uq5Xw7L rA3nCexOtD+wm1f6RrGG+zwfrF5MWkH4qwd8WNrTf2X20PymfFvKZ8MiC3Ah9Rmj9Unr gRfSZfAB5YMnUKaGYQZEyoeJbmpnPbCgFX5/oWGiukpSRWXak9QqhB7VEjbhZm6mYOUn fJQQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=rTnrBYE085MJY+2u13aswxFAWxqdXWt9fHSAaRqIcjw=; b=Uy0ucFPsp7Mv9E3HVyLVHeB66A6Rn5HyXs1G+BLSs0l/mhOyxXitdDK/WfwSZxfG+g geo1cEscLiEfxRtZ6c9AEMuZ4JC4EaRMjSTStJYn7HdH8cDBGAHqVu3KjjGLMuxh57C9 QrtT6P8L0fIHSSg6FS3WsThY3BkxAP76Th8ZEBT5g2kZSnJwbUgTJeYp8dPZOCGPa6WG eXNP6akqZQu+5z6XfHUSjPseS4n/CpKKJxXCJv6TU5ZZHjBsTAjdHffJ2vjilqFafqn1 kucmeait+AS3RbrWKAXojbVXu65sck8E0+tP5lkoyPYtJtb3luN01KSk6ClrPOKnpKTt oznQ== 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:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=rTnrBYE085MJY+2u13aswxFAWxqdXWt9fHSAaRqIcjw=; b=IdUDqXqQzoxktaoFn1OzFlHN0CfM8OWTHyCl64tV4fEdPpGschOYUhY0z+s2L1UssR P5j6RdaiZcETHBAcbVWv4s0JGI7fQnhyp/H0u49kHWGXZXn+cD19zsa8hscXT13OW6QV iDvHpQUxOFvIW9HTw85dei1kN1L0C7AJaWNuERl+t1dCBFqw3NJtsgKXx+K6+eqaYiT6 11GH9MYmJ94YQIvD7MxBVoLr7vzooHBOx1xZlHv+6ex/vvEJFxHEF74Q9oXleDudddG1 YMxwrK4DQrsb6i2GjMZply02LMMBFoVUeECwObN1QCTTnnFxcyE0M7spY2Wi8wcfqSy7 w0Lg== 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:in-reply-to:references: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=rTnrBYE085MJY+2u13aswxFAWxqdXWt9fHSAaRqIcjw=; b=hES6y08Rd6wYPNXRchjlAwCNgRJyYch5kqxOYKTGsLe6JlBW564vyg1PHbYKfk5iYk Sg79LsS+Use552MENZFW21Yj3CNihItrE82C9CYGi0jh3FpLmYZ1bKamtS2azTEXddV3 5+nw/TsJtW9WaIK5TH3h7ZU12qZcOcKjQ7DaAj7SeNnxZqEL34wGAQOVpxRblNDmvqgg B8MExpdRRvkXuBGfG1+v/Kpoyf+xzz1gOiVXvNVFiKziNWWFvYUaNZ5LhQBWqAk205Px wrQsZhHhcU6ssyzGOSz02/Yz/QAXfhzUXLDsnsMY8EtDMe9yqcRRK0SR7mE8M+ovpN55 X9Qg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxyteIIORrvF70gf61E0cvwkTHOqHlGm3Tn/2U1mDLjsmCfkM3SeNV 6B1VXCAYdKMrlvS6vJpmpMg= X-Google-Smtp-Source: AH8x225y8LSS2mee5RHIU2qLKsLpCFcu0szEImWDrRBNlnf5Dvy/rRUSuM8Vyu8mwIY5jK2E7N/YFA== X-Received: by 10.28.40.134 with SMTP id o128mr29663wmo.0.1516715772338; Tue, 23 Jan 2018 05:56:12 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.208.199 with SMTP id h190ls2165811wmg.6.canary-gmail; Tue, 23 Jan 2018 05:56:11 -0800 (PST) X-Received: by 10.28.150.216 with SMTP id y207mr314609wmd.21.1516715771621; Tue, 23 Jan 2018 05:56:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516715771; cv=none; d=google.com; s=arc-20160816; b=OREPymwX65PCJ/4ymbC4MkfHLui1zbt8/UnPuz3NQBmj/ixj0sjgLNeNpE0lB4nECn P0d3ChmNudsvIr8dOKduCsImMrZgAjTKX9ZNbJy+xr13rwl3tc1EI32J9v2T5NM3Yi6z Tyka643wrqVCKbCYvxtfLegDjQmPZV1tIZAkYdefbo+OppTZ/cdJia5l7qTmYDvaihME qXHFvMXVe6Zj3RHmlaj9diXJc8vgouFFMHDEE8rhv8uEh6G6/Rm6A2q+NW4XTIwJc6aF xj4F+oSdeqkr+qGM/mIrHv+axXXvT/UpB48IPjXpZenzJiuviJ1d6wyJW1hMedOTLl5R qTQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=89Nw4bMDVOmMADJE0o7naNpagIkF2lDklGI8wOs29XI=; b=wPmV5AIPCDDyPLpbZYsImINJtP/1U02JdDHoM2xzTG0cdCOvh67BWuAe9gFlPJcqGR dAjLPVqmvr1G2LR0I0UxyyG5fT7VmTU5XoVp4sy1dLezd6khTjXN+qLh0fDh4xPR3laj /htqpcIHJNrkboNzSKLep/rMFVR/ScE4c54DCrqimkwjQX9IT/BC/HOO4dDB6qgupFab w/vve8q8UPw9vh/JxpGxF9NLVaWiXsHsm/vyxxx2nX4k1sDJx5psQ+CbBOSIZfSjsEAU uNdA+3twCrSr93e3DQwD6U2rjnw1nncMCZXtl/VEWWxOknkPCqVitG/69QadelRbCciF cCrA== 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 f8si1409066wmc.2.2018.01.23.05.56.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 05:56:11 -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 4536A11A0CAE; Tue, 23 Jan 2018 14:56:11 +0100 (CET) From: stefan@herbrechtsmeier.net To: swupdate@googlegroups.com Cc: Stefan Herbrechtsmeier Subject: [swupdate] [PATCH 2/5] installer: Add free_image function to always drop dictionary and free image together Date: Tue, 23 Jan 2018 14:55:58 +0100 Message-Id: <1516715761-3043-2-git-send-email-stefan@herbrechtsmeier.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516715761-3043-1-git-send-email-stefan@herbrechtsmeier.net> References: <1516715761-3043-1-git-send-email-stefan@herbrechtsmeier.net> 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 Signed-off-by: Stefan Herbrechtsmeier Acked-by: Stefano Babic --- core/parser.c | 2 +- corelib/installer.c | 10 +++++++--- include/swupdate.h | 1 + parser/parser.c | 19 ++++++++----------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/core/parser.c b/core/parser.c index 0edbe1b..27c78ec 100644 --- a/core/parser.c +++ b/core/parser.c @@ -170,7 +170,7 @@ static void remove_installed_image_list(struct imglist *img_list, LIST_FOREACH(img, img_list, next) { if (is_image_installed(sw_ver_list, img)) { LIST_REMOVE(img, next); - free(img); + free_image(img); } } } diff --git a/corelib/installer.c b/corelib/installer.c index c630b9d..811723c 100644 --- a/corelib/installer.c +++ b/corelib/installer.c @@ -335,7 +335,7 @@ int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile) break; } } - free(img); + free_image(img); ret = 0; } else { ret = install_single_image(img); @@ -386,7 +386,11 @@ static void cleaup_img_entry(struct img_type *img) } } } +} + +void free_image(struct img_type *img) { dict_drop_db(&img->properties); + free(img); } void cleanup_files(struct swupdate_cfg *software) { @@ -405,7 +409,7 @@ void cleanup_files(struct swupdate_cfg *software) { remove_sw_file(fn); } LIST_REMOVE(img, next); - free(img); + free_image(img); } for (unsigned int count = 0; count < ARRAY_SIZE(list); count++) { @@ -413,7 +417,7 @@ void cleanup_files(struct swupdate_cfg *software) { cleaup_img_entry(img); LIST_REMOVE(img, next); - free(img); + free_image(img); } } diff --git a/include/swupdate.h b/include/swupdate.h index db9abbf..7de096a 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -147,5 +147,6 @@ struct swupdate_cfg { off_t extract_sw_description(int fd, const char *descfile, off_t start); int cpio_scan(int fd, struct swupdate_cfg *cfg, off_t start); struct swupdate_cfg *get_swupdate_cfg(void); +void free_image(struct img_type *img); #endif diff --git a/parser/parser.c b/parser/parser.c index 06f03b6..e07ed8e 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -225,7 +225,6 @@ static int run_embscript(parsertype p, void *elem, struct img_type *img, if (!exist_field_string(p, elem, "hook")) return 0; embfcn = get_field_string(p, elem, "hook"); - return lua_parser_fn(L, embfcn, img); } @@ -302,7 +301,7 @@ static int parse_partitions(parsertype p, void *cfg, struct swupdate_cfg *swcfg) return -ENOMEM; } if (parse_common_attributes(p, elem, partition) < 0) { - free(partition); + free_image(partition); return -1; } GET_FIELD_STRING(p, elem, "name", partition->volname); @@ -315,7 +314,7 @@ static int parse_partitions(parsertype p, void *cfg, struct swupdate_cfg *swcfg) if (!strlen(partition->volname) || !strlen(partition->device)) { ERROR("Partition incompleted in description file"); - free(partition); + free_image(partition); return -1; } @@ -368,7 +367,7 @@ static int parse_scripts(parsertype p, void *cfg, struct swupdate_cfg *swcfg) } if (parse_common_attributes(p, elem, script) < 0) { - free(script); + free_image(script); return -1; } @@ -440,7 +439,7 @@ static int parse_bootloader(parsertype p, void *cfg, struct swupdate_cfg *swcfg) } if (parse_common_attributes(p, elem, script) < 0) { - free(script); + free_image(script); return -1; } @@ -489,7 +488,7 @@ static int parse_images(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua } if (parse_common_attributes(p, elem, image) < 0) { - free(image); + free_image(image); return -1; } @@ -504,8 +503,7 @@ static int parse_images(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua add_properties(p, elem, image); if (run_embscript(p, elem, image, L, swcfg->embscript)) { - dict_drop_db(&image->properties); - free(image); + free_image(image); return -1; } @@ -563,7 +561,7 @@ static int parse_files(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_ } if (parse_common_attributes(p, elem, file) < 0) { - free(file); + free_image(file); return -1; } @@ -574,8 +572,7 @@ static int parse_files(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_ add_properties(p, elem, file); if (run_embscript(p, elem, file, L, swcfg->embscript)) { - dict_drop_db(&file->properties); - free(file); + free_image(file); return -1; } From patchwork Tue Jan 23 13:55:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 864793 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:4010:c07::23d; helo=mail-lf0-x23d.google.com; envelope-from=swupdate+bncbdn7dbh5yqibbax6ttjqkgqelqzhmga@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="IOo0Gkw5"; dkim-atps=neutral Received: from mail-lf0-x23d.google.com (mail-lf0-x23d.google.com [IPv6:2a00:1450:4010:c07::23d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zQqbC0qVBz9s1h for ; Wed, 24 Jan 2018 00:56:22 +1100 (AEDT) Received: by mail-lf0-x23d.google.com with SMTP id h8sf145991lfe.18 for ; Tue, 23 Jan 2018 05:56:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1516715779; cv=pass; d=google.com; s=arc-20160816; b=sFHpfJ429J54TE75fH/cFmKM4TWPLxXTnl07Wbf3uOVc8+j5VFh0K9fhIU7pQqU4IR WZ1gGp4atvotBEWa54tIGVWArAkuXAbKNd7dz5GkYZUkrKMgTBs25b9+rBXTubuOdeV3 WlkxoEODa9MDyHjtp6TarnmRv3tP2nCSus0iYRgKb5/TgYpR43n72ebdDwAfid9JWiju 7LLepHs+mVZ1JXe/rl5EorTSdtgd5oeENWbHc6sXrO48lqaKeylFprdEHQzatdHq3s/A oBUrxJVTgjg415h/vVSEZx3IuMFIOxrJkPTDvYo76Tmum7fhhvSw8gTrzGWkRS8hQiy3 XxIQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=JhSlP+XA94evop/Uar2uuNbFFH2gWXjp0NTgHz+R3fQ=; b=JKiLReme+JhmqAL9nB53yIjpVqRrCHGSKiXCrguSl0bG1HN3RW6IJu9VSijM8OCEmt ccfanhqMDx9GNFVsoOFQOLPNG8n5Z4ebB5JTHYHDYrQkZJPkmp3hp0zqtNx9pjycM+6H 5rSUehya4KcKufyCVzWqWd1Ms7S2KkAhz+nM+McDf9py0dVNBsbcWc77DlJUX2PfgswS c2QV5i6rp5qK5RNviyw7XJYDT401g7dTEGvtBzUCMS8+tRMxerJUVPW/Gr+fRXdrwg7+ m2HIO3kmdkEM++0lwoo1/UfujsDRYvRXkXTsOA0h/K9RZDP1mTHN3ZZOYpjqIhr2LY6d OB6w== 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:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=JhSlP+XA94evop/Uar2uuNbFFH2gWXjp0NTgHz+R3fQ=; b=IOo0Gkw5E7Qnz+SxJ9T39nDJf9RYo8t5/h0pB+l/k2NbV7q3Gj+OuysA1/6UBsVGrd zUOZAeT7sw2rDuxaZ9YmLZimS3px0LWnUXXiTxRRSQpDIekKlAKipV8pcHFLI9iO8j0c 1rPVCBMuLrtjRSzL7eYwJIcvO3Mw6nt4ENJa/596A9MrUffyWK7TkkDYGYQkbOecqdao nc9pLuAZ4aqZpVIjYzoP8A7Wcv9ATNJH6rQ6a4tHcH068+7Vj+ND7j1gHdFjem61FxOi psrFrrXqXUtFvkz7IA7ry2oTkND4m9/OLD/WOC4FOtCpeHLmWTbLt+moXE4eYrBVlz8/ Hhuw== 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:in-reply-to:references: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=JhSlP+XA94evop/Uar2uuNbFFH2gWXjp0NTgHz+R3fQ=; b=CSvijpqBw22yWZ+gDzzQi8jMLJau8i2AgbYX6MVY3/LzkMzzhbg1BMEmzvnbuZ1EjF 0VKGkmWu5BUSgfyYX7pIq0sOg1qP6E5AwVAecNwEIJR9Yl5IOCPWnx52Wx500xWxtNl+ lbnx8lZqPJs35d7L2Tnmwrvd5atbJUDjUrq+aaevSEB5z6dThG0wxrni1ZYvWx+vam+8 owpKu87cPtLc/H6fYLVWxHsutIx2Eb8Dvgaq/Em0LlMC9WfalmWYKmyanyPxrH6kNSmf r0BChaSOXKnfFaBM/81Nkd1db+JLXqBlobTSedQQwFzmtiZtvIO3mKsiaQriEcZCTF/r 8dfQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxytdMvi43xmpOqQsD2/0bfNYhk6HFt/oNAYNlYWI998AeQo2Oz/LM WTvlwFxMuAa6X3et4x/QKaA= X-Google-Smtp-Source: AH8x225WdOMBTJf03E+VQVe78LczXuG8aLNqIWSi1pzXyeR/5evLxr+eCUDFzqUqlVAkjTbgnnQ42Q== X-Received: by 10.46.77.89 with SMTP id a86mr7656ljb.4.1516715779098; Tue, 23 Jan 2018 05:56:19 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.46.22.21 with SMTP id w21ls899891ljd.12.gmail; Tue, 23 Jan 2018 05:56:18 -0800 (PST) X-Received: by 10.46.0.163 with SMTP id e35mr190915lji.31.1516715778280; Tue, 23 Jan 2018 05:56:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516715778; cv=none; d=google.com; s=arc-20160816; b=vSD87gro7oaWRg1kZxZeZrUJzKjAbxB/91+nYgIStQlpfPumfd/AGxGhnbiBvA5BBg GlDNda2UkxVxKLLzYM4q0RNvj4dzjDmt1W/LOmWti9Rz3zb1HTrrcKrQp57A0qgo4eoE OeCAGaTVfN0UcVU304vm1AvcU3HxsCUKS7WXfBntdDCxSc0quDLgf/cLIL9TMy+s46KW yYZQsByhCShc4/p2gAlk1YQkGt4eLe7EH1qQRTR3riH6TTn0HiPTeESB9jvDrGJR8zS7 M/GCQ14DmQPUL/JFiEKXFeTqsCzawW8I0+Gx4qxIpBZQJv2eRKzqDdt6K78ISj6qPyAk BN/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=b7LxkD5U2aBFDKTswHeTsi0fGeAA8tsL6myTSlOX05o=; b=NMtr2DyZ88Q0e4HRvCy3lGh0RlW8W6dfZ8gUrd3caM4CajD2QYwLuZW/y+MEI4Nuan CPh9AXjBlRUqvpsYX2gWHQJQyEQTXK88Y1TIDr/a3oa+v9xNWhjtSHfvL/dTBKWqKUxp rAPRPqFAK/OEq33m9iRnn9OKp+WsxvA5DS+xODePb4uvyr6kdwSuw1ThgoGJWEaiRNsv MvEnDupQGeMRnIx0wIvF+tm+EeJ5NKQaiXOf41bMAFHel82uhLOT38yKeR7/gO3c7WIv /VFO+yTJQLpZFZoDHTqZo6RKSttaS3Luau9AGPutglyosdOWZL8GJXWkz8tgYOedrSEs KEsw== 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 l26si2200767lja.0.2018.01.23.05.56.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 05:56:18 -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 52D3411A05ED; Tue, 23 Jan 2018 14:56:17 +0100 (CET) From: stefan@herbrechtsmeier.net To: swupdate@googlegroups.com Cc: Stefan Herbrechtsmeier Subject: [swupdate] [PATCH 3/5] parser: Add support for Lua hook script to script artifacts Date: Tue, 23 Jan 2018 14:55:59 +0100 Message-Id: <1516715761-3043-3-git-send-email-stefan@herbrechtsmeier.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516715761-3043-1-git-send-email-stefan@herbrechtsmeier.net> References: <1516715761-3043-1-git-send-email-stefan@herbrechtsmeier.net> 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 Signed-off-by: Stefan Herbrechtsmeier Acked-by: Stefano Babic --- parser/parser.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/parser/parser.c b/parser/parser.c index e07ed8e..6add999 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -330,7 +330,7 @@ static int parse_partitions(parsertype p, void *cfg, struct swupdate_cfg *swcfg) return 0; } -static int parse_scripts(parsertype p, void *cfg, struct swupdate_cfg *swcfg) +static int parse_scripts(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_State *L) { void *setting, *elem; int count, i; @@ -377,6 +377,13 @@ static int parse_scripts(parsertype p, void *cfg, struct swupdate_cfg *swcfg) } script->is_script = 1; + add_properties(p, elem, script); + + if (run_embscript(p, elem, script, L, swcfg->embscript)) { + free_image(script); + return -1; + } + LIST_INSERT_HEAD(&swcfg->scripts, script, next); TRACE("Found Script: %s\n", @@ -619,7 +626,7 @@ static int parser(parsertype p, void *cfg, struct swupdate_cfg *swcfg) ret = parse_hw_compatibility(p, cfg, swcfg) || parse_files(p, cfg, swcfg, L) || parse_images(p, cfg, swcfg, L) || - parse_scripts(p, cfg, swcfg) || + parse_scripts(p, cfg, swcfg, L) || parse_bootloader(p, cfg, swcfg); /* From patchwork Tue Jan 23 13:56:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 864794 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:c0c::239; helo=mail-wr0-x239.google.com; envelope-from=swupdate+bncbdn7dbh5yqibbdh6ttjqkgqewvep3ii@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="pguDaAId"; dkim-atps=neutral Received: from mail-wr0-x239.google.com (mail-wr0-x239.google.com [IPv6:2a00:1450:400c:c0c::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 3zQqbM2VXGz9s1h for ; Wed, 24 Jan 2018 00:56:31 +1100 (AEDT) Received: by mail-wr0-x239.google.com with SMTP id q2sf310569wrg.5 for ; Tue, 23 Jan 2018 05:56:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1516715788; cv=pass; d=google.com; s=arc-20160816; b=AmQnCf+h6Xx5DXpbmHJcqqittsbPNcqjFTOs0vCfHRDfSjYZTC59fjcZTpawjtIMT3 3nyniWrScNSbLLqHkho8G4QSRrf0fVmvKgQUvrF6s8sVJNvPIbs6oTDmUPX9RybUiwbK s/JBu2jaRONn2rXw++f0+Ik3funO4s9L3HAx3ZiX3Z/jQXoneajvkPJmLYBjdXD1FDZ5 XUCYjhg9sTTkagb7z8p1P1fKBhlcLJCLiwW8gmLqAe2NFo3AbGjvS/QQZyL+Qsx+ugZa cMKAX0798ZAcFlPqUijoQhhJ/8AHBjXH07CqJVN9UCwnCstPafD8k4KBP83D7BzrlW2h JXEg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=6f0smj2gJ9BslSwh94gkKBdMm3nnIWBQP0yq+eVy1as=; b=TDVuaKBkH4Zn3G615Jk65nfwMRLc1dN6Q9iMf+MUEFoM2S086VP47s8t1nGlcD6ytI 0d4cTW7Ry/FGwSIasBrhJCNjr+liS4OBCaDFvZ08NPgGWiSiL77dZr6JRDuVtp09o415 WJMcCgkAUoU5n6IlkISXpKoCI8qdDJIPQuIRMXqPAUMYiN7UDaH1PYudgieVphnqjCTy wHOPo27fWW2NSTsQ+MJLxx1u9TPYWu8g2o0Ssi31aQdcZ5W15nfnE42/0I09CzWds5IA rvveb9/4YjT6QRl2Dh8N5cKVPtrOG3ePh6SN0cg/CaGVt/WHfWK3OGB6YPLnl20uYSbA cOJw== 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:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=6f0smj2gJ9BslSwh94gkKBdMm3nnIWBQP0yq+eVy1as=; b=pguDaAId4J/ifJJhZ89HoXNngczbEUCIYNniT62mg7rN8uS1dH0dNxWmB5GCgkahdz Rf/MDAKNGlWECb2WNo+vtmO5FPSMvA0gJrkeP6M7nJOCqLW46Sq0MbNXom65KWLwe429 ky9AYHM14GKSj27kvbWq42UJ+CUcKu4KbcoaJwKEBg/O92iOHcaXcKqNvcbWuUI/93s4 6lHa94acD7QxyALnq+Kh5RmgGGynI9gzgOJ/JmB6wJ8Ifx2etX1PZ51vbkBU1bQl93sw fp2Lxw+lojBVcE+KSPrAPNOwPX+QRqLDlOU0LwYlS3MYnA8jWjLkDrdAVHBHZkoW7/fE MMuA== 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:in-reply-to:references: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=6f0smj2gJ9BslSwh94gkKBdMm3nnIWBQP0yq+eVy1as=; b=QHsFDD0CzVsaupDohhq30rspll3+5AX+lu2HlLUamPXK/09LNo8XVRzVgOr8TtV7ID ls1pxZATIi3gtv3fMr9W/WpGXx47SrIVG4wW/XT/q3Br8DvEXdYKXsLV1vH7IrJUEFxk ZOVVYcOHQ/3TXc19caNoM14GAVMHeZS/8PsUphw5SXho+CAes3Sp3vWWjhHdm9NFZoud Ql7gA+bNgdO1F3xc21CyYwjfxgqQGXMZlnT0n7hT5nlQTc1Y3r7vIqAhNNuHCa0cpS8B ESw6E4zdeuB1pZtEbYbERBYnSY/kHMJOYhParMx7Mao62zw0gU0h9lLBhAFgmflqX/IH QhMA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxytd5gFD30Qvbg5gDWycK86xoaIJWnI8/HnFV5O7HGzix0LAii5rX wXkDO85w2QIvrIgAg42TLL4= X-Google-Smtp-Source: AH8x225tM5uY0/WUFqDrDfcWP8wVeeGTSuqCjoObHXHFf7nTm9mKBjCeoJltdEmiBfcXnq4sgg2/WA== X-Received: by 10.28.114.10 with SMTP id n10mr29291wmc.4.1516715788570; Tue, 23 Jan 2018 05:56:28 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.47.71 with SMTP id v68ls1600890wmv.6.gmail; Tue, 23 Jan 2018 05:56:27 -0800 (PST) X-Received: by 10.223.151.40 with SMTP id r37mr299905wrb.27.1516715787844; Tue, 23 Jan 2018 05:56:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516715787; cv=none; d=google.com; s=arc-20160816; b=tx5eOfPU+VNrFNaz1Mt7ja8dAvbrIWiwAHWFNVYN4qvGnw12FowZpLD8jmcY7W6t1S 4ukRJWyaW+GBkYBK0hOO3WVVPBlWDdl1ZMRshJK+ZdtQWSWXTGUaGoF5jLftz3iRwG+r IoXQ0uhgY1y/6WIIyNkaVkWLvv3YalC7+kJ0X7yKdLhcTr929reB4SoWf1o69I7AgeWj mcChBgoTM6WW83lsm12BwbxVUChsuHWGu9VkUa432og7/5A5k1aBMUEyv9jrHyMBIR9E J5WXsE0kVeasndPsVlARi7h1rj0cmeX0ylfoPbmtNvySwMiUT4kZzUpQdXHV1yW6PZNm uksg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=R3YMtg1PQq/TXiloH1d9DO/h90ku+QwW88B9Wo9yP0o=; b=synXWZefnghxZQjmj8M+vmVh8o9pXeVFEV78YS3ZDHIEd9sDGMhahfcsHIhQfsd/v3 /paK8VQvQQOpgp0hftL5X0wBFFJ+fqXiXanub8F4QJOVyvVwFwCVkI6pCd3QzuMazwKf 9S/ibHOqzaPrI7sbJJmVU2kGWrfstfYGBrc7D0HkVeXD/VAYaUWWEsXbssKF9vEHMSyz XcaYgqiq+oMl19DTGkV8AmPqTwA2WjyHZKbz3zKlF5VBys2oCaD/cOLEcn9vFDbYvCNH o1ZAzVelZ+bD5Xw9DLqQWpHfbEU9/t0r4V1XJQ53POzcd66JHDArnRuVXHbx77+r6Ibr x80A== 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 r70si1771655wmg.2.2018.01.23.05.56.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 05:56:27 -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 7801311A05ED; Tue, 23 Jan 2018 14:56:27 +0100 (CET) From: stefan@herbrechtsmeier.net To: swupdate@googlegroups.com Cc: Stefan Herbrechtsmeier Subject: [swupdate] [PATCH 4/5] parser: Remove double spaces from trace output Date: Tue, 23 Jan 2018 14:56:00 +0100 Message-Id: <1516715761-3043-4-git-send-email-stefan@herbrechtsmeier.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516715761-3043-1-git-send-email-stefan@herbrechtsmeier.net> References: <1516715761-3043-1-git-send-email-stefan@herbrechtsmeier.net> 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 Signed-off-by: Stefan Herbrechtsmeier Reviewed-by: Stefano Babic --- parser/parser.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/parser/parser.c b/parser/parser.c index 6add999..739cc4c 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -516,10 +516,10 @@ static int parse_images(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua LIST_INSERT_HEAD(&swcfg->images, image, next); - TRACE("Found %sImage %s %s: %s in %s : %s for handler %s%s %s\n", + TRACE("Found %sImage%s%s%s%s: %s in %s : %s for handler %s%s%s\n", image->compressed ? "compressed " : "", - image->id.name, - image->id.version, + strlen(image->id.name) ? " " : "", image->id.name, + strlen(image->id.version) ? " " : "", image->id.version, image->fname, strlen(image->volname) ? "volume" : "device", strlen(image->volname) ? image->volname : @@ -585,15 +585,15 @@ static int parse_files(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_ LIST_INSERT_HEAD(&swcfg->images, file, next); - TRACE("Found %sFile %s %s: %s --> %s (%s) %s\n", + TRACE("Found %sFile%s%s%s%s: %s --> %s (%s)%s\n", file->compressed ? "compressed " : "", - file->id.name, - file->id.version, + strlen(file->id.name) ? " " : "", file->id.name, + strlen(file->id.version) ? " " : "", file->id.version, file->fname, file->path, strlen(file->device) ? file->device : "ROOTFS", (strlen(file->id.name) && file->id.install_if_different) ? - "Version must be checked" : ""); + "; Version must be checked" : ""); } return 0; From patchwork Tue Jan 23 13:56:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 864795 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:4010:c07::23b; helo=mail-lf0-x23b.google.com; envelope-from=swupdate+bncbdn7dbh5yqibbfx6ttjqkgqehjunbwa@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="BBOfv2au"; dkim-atps=neutral Received: from mail-lf0-x23b.google.com (mail-lf0-x23b.google.com [IPv6:2a00:1450:4010:c07::23b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zQqbY0c3rz9s1h for ; Wed, 24 Jan 2018 00:56:40 +1100 (AEDT) Received: by mail-lf0-x23b.google.com with SMTP id l88sf150276lfi.19 for ; Tue, 23 Jan 2018 05:56:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1516715798; cv=pass; d=google.com; s=arc-20160816; b=uriytJVwh51e+5g1mNehpIGsDyWfmaqM0rBm0kAtS4bvJhzJbgEZk7rBYZwQ1rIdRs d+Y2C8DkewAFdWvEQhaVXtiFq1V8uHUx2SC05uXKAWvWhuvw7WkG/fu1xhZecNh4MmBh TRpA5yvX6BZcKni0reyE9VcY5egHqxCvNIYUtR0Wo0H7jgEtVgx3LbSSswf+M/ZGCaqr stsdcPDKFoaeKV4szBJwTKEwbdrg888MzsyR4snWdqeGBPIIp9YxyakWlSbizKi4Cq3z kiNz2pxeUUjRccet3buiUeQ+vGHZsA24VjyvFcnRkCMi0/kt2KU03/agR9OL50Mdp1Ap h2Fg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=go3oRzEvah6AuglXSEtf11WX9VXKS7AeuyFIL9lRYPk=; b=O3FYXphwkZEOSaHaARbyeu6snfN1MoJx2B/HLhgxS16o/vlBJBhkyHNSQx/LfY8+Hm V+1ySihXF2jYVaw9FZqir0Y8FHBEiyHqkNBlhsTT8jD+8ibBt7loO31fxhhwWIVE66Zu +b6riOgoB51rf+zzaWLBbf4IhJhLI8Lja1oS0wB+QZDi4vQqrSAsK0lUSyAVl3VwnB0h p2xNEmIEF4mQNl8RQdaV17Mg9hMyGWSweDbqt8kNacKBi5PJt6CuKRVFFYcrq0mHr0cP ecL8e22UR77UTBhSE5SSiJ09xG73PkJCsDoIO3UePiWxlHEjzlRrMumVWD/91Ld3Ho18 AxcA== 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:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=go3oRzEvah6AuglXSEtf11WX9VXKS7AeuyFIL9lRYPk=; b=BBOfv2auPcQyYs/4SONx9S9wFyIwNfxLp229+DHm4RO+NrsrZDl3b6wr9Z+o9Y00Jf 9LdAyQp4sNBbrzu8RmbGL2scWxjnub8wuFA4ybC13Lm5ZzoNhHeloNOCMeT40KAzldLI Sk2Sz74HPsnh9hfE1hRPELRfX5/8B483xEirJjCjNdaxXAb/5P467A/Hx2oAU0ynwvvC Uo9euO1U+64gU+arbmcki7HeLVlknhUfnBhBJjAgnpwRmGOfFHUWhyES9H6rAXIdUevm L4WjZt8dOoJr2e790vVwHdHBMVvt1uGb5WG1I0Hh+ECfz0n/RjtJDzVL30zRPaUkb8X6 jP2A== 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:in-reply-to:references: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=go3oRzEvah6AuglXSEtf11WX9VXKS7AeuyFIL9lRYPk=; b=ZN1BZOovh4aP/dN5V6KgeSEgDadM7ogkKWpU+NdeavUihopWFbNscuMci7sUtkDiC8 CFYZmpcsFbf1S2XjI/9awpDj423QhDLlFgTrZzdwXMr9+Pwd+MjN7RpNmHHgXBIkmFP3 fyrcEd31YEU/r2dWHfjQeyWq8uk0bsPgbgSGjbGGjja5eYQgT0R3+mykIKfnwJmikkwa RFWjycV96EVoUH28SG+RPoqyvfP5J74HG4AGynvKzB3yJMiOGpZPtTCXcUtDXVL5EjuO CN3b0bIllsMesaQiRYlBFKd9dtAoZzYb0p/HKtNpsGkBVlyjA3JpcDd8MBVwbK6pnO7+ RvWQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxytd2sWDHYTaT0q6up1YLz3tRSmw0EExCwrF16kyuO1F/ovRI3ud7 g880kfz4UFzOA4+fUaibGxg= X-Google-Smtp-Source: AH8x227WoXJ8XFV2wHv89BLCNi8dB3gXWWb4gPolnh1psfUt/k9xeV794CP4iJcyE7y4MGrngud0Tw== X-Received: by 10.25.149.65 with SMTP id x62mr6956lfd.8.1516715798221; Tue, 23 Jan 2018 05:56:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.25.141.139 with SMTP id p133ls841070lfd.8.gmail; Tue, 23 Jan 2018 05:56:37 -0800 (PST) X-Received: by 10.25.202.77 with SMTP id h13mr224834lfj.21.1516715797387; Tue, 23 Jan 2018 05:56:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516715797; cv=none; d=google.com; s=arc-20160816; b=hrRkR3QgpPIHrtAnfv8EHKDnMcWsak3z226MRdxk2mqQmj2mNOA+/vPtGaxxjMjEWw YE3KztkXxGGcra+TJazNV8tLUePgJT14u6ffy4hqqDSz22XU/RUixDYIC/PHjtDF3wH3 +2rieKSt3uAlqrHvh9pM+Ir/0VfA6zjuEg0HZV3PEXH7SGIif0Ezyx/6F4tTzbY+Y4O8 n7R3oaC/SumVQ8e+rsIHNil3prBYJcfhBQwXeFFswM/73pUdoX0/R6WL3CSTdNYqayGP qj2hBEyp973MN92A9jCkCdOuxVPKUX9G5ZYK/b6616LHWD561ZKK+ROk9NzTUcL9wDyD AgOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rx8iEPiz98IAR7NaYYFcAXWiL7LTQ23HYGLRWc1XNnQ=; b=bY2DNQGWjUasSl9bD7oE+DJCsOnX7TedAJR+haYmxAoFs2d/eSRr+MyElyYc9Ectsb /V84Yn3bT8+IsrS3APY/yhg3O2F7blMkO2A4CZF4/ZyjbVj00a0dXSGSHJdsO0nUNCUw TLyQxBR6Ez1nla/74u9z9pTQIELdTkpSgSXN9stIzqRy4iwprBVBKLntkaxucwVFNAae T4aDuiXmPjKw/s64wdfWPiTw9ijeBmUvbjmeVmgE6wCcTIef9pBR0ffGbYxmsut3WR5S 9c1lixun2UjbYiee0PijZWdPmwEKiAuRHyImv3gjh9GSJilBXI7PPfmhg1Wa+pj9et10 xL/g== 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 b10si49586lfe.4.2018.01.23.05.56.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 05:56:36 -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 3FA7211A05ED; Tue, 23 Jan 2018 14:56:36 +0100 (CET) From: stefan@herbrechtsmeier.net To: swupdate@googlegroups.com Cc: Stefan Herbrechtsmeier Subject: [swupdate] [PATCH 5/5] parser: Allow embedded script to skip images Date: Tue, 23 Jan 2018 14:56:01 +0100 Message-Id: <1516715761-3043-5-git-send-email-stefan@herbrechtsmeier.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516715761-3043-1-git-send-email-stefan@herbrechtsmeier.net> References: <1516715761-3043-1-git-send-email-stefan@herbrechtsmeier.net> 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 Skip an image if the embedded script returns a nil instead of a image table Signed-off-by: Stefan Herbrechtsmeier Acked-by: Stefano Babic --- corelib/lua_interface.c | 12 ++++++---- doc/source/sw-description.rst | 2 +- parser/parser.c | 51 ++++++++++++++++++++++++++++++------------- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 57f5908..64e5a5f 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -990,17 +990,21 @@ int lua_parser_fn(lua_State *L, const char *fcn, struct img_type *img) */ image2table(L, img); - if (lua_pcall(L, 1, 2, 0)) { + ret = lua_pcall(L, 1, 2, 0); + if (ret || !lua_isboolean(L, -2)) { LUAstackDump(L); ERROR("ERROR Calling Lua %s", fcn); return -1; } - if (lua_type(L, -2) == LUA_TBOOLEAN) - ret = lua_toboolean(L, -2) ? 0 : 1; - LUAstackDump(L); + ret = lua_toboolean(L, -2) ? 0 : -1; + + /* Return 1 to indicate a missing (skipped) image */ + if (!ret && !lua_toboolean(L, -1)) + ret = 1; + table2image(L, img); lua_pop(L, 2); /* clear stack */ diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index 58b5aa9..10562e6 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -770,7 +770,7 @@ Attributes can be changed in the Lua script and values are taken over on return. The Lua function must return 2 values: - a boolean, to indicate whether the parsing was correct - - the image table + - the image table or nil to indicate that the image should be skipped Example: diff --git a/parser/parser.c b/parser/parser.c index 739cc4c..9b92480 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -333,7 +333,7 @@ static int parse_partitions(parsertype p, void *cfg, struct swupdate_cfg *swcfg) static int parse_scripts(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_State *L) { void *setting, *elem; - int count, i; + int count, i, skip; struct img_type *script; setting = find_node(p, cfg, "scripts", swcfg); @@ -379,15 +379,22 @@ static int parse_scripts(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lu add_properties(p, elem, script); - if (run_embscript(p, elem, script, L, swcfg->embscript)) { + skip = run_embscript(p, elem, script, L, swcfg->embscript); + if (skip < 0) { free_image(script); return -1; } - LIST_INSERT_HEAD(&swcfg->scripts, script, next); - - TRACE("Found Script: %s\n", + TRACE("%s Script: %s\n", + skip ? "Skip" : "Found", script->fname); + + if (skip) { + free_image(script); + continue; + } + + LIST_INSERT_HEAD(&swcfg->scripts, script, next); } return 0; } @@ -464,7 +471,7 @@ static int parse_bootloader(parsertype p, void *cfg, struct swupdate_cfg *swcfg) static int parse_images(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_State *L) { void *setting, *elem; - int count, i; + int count, i, skip; struct img_type *image; setting = find_node(p, cfg, "images", swcfg); @@ -509,14 +516,14 @@ static int parse_images(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua add_properties(p, elem, image); - if (run_embscript(p, elem, image, L, swcfg->embscript)) { + skip = run_embscript(p, elem, image, L, swcfg->embscript); + if (skip < 0) { free_image(image); return -1; } - LIST_INSERT_HEAD(&swcfg->images, image, next); - - TRACE("Found %sImage%s%s%s%s: %s in %s : %s for handler %s%s%s\n", + TRACE("%s %sImage%s%s%s%s: %s in %s : %s for handler %s%s%s\n", + skip ? "Skip" : "Found", image->compressed ? "compressed " : "", strlen(image->id.name) ? " " : "", image->id.name, strlen(image->id.version) ? " " : "", image->id.version, @@ -529,6 +536,13 @@ static int parse_images(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua (strlen(image->id.name) && image->id.install_if_different) ? "Version must be checked" : "" ); + + if (skip) { + free_image(image); + continue; + } + + LIST_INSERT_HEAD(&swcfg->images, image, next); } return 0; @@ -537,7 +551,7 @@ static int parse_images(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua static int parse_files(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_State *L) { void *setting, *elem; - int count, i; + int count, i, skip; struct img_type *file; setting = find_node(p, cfg, "files", swcfg); @@ -578,14 +592,14 @@ static int parse_files(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_ add_properties(p, elem, file); - if (run_embscript(p, elem, file, L, swcfg->embscript)) { + skip = run_embscript(p, elem, file, L, swcfg->embscript); + if (skip < 0) { free_image(file); return -1; } - LIST_INSERT_HEAD(&swcfg->images, file, next); - - TRACE("Found %sFile%s%s%s%s: %s --> %s (%s)%s\n", + TRACE("%s %sFile%s%s%s%s: %s --> %s (%s)%s\n", + skip ? "Skip" : "Found", file->compressed ? "compressed " : "", strlen(file->id.name) ? " " : "", file->id.name, strlen(file->id.version) ? " " : "", file->id.version, @@ -594,6 +608,13 @@ static int parse_files(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_ strlen(file->device) ? file->device : "ROOTFS", (strlen(file->id.name) && file->id.install_if_different) ? "; Version must be checked" : ""); + + if (skip) { + free_image(file); + continue; + } + + LIST_INSERT_HEAD(&swcfg->images, file, next); } return 0;