From owner-svn-ports-all@freebsd.org Tue Feb 23 23:24:27 2021 Return-Path: Delivered-To: svn-ports-all@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 A76A2557F9C; Tue, 23 Feb 2021 23:24:27 +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 4DlZrW4K1Sz4pvN; Tue, 23 Feb 2021 23:24:27 +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 86CF322472; Tue, 23 Feb 2021 23:24:27 +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 11NNOR99095274; Tue, 23 Feb 2021 23:24:27 GMT (envelope-from adridg@FreeBSD.org) Received: (from adridg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 11NNORXb095272; Tue, 23 Feb 2021 23:24:27 GMT (envelope-from adridg@FreeBSD.org) Message-Id: <202102232324.11NNORXb095272@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adridg set sender to adridg@FreeBSD.org using -f From: Adriaan de Groot Date: Tue, 23 Feb 2021 23:24:27 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r566434 - 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: 566434 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Feb 2021 23:24:27 -0000 Author: adridg Date: Tue Feb 23 23:24:26 2021 New Revision: 566434 URL: https://svnweb.freebsd.org/changeset/ports/566434 Log: Update CMake's FreeBSD pkg(8) generator There is an OPTION CPACK for CMake that enables a FreeBSD pkg(8) generator: after building anything CMake-based, `cpack -G FREEBSD` gives you a a ready-to-go installable package. Well, assuming you turn the option on, and the bugs in the generator are fixed. Which this patch does. I've tried it with supertux2 and some other bits and pieces and the patch is in a MR upstream. Added: head/devel/cmake/files/patch-cmake-issue-18031 (contents, props changed) Modified: head/devel/cmake/Makefile Modified: head/devel/cmake/Makefile ============================================================================== --- head/devel/cmake/Makefile Tue Feb 23 23:19:40 2021 (r566433) +++ head/devel/cmake/Makefile Tue Feb 23 23:24:26 2021 (r566434) @@ -4,6 +4,7 @@ PORTNAME= cmake # Remember to update devel/cmake-doc and devel/cmake-gui as well. DISTVERSION= 3.19.5 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= https://github.com/Kitware/CMake/releases/download/v${DISTVERSION}/ \ https://www.cmake.org/files/v${PORTVERSION}/ Added: head/devel/cmake/files/patch-cmake-issue-18031 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/cmake/files/patch-cmake-issue-18031 Tue Feb 23 23:24:26 2021 (r566434) @@ -0,0 +1,100 @@ +Use newer pkg_create() API + +diff --git Source/CPack/cmCPackFreeBSDGenerator.cxx Source/CPack/cmCPackFreeBSDGenerator.cxx +index b673006f25..63c7810b15 100644 +--- Source/CPack/cmCPackFreeBSDGenerator.cxx ++++ Source/CPack/cmCPackFreeBSDGenerator.cxx +@@ -35,6 +35,56 @@ int cmCPackFreeBSDGenerator::InitializeInternal() + + cmCPackFreeBSDGenerator::~cmCPackFreeBSDGenerator() = default; + ++// This is a wrapper for struct pkg_create and pkg_create() ++// ++// Instantiate this class with suitable parameters, then ++// check isValid() to check if it's ok. Afterwards, call ++// Create() to do the actual work. This will leave a package ++// in the given `output_dir`. ++// ++// This wrapper cleans up the struct pkg_create. ++class PkgCreate ++{ ++public: ++ PkgCreate() ++ : d(nullptr) ++ { ++ } ++ PkgCreate(const std::string& output_dir, const std::string& toplevel_dir, ++ const std::string& manifest_name) ++ : d(pkg_create_new()) ++ , manifest(manifest_name) ++ ++ { ++ if (d) { ++ pkg_create_set_format(d, "txz"); ++ 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()); ++ pkg_create_set_output_dir(d, output_dir.c_str()); ++ } ++ } ++ ~PkgCreate() ++ { ++ if (d) ++ pkg_create_free(d); ++ } ++ ++ bool isValid() const { return d; } ++ ++ bool Create() ++ { ++ if (!isValid()) ++ return false; ++ int r = pkg_create(d, manifest.c_str(), nullptr, false); ++ return r == 0; ++ } ++ ++private: ++ struct pkg_create* d; ++ std::string manifest; ++}; ++ + // 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() + { + if (!this->ReadListFile("Internal/CPack/CPackFreeBSD.cmake")) { + cmCPackLogger(cmCPackLog::LOG_ERROR, +- "Error while execution CPackFreeBSD.cmake" << std::endl); ++ "Error while executing CPackFreeBSD.cmake" << std::endl); + return 0; + } + +@@ -317,9 +367,25 @@ int cmCPackFreeBSDGenerator::PackageFiles() + ONE_PACKAGE_PER_COMPONENT); + } + ++ if (!pkg_initialized() && pkg_init(NULL, NULL) != EPKG_OK) { ++ cmCPackLogger(cmCPackLog::LOG_ERROR, ++ "Can not initialize FreeBSD libpkg." << std::endl); ++ return 0; ++ } ++ + std::string output_dir = cmSystemTools::CollapseFullPath("../", toplevel); +- pkg_create_from_manifest(output_dir.c_str(), ::TXZ, toplevel.c_str(), +- manifestname.c_str(), nullptr); ++ PkgCreate package(output_dir, toplevel, manifestname); ++ if (package.isValid()) { ++ if (!package.Create()) { ++ cmCPackLogger(cmCPackLog::LOG_ERROR, ++ "Error during pkg_create()" << std::endl); ++ return 0; ++ } ++ } else { ++ cmCPackLogger(cmCPackLog::LOG_ERROR, ++ "Error before pkg_create()" << std::endl); ++ return 0; ++ } + + std::string broken_suffix = + cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), ".txz");