Skip to content

Commit

Permalink
libmount: Add version 2.40, use Meson
Browse files Browse the repository at this point in the history
  • Loading branch information
jwillikers committed Mar 20, 2024
1 parent 92bca12 commit 1cef22a
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 8 deletions.
12 changes: 4 additions & 8 deletions recipes/libmount/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ def package(self):
rm(self, "*.la", os.path.join(self.package_folder, "lib"))

def package_info(self):
self.cpp_info.components["libblkid"].libs = ["blkid"]
self.cpp_info.components["libblkid"].set_property("pkg_config_name", "blkid")

self.cpp_info.components["libmount"].libs = ["mount"]
self.cpp_info.components["libmount"].system_libs = ["rt"]
self.cpp_info.components["libmount"].includedirs.append(os.path.join("include", "libmount"))
self.cpp_info.components["libmount"].set_property("pkg_config_name", "mount")
self.cpp_info.components["libmount"].requires = ["libblkid"]
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")
2 changes: 2 additions & 0 deletions recipes/libmount/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"2.40-rc2":
folder: meson
"2.39.2":
folder: all
"2.39":
Expand Down
7 changes: 7 additions & 0 deletions recipes/libmount/meson/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sources:
"2.40-rc2":
url: "https://github.com/util-linux/util-linux/archive/refs/tags/v2.40-rc2.tar.gz"
sha256: "0fdf4a47eb415639cfcdf2ca4cb76919ca971dc173ce5bb034857a77188a7c27"
patches:
"2.40-rc2":
- patch_file: "patches/4ebdd569049ac48a3867a59537cea769fa319e8f.patch"

Check warning on line 7 in recipes/libmount/meson/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/4ebdd569 ... ^ (line: 7)
101 changes: 101 additions & 0 deletions recipes/libmount/meson/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.env import VirtualBuildEnv
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"


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:
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")

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("flex/2.6.4")
self.tool_requires("meson/1.3.2")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/2.1.0")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = MesonToolchain(self)
tc.project_options["auto_features"] = "disabled"
tc.project_options["build-libblkid"] = "enabled"
tc.project_options["build-libmount"] = "enabled"
# Enable libutil for older versions of glibc which still provide an actual libutil library.
tc.project_options["libutil"] = "enabled"
tc.project_options["program-tests"] = False
tc.generate()
virtual_build_env = VirtualBuildEnv(self)
virtual_build_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):
self._patch_sources()
meson = Meson(self)
meson.configure()
meson.build()

def package(self):
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.components["libblkid"].libs = ["blkid"]
self.cpp_info.components["libblkid"].set_property("pkg_config_name", "blkid")

self.cpp_info.components["libmount"].libs = ["mount"]
self.cpp_info.components["libmount"].system_libs = ["rt"]
self.cpp_info.components["libmount"].includedirs.append(os.path.join("include", "libmount"))
self.cpp_info.components["libmount"].set_property("pkg_config_name", "mount")
self.cpp_info.components["libmount"].requires = ["libblkid"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 4ebdd569049ac48a3867a59537cea769fa319e8f Mon Sep 17 00:00:00 2001
From: Karel Zak <[email protected]>
Date: Wed, 20 Mar 2024 15:03:05 +0100
Subject: [PATCH] lib/sha1: fix for old glibc

Fixes: https://github.com/util-linux/util-linux/issues/2830
References: http://github.com/util-linux/util-linux/commit/a8902e4cdd6149e5124383b25db8688dcdacd790
Signed-off-by: Karel Zak <[email protected]>
---
lib/sha1.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/lib/sha1.c b/lib/sha1.c
index 32ef5b9ca9..3edff122c4 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -156,11 +156,15 @@ void ul_SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
state[3] += d;
state[4] += e;
/* Wipe variables */
+#ifdef HAVE_EXPLICIT_BZERO
explicit_bzero(&a, sizeof(a));
explicit_bzero(&b, sizeof(b));
explicit_bzero(&c, sizeof(c));
explicit_bzero(&d, sizeof(d));
explicit_bzero(&e, sizeof(e));
+#else
+ a = b = c = d = e = 0;
+#endif
#ifdef UL_SHA1HANDSOFF
memset(block, '\0', sizeof(block));
#endif
7 changes: 7 additions & 0 deletions recipes/libmount/meson/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.15)
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)
26 changes: 26 additions & 0 deletions recipes/libmount/meson/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
16 changes: 16 additions & 0 deletions recipes/libmount/meson/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <libmount/libmount.h>

#include <stdio.h>
#include <stdlib.h>

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;
}

0 comments on commit 1cef22a

Please sign in to comment.