From owner-svn-ports-head@freebsd.org Sat Feb 27 16:52:21 2021 Return-Path: Delivered-To: svn-ports-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2D6D754CDE4; Sat, 27 Feb 2021 16:52:21 +0000 (UTC) (envelope-from adridg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DnsyF0sZ4z3MhP; Sat, 27 Feb 2021 16:52:21 +0000 (UTC) (envelope-from adridg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 10BB3211A6; Sat, 27 Feb 2021 16:52:21 +0000 (UTC) (envelope-from adridg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 11RGqKsk080911; Sat, 27 Feb 2021 16:52:20 GMT (envelope-from adridg@FreeBSD.org) Received: (from adridg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 11RGqKnK080910; Sat, 27 Feb 2021 16:52:20 GMT (envelope-from adridg@FreeBSD.org) Message-Id: <202102271652.11RGqKnK080910@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adridg set sender to adridg@FreeBSD.org using -f From: Adriaan de Groot Date: Sat, 27 Feb 2021 16:52:20 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r566712 - in head/devel/cmake: . files X-SVN-Group: ports-head X-SVN-Commit-Author: adridg X-SVN-Commit-Paths: in head/devel/cmake: . files X-SVN-Commit-Revision: 566712 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Feb 2021 16:52:21 -0000 Author: adridg Date: Sat Feb 27 16:52:20 2021 New Revision: 566712 URL: https://svnweb.freebsd.org/changeset/ports/566712 Log: Improve FreeBSD packaging in devel/cmake The OPTION CPACK in CMake enables building FreeBSD packages directly from cmake / cpack. This can be useful, for instance, with not-yet- packaged software, or building packages for proprietary software. This patch has been submitted upstream; it resolves a disagreement between cmake and libpkg about the name of the resulting package. Modified: head/devel/cmake/Makefile head/devel/cmake/files/patch-cmake-issue-18031 Modified: head/devel/cmake/Makefile ============================================================================== --- head/devel/cmake/Makefile Sat Feb 27 16:50:21 2021 (r566711) +++ head/devel/cmake/Makefile Sat Feb 27 16:52:20 2021 (r566712) @@ -4,7 +4,7 @@ PORTNAME= cmake # Remember to update devel/cmake-doc and devel/cmake-gui as well. DISTVERSION= 3.19.5 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= devel MASTER_SITES= https://github.com/Kitware/CMake/releases/download/v${DISTVERSION}/ \ https://www.cmake.org/files/v${PORTVERSION}/ Modified: head/devel/cmake/files/patch-cmake-issue-18031 ============================================================================== --- head/devel/cmake/files/patch-cmake-issue-18031 Sat Feb 27 16:50:21 2021 (r566711) +++ head/devel/cmake/files/patch-cmake-issue-18031 Sat Feb 27 16:52:20 2021 (r566712) @@ -1,11 +1,36 @@ -Use newer pkg_create() API - +diff --git Modules/Internal/CPack/CPackFreeBSD.cmake Modules/Internal/CPack/CPackFreeBSD.cmake +index ae40532017..c35089cbcf 100644 +--- Modules/Internal/CPack/CPackFreeBSD.cmake ++++ Modules/Internal/CPack/CPackFreeBSD.cmake +@@ -34,7 +34,7 @@ function(_cpack_freebsd_fallback_var OUTPUT_VAR_NAME) + endif() + endforeach() + if(NOT VALUE) +- message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from any variable ${FALLBACK_VAR_NAMES}.") ++ message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from (any of) ${FALLBACK_VAR_NAMES}.") + endif() + endfunction() + diff --git Source/CPack/cmCPackFreeBSDGenerator.cxx Source/CPack/cmCPackFreeBSDGenerator.cxx -index b673006f25..63c7810b15 100644 +index b673006f25..9bafc792db 100644 --- Source/CPack/cmCPackFreeBSDGenerator.cxx +++ Source/CPack/cmCPackFreeBSDGenerator.cxx -@@ -35,6 +35,56 @@ int cmCPackFreeBSDGenerator::InitializeInternal() +@@ -21,8 +21,12 @@ + #include + ++// Suffix including the '.', used to tell libpkg what compression to use ++static const char FreeBSDPackageSuffix[] = ".txz"; ++ + cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator() +- : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr", ".txz") ++ : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr", ++ FreeBSDPackageSuffix) + { + } + +@@ -35,6 +39,56 @@ int cmCPackFreeBSDGenerator::InitializeInternal() + cmCPackFreeBSDGenerator::~cmCPackFreeBSDGenerator() = default; +// This is a wrapper for struct pkg_create and pkg_create() @@ -30,7 +55,7 @@ index b673006f25..63c7810b15 100644 + + { + if (d) { -+ pkg_create_set_format(d, "txz"); ++ pkg_create_set_format(d, FreeBSDPackageSuffix + 1); // Skip over the '.' + pkg_create_set_compression_level(d, 0); // Explicitly set default + pkg_create_set_overwrite(d, false); + pkg_create_set_rootdir(d, toplevel_dir.c_str()); @@ -61,7 +86,16 @@ index b673006f25..63c7810b15 100644 // This is a wrapper, for use only in stream-based output, // that will output a string in UCL escaped fashion (in particular, // quotes and backslashes are escaped). The list of characters -@@ -281,7 +331,7 @@ int cmCPackFreeBSDGenerator::PackageFiles() +@@ -271,7 +325,7 @@ void write_manifest_files(cmGeneratedFileStream& s, + s << "\"files\": {\n"; + for (std::string const& file : files) { + s << " \"/" << cmSystemTools::RelativePath(toplevel, file) << "\": \"" +- << "" ++ << "" // this gets replaced by libpkg by the actual SHA256 + << "\",\n"; + } + s << " },\n"; +@@ -281,11 +335,10 @@ int cmCPackFreeBSDGenerator::PackageFiles() { if (!this->ReadListFile("Internal/CPack/CPackFreeBSD.cmake")) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -70,10 +104,40 @@ index b673006f25..63c7810b15 100644 return 0; } -@@ -317,9 +367,25 @@ int cmCPackFreeBSDGenerator::PackageFiles() +- std::vector::const_iterator fileIt; + cmWorkingDirectory wd(toplevel); + + files.erase(std::remove_if(files.begin(), files.end(), ignore_file), +@@ -317,17 +370,59 @@ int cmCPackFreeBSDGenerator::PackageFiles() ONE_PACKAGE_PER_COMPONENT); } ++ // There should be one name in the packageFileNames (already, see comment ++ // in cmCPackGenerator::DoPackage(), which holds what CPack guesses ++ // will be the package filename. libpkg does something else, though, ++ // so update the single filename to what we know will be right. ++ if (this->packageFileNames.size() == 1) { ++ std::string currentPackage = this->packageFileNames[0]; ++ int lastSlash = currentPackage.rfind('/'); ++ ++ // If there is a pathname, preserve that; libpkg will write out ++ // a file with the package name and version as specified in the ++ // manifest, so we look those up (again). lastSlash is the slash ++ // itself, we need that as path separator to the calculated package name. ++ std::string actualPackage = ++ ((lastSlash != std::string::npos) ++ ? std::string(currentPackage, 0, lastSlash + 1) ++ : std::string()) + ++ var_lookup("CPACK_FREEBSD_PACKAGE_NAME") + '-' + ++ var_lookup("CPACK_FREEBSD_PACKAGE_VERSION") + FreeBSDPackageSuffix; ++ ++ this->packageFileNames.clear(); ++ this->packageFileNames.emplace_back(actualPackage); ++ ++ cmCPackLogger(cmCPackLog::LOG_DEBUG, ++ "Real filename:" << this->packageFileNames[0] << std::endl); ++ } ++ + if (!pkg_initialized() && pkg_init(NULL, NULL) != EPKG_OK) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Can not initialize FreeBSD libpkg." << std::endl); @@ -97,4 +161,14 @@ index b673006f25..63c7810b15 100644 + } std::string broken_suffix = - cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), ".txz"); +- cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), ".txz"); ++ cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), FreeBSDPackageSuffix); + for (std::string& name : packageFileNames) { + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Packagefile " << name << std::endl); + if (cmHasSuffix(name, broken_suffix)) { + name.replace(name.size() - broken_suffix.size(), std::string::npos, +- ".txz"); ++ FreeBSDPackageSuffix); + break; + } + }