This does seem sensible as long as it isn't some file which you might later
need to patch to fix something quickly.
I think this is OK but will defer to ${MAINTAINER} if opinions differ :)
On 2022/05/22 04:29, Klemens Nanni wrote:
> A new port wants to fetch from the internet at build time:
>
> > file( DOWNLOAD ${CONFIG_URL} ${CMAKE_CURRENT_BINARY_DIR}/config.json )
>
> No problem, I fetch the file via DISTFILES.
>
> Now I'd like to pass in the fetched file via the same variable,
> without patching, like so:
>
> CONFIGURE_ARGS += `-DCONFIG_URL=file://${DISTDIR}/config.json`
>
> but using an offline file:// URL pointing at an absoloute path does not
> work here since out cmake cmake denies `file(DOWNLOAD, ...) completely.
>
> So now I have to patch the sources and add yet another hack, e.g.
>
> -> file( DOWNLOAD ${CONFIG_URL} ${CMAKE_CURRENT_BINARY_DIR}/config.json )
> +> configure_file(${CONFIG_URL} ${CMAKE_CURRENT_BINARY_DIR}/config.json
> COPYONLY )
>
>
> This is more annoying than it could be, imho.
>
> Would it be sensible to allow DOWNLOAD'ing absoloute file:// URLs?
> Then no patching would be required.
> I have to patch four times in total now, in two new ports.
>
> I just gave this a shot and made cmake only bail out if the URL does not
> begin with "file:///" (three slashes).
>
>
> Feedback? Objection? OK?
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/devel/cmake/Makefile,v
> retrieving revision 1.207
> diff -u -p -r1.207 Makefile
> --- Makefile 26 Mar 2022 08:14:00 -0000 1.207
> +++ Makefile 22 May 2022 03:15:07 -0000
> @@ -6,7 +6,7 @@ VER = 3.20.3
> EPOCH = 0
> DISTNAME = cmake-${VER}
> CATEGORIES = devel
> -REVISION = 6
> +REVISION = 7
>
> HOMEPAGE = https://www.cmake.org/
>
> Index: patches/patch-Source_cmFileCommand_cxx
> ===================================================================
> RCS file: /cvs/ports/devel/cmake/patches/patch-Source_cmFileCommand_cxx,v
> retrieving revision 1.6
> diff -u -p -r1.6 patch-Source_cmFileCommand_cxx
> --- patches/patch-Source_cmFileCommand_cxx 11 Mar 2022 18:49:50 -0000
> 1.6
> +++ patches/patch-Source_cmFileCommand_cxx 22 May 2022 04:28:41 -0000
> @@ -1,19 +1,19 @@
> Index: Source/cmFileCommand.cxx
> --- Source/cmFileCommand.cxx.orig
> +++ Source/cmFileCommand.cxx
> -@@ -1599,6 +1599,12 @@ bool HandleDownloadCommand(std::vector<std::string> co
> - cmExecutionStatus& status)
> - {
> - #if !defined(CMAKE_BOOTSTRAP)
> +@@ -1609,6 +1609,12 @@ bool HandleDownloadCommand(std::vector<std::string> co
> + ++i;
> + std::string file;
> +
> + std::string openbsd_build;
> + if ((cmSystemTools::GetEnv("MODCMAKE_PORT_BUILD", openbsd_build) &&
> -+ openbsd_build == std::string("yes"))) {
> ++ openbsd_build == std::string("yes")) && !cmHasPrefix(url, "file:///"))
> {
> + status.SetError("DOWNLOAD not supported in OpenBSD ports builds.");
> + return false;
> + }
> - auto i = args.begin();
> - if (args.size() < 2) {
> - status.SetError("DOWNLOAD must be called with at least two arguments.");
> + long timeout = 0;
> + long inactivity_timeout = 0;
> + std::string logVar;
> @@ -1985,6 +1991,12 @@ bool HandleUploadCommand(std::vector<std::string> cons
> cmExecutionStatus& status)
> {