[{"id":34701,"web_url":"https://patchwork.libcamera.org/comment/34701/","msgid":"<1e6ba8e7-4d71-4ef6-a894-182e43e6151d@ideasonboard.com>","date":"2025-06-27T14:00:44","subject":"Re: [PATCH v11 12/12] config: Make configuration directories\n\tconfigurable","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2025. 06. 24. 10:36 keltezéssel, Milan Zamazal írta:\n> A newly introduced LIBCAMERA_CONFIG_DIR environment variable specifies a\n> directory or a list of directories separated by colons where to look for\n> the libcamera configuration file before trying the standard locations.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>   Documentation/runtime_configuration.rst |  5 +++++\n>   src/libcamera/global_configuration.cpp  | 14 +++++++++-----\n>   2 files changed, 14 insertions(+), 5 deletions(-)\n> \n> diff --git a/Documentation/runtime_configuration.rst b/Documentation/runtime_configuration.rst\n> index 5648db7d7..3146cdba6 100644\n> --- a/Documentation/runtime_configuration.rst\n> +++ b/Documentation/runtime_configuration.rst\n> @@ -19,6 +19,11 @@ order:\n>   - LIBCAMERA_SYSCONF_DIR/configuration.yaml\n>   - /etc/libcamera/configuration.yaml\n>   \n> +If LIBCAMERA_CONFIG_DIR environment variable is non-empty then it\n> +specifies additional directories where to look for the configuration\n> +file, before looking at the standard locations. It can be a single\n> +directory or multiple directories separated by colons.\n> +\n>   The default name of the configuration file, configuration.yaml, can be\n>   overridden in LIBCAMERA_CONFIG_NAME environment variable. The variable\n>   can specify just an alternative configuration file name to be looked up\n> diff --git a/src/libcamera/global_configuration.cpp b/src/libcamera/global_configuration.cpp\n> index 2c3b6cf97..2b990cdea 100644\n> --- a/src/libcamera/global_configuration.cpp\n> +++ b/src/libcamera/global_configuration.cpp\n> @@ -67,11 +67,6 @@ bool GlobalConfiguration::loadFile(const std::filesystem::path &fileName)\n>   \n>   bool GlobalConfiguration::load()\n>   {\n> -\tconst std::vector<std::filesystem::path> globalConfigurationDirectories = {\n> -\t\tstd::filesystem::path(LIBCAMERA_SYSCONF_DIR),\n> -\t\tstd::filesystem::path(\"/etc/libcamera\"),\n> -\t};\n> -\n>   \tconst char *libcameraConfigName =\n>   \t\tutils::secure_getenv(\"LIBCAMERA_CONFIG_NAME\");\n>   \tif (!libcameraConfigName)\n> @@ -86,6 +81,15 @@ bool GlobalConfiguration::load()\n>   \tif (configName.empty())\n>   \t\tconfigName = std::filesystem::path(\"configuration.yaml\");\n>   \n> +\tconst char *const configDir = utils::secure_getenv(\"LIBCAMERA_CONFIG_DIR\");\n\nI think you can drop the top-level `const`, other variables here don't have it.\n\n\n> +\tstd::vector<std::filesystem::path> globalConfigurationDirectories;\n> +\tif (configDir)\n> +\t\tfor (auto const &path : utils::split(configDir, \":\"))\n> +\t\t\tif (!path.empty())\n> +\t\t\t\tglobalConfigurationDirectories.push_back(path);\n\nI would probably add `{}` around everything except the innermost `if`.\n\n\nRegards,\nBarnabás Pőcze\n\n\n> +\tglobalConfigurationDirectories.push_back(LIBCAMERA_SYSCONF_DIR);\n> +\tglobalConfigurationDirectories.push_back(\"/etc/libcamera\");\n> +\n>   \tstd::filesystem::path userConfigurationDirectory;\n>   \tconst char *xdgConfigHome = utils::secure_getenv(\"XDG_CONFIG_HOME\");\n>   \tif (xdgConfigHome) {","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4E3C8C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 Jun 2025 14:01:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 404C168E06;\n\tFri, 27 Jun 2025 16:01:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F50468E0D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Jun 2025 16:00:54 +0200 (CEST)","from [192.168.33.12] (185.221.143.107.nat.pool.zt.hu\n\t[185.221.143.107])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9FCEF1809;\n\tFri, 27 Jun 2025 16:00:34 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"WoMr8i59\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1751032834;\n\tbh=kHa7zj3TCVLSsjAQt+7Gc0fozN2MvhkWj7ZjRXh7VyU=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=WoMr8i59mNPzXxYQz2c2GjqDMG7MeBDMZnRq6zMQXbkywl9ro3EFbJFHrwTYLVKPf\n\tW6Wc7+fXTEeVfCn4HZLAWU9gS/TNf/43mXNHgMHYXkK5b/IElAaPnqLvD+dBWDmjM8\n\taVjctBO+lMAogLwGeZGWy/d0VGTsDs2UfZhftYVo=","Message-ID":"<1e6ba8e7-4d71-4ef6-a894-182e43e6151d@ideasonboard.com>","Date":"Fri, 27 Jun 2025 16:00:44 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v11 12/12] config: Make configuration directories\n\tconfigurable","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20250624083612.27230-1-mzamazal@redhat.com>\n\t<20250624083612.27230-13-mzamazal@redhat.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250624083612.27230-13-mzamazal@redhat.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":34717,"web_url":"https://patchwork.libcamera.org/comment/34717/","msgid":"<85tt40vqej.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-06-27T21:13:56","subject":"Re: [PATCH v11 12/12] config: Make configuration directories\n\tconfigurable","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Barnabás,\n\nBarnabás Pőcze <barnabas.pocze@ideasonboard.com> writes:\n\n> Hi\n>\n> 2025. 06. 24. 10:36 keltezéssel, Milan Zamazal írta:\n>> A newly introduced LIBCAMERA_CONFIG_DIR environment variable specifies a\n>> directory or a list of directories separated by colons where to look for\n>> the libcamera configuration file before trying the standard locations.\n>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n>> ---\n>>   Documentation/runtime_configuration.rst |  5 +++++\n>>   src/libcamera/global_configuration.cpp  | 14 +++++++++-----\n>>   2 files changed, 14 insertions(+), 5 deletions(-)\n>> diff --git a/Documentation/runtime_configuration.rst b/Documentation/runtime_configuration.rst\n>> index 5648db7d7..3146cdba6 100644\n>> --- a/Documentation/runtime_configuration.rst\n>> +++ b/Documentation/runtime_configuration.rst\n>> @@ -19,6 +19,11 @@ order:\n>>   - LIBCAMERA_SYSCONF_DIR/configuration.yaml\n>>   - /etc/libcamera/configuration.yaml\n>>   +If LIBCAMERA_CONFIG_DIR environment variable is non-empty then it\n>> +specifies additional directories where to look for the configuration\n>> +file, before looking at the standard locations. It can be a single\n>> +directory or multiple directories separated by colons.\n>> +\n>>   The default name of the configuration file, configuration.yaml, can be\n>>   overridden in LIBCAMERA_CONFIG_NAME environment variable. The variable\n>>   can specify just an alternative configuration file name to be looked up\n>> diff --git a/src/libcamera/global_configuration.cpp b/src/libcamera/global_configuration.cpp\n>> index 2c3b6cf97..2b990cdea 100644\n>> --- a/src/libcamera/global_configuration.cpp\n>> +++ b/src/libcamera/global_configuration.cpp\n>> @@ -67,11 +67,6 @@ bool GlobalConfiguration::loadFile(const std::filesystem::path &fileName)\n>>     bool GlobalConfiguration::load()\n>>   {\n>> -\tconst std::vector<std::filesystem::path> globalConfigurationDirectories = {\n>> -\t\tstd::filesystem::path(LIBCAMERA_SYSCONF_DIR),\n>> -\t\tstd::filesystem::path(\"/etc/libcamera\"),\n>> -\t};\n>> -\n>>   \tconst char *libcameraConfigName =\n>>   \t\tutils::secure_getenv(\"LIBCAMERA_CONFIG_NAME\");\n>>   \tif (!libcameraConfigName)\n>> @@ -86,6 +81,15 @@ bool GlobalConfiguration::load()\n>>   \tif (configName.empty())\n>>   \t\tconfigName = std::filesystem::path(\"configuration.yaml\");\n>>   +\tconst char *const configDir = utils::secure_getenv(\"LIBCAMERA_CONFIG_DIR\");\n>\n> I think you can drop the top-level `const`, other variables here don't have it.\n\nOK.\n\n>> +\tstd::vector<std::filesystem::path> globalConfigurationDirectories;\n>> +\tif (configDir)\n>> +\t\tfor (auto const &path : utils::split(configDir, \":\"))\n>> +\t\t\tif (!path.empty())\n>> +\t\t\t\tglobalConfigurationDirectories.push_back(path);\n>\n> I would probably add `{}` around everything except the innermost `if`.\n\nOK.\n\n> Regards,\n> Barnabás Pőcze\n>\n>\n>> +\tglobalConfigurationDirectories.push_back(LIBCAMERA_SYSCONF_DIR);\n>> +\tglobalConfigurationDirectories.push_back(\"/etc/libcamera\");\n>> +\n>>   \tstd::filesystem::path userConfigurationDirectory;\n>>   \tconst char *xdgConfigHome = utils::secure_getenv(\"XDG_CONFIG_HOME\");\n>>   \tif (xdgConfigHome) {","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 42302C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 Jun 2025 21:14:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C821C68E04;\n\tFri, 27 Jun 2025 23:14:03 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C5EA968DE5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Jun 2025 23:14:01 +0200 (CEST)","from mail-wm1-f72.google.com (mail-wm1-f72.google.com\n\t[209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-451-jFCMFJ_lMX2YB2Pc4H4oGA-1; Fri, 27 Jun 2025 17:13:59 -0400","by mail-wm1-f72.google.com with SMTP id\n\t5b1f17b1804b1-450d6768d4dso1508725e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Jun 2025 14:13:58 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-453823b75cdsm89022305e9.32.2025.06.27.14.13.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 27 Jun 2025 14:13:56 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"bvJASt/w\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1751058840;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=v9vIXeGhF+O2M0ZEla0dXbb62t4GpzVtLK/n0l2hD0Y=;\n\tb=bvJASt/w1FSyxkHMYTu+nI2VJCmQ/3R2dJP5wDvC6f3Fy/mHxwQcaFQeJ2+A5NnK5SvlBn\n\tYtVVF6w72xK9nxWkw8oWPOLTKqOeuf5VPHP5P8eee7xtPlP1TvlCPuJtNCHbN7QVSQjsEt\n\t6+gzChA2/EDVo8Jg1+1Dx4qYX+7sTFA=","X-MC-Unique":"jFCMFJ_lMX2YB2Pc4H4oGA-1","X-Mimecast-MFC-AGG-ID":"jFCMFJ_lMX2YB2Pc4H4oGA_1751058838","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1751058838; x=1751663638;\n\th=content-transfer-encoding:mime-version:user-agent:message-id:date\n\t:references:in-reply-to:subject:cc:to:from:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=YbN4/7rs0AQnknq/ERvaUYMlXDeXiENCQT9TZIR7xQY=;\n\tb=vxkICXms6llyfK+Ne9I/y8RUEbYHbFnnN0nyxeId/fFixq/wrFbHF2H5ng/gfJQAj6\n\tzF6q32l7SjutoPpCxHYZspVsayu1xvWur9a5D1/QdX/pyBpl56xoMVQGOBh9A0pxd+8B\n\tp8tS/sSQW7sZjbie5zfbGnLB3ItRKU6+040MNSstk2K5WdhvxoJiG7uGgUFspF0ToEeJ\n\tBd6G1eMoVMhFa3l8mZeB2erVKIFUPaSh7VTryRutlZ8CWQX8tlUD/maSFOMWnqzx3hrL\n\t9tiDgPiHCltDXetYp1ijpM/GIFU2XojWJbvtPxMFN8SY9I/gOgBliMjmSYgoO0zs54rJ\n\tPlTw==","X-Gm-Message-State":"AOJu0YzwMKQOlU1K+VaTCJ/7RYJTPGhP1Z33UFe/FMF9utMGCPK0O60b\n\taiAu5hioR601AfI+AhAJv4OXT5G8pE7vP4HzERucttOe7yCzKQHXhjMo1ij2fdC3afgy+CwvcnO\n\teiv2Mr9lJphaLb6mJ8LV0S8F90iRC85nHmun1qAFDVbyTHuhkAiZs+Zr6ec6WysNNh7FWxz3VBx\n\tM=","X-Gm-Gg":"ASbGnctHKFcnchPxdinMfYUTzPOw+p69S71MIaoh+ZUHMtS+GfDGkWYGyqEe9TEgFqO\n\tUk7CMpLVlkvytx41HUDYJGg4K84v6xLu15eclY7shSbHXnC5TLYwinX8l69a2aQYPYMPazGXQQG\n\tRxPvSIBDFDqExYBnxWLd64dIKFecFRwvfExlZ6VBCKfXAypktmaqw4VxPhABiPImHoAEIpd6/km\n\t5RTIx7/0EyILY0kC5ubM58DfmFSnEZDNw1Am8yrUUnM8YTO1Ng/T253gs11cxncQBHlRNhjoJpe\n\tNk5EeKIMltDG5wvyySjYjbm7L723i/kngJqhbRrhxxnbXpJHZNirDoMkR3Edog7GeUtFuQrc8/0\n\t=","X-Received":["by 2002:a05:600c:474a:b0:450:d3b9:4b96 with SMTP id\n\t5b1f17b1804b1-4538ee39fbdmr51225795e9.13.1751058837696; \n\tFri, 27 Jun 2025 14:13:57 -0700 (PDT)","by 2002:a05:600c:474a:b0:450:d3b9:4b96 with SMTP id\n\t5b1f17b1804b1-4538ee39fbdmr51225615e9.13.1751058837300; \n\tFri, 27 Jun 2025 14:13:57 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IEy9aZcWtyj1fl2OGKdHY8jBMyvoKjXet/MkKQ2RXguR8l8W6KqsvkQYAKnSVjjabBhJxoBig==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,  Kieran Bingham\n\t<kieran.bingham@ideasonboard.com>,  Laurent Pinchart\n\t<laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH v11 12/12] config: Make configuration directories\n\tconfigurable","In-Reply-To":"<1e6ba8e7-4d71-4ef6-a894-182e43e6151d@ideasonboard.com> (\n\t=?utf-8?b?IkJhcm5hYsOhcyBQxZFjemUiJ3M=?= message of \"Fri,\n\t27 Jun 2025  16:00:44 +0200\")","References":"<20250624083612.27230-1-mzamazal@redhat.com>\n\t<20250624083612.27230-13-mzamazal@redhat.com>\n\t<1e6ba8e7-4d71-4ef6-a894-182e43e6151d@ideasonboard.com>","Date":"Fri, 27 Jun 2025 23:13:56 +0200","Message-ID":"<85tt40vqej.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"DMDevZGDHx9wljt4L3LYIqchjjMS1OJrrJF0Sij7R9s_1751058838","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]