diff --git a/recipes/libmount/all/conandata.yml b/recipes/libmount/all/conandata.yml index 18c98b7cab46ce..4e1010ee8b94f4 100644 --- a/recipes/libmount/all/conandata.yml +++ b/recipes/libmount/all/conandata.yml @@ -2,12 +2,3 @@ sources: "2.39": url: "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.39/util-linux-2.39.tar.xz" sha256: "32b30a336cda903182ed61feb3e9b908b762a5e66fe14e43efb88d37162075cb" - "2.36.2": - url: "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.36/util-linux-2.36.2.tar.xz" - sha256: "f7516ba9d8689343594356f0e5e1a5f0da34adfbc89023437735872bb5024c5f" - "2.36": - url: "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.36/util-linux-2.36.tar.xz" - sha256: "9e4b1c67eb13b9b67feb32ae1dc0d50e08ce9e5d82e1cccd0ee771ad2fa9e0b1" - "2.33.1": - url: "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.33/util-linux-2.33.1.tar.xz" - sha256: "c14bd9f3b6e1792b90db87696e87ec643f9d63efa0a424f092a5a6b2f2dbef21" diff --git a/recipes/libmount/all/conanfile.py b/recipes/libmount/all/conanfile.py index b9ec541d71963d..f0c66cba766b1e 100644 --- a/recipes/libmount/all/conanfile.py +++ b/recipes/libmount/all/conanfile.py @@ -1,8 +1,9 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.files import copy, get, rm, rmdir -from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import copy, get, replace_in_file, rm, rmdir from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain import os required_conan_version = ">=1.53.0" @@ -18,7 +19,6 @@ class LibmountConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git" license = "LGPL-2.1-or-later" - package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { @@ -32,9 +32,9 @@ class LibmountConan(ConanFile): def configure(self): if self.options.shared: - del self.options.fPIC - self.settings.rm_safe("compiler.libcxx") + self.options.rm_safe("fPIC") self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") def layout(self): basic_layout(self, src_folder="src") @@ -43,33 +43,50 @@ def validate(self): if self.settings.os != "Linux": raise ConanInvalidConfiguration(f"{self.ref} only supports Linux") + def build_requirements(self): + self.tool_requires("bison/3.8.2") + self.tool_requires("meson/1.2.2") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/2.0.3") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): - tc = AutotoolsToolchain(self) - tc.configure_args.extend([ - "--disable-all-programs", - "--enable-libmount", - "--enable-libblkid", - ]) + tc = MesonToolchain(self) + tc.project_options["auto_features"] = "disabled" + tc.project_options["build-libblkid"] = "enabled" + tc.project_options["build-libmount"] = "enabled" tc.generate() + virtual_build_env = VirtualBuildEnv(self) + virtual_build_env.generate() + virtual_run_env = VirtualRunEnv(self) + virtual_run_env.generate() + + def _patch_sources(self): + # Disable translations. + replace_in_file(self, os.path.join(self.source_folder, "meson.build"), "subdir('po')", "#subdir('po')") + # Disable tests for libmount. + replace_in_file(self, os.path.join(self.source_folder, "libmount", "meson.build"), "foreach libmount_test: libmount_tests", "foreach libmount_test: []") def build(self): - autotools = Autotools(self) - autotools.configure() - autotools.make() + self._patch_sources() + meson = Meson(self) + meson.configure() + meson.build() def package(self): - copy(self, "COPYING", src=os.path.join(self.source_folder, "libmount"), dst=os.path.join(self.package_folder, "licenses")) - copy(self, "COPYING.LGPL-2.1-or-later", src=os.path.join(self.source_folder, "Documentation", "licenses"), dst=os.path.join(self.package_folder, "licenses")) - autotools = Autotools(self) - autotools.install() + copy(self, "COPYING", os.path.join(self.source_folder, "libmount"), os.path.join(self.package_folder, "licenses")) + copy(self, "COPYING.LGPL-2.1-or-later", os.path.join(self.source_folder, "Documentation", "licenses"), os.path.join(self.package_folder, "licenses")) + meson = Meson(self) + meson.install() rmdir(self, os.path.join(self.package_folder, "sbin")) rmdir(self, os.path.join(self.package_folder, "share")) rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) rmdir(self, os.path.join(self.package_folder, "usr")) rm(self, "*.la", os.path.join(self.package_folder, "lib")) + # util-linux always builds both the shared and static libraries of libblkid, so delete the one that isn't needed. + rm(self, "libblkid.a" if self.options.shared else "libblkid.so*", os.path.join(self.package_folder, "lib")) def package_info(self): self.cpp_info.libs = ["mount", "blkid"] diff --git a/recipes/libmount/all/test_package/CMakeLists.txt b/recipes/libmount/all/test_package/CMakeLists.txt index 79b7610d1fb9b5..4b97a71d1061a5 100644 --- a/recipes/libmount/all/test_package/CMakeLists.txt +++ b/recipes/libmount/all/test_package/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.15) project(test_package LANGUAGES C) find_package(libmount REQUIRED CONFIG) diff --git a/recipes/libmount/autotools/conandata.yml b/recipes/libmount/autotools/conandata.yml new file mode 100644 index 00000000000000..5bf946443eb386 --- /dev/null +++ b/recipes/libmount/autotools/conandata.yml @@ -0,0 +1,10 @@ +sources: + "2.36.2": + url: "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.36/util-linux-2.36.2.tar.xz" + sha256: "f7516ba9d8689343594356f0e5e1a5f0da34adfbc89023437735872bb5024c5f" + "2.36": + url: "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.36/util-linux-2.36.tar.xz" + sha256: "9e4b1c67eb13b9b67feb32ae1dc0d50e08ce9e5d82e1cccd0ee771ad2fa9e0b1" + "2.33.1": + url: "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.33/util-linux-2.33.1.tar.xz" + sha256: "c14bd9f3b6e1792b90db87696e87ec643f9d63efa0a424f092a5a6b2f2dbef21" diff --git a/recipes/libmount/autotools/conanfile.py b/recipes/libmount/autotools/conanfile.py new file mode 100644 index 00000000000000..b9ec541d71963d --- /dev/null +++ b/recipes/libmount/autotools/conanfile.py @@ -0,0 +1,78 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.53.0" + + +class LibmountConan(ConanFile): + name = "libmount" + description = ( + "The libmount library is used to parse /etc/fstab, /etc/mtab and " + "/proc/self/mountinfo files, manage the mtab file, evaluate mount options, etc" + ) + topics = ("mount", "linux", "util-linux") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git" + license = "LGPL-2.1-or-later" + + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def configure(self): + if self.options.shared: + del self.options.fPIC + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration(f"{self.ref} only supports Linux") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ + "--disable-all-programs", + "--enable-libmount", + "--enable-libblkid", + ]) + tc.generate() + + def build(self): + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", src=os.path.join(self.source_folder, "libmount"), dst=os.path.join(self.package_folder, "licenses")) + copy(self, "COPYING.LGPL-2.1-or-later", src=os.path.join(self.source_folder, "Documentation", "licenses"), dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "sbin")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "usr")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + + def package_info(self): + self.cpp_info.libs = ["mount", "blkid"] + self.cpp_info.system_libs = ["rt"] + self.cpp_info.includedirs.append(os.path.join("include", "libmount")) + self.cpp_info.set_property("pkg_config_name", "mount") diff --git a/recipes/libmount/autotools/test_package/CMakeLists.txt b/recipes/libmount/autotools/test_package/CMakeLists.txt new file mode 100644 index 00000000000000..79b7610d1fb9b5 --- /dev/null +++ b/recipes/libmount/autotools/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libmount REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libmount::libmount) diff --git a/recipes/libmount/autotools/test_package/conanfile.py b/recipes/libmount/autotools/test_package/conanfile.py new file mode 100644 index 00000000000000..0a6bc68712d901 --- /dev/null +++ b/recipes/libmount/autotools/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + 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], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libmount/autotools/test_package/test_package.c b/recipes/libmount/autotools/test_package/test_package.c new file mode 100644 index 00000000000000..d4e4d653742e8c --- /dev/null +++ b/recipes/libmount/autotools/test_package/test_package.c @@ -0,0 +1,16 @@ +#include + +#include +#include + +int main() +{ + struct libmnt_context *ctx = mnt_new_context(); + if (!ctx) { + printf("failed to initialize libmount\n"); + return EXIT_FAILURE; + } + printf("path to fstab: %s", mnt_get_fstab_path()); + mnt_free_context(ctx); + return EXIT_SUCCESS; +} diff --git a/recipes/libmount/all/test_v1_package/CMakeLists.txt b/recipes/libmount/autotools/test_v1_package/CMakeLists.txt similarity index 100% rename from recipes/libmount/all/test_v1_package/CMakeLists.txt rename to recipes/libmount/autotools/test_v1_package/CMakeLists.txt diff --git a/recipes/libmount/all/test_v1_package/conanfile.py b/recipes/libmount/autotools/test_v1_package/conanfile.py similarity index 100% rename from recipes/libmount/all/test_v1_package/conanfile.py rename to recipes/libmount/autotools/test_v1_package/conanfile.py diff --git a/recipes/libmount/config.yml b/recipes/libmount/config.yml index b9150d1aa9e481..ea17dfa1e1d7b0 100644 --- a/recipes/libmount/config.yml +++ b/recipes/libmount/config.yml @@ -2,8 +2,8 @@ versions: "2.39": folder: all "2.36.2": - folder: all + folder: autotools "2.36": - folder: all + folder: autotools "2.33.1": - folder: all + folder: autotools