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

libselinux: add 3.2 and components #4804

Merged
merged 10 commits into from
Mar 9, 2021
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
16 changes: 16 additions & 0 deletions recipes/libselinux/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,19 @@ sources:
sha256: "ea5dcbb4d859e3f999c26a13c630da2f16dff9462e3cc8cb7b458ac157d112e7"
- url: "https://github.com/SELinuxProject/selinux/releases/download/20200710/libsepol-3.1.tar.gz"
sha256: "ae6778d01443fdd38cd30eeee846494e19f4d407b09872580372f4aa4bf8a3cc"
"3.2":
- url: "https://github.com/SELinuxProject/selinux/releases/download/3.2/libselinux-3.2.tar.gz"
sha256: "df758ef1d9d4811051dd901ea6b029ae334ffd7c671c128beb16bce1e25ac161"
- url: "https://github.com/SELinuxProject/selinux/releases/download/3.2/libsepol-3.2.tar.gz"
sha256: "dfc7f662af8000116e56a01de6a0394ed79be1b34b999e551346233c5dd19508"
patches:
"2.9":
- patch_file: patches/0001-fix-fno-common-2.9.patch
base_path: libsepol-2.9
- patch_file: patches/0002-remove-cil_mem_error_handler.patch
base_path: libsepol-2.9
"3.0":
- patch_file: patches/0001-fix-fno-common-3.0.patch
base_path: libsepol-3.0
- patch_file: patches/0002-remove-cil_mem_error_handler.patch
base_path: libsepol-3.0
30 changes: 25 additions & 5 deletions recipes/libselinux/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from conans import ConanFile, tools, AutoToolsBuildEnvironment
from conans.errors import ConanInvalidConfiguration
import os
import glob


class LibSELinuxConan(ConanFile):
Expand All @@ -14,38 +13,54 @@ class LibSELinuxConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
requires = ("pcre2/10.33",)

exports_sources = "patches/**"

def _get_subfolders(self):
_sepol_subfolder = "libsepol-%s" % self.version
_selinux_subfolder = "libselinux-%s" % self.version
return _sepol_subfolder, _selinux_subfolder

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if self.settings.os != "Linux":
raise ConanInvalidConfiguration("Only Linux is supported")

def requirements(self):
self.requires("pcre2/10.36")

def build_requirements(self):
self.build_requires("flex/2.6.4")

def source(self):
for download in self.conan_data["sources"][self.version]:
tools.get(**download)

@property
def _sepol_soversion(self):
return "2" if tools.Version(self.version) >= "3.2" else "1"

@property
def _selinux_soversion(self):
return "1"

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
_sepol_subfolder, _selinux_subfolder = self._get_subfolders()
pcre_inc = os.path.join(self.deps_cpp_info["pcre2"].rootpath,
self.deps_cpp_info["pcre2"].includedirs[0])
pcre_libs = ' '.join(["-l%s" % lib for lib in self.deps_cpp_info["pcre2"].libs])
sepol_inc = os.path.join(self.source_folder, _sepol_subfolder, "include")
with tools.chdir(os.path.join(_sepol_subfolder, "src")):
args = ["libsepol.so.1" if self.options.shared else "libsepol.a"]
args = ["libsepol.so.{}".format(self._sepol_soversion) if self.options.shared else "libsepol.a"]
env_build = AutoToolsBuildEnvironment(self)
env_build.make(args=args)
with tools.chdir(os.path.join(_selinux_subfolder, "src")):
args = ["libselinux.so.1" if self.options.shared else "libselinux.a",
args = ["libselinux.so.{}".format(self._selinux_soversion) if self.options.shared else "libselinux.a",
'PCRE_CFLAGS=-DPCRE2_CODE_UNIT_WIDTH=8 -DUSE_PCRE2=1 -I%s -I%s' % (pcre_inc, sepol_inc),
'PCRE_LDLIBS=%s' % pcre_libs]
env_build = AutoToolsBuildEnvironment(self)
Expand All @@ -60,4 +75,9 @@ def package(self):
self.copy(pattern="*.a", dst="lib", src=library, keep_path=False)

def package_info(self):
self.cpp_info.libs = ["selinux", "sepol"]
self.cpp_info.components["selinux"].names["pkg_config"] = "libselinux"
self.cpp_info.components["selinux"].libs = ["selinux"]
self.cpp_info.components["selinux"].requires = ["sepol", "pcre2::pcre2"]

self.cpp_info.components["sepol"].names["pkg_config"] = "libsepol"
self.cpp_info.components["sepol"].libs = ["sepol"]
Loading