From patchwork Fri Oct 28 10:05:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1695940 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::339; helo=mail-wm1-x339.google.com; envelope-from=swupdate+bncbcxploxj6ikrb26s52namgqedbewlpy@googlegroups.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=HQT0QI/7; dkim-atps=neutral Received: from mail-wm1-x339.google.com (mail-wm1-x339.google.com [IPv6:2a00:1450:4864:20::339]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MzJ8J3Vcwz20S2 for ; Fri, 28 Oct 2022 21:05:35 +1100 (AEDT) Received: by mail-wm1-x339.google.com with SMTP id t20-20020a7bc3d4000000b003c6bfea856asf1276870wmj.1 for ; Fri, 28 Oct 2022 03:05:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666951531; cv=pass; d=google.com; s=arc-20160816; b=nZH/qziKlwwerF3Pfxp3bOOKGeosOcQMTN6uyKvIRLdM3RViNd2aR3D/vw2a6TbqF+ Yh1UPgXATCor60gs+3Lm+FBM6HuNUFT13TnajsCOXioj7eeZg2lFDq7o0txKUNc2MEFa KM7uwkQXRy5H5/KsrBnL02JHjl8ZicxKKxS2wnm+jYnm2Escf0Tx9Ao2T49nnupnoO0A 8rQ7DqrT5XEjy5cwSvFYS35t6MG+VQeBo7hkerOt2xPGHLjyA99f7gdGaO5sOun5ch6s Oj8rdI1QLWBp5l9FlyBtGTLC1LdI91IGaY9uBkwR8bT6Cy2P8EJVFxrxYMs7TXUEOeHs aQ2Q== 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=HH1JjtHUp60Ppu2jTE8tfJeDfPJ3lDdxaDb6FmIzNf8=; b=mEKCjVPA0hxbQga79qNrvdRsJABt2d0OE3b2OWRHVFA3D5XaWljFq7RFwBTKmZLmhG PyESWycyNwPb+4P/lw1IUP9GVECNCe87v+P1k/YWwrvF4ks6BPYA5NRzskOMREpRlvS5 v7msRkk5qb0pz5Sg1CwTKDDyeBPZmm8uVmE7az+ebgQJLP+1xmAcLa5e2UaZ/7GmzaO8 v1/nNt68wk/KYbhpmbQyKi/rap7TVFuvOVet9PRebjOlOiIfL/k4NCuycejd2GTSgfPA wLL2UdGJFr0tLRjRWpiwdxcJF1CrQmoqAO4jVXKKHnAQLVut3Y7gX4LB3hHGlTzVenrO +Dfw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=HH1JjtHUp60Ppu2jTE8tfJeDfPJ3lDdxaDb6FmIzNf8=; b=HQT0QI/7qr7jHGh/pEREhQKyhgePlp07v0ZSn0Zwl6x6gZq4FO/2RPWe5gMSlJsb6n 8VG2XMbIOsbGfSWyh1XVk7xp+lCG9rh+7fK1L3+ogX0ehp0UtZdqxsFLWo5ax+gQoUBw LwXaI1h5bnMNlWsIVo37FTU1JSqjBUTbsVc9ami/Bg/ZyTHqfUTEtidEqQkj3vrnVf+Y pWF9DEAiBPiW3grB0PCk3e9PUpbkmNwn7WvyOLgSwEicsXIWiGXyUye5PyCRP5e+72C9 RMxs4FdMiIuPcV98d26Js8bnWQBZId9UPC82P3rfR0X4b4JPaLcvSNunLnS0tc2sM9vJ z43g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=HH1JjtHUp60Ppu2jTE8tfJeDfPJ3lDdxaDb6FmIzNf8=; b=qumMJQ0qPwOxeWWeneMU5chsFf8ZVLfEBJhqczQpw9jT77uSC9JkLQJ6O1912gqStc 2QZkAblVEna8mnZ3vybRCWsPCbWh5eVS/km9gKRnksTvR6wjFOmyJtLBYLgYedWGnVKM awHRiRHvNOaCXPPuDl6970B/iD0iwZZfbS8u3InnB4RCkTsDVTq46BJvndL4+gE3UKKg SczlWl3yswGut89wGVzGyBPiPqS6w/HTVQMwQoH/UjvXMePykWvKNKLoXfW+gx0jLMYG SFXQ8GJXSAYAByb/gbFskrJWwQYuF/Nh5LwmXPdHfA69xfdtcWz58kKXWJxVDCx47+20 vVEA== Sender: swupdate@googlegroups.com X-Gm-Message-State: ACrzQf05MIIuwmgjMQ96kustcTiYKg1cjcHnOTyJqLKEbMHpFI9keJVd DoeQuGADcQ74gkCC7Q1PAoc= X-Google-Smtp-Source: AMsMyM4H0LZAYiGbGje85g7KAc1wlukVA19Lag9hDxCpfR1xdyrpX212Zs+/6txC9i0fS26YUlKWUA== X-Received: by 2002:a05:600c:1e17:b0:3c6:bc31:1f3d with SMTP id ay23-20020a05600c1e1700b003c6bc311f3dmr9059069wmb.52.1666951531692; Fri, 28 Oct 2022 03:05:31 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:d205:0:b0:228:ddd7:f40e with SMTP id j5-20020adfd205000000b00228ddd7f40els2959760wrh.3.-pod-prod-gmail; Fri, 28 Oct 2022 03:05:30 -0700 (PDT) X-Received: by 2002:a05:6000:15c7:b0:22e:7aea:f7b1 with SMTP id y7-20020a05600015c700b0022e7aeaf7b1mr35390176wry.213.1666951530385; Fri, 28 Oct 2022 03:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666951530; cv=none; d=google.com; s=arc-20160816; b=wD7k14/aRtxPwKBwHwY2ccSj+6S53L9IeV/Yuh6bXjh5/JReIo4rbMPe+gzeYrv4kU mMSOJ2auFLp0HQxIepdXqECKMq7icaZvmKeprzLMeCoS8YEIswMutm/oLwTA9Nb0Mq9l Ma2hZ69Gkt+J87bY2hYUmuUpsBauhfk1qJssh0vnQJDpNtD0msTeG1IAAyyoHptzYWO3 zM5MjLjbU/glrxDMgt9oa83wgraXjccdutd7MhA9ZrNZqA/pqK3/qUvKir4uJRGYoxLe kfEPpkY2bw51eqZTKLt6iEISk0nNmrAIB9YCydnmDs6iXXHAHWOsLUJt2y5bNWBQG4Z2 RgkA== 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=OAQ2ovpTej7wnV2thcTJL9+BcTVVtF2bqzHe7s9zmD8=; b=JyblL4/3HsYQJUx6gaDIVaQTA3bj4of8rraZwRd8LL6QE09Fczxw06PLBivZiRMuWk r3uRFfXna004l/Q+1rWWNTbd1PBic9ve2avMG33f+mI76IrSdBPd5ZUyCMQI4wiEAqYz lCkrhIblphvQ5zP+D9hLzTXlDC0Bd519vg0UZ6krzPDAKW2WzbOMN8AvqSxe32KC7PJN n/rkc3cWzx7P1iqlvLihYBAHI81MzX3o5dITb8kI+QLD7EOSKpooJ5M8odcu4usSeC64 WBAESuLZcvr5yjGKKTMS0g6wbMQrTv5todC8/bUnrnjD6cXdl7APTnwwmjsDFYNsAdAK J86Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by 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 l8-20020a5d6d88000000b002367b2e748esi132560wrs.5.2022.10.28.03.05.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Oct 2022 03:05:30 -0700 (PDT) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend03.mail.m-online.net (unknown [192.168.6.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4MzJ8B0cJYz1s949; Fri, 28 Oct 2022 12:05:30 +0200 (CEST) Received: from localhost (dynscan3.mnet-online.de [192.168.6.84]) by mail.m-online.net (Postfix) with ESMTP id 4MzJ896tWGz1qqlR; Fri, 28 Oct 2022 12:05:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan3.mail.m-online.net [192.168.6.84]) (amavisd-new, port 10024) with ESMTP id EDDvl4zeP6QS; Fri, 28 Oct 2022 12:05:28 +0200 (CEST) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 28 Oct 2022 12:05:28 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 16B2445406BB; Fri, 28 Oct 2022 12:05:28 +0200 (CEST) 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 yENU-7QpTHnU; Fri, 28 Oct 2022 12:05:25 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 5FEAC45404E4; Fri, 28 Oct 2022 12:05:25 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic , Frieder Schrempf Subject: [swupdate] [PATCH V2] bootloader handler: flag to not override bootenv values Date: Fri, 28 Oct 2022 12:05:24 +0200 Message-Id: <20221028100524.131772-1-sbabic@denx.de> X-Mailer: git-send-email 2.34.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.10 is neither permitted nor denied by 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: , The handler sets all variable found in the file, independently if they were also set in the bootenv section of sw-description. Add a "nooverride" flag to avoid that variables set in sw-description can be overwritten. Add documentation for the handler. Signed-off-by: Stefano Babic Reported-by: Frieder Schrempf --- Changes since V1: - make code readable (F. Schrempf) doc/source/handlers.rst | 36 ++++++++++++++++++++++++++++++++++++ handlers/boot_handler.c | 13 +++++++++++++ 2 files changed, 49 insertions(+) diff --git a/doc/source/handlers.rst b/doc/source/handlers.rst index 67fb2c7..5f686fe 100644 --- a/doc/source/handlers.rst +++ b/doc/source/handlers.rst @@ -829,6 +829,42 @@ is called twice. } +Bootloader handler +------------------ + +The bootloader handler allows to set bootloader's environment with a file. The file shold have the format: + +:: + + # Comments are allowed using the hash char + + varname=value + +Empty lines are skipped. This simplifies the update of the whole environment instead of setting each variable inside the +"bootenv" section in sw-description. The property *nooverride* allows to skip variables that are already set in sw-description. If +not set, variables set in bootenv are overwritten. + + +:: + + images: ( + { + filename = "uEnv.txt"; + type = "bootloader"; + properties: { + nooverride = "true"; + } + } + ); + + bootenv: ( + { + name = "bootenv01key"; + value = "SOME VALUE"; + }); + +In the example above, bootenv01key is not overwritten by a value in uEnv.txt because the flag "nooverride" is set. + Archive handler --------------- diff --git a/handlers/boot_handler.c b/handlers/boot_handler.c index 73c9116..1324015 100644 --- a/handlers/boot_handler.c +++ b/handlers/boot_handler.c @@ -33,6 +33,7 @@ static int install_boot_environment(struct img_type *img, char *buf; char filename[MAX_IMAGE_FNAME]; struct stat statbuf; + bool no_override = false; /* do not override variables in bootenv */ if (snprintf(filename, sizeof(filename), "%s%s", get_tmpdirscripts(), img->fname) >= (int)sizeof(filename)) { @@ -75,6 +76,7 @@ static int install_boot_environment(struct img_type *img, return -ENOMEM; } + no_override = strtobool(dict_get_value(&img->properties, "nooverride")); while (fgets(buf, MAX_BOOT_SCRIPT_LINE_LENGTH, fp)) { char **pair = NULL; unsigned int cnt; @@ -90,6 +92,17 @@ static int install_boot_environment(struct img_type *img, pair = string_split(buf, '='); cnt = count_string_array((const char **)pair); + /* + * Skip if a variable was already parsed in the bootenv + * section, in that case it is already present in the dictionary. + * This avoid to override with the value in file + */ + if (cnt && no_override && dict_get_value(img->bootloader, pair[0])) { + TRACE("Variable %s already set, skipping..", pair[0]); + free_string_array(pair); + continue; + } + switch (cnt) { case 2: TRACE("name = %s value = %s", pair[0], pair[1]);