From 5be487d27af4647b6ab7ce7f8b6ea6e312b0ac3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Bjarni?= Date: Wed, 20 Sep 2023 16:56:16 +0000 Subject: [PATCH] [libsystemd] add new port (#31150) * add libsystemd, libcap, libxcrypt * baseline libsystemd, libcap, libxcrypt * versions tree libsystemd, libcap, libxcrypt * licenses for libsystemd, libcap, libxcrypt in vcpkg.json * update tree for libsystemd, libcap, libxcrypt * allow restricted header libxcrypt * tree allow restricted header libxcrypt * remove message Warning * use targets exist during configure, instead of configure_file variable to search for zstd * update git-tree * add quotes to full paths and remove messages in portfiles * update git-tree * remove extra spaces * update git-tree * remove extra line * update git tree * do configure hack differently and remove cross compile patch and override compiler during build_make * update git tree * try either gcc or clang for libcap and specify log file root for each build command * update git-tree * libcap use host dependency of self * libcap update git tree * libsystemd is LGPL2.1 * update libsystemd git-tree * change from find_package to find_dependency in unofficial cmake export of libsystemd * update libsystemd git-tree * update libxcrypt * update git tree libxcrypt * patch pkgconfig file of libsystemd * update libsystemd git-tree * update libsystemd to 254 * update git-tree libsystemd * * Copy of cap_names.h checked in for cross compilation * Decouple cap_names.h from libcap.* make targets * Use vcpkg_cmake_get_vars instead of ENV{CC} etc. * Remove unnecessary self dependency of libcap * Update libcap to 1.2.69 * Update git-tree * cleanup old versions from version jsons --- ports/libcap/cap_names.h | 56 ++++++++++++++++ ports/libcap/cap_names.separation.patch | 13 ++++ ports/libcap/configure | 1 + ports/libcap/portfile.cmake | 85 +++++++++++++++++++++++++ ports/libcap/vcpkg.json | 14 ++++ ports/libsystemd/pkgconfig.patch | 11 ++++ ports/libsystemd/portfile.cmake | 54 ++++++++++++++++ ports/libsystemd/vcpkg.json | 20 ++++++ ports/libxcrypt/portfile.cmake | 20 ++++++ ports/libxcrypt/vcpkg.json | 8 +++ versions/baseline.json | 12 ++++ versions/l-/libcap.json | 9 +++ versions/l-/libsystemd.json | 9 +++ versions/l-/libxcrypt.json | 9 +++ 14 files changed, 321 insertions(+) create mode 100644 ports/libcap/cap_names.h create mode 100644 ports/libcap/cap_names.separation.patch create mode 100755 ports/libcap/configure create mode 100644 ports/libcap/portfile.cmake create mode 100644 ports/libcap/vcpkg.json create mode 100644 ports/libsystemd/pkgconfig.patch create mode 100644 ports/libsystemd/portfile.cmake create mode 100644 ports/libsystemd/vcpkg.json create mode 100644 ports/libxcrypt/portfile.cmake create mode 100644 ports/libxcrypt/vcpkg.json create mode 100644 versions/l-/libcap.json create mode 100644 versions/l-/libsystemd.json create mode 100644 versions/l-/libxcrypt.json diff --git a/ports/libcap/cap_names.h b/ports/libcap/cap_names.h new file mode 100644 index 0000000000..8186d5ce89 --- /dev/null +++ b/ports/libcap/cap_names.h @@ -0,0 +1,56 @@ +/* + * DO NOT EDIT: this file is generated automatically from + * + * + */ + +#define __CAP_BITS 41 +#define __CAP_NAME_SIZE 23 + +#ifdef LIBCAP_PLEASE_INCLUDE_ARRAY +#define LIBCAP_CAP_NAMES { \ + /* 0 */ "cap_chown", \ + /* 1 */ "cap_dac_override", \ + /* 2 */ "cap_dac_read_search", \ + /* 3 */ "cap_fowner", \ + /* 4 */ "cap_fsetid", \ + /* 5 */ "cap_kill", \ + /* 6 */ "cap_setgid", \ + /* 7 */ "cap_setuid", \ + /* 8 */ "cap_setpcap", \ + /* 9 */ "cap_linux_immutable", \ + /* 10 */ "cap_net_bind_service", \ + /* 11 */ "cap_net_broadcast", \ + /* 12 */ "cap_net_admin", \ + /* 13 */ "cap_net_raw", \ + /* 14 */ "cap_ipc_lock", \ + /* 15 */ "cap_ipc_owner", \ + /* 16 */ "cap_sys_module", \ + /* 17 */ "cap_sys_rawio", \ + /* 18 */ "cap_sys_chroot", \ + /* 19 */ "cap_sys_ptrace", \ + /* 20 */ "cap_sys_pacct", \ + /* 21 */ "cap_sys_admin", \ + /* 22 */ "cap_sys_boot", \ + /* 23 */ "cap_sys_nice", \ + /* 24 */ "cap_sys_resource", \ + /* 25 */ "cap_sys_time", \ + /* 26 */ "cap_sys_tty_config", \ + /* 27 */ "cap_mknod", \ + /* 28 */ "cap_lease", \ + /* 29 */ "cap_audit_write", \ + /* 30 */ "cap_audit_control", \ + /* 31 */ "cap_setfcap", \ + /* 32 */ "cap_mac_override", \ + /* 33 */ "cap_mac_admin", \ + /* 34 */ "cap_syslog", \ + /* 35 */ "cap_wake_alarm", \ + /* 36 */ "cap_block_suspend", \ + /* 37 */ "cap_audit_read", \ + /* 38 */ "cap_perfmon", \ + /* 39 */ "cap_bpf", \ + /* 40 */ "cap_checkpoint_restore", \ + } +#endif /* LIBCAP_PLEASE_INCLUDE_ARRAY */ + +/* END OF FILE */ diff --git a/ports/libcap/cap_names.separation.patch b/ports/libcap/cap_names.separation.patch new file mode 100644 index 0000000000..f18dcd767d --- /dev/null +++ b/ports/libcap/cap_names.separation.patch @@ -0,0 +1,13 @@ +diff --git a/libcap/Makefile b/libcap/Makefile +index f5dde3e..4eb13aa 100644 +--- a/libcap/Makefile ++++ b/libcap/Makefile +@@ -25,7 +25,7 @@ CFLAGS += -fPIC + # executable + MAGIC=-Wl,-e,__so_start + +-INCLS=libcap.h cap_names.h $(INCS) ++INCLS=libcap.h $(INCS) + GPERF_OUTPUT = _caps_output.gperf + + CAPOBJS=$(addsuffix .o, $(CAPFILES)) diff --git a/ports/libcap/configure b/ports/libcap/configure new file mode 100755 index 0000000000..1a2485251c --- /dev/null +++ b/ports/libcap/configure @@ -0,0 +1 @@ +#!/bin/sh diff --git a/ports/libcap/portfile.cmake b/ports/libcap/portfile.cmake new file mode 100644 index 0000000000..3664e8bb82 --- /dev/null +++ b/ports/libcap/portfile.cmake @@ -0,0 +1,85 @@ +vcpkg_from_git( + OUT_SOURCE_PATH SOURCE_PATH + URL git://git.kernel.org/pub/scm/libs/libcap/libcap.git + FETCH_REF "libcap-${VERSION}" + REF 3c7dda330bd9a154bb5b878d31fd591e4951fe17 + PATCHES + cap_names.separation.patch +) +# Note: if libcap version is updated, the according cap_names.h should be updated if necessary. + +# SKIP_CONFIGURE is broken https://github.com/microsoft/vcpkg/issues/14389 +# so we use patch to create empty configure executable +file(COPY "${CMAKE_CURRENT_LIST_DIR}/configure" DESTINATION "${SOURCE_PATH}") + +# This needs to be called before configure +vcpkg_cmake_get_vars(cmake_vars_file) + +if(VCPKG_CROSSCOMPILING) + file(COPY "${CMAKE_CURRENT_LIST_DIR}/cap_names.h" DESTINATION "${SOURCE_PATH}/libcap/") +endif () + +vcpkg_configure_make( + SOURCE_PATH "${SOURCE_PATH}" + COPY_SOURCE +) + +include("${cmake_vars_file}") +list(APPEND libcap_OPTIONS "prefix=${CURRENT_INSTALLED_DIR}" "CC=${VCPKG_DETECTED_CMAKE_C_COMPILER}" "AR=${VCPKG_DETECTED_CMAKE_AR}" "RANLIB=${VCPKG_DETECTED_CMAKE_RANLIB}") + +if (NOT VCPKG_CROSSCOMPILING) + # patch decouples cap_names.h target from libcap.* for cross compile compatibility, + # so for host=target build we manually make it + vcpkg_build_make(SUBPATH libcap + BUILD_TARGET cap_names.h + LOGFILE_ROOT "configure" + OPTIONS + ${libcap_OPTIONS} + ) +endif () + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_build_make(SUBPATH libcap + BUILD_TARGET libcap.a + LOGFILE_ROOT "build" + OPTIONS + ${libcap_OPTIONS} + ) +else() + vcpkg_build_make(SUBPATH libcap + BUILD_TARGET libcap.so + LOGFILE_ROOT "build" + OPTIONS + ${libcap_OPTIONS} + ) +endif() + +vcpkg_build_make(SUBPATH libcap + BUILD_TARGET libcap.pc + LOGFILE_ROOT "pkgconfig" + OPTIONS + ${libcap_OPTIONS} +) + +file(INSTALL "${SOURCE_PATH}/libcap/include/" DESTINATION "${CURRENT_PACKAGES_DIR}/include" FILES_MATCHING PATTERN "*.h") + +set(BUILD_DIR_RELEASE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(INSTALL "${BUILD_DIR_RELEASE}/libcap/libcap.a" DESTINATION "${CURRENT_PACKAGES_DIR}/lib") +else() + file(INSTALL "${BUILD_DIR_RELEASE}/libcap/libcap.so" DESTINATION "${CURRENT_PACKAGES_DIR}/lib" FOLLOW_SYMLINK_CHAIN) +endif() + +set(BUILD_DIR_DEBUG "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(INSTALL "${BUILD_DIR_DEBUG}/libcap/libcap.a" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib") +else() + file(INSTALL "${BUILD_DIR_DEBUG}/libcap/libcap.so" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib" FOLLOW_SYMLINK_CHAIN) +endif() + +file(INSTALL "${BUILD_DIR_RELEASE}/libcap/libcap.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/lib/pkgconfig") +file(INSTALL "${BUILD_DIR_DEBUG}/libcap/libcap.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/License") + +vcpkg_fixup_pkgconfig() diff --git a/ports/libcap/vcpkg.json b/ports/libcap/vcpkg.json new file mode 100644 index 0000000000..71bfa59999 --- /dev/null +++ b/ports/libcap/vcpkg.json @@ -0,0 +1,14 @@ +{ + "name": "libcap", + "version": "2.69", + "description": "capability library: includes libcap2 file caps, setcap, getcap and capsh", + "homepage": "https://git.kernel.org/pub/scm/libs/libcap/libcap.git", + "license": "BSD-3-Clause", + "supports": "linux", + "dependencies": [ + { + "name": "vcpkg-cmake-get-vars", + "host": true + } + ] +} diff --git a/ports/libsystemd/pkgconfig.patch b/ports/libsystemd/pkgconfig.patch new file mode 100644 index 0000000000..1c6f5dee35 --- /dev/null +++ b/ports/libsystemd/pkgconfig.patch @@ -0,0 +1,11 @@ +diff --git a/src/libsystemd/libsystemd.pc.in b/src/libsystemd/libsystemd.pc.in +index da6e4e667e..3786238ccb 100644 +--- a/src/libsystemd/libsystemd.pc.in ++++ b/src/libsystemd/libsystemd.pc.in +@@ -17,4 +17,6 @@ Description: systemd Library + URL: {{PROJECT_URL}} + Version: {{PROJECT_VERSION}} + Libs: -L${libdir} -lsystemd ++Libs.private: -lrt ++Requires.private: libcap libcrypt liblz4 liblzma libzstd mount + Cflags: -I${includedir} diff --git a/ports/libsystemd/portfile.cmake b/ports/libsystemd/portfile.cmake new file mode 100644 index 0000000000..7d154b8a36 --- /dev/null +++ b/ports/libsystemd/portfile.cmake @@ -0,0 +1,54 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO systemd/systemd + REF "v${VERSION}" + SHA512 84b4d16980fe2e64d5c3c95b9b4fbaad1076f368f493fdd745cbafbe7ce825293384f5fa0b6360ba8188da23c4575e87402fb666a3b71f84ff8b323aba0c07ff + PATCHES + pkgconfig.patch +) + +vcpkg_configure_meson( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -Dstatic-libsystemd=true + -Daudit=false + -Dgcrypt=false + OPTIONS_DEBUG + -Drootprefix=${CURRENT_PACKAGES_DIR}/debug + -Dpkgconfiglibdir={CURRENT_PACKAGES_DIR}/debug + OPTIONS_RELEASE + -Drootprefix=${CURRENT_PACKAGES_DIR} + -Dpkgconfiglibdir={CURRENT_PACKAGES_DIR} +) +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_build_ninja( + TARGETS libsystemd.a devel + ) +else() + vcpkg_build_ninja( + TARGETS libsystemd devel + ) +endif() + +file(INSTALL "${SOURCE_PATH}/src/systemd" DESTINATION "${CURRENT_PACKAGES_DIR}/include" FILES_MATCHING PATTERN "*.h") + +set(BUILD_DIR_RELEASE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(INSTALL "${BUILD_DIR_RELEASE}/libsystemd.a" DESTINATION "${CURRENT_PACKAGES_DIR}/lib") +else() + file(INSTALL "${BUILD_DIR_RELEASE}/libsystemd.so" DESTINATION "${CURRENT_PACKAGES_DIR}/lib" FOLLOW_SYMLINK_CHAIN) +endif() + +set(BUILD_DIR_DEBUG "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + file(INSTALL "${BUILD_DIR_DEBUG}/libsystemd.a" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib") +else() + file(INSTALL "${BUILD_DIR_DEBUG}/libsystemd.so" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib" FOLLOW_SYMLINK_CHAIN) +endif() + +file(INSTALL "${BUILD_DIR_RELEASE}/src/libsystemd/libsystemd.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/lib/pkgconfig") +file(INSTALL "${BUILD_DIR_DEBUG}/src/libsystemd/libsystemd.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig") + +vcpkg_fixup_pkgconfig() + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.LGPL2.1") diff --git a/ports/libsystemd/vcpkg.json b/ports/libsystemd/vcpkg.json new file mode 100644 index 0000000000..57b3119759 --- /dev/null +++ b/ports/libsystemd/vcpkg.json @@ -0,0 +1,20 @@ +{ + "name": "libsystemd", + "version": "254", + "description": "Libsystemd", + "homepage": "https://github.com/systemd/systemd", + "license": "LGPL-2.1+", + "supports": "linux", + "dependencies": [ + "libcap", + "liblzma", + "libmount", + "libxcrypt", + "lz4", + { + "name": "vcpkg-tool-meson", + "host": true + }, + "zstd" + ] +} diff --git a/ports/libxcrypt/portfile.cmake b/ports/libxcrypt/portfile.cmake new file mode 100644 index 0000000000..fac97500e4 --- /dev/null +++ b/ports/libxcrypt/portfile.cmake @@ -0,0 +1,20 @@ +set(VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS enabled) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO besser82/libxcrypt + REF "v${VERSION}" + SHA512 61e5e393654f37775457474d4170098314879ee79963d423c1c461e80dc5dc74f0c161dd8754f016ce96109167be6c580ad23994fa1d2c38c54b96e602f3aece +) + +vcpkg_configure_make( + SOURCE_PATH "${SOURCE_PATH}" + AUTOCONFIG +) + +vcpkg_install_make() +vcpkg_fixup_pkgconfig() + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSING" "${SOURCE_PATH}/COPYING.LIB") + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") diff --git a/ports/libxcrypt/vcpkg.json b/ports/libxcrypt/vcpkg.json new file mode 100644 index 0000000000..e0f08eb183 --- /dev/null +++ b/ports/libxcrypt/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "libxcrypt", + "version": "4.4.36", + "description": "libxcrypt is a modern library for one-way hashing of passwords. On Linux-based systems, by default libxcrypt will be binary backward compatible with the libcrypt.so.1 shipped as part of the GNU C Library.", + "homepage": "https://github.com/besser82/libxcrypt", + "license": "LGPL-2.1-only", + "supports": "linux" +} diff --git a/versions/baseline.json b/versions/baseline.json index f8b733fd4f..3c01d7ab6e 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -3968,6 +3968,10 @@ "baseline": "0.30", "port-version": 4 }, + "libcap": { + "baseline": "2.69", + "port-version": 0 + }, "libcbor": { "baseline": "0.10.2", "port-version": 0 @@ -4692,6 +4696,10 @@ "baseline": "3.25", "port-version": 1 }, + "libsystemd": { + "baseline": "254", + "port-version": 0 + }, "libtar": { "baseline": "1.2.20", "port-version": 0 @@ -4852,6 +4860,10 @@ "baseline": "0.4.5", "port-version": 0 }, + "libxcrypt": { + "baseline": "4.4.36", + "port-version": 0 + }, "libxcvt": { "baseline": "0.1.2", "port-version": 0 diff --git a/versions/l-/libcap.json b/versions/l-/libcap.json new file mode 100644 index 0000000000..48fadc891b --- /dev/null +++ b/versions/l-/libcap.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "78c061106eac6df0a86b27df684998c780c70008", + "version": "2.69", + "port-version": 0 + } + ] +} diff --git a/versions/l-/libsystemd.json b/versions/l-/libsystemd.json new file mode 100644 index 0000000000..24e90f3bdc --- /dev/null +++ b/versions/l-/libsystemd.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "bc87d660ee35fa2665c12cbd8cb80896f21f99af", + "version": "254", + "port-version": 0 + } + ] +} diff --git a/versions/l-/libxcrypt.json b/versions/l-/libxcrypt.json new file mode 100644 index 0000000000..c2b8418ba4 --- /dev/null +++ b/versions/l-/libxcrypt.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "85a0274aca1b0c7bf756cb41f77d9dbfc2b6fb78", + "version": "4.4.36", + "port-version": 0 + } + ] +}