From patchwork Tue Mar 27 14:40:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faustas Azuolas Bagdonas X-Patchwork-Id: 891616 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::240; helo=mail-wm0-x240.google.com; envelope-from=swupdate+bncbcf5bcwlqmprbbfq5hkqkgqez3khmjq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="GP7aQf1f"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="o8dlGK+J"; dkim-atps=neutral Received: from mail-wm0-x240.google.com (mail-wm0-x240.google.com [IPv6:2a00:1450:400c:c09::240]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 409Ybr6Xs9z9s1j for ; Wed, 28 Mar 2018 01:41:11 +1100 (AEDT) Received: by mail-wm0-x240.google.com with SMTP id i64sf5614531wmd.8 for ; Tue, 27 Mar 2018 07:41:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1522161669; cv=pass; d=google.com; s=arc-20160816; b=ZzEDB8AwqeOK/Lh1AMFdIHj8L74+gzJCRtWkSiQ/tC/F5QYj5cLeh24KAKUV1eyVhA s001+Kk9dXDKHTPjIHf73V903Bcu8jMbkwvjnNl8sY+FxV70dg71ZnLA7Y4w8GC628h0 KOglNnuev8NVrl6JUkaVDi8UnUeKvxF1COUi3+f5YVUS9jI7naItzDICwb8ZHWGLOLDJ iHDvNunFIw8kJD3gLtRst2uitbhgB/L9PoTAb5ltRCW4EnabV6fWv/EdfHKpg0w5t3W0 RfMRoWpWGOjHI5c6d58V9Aunr8ILKOUhOJPfBBmyM7G4lfq8+b7TGi94PWOYy4xUYKhf g71A== 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:dkim-signature:arc-authentication-results; bh=YnWRI0RIiX2ALzGLCU3ugy8ag6oM1zRFMB8GT+rEh2U=; b=j9YinMUP3vuqz2JU1lhe0BRH+wxfGYTkutfKkVCVekq2YoX6ZTfnP6QpkJ8vYeZvg1 qXdX+10zOxew3i1PeeF+T/zWLckWyLWbifLX5LMe/gYVWdhWcGzHann5mMFHe8ZE2rHH m/u0kb5Co2W3VkjnrmCIcJUgO2eoqaCKdG9o/pZCJxx8sujbBk7sN1E5Gd/f9Gz1tarV +dBdKtteLMxrKfkhVt5s6H+ztMBiCJCOK6c6qHFjEIG+W7hilAy81sOFTfTCBxGs+Jio wweiI7h9UKBcGeIoA8NAfa1u+UrhvMqZSwnhwWyk0++KqciZxgY8MKwiwTKSO3Nu842Y pwcg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kQCnqOoy; spf=pass (google.com: domain of afaustas@gmail.com designates 2a00:1450:400c:c0c::22b as permitted sender) smtp.mailfrom=afaustas@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=YnWRI0RIiX2ALzGLCU3ugy8ag6oM1zRFMB8GT+rEh2U=; b=GP7aQf1fhCKfqgcIvfN3BIVPRsny9quvWUNln1ckKEuRTeGDFm9GUxAuz7AhctSWr8 KB2+U3ansnorMLoZ2DYn6kswt1IshW6/dP47ZOP2BqtnoKy/KXMHAVzo6XIYqEGaOUpg mQaFxaB1sbEUUhE6IDj3Z3Rc2bgPuqYhxNInyAqsJMND8MTr2GD0DzNEgrgTmwmZq/8Z 1kXp13uc8Ex3eYbSH+zd/LWeiyeQAcQPkURHX/hzRTax0iwNYWuzDlsS0fT4x/bFazv9 Ot6XdV2Wb7/biDuSkhgyCJcZ+7XjaXfUKLoMFDwieCATG9fFMDSV5k27Y4Bo/tI6T/GD RWQw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=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=YnWRI0RIiX2ALzGLCU3ugy8ag6oM1zRFMB8GT+rEh2U=; b=o8dlGK+JPktlH3BZiu8ZtNp034mmH3eUUBrfdXDkbPh67AWfZ7ykAaquLMCfHe7x/A 5m0SkKtBSFBfpZMWg696OZ2bLmlnPzTci3MPtjGwgAydXLNYX3AGWQg+5KEP2YdUIM49 Y+pa6rvi6ccs2zEWYeihiEC1yik0dRPM+8sdlEJpCSj72shwlBv65DI8g8Dzl1y01K4W kbnzUwQkCVlYefiEJR09yHRGqkKFWbLjB+jHwtr8rluXY09Z8ULEnGE6qxHD4swFM5v5 EpVNTLQ7/ze8cLBKntQd6+g64SvzBY/EB3CCE+FGRcoTBJ0XdL7ihIaqsixluO67uRVo HbcQ== 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=YnWRI0RIiX2ALzGLCU3ugy8ag6oM1zRFMB8GT+rEh2U=; b=aaqelPsJ8du36UupuQdkr8sb8dWbwZU7bZmaTWHnXFNUhDOAHf8GBpVYo6oo5FnAkK hQO/0YS7YHFGtPNTSH1+w3gS+qixhdpMEqt9ZHsoB/rvGEQgpgvBA7Q7EZXkW0bXyTMF dDt7X0H78IBgeQ6uobFeMSFa4z632/ys7TyARty1ySSGsKqvZXyR0pzY+YkfR2gHeuuG Ldq/yfKyE6yOUijhgWgP3rRGkMqYk0a7xvGFm37uwdlr6cDeHYAREPaW0+g8TowKAk5O sV73ZXUjgvR7KeuttEHVtl3f7EgR/hdC7NTKCjgX3KNOoBIRgxpxvIQVlkr/Nhp2qXFr si3A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AElRT7H9FiHgPBUrB3CS3T+NYQqswu9cPe3i3OS4MNHb9ihuAB9aUn8y j1yloFY9B6/fyYgsuJmMWOU= X-Google-Smtp-Source: AIpwx4818cxTvGlcM3bDNkbVJScNmKtX3yzqsWZS1WfzGY1YDI2sPPC91UIZaqJUztSqUQqtYgqr7g== X-Received: by 10.28.112.11 with SMTP id l11mr23264wmc.4.1522161669095; Tue, 27 Mar 2018 07:41:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.223.227.8 with SMTP id b8ls440459wrj.10.gmail; Tue, 27 Mar 2018 07:41:08 -0700 (PDT) X-Received: by 10.223.209.195 with SMTP id m3mr2868584wri.15.1522161668538; Tue, 27 Mar 2018 07:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522161668; cv=none; d=google.com; s=arc-20160816; b=E3ucIxcAE+eGPqC3iJpEFTq+89TyzedySsowL2kQs05uIyZFD6UCaMX65WIwyduZI0 N3BjyFuB41t+jGzt0BDby/gh3NOuV5F0W/5n6v2ZOtw6MsBBeDkbfuQ/4sS8aikjvbKp cARL9fEc3OspaiujH1F+EZiU2gnUTdZoT3g612x4IqA2AFQtIVNd3CqqGohL6sLEQMPB RNGUb84b3yIRwaiJCEfQg4daJQqCzxebLL5/8CdDJ1fCwHIWklrjdfFAAFaGSk8+EEA2 AuUFg4m9WLmbS1VI/k5gmvgD1RwmE+I8rmVCjmyA2NrerCNVl2AzkmPVv+wttkNqswFz TN2w== 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:dkim-signature :arc-authentication-results; bh=gkN8yR/vVwtSbYCd6wXNqF9gRk+qEmNDmKMwkYa67UU=; b=my3yOipgLz85R6hDEzlZe1GBl09OCl/QAMYRxVYhyEWDwa4QmfhyL7Z821UJRxBV0v z/Urz2Tc2TbghdZtnnkzB4hU8HeGsuRCkaVDtLt6b7vVGJ4hSzALXKuK3cLlmcl9y0+F n7jafd1IUBIHETyjL8/cWms90TzHOm4gn4OLGPJ/jkQuiVdKkPxw3x1VjK71+sEs6qyn VZCczx4ugtMTrDNVgBilkp+8JQZ0wOy2gP0kFzV59vf3xOLvYEEspIO8qPfe+SUV39Zy OdFcDXzUHW+ELvhbs5CK7mYI1kc/8PKSDz931Lz3DVQzgleCip+bES+NqE8A6oFAccT3 l1lQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kQCnqOoy; spf=pass (google.com: domain of afaustas@gmail.com designates 2a00:1450:400c:c0c::22b as permitted sender) smtp.mailfrom=afaustas@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-wr0-x22b.google.com (mail-wr0-x22b.google.com. [2a00:1450:400c:c0c::22b]) by gmr-mx.google.com with ESMTPS id f137si600926wme.0.2018.03.27.07.41.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 07:41:08 -0700 (PDT) Received-SPF: pass (google.com: domain of afaustas@gmail.com designates 2a00:1450:400c:c0c::22b as permitted sender) client-ip=2a00:1450:400c:c0c::22b; Received: by mail-wr0-x22b.google.com with SMTP id c24so22662385wrc.6 for ; Tue, 27 Mar 2018 07:41:08 -0700 (PDT) X-Received: by 10.223.142.23 with SMTP id n23mr36419597wrb.28.1522161667765; Tue, 27 Mar 2018 07:41:07 -0700 (PDT) Received: from faustaspc.lifodas.local ([213.197.143.19]) by smtp.gmail.com with ESMTPSA id q9sm1264526wrf.11.2018.03.27.07.41.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Mar 2018 07:41:06 -0700 (PDT) From: Faustas Azuolas Bagdonas To: swupdate@googlegroups.com Cc: Faustas Azuolas Bagdonas Subject: [swupdate] [PATCH] Added update description field support. Date: Tue, 27 Mar 2018 17:40:15 +0300 Message-Id: <1522161615-4794-1-git-send-email-afaustas@gmail.com> X-Mailer: git-send-email 2.7.4 X-Original-Sender: afaustas@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kQCnqOoy; spf=pass (google.com: domain of afaustas@gmail.com designates 2a00:1450:400c:c0c::22b as permitted sender) smtp.mailfrom=afaustas@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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: , Signed-off-by: Faustas Azuolas Bagdonas --- doc/source/sw-description.rst | 4 ++++ include/globals.h | 1 + include/swupdate.h | 1 + parser/parser.c | 30 ++++++++++++++++++++++++------ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index 4498431..2944d3d 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -27,6 +27,7 @@ The following example explains better the implemented tags: software = { version = "0.1.0"; + description = "Firmware update for XXXXX Project"; hardware-compatibility: [ "1.0", "1.2", "1.3"]; @@ -898,6 +899,9 @@ There are 4 main sections inside sw-description: | | | | compared with the entries in | | | | | sw-versions | +-------------+----------+------------+---------------------------------------+ + | description | string | | user-friendly description of the | + | | | | swupdate archive (any string) | + +-------------+----------+------------+---------------------------------------+ | install-if | bool | images | flag | | different | | files | if set, name and version are | | | | | compared with the entries in | diff --git a/include/globals.h b/include/globals.h index 91f6c29..f797f4f 100644 --- a/include/globals.h +++ b/include/globals.h @@ -11,6 +11,7 @@ #define BANNER "Swupdate v" SWU_VER "\n" #define SWUPDATE_GENERAL_STRING_SIZE 256 +#define SWUPDATE_UPDATE_DESCRIPTION_STRING_SIZE 512 #define MAX_IMAGE_FNAME SWUPDATE_GENERAL_STRING_SIZE #define MAX_URL SWUPDATE_GENERAL_STRING_SIZE #define MAX_VOLNAME SWUPDATE_GENERAL_STRING_SIZE diff --git a/include/swupdate.h b/include/swupdate.h index 6f0170d..6f57fab 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -113,6 +113,7 @@ struct swupdate_global_cfg { struct swupdate_cfg { char name[SWUPDATE_GENERAL_STRING_SIZE]; + char description[SWUPDATE_UPDATE_DESCRIPTION_STRING_SIZE]; char version[SWUPDATE_GENERAL_STRING_SIZE]; char software_set[SWUPDATE_GENERAL_STRING_SIZE]; char running_mode[SWUPDATE_GENERAL_STRING_SIZE]; diff --git a/parser/parser.c b/parser/parser.c index 9b92480..1afb476 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -678,6 +678,7 @@ int parse_cfg (struct swupdate_cfg *swcfg, const char *filename) char node[128]; parsertype p = LIBCFG_PARSER; int ret; + config_setting_t *setting; memset(&cfg, 0, sizeof(cfg)); config_init(&cfg); @@ -695,16 +696,19 @@ int parse_cfg (struct swupdate_cfg *swcfg, const char *filename) return -1; } - snprintf(node, sizeof(node), "%s.version", - NODEROOT); - - if (!config_lookup_string(&cfg, node, &str)) { + if((setting = find_node(p, &cfg, "version", swcfg)) == NULL) { ERROR("Missing version in configuration file\n"); return -1; } else { - strncpy(swcfg->version, str, sizeof(swcfg->version)); + GET_FIELD_STRING(p, setting, NULL, swcfg->version); TRACE("Version %s", swcfg->version); } + + if((setting = find_node(p, &cfg, "description", swcfg)) != NULL) { + GET_FIELD_STRING(p, setting, NULL, swcfg->description); + TRACE("Description %s", swcfg->description); + } + snprintf(node, sizeof(node), "%s.embedded-script", NODEROOT); if (config_lookup_string(&cfg, node, &str)) { @@ -732,7 +736,7 @@ int parse_json(struct swupdate_cfg *swcfg, const char *filename) struct stat stbuf; unsigned int size; char *string; - json_object *cfg; + json_object *cfg, *setting; parsertype p = JSON_PARSER; /* Read the file. If there is an error, report it and exit. */ @@ -762,6 +766,20 @@ int parse_json(struct swupdate_cfg *swcfg, const char *filename) return -1; } + if((setting = find_node(p, cfg, "version", swcfg)) == NULL) { + ERROR("Missing version in configuration file\n"); + free(string); + return -1; + } else { + GET_FIELD_STRING(p, setting, NULL, swcfg->version); + TRACE("Version %s", swcfg->version); + } + + if((setting = find_node(p, cfg, "description", swcfg)) != NULL) { + GET_FIELD_STRING(p, setting, NULL, swcfg->description); + TRACE("Description %s", swcfg->description); + } + ret = parser(p, cfg, swcfg); json_object_put(cfg);