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

libblkid: Add recipe #20373

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions recipes/libblkid/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.39":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be bumped to 2.39.3.

url: "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.39/util-linux-2.39.tar.xz"
sha256: "32b30a336cda903182ed61feb3e9b908b762a5e66fe14e43efb88d37162075cb"
73 changes: 73 additions & 0 deletions recipes/libblkid/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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 LibblkidConan(ConanFile):
name = "libblkid"
description = (
"The libblkid library is used to identify block devices (disks) as to their content (e.g. filesystem type, partitions) as well as extracting additional information such as filesystem labels/volume names, partitions, unique identifiers/serial numbers, etc."
)
topics = ("block", "device", "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-libblkid",
])
tc.generate()

def build(self):
autotools = Autotools(self)
autotools.configure()
autotools.make()

def package(self):
copy(self, "COPYING", os.path.join(self.source_folder, "libblkid"), 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"))
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 = ["blkid"]
self.cpp_info.set_property("pkg_config_name", "blkid")
7 changes: 7 additions & 0 deletions recipes/libblkid/all/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(libblkid REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE libblkid::libblkid)
26 changes: 26 additions & 0 deletions recipes/libblkid/all/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")
12 changes: 12 additions & 0 deletions recipes/libblkid/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stddef.h>

#include <blkid/blkid.h>
#include <stdlib.h>

int main()
{
if (blkid_get_library_version(NULL, NULL) <= 0) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/libblkid/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.39":
folder: all