[{"id":34464,"web_url":"https://patchwork.libcamera.org/comment/34464/","msgid":"<bb66daf0-20f4-4db5-a24c-0a8cc6b1de63@ideasonboard.com>","date":"2025-06-13T13:05:15","subject":"Re: [PATCH v9 13/13] 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. 11. 16:24 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/base/global_configuration.cpp | 17 +++++++++++------\n>   2 files changed, 16 insertions(+), 6 deletions(-)\n> \n> diff --git a/Documentation/runtime_configuration.rst b/Documentation/runtime_configuration.rst\n> index 9e2650799..8f9e6fd75 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/base/global_configuration.cpp b/src/libcamera/base/global_configuration.cpp\n> index 9c9d1d74e..bcafadda2 100644\n> --- a/src/libcamera/base/global_configuration.cpp\n> +++ b/src/libcamera/base/global_configuration.cpp\n> @@ -75,12 +75,6 @@ bool GlobalConfiguration::loadFile(const std::filesystem::path &fileName)\n>   \treturn true;\n>   }\n> \n> -const std::vector<std::filesystem::path>\n> -\tglobalConfigurationDirectories = {\n> -\t\tstd::filesystem::path(LIBCAMERA_SYSCONF_DIR),\n> -\t\tstd::filesystem::path(\"/etc/libcamera\"),\n> -\t};\n> -\n>   void GlobalConfiguration::load()\n>   {\n>   \tconst char *libcameraConfigName =\n> @@ -97,6 +91,17 @@ void 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> +\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> +\tglobalConfigurationDirectories.push_back(\n> +\t\tstd::filesystem::path(LIBCAMERA_SYSCONF_DIR));\n> +\tglobalConfigurationDirectories.push_back(\n> +\t\tstd::filesystem::path(\"/etc/libcamera\"));\n\nI think you can get rid of the explicit `std::filesystem::path(...)`.\n\n\nRegards,\nBarnabás Pőcze\n\n\n> +\n>   \tstd::filesystem::path userConfigurationDirectory;\n>   \tchar *xdgConfigHome = utils::secure_getenv(\"XDG_CONFIG_HOME\");\n>   \tif (xdgConfigHome) {\n> --\n> 2.49.0\n>","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 F296DBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Jun 2025 13:05:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2BD1F68DBB;\n\tFri, 13 Jun 2025 15:05:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 76E2E68DB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Jun 2025 15:05:19 +0200 (CEST)","from [192.168.33.21] (185.221.143.107.nat.pool.zt.hu\n\t[185.221.143.107])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9C580348;\n\tFri, 13 Jun 2025 15:05:09 +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=\"MXacJ6ME\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1749819910;\n\tbh=ZOg7uX8LHEEhg/Q+FoPJZ34TGmOtH1UmqeHohpsRaHY=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=MXacJ6MEb4MyqeG6n9n58ypOQl8FLroWCLQytPOV9ELu8kBXcLC4zVr3ogy03qBaN\n\tKwbnw+l4t+EzOnYACDDi7VN19eIO8rBfS4m2y67MXbpfv4Px0jIw6xYqbtL2CrupOX\n\t+fn6XT/z3Lf6tHnP7sTCfRlWqVHVnoKFqW1FD6/s=","Message-ID":"<bb66daf0-20f4-4db5-a24c-0a8cc6b1de63@ideasonboard.com>","Date":"Fri, 13 Jun 2025 15:05:15 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v9 13/13] 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":"<20250611142431.33306-1-mzamazal@redhat.com>\n\t<v8O1cwv8C4rHquUnY5hO7XGbsbWlAjy1ktXp23v7oCxCG_z9W29C36APVhTKVF709vvkQsrnI5cMzyce64TUHw==@protonmail.internalid>\n\t<20250611142431.33306-14-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":"<20250611142431.33306-14-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>"}}]