[libqcow] Initial port (#11036)

* [libqcow] Add new port

Signed-off-by: Alexandro Sanchez Bach <alexandro@phi.nz>

* [libqcow] fix build

Co-authored-by: Alexandro Sanchez Bach <asanchez@kryptoslogic.com>
This commit is contained in:
Nick Renieris 2020-05-01 03:21:19 +03:00 committed by GitHub
parent 86f5397f76
commit c1dd394d1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 172 additions and 1 deletions

View File

@ -0,0 +1,83 @@
cmake_minimum_required(VERSION 3.12)
project(libqcow C)
find_package(OpenSSL)
find_package(ZLIB REQUIRED)
if(MSVC)
add_compile_definitions(_CRT_SECURE_NO_DEPRECATE)
add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE)
endif()
add_compile_definitions(HAVE_LOCAL_LIBCAES)
add_compile_definitions(HAVE_LOCAL_LIBCERROR)
add_compile_definitions(HAVE_LOCAL_LIBCTHREADS)
add_compile_definitions(HAVE_LOCAL_LIBCDATA)
add_compile_definitions(HAVE_LOCAL_LIBCLOCALE)
add_compile_definitions(HAVE_LOCAL_LIBCNOTIFY)
add_compile_definitions(HAVE_LOCAL_LIBCSPLIT)
add_compile_definitions(HAVE_LOCAL_LIBCFILE)
add_compile_definitions(HAVE_LOCAL_LIBCPATH)
add_compile_definitions(HAVE_LOCAL_LIBUNA)
add_compile_definitions(HAVE_LOCAL_LIBBFIO)
add_compile_definitions(HAVE_LOCAL_LIBFCACHE)
add_compile_definitions(HAVE_LOCAL_LIBFDATA)
add_compile_definitions(ZLIB_DLL)
if(UNIX)
configure_file(common/config.h.in common/config.h)
add_compile_definitions(HAVE_CONFIG_H)
add_compile_definitions(LOCALEDIR="/usr/share/locale")
endif()
if(MSVC)
add_compile_definitions(LIBQCOW_DLL_EXPORT)
set(LIB_RC libqcow/libqcow.rc)
endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# Add CMake find_package() integration
set(PROJECT_TARGET_NAME "${PROJECT_NAME}")
set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(PROJECT_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_TARGET_NAME}Config.cmake")
set(TARGETS_EXPORT_NAME "${PROJECT_TARGET_NAME}Targets")
set(NAMESPACE "libqcow::")
# Source files
file(GLOB LIB_SRC lib*/*.c)
# Headers
file(GLOB LIB_INST_HEADERS include/libqcow/*.h)
add_library(${PROJECT_NAME} ${LIB_SRC} ${LIB_RC})
target_include_directories(${PROJECT_NAME} PRIVATE ./include ./common)
target_include_directories(${PROJECT_NAME} PRIVATE ./libbfio ./libcaes ./libcdata ./libcerror ./libcfile ./libclocale)
target_include_directories(${PROJECT_NAME} PRIVATE ./libcnotify ./libcpath ./libcsplit ./libcthreads)
target_include_directories(${PROJECT_NAME} PRIVATE ./libfcache ./libfdata ./libuna)
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB OpenSSL::Crypto)
install(TARGETS ${PROJECT_NAME}
EXPORT ${TARGETS_EXPORT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include)
install(FILES ${LIB_INST_HEADERS} DESTINATION include/libqcow)
install(FILES include/libqcow.h DESTINATION include)
# Generate and install libqcowConfig.cmake
configure_package_config_file("Config.cmake.in" "${PROJECT_CONFIG}" INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}")
install(FILES "${PROJECT_CONFIG}" DESTINATION "${CONFIG_INSTALL_DIR}")
# Generate and install libqcowTargets*.cmake
install(EXPORT ${TARGETS_EXPORT_NAME}
NAMESPACE ${NAMESPACE}
DESTINATION "${CONFIG_INSTALL_DIR}")

6
ports/libqcow/CONTROL Normal file
View File

@ -0,0 +1,6 @@
Source: libqcow
Version: 20191221
Homepage: https://github.com/libyal/libqcow
Build-Depends: gettext,openssl,zlib
Description: Library and tools to access the QEMU Copy-On-Write (QCOW) image format.
Supports: !uwp

View File

@ -0,0 +1,4 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
check_required_components("@PROJECT_NAME@")

View File

@ -0,0 +1,38 @@
diff --git a/libcfile/libcfile_file.c b/libcfile/libcfile_file.c
index 13eab02..690cc04 100644
--- a/libcfile/libcfile_file.c
+++ b/libcfile/libcfile_file.c
@@ -56,7 +56,7 @@
#elif defined( HAVE_CYGWIN_FS_H )
#include <cygwin/fs.h>
-#elif defined( HAVE_LINUX_FS_H )
+#elif defined( __linux__ ) && defined( HAVE_LINUX_FS_H )
/* Required for Linux platforms that use a sizeof( u64 )
* in linux/fs.h but have no typedef of it
*/
@@ -4603,6 +4603,11 @@ ssize_t libcfile_file_io_control_read_with_error_code(
#error Missing file IO control with data function
#endif
+// Force disable on Darwin, it can be erroneously defined
+#if defined ( __APPLE__ )
+#undef HAVE_POSIX_FADVISE
+#endif
+
/* On some versions of Linux the FADVISE definions seem to be missing from fcntl.h
*/
#if defined( HAVE_POSIX_FADVISE ) && !defined( WINAPI )
diff --git a/libqcow/libqcow_i18n.c b/libqcow/libqcow_i18n.c
index f8a3164..d09ec79 100644
--- a/libqcow/libqcow_i18n.c
+++ b/libqcow/libqcow_i18n.c
@@ -40,7 +40,7 @@ int libqcow_i18n_initialize(
if( libqcow_i18n_initialized == 0 )
{
-#if defined( HAVE_BINDTEXTDOMAIN )
+#if !defined( __APPLE__ ) && defined( HAVE_BINDTEXTDOMAIN )
if( bindtextdomain(
"libqcow",
LOCALEDIR ) == NULL )

View File

@ -0,0 +1,37 @@
vcpkg_fail_port_install(ON_TARGET "uwp")
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
set(LIB_VERSION 20191221)
set(LIB_FILENAME libqcow-alpha-${LIB_VERSION}.tar.gz)
# Release distribution file contains configured sources, while the source code in the repository does not.
vcpkg_download_distfile(ARCHIVE
URLS "https://github.com/libyal/libqcow/releases/download/${LIB_VERSION}/${LIB_FILENAME}"
FILENAME "${LIB_FILENAME}"
SHA512 de0c5cfad84bbccc9a4144b108c7e022a98d130e829385e69ff00a8750709c9de814410eebfa1c0fc89051cf8f596d87b9bbc8228d99efd8be1c3efdc2b52730
)
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
REF ${LIB_VERSION}
PATCHES macos_fixes.patch
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/Config.cmake.in" DESTINATION "${SOURCE_PATH}")
vcpkg_configure_cmake(
SOURCE_PATH "${SOURCE_PATH}"
PREFER_NINJA
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH "lib/cmake/libqcow" TARGET_PATH "share/libqcow")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
# License and man
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
vcpkg_copy_pdbs()

View File

@ -875,6 +875,9 @@ libpng-apng:x64-windows-static = skip
libpng-apng:x86-windows = skip
libpq:arm-uwp=fail
libpq:x64-uwp=fail
libqcow:arm-uwp=fail
libqcow:x64-uwp=fail
libqcow:x64-windows-static=fail
librabbitmq:x64-linux=ignore
libraqm:x64-windows-static=fail
librdkafka:arm-uwp=fail
@ -1479,7 +1482,7 @@ qt5-wayland:x64-windows=fail
qt5-wayland:x64-windows-static=fail
qt5-winextras:x64-linux=fail
qt5-winextras:x64-osx=fail
# Too big for CI.
# Too big for CI.
qt5-webengine:x64-windows=skip
qt5-webengine:x86-windows=skip
# Missing prerequisites for CI success