Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcap: modernize more #15300

Merged
merged 1 commit into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 48 additions & 49 deletions recipes/libcap/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,58 @@
sources:
"2.45":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.45.tar.xz"
sha256: "d66639f765c0e10557666b00f519caf0bd07a95f867dddaee131cd284fac3286"
"2.46":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.46.tar.xz"
sha256: "4ed3d11413fa6c9667e49f819808fbb581cd8864b839f87d7c2a02c70f21d8b4"
"2.48":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.48.tar.xz"
sha256: "4de9590ee09a87c282d558737ffb5b6175ccbfd26d580add10df44d0f047f6c2"
"2.50":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.50.tar.xz"
sha256: "47a57b8bd238b84c93c921a9b4ff82337551dbcb0cca071316aadf3e23b19261"
"2.57":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.57.tar.xz"
sha256: "750221e347689e779a0ce2b22746ee9987d229712da934acb81b2d280684b7ab"
"2.58":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.58.tar.xz"
sha256: "41399a7d77497d348d20475dc9b2046f53e6b9755bf858ec78cc235101a11d4b"
"2.62":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.62.tar.xz"
sha256: "190c5baac9bee06a129eae20d3e827de62f664fe3507f0bf6c50a9a59fbd83a2"
"2.65":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.65.tar.xz"
sha256: "73e350020cc31fe15360879d19384ffa3395a825f065fcf6bda3a5cdf965bebd"
"2.66":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.66.tar.xz"
sha256: "15c40ededb3003d70a283fe587a36b7d19c8b3b554e33f86129c059a4bb466b2"

patches:
"2.65":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.65.tar.xz"
sha256: "73e350020cc31fe15360879d19384ffa3395a825f065fcf6bda3a5cdf965bebd"
"2.62":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.62.tar.xz"
sha256: "190c5baac9bee06a129eae20d3e827de62f664fe3507f0bf6c50a9a59fbd83a2"
"2.58":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.58.tar.xz"
sha256: "41399a7d77497d348d20475dc9b2046f53e6b9755bf858ec78cc235101a11d4b"
"2.57":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.57.tar.xz"
sha256: "750221e347689e779a0ce2b22746ee9987d229712da934acb81b2d280684b7ab"
"2.50":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.50.tar.xz"
sha256: "47a57b8bd238b84c93c921a9b4ff82337551dbcb0cca071316aadf3e23b19261"
"2.48":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.48.tar.xz"
sha256: "4de9590ee09a87c282d558737ffb5b6175ccbfd26d580add10df44d0f047f6c2"
"2.46":
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.46.tar.xz"
sha256: "4ed3d11413fa6c9667e49f819808fbb581cd8864b839f87d7c2a02c70f21d8b4"
"2.45":
- patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch"
url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.45.tar.xz"
sha256: "d66639f765c0e10557666b00f519caf0bd07a95f867dddaee131cd284fac3286"
patches:
"2.66":
- patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch"
patch_description: "allow to configure fPIC option from conan recipe"
patch_type: "conan"
- patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch"
- patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch"
patch_description: "allow to override compiler via environment variables"
patch_type: "conan"
"2.46":
- patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch"
"2.65":
- patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch"
patch_description: "allow to configure fPIC option from conan recipe"
patch_type: "conan"
- patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch"
- patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch"
patch_description: "allow to override compiler via environment variables"
patch_type: "conan"
"2.48":
- patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch"
"2.62":
- patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch"
patch_description: "allow to configure fPIC option from conan recipe"
patch_type: "conan"
- patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch"
- patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch"
patch_description: "allow to override compiler via environment variables"
patch_type: "conan"
"2.50":
- patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch"
"2.58":
- patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch"
patch_description: "allow to configure fPIC option from conan recipe"
patch_type: "conan"
- patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch"
- patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch"
patch_description: "allow to override compiler via environment variables"
patch_type: "conan"
"2.57":
Expand All @@ -63,31 +62,31 @@ patches:
- patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch"
patch_description: "allow to override compiler via environment variables"
patch_type: "conan"
"2.58":
- patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch"
"2.50":
- patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch"
patch_description: "allow to configure fPIC option from conan recipe"
patch_type: "conan"
- patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch"
- patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch"
patch_description: "allow to override compiler via environment variables"
patch_type: "conan"
"2.62":
- patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch"
"2.48":
- patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch"
patch_description: "allow to configure fPIC option from conan recipe"
patch_type: "conan"
- patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch"
- patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch"
patch_description: "allow to override compiler via environment variables"
patch_type: "conan"
"2.65":
- patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch"
"2.46":
- patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch"
patch_description: "allow to configure fPIC option from conan recipe"
patch_type: "conan"
- patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch"
- patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch"
patch_description: "allow to override compiler via environment variables"
patch_type: "conan"
"2.66":
- patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch"
"2.45":
- patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch"
patch_description: "allow to configure fPIC option from conan recipe"
patch_type: "conan"
- patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch"
- patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch"
patch_description: "allow to override compiler via environment variables"
patch_type: "conan"
38 changes: 17 additions & 21 deletions recipes/libcap/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LibcapConan(ConanFile):
description = "This is a library for getting and setting POSIX.1e" \
" (formerly POSIX 6) draft 15 capabilities"
topics = ("capabilities")
settings = "os", "compiler", "build_type", "arch"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
Expand All @@ -31,21 +31,21 @@ class LibcapConan(ConanFile):
"psx_syscals": False,
}

def export_sources(self):
export_conandata_patches(self)

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

def validate(self):
if self.info.settings.os != "Linux":
raise ConanInvalidConfiguration(f"{self.ref} only supports Linux")

def layout(self):
basic_layout(self, src_folder="src")

def export_sources(self):
export_conandata_patches(self)
def validate(self):
if self.settings.os != "Linux":
raise ConanInvalidConfiguration(f"{self.name} only supports Linux")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
Expand All @@ -60,8 +60,8 @@ def generate(self):
env.define("prefix", "/")
env.define("lib", "lib")

if cross_building(self) and not env.vars(self).get("BUILD_CC"):
native_cc = VirtualBuildEnv(self).vars().get("CC")
if cross_building(self):
native_cc = env.vars(self).get("CC", VirtualBuildEnv(self).vars().get("CC"))
if not native_cc:
native_cc = "cc"
self.output.info(f"Using native compiler '{native_cc}'")
Expand All @@ -73,15 +73,14 @@ def build(self):
apply_conandata_patches(self)

autotools = Autotools(self)
with chdir(self, os.path.join(self.source_folder, self.name)):
with chdir(self, os.path.join(self.source_folder, "libcap")):
autotools.make()

def package(self):
copy(self, "License", self.source_folder,
os.path.join(self.package_folder, "licenses"), keep_path=False)
copy(self, "License", self.source_folder, os.path.join(self.package_folder, "licenses"))

autotools = Autotools(self)
with chdir(self, os.path.join(self.source_folder, self.name)):
with chdir(self, os.path.join(self.source_folder, "libcap")):
autotools.make(target="install-common-cap")
install_cap = ("install-shared-cap" if self.options.shared
else "install-static-cap")
Expand All @@ -96,15 +95,12 @@ def package(self):
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))

def package_info(self):
self.cpp_info.components["cap"].set_property("pkg_config_name",
"libcap")
self.cpp_info.components["cap"].names["pkg_config"] = "libcap"
self.cpp_info.components["cap"].set_property("pkg_config_name", "libcap")
self.cpp_info.components["cap"].libs = ["cap"]
if self.options.psx_syscals:
self.cpp_info.components["psx"].set_property("pkg_config_name",
"libpsx")
self.cpp_info.components["psx"].names["pkg_config"] = "libpsx"
self.cpp_info.components["psx"].set_property("pkg_config_name", "libpsx")
self.cpp_info.components["psx"].libs = ["psx"]
self.cpp_info.components["psx"].system_libs = ["pthread"]
self.cpp_info.components["psx"].exelinkflags = [
"-Wl,-wrap,pthread_create"]
self.cpp_info.components["psx"].exelinkflags = ["-Wl,-wrap,pthread_create"]
# trick to avoid conflicts with cap component
self.cpp_info.set_property("pkg_config_name", "libcap-do-not-use")
8 changes: 4 additions & 4 deletions recipes/libcap/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(PackageTest LANGUAGES C)
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)

find_package(PkgConfig REQUIRED)
pkg_check_modules(CAP REQUIRED IMPORTED_TARGET libcap)

add_executable(example example.c)
target_link_libraries(example PRIVATE PkgConfig::CAP)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::CAP)
19 changes: 6 additions & 13 deletions recipes/libcap/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,28 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.env import Environment


class LibcapTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "PkgConfigDeps", "VirtualBuildEnv", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build_requirements(self):
self.tool_requires("pkgconf/1.9.3")

def layout(self):
cmake_layout(self)

def generate(self):
env = Environment()
env.prepend_path("PKG_CONFIG_PATH", self.generators_folder)
envvars = env.vars(self)
envvars.save_script("pkg_config")

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "example")
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
13 changes: 6 additions & 7 deletions recipes/libcap/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import os

from conan import ConanFile
from conan.tools.build import cross_building
from conans import ConanFile, tools
from conans import CMake


class LibcapTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "pkg_config"

def build_requirements(self):
self.tool_requires("pkgconf/1.9.3")
self.build_requires("pkgconf/1.9.3")

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not cross_building(self):
bin_path = os.path.join("bin", "example")
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
16 changes: 8 additions & 8 deletions recipes/libcap/config.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
versions:
"2.45":
"2.66":
folder: all
"2.46":
"2.65":
folder: all
"2.48":
"2.62":
folder: all
"2.50":
"2.58":
folder: all
"2.57":
folder: all
"2.58":
"2.50":
folder: all
"2.62":
"2.48":
folder: all
"2.65":
"2.46":
folder: all
"2.66":
"2.45":
folder: all