[libvhdi] Initial Port (#36063)

* Add libvhdi library to vcpkg

* Fixed formatting.

* version database.

* Added license.

* Fixed version formatting.

* Updated version.

* Fix osx build.

* Added version.

* Fixed config.h file.

* Added versions.

* Check for linux/fs.h

* Added version.

* Fix include.

* Added version.

* Fixed build.

* Fixed formatting.

* Added version.

* Fixed dependencies.

* Added version.

* Fixed build.

* Fixed formatting.

* Added versions.

* Revert "Added versions."

This reverts commit 94e0c97c74.

* Revert "Fixed formatting."

This reverts commit 29a8590ee0.

* Revert "Fixed build."

This reverts commit 63622e6c3d.

* Revert "Added version."

This reverts commit a9e0110664.

* Revert "Fixed dependencies."

This reverts commit c0517a5f96.

* Use CMake again.

* Fix MacOS build.

* updated version.

* Fixed CMake config.

* Updated version.
This commit is contained in:
TomKatom 2024-02-10 06:03:54 +02:00 committed by GitHub
parent 2b195fb720
commit 2cb7bfd2ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 208 additions and 0 deletions

View File

@ -0,0 +1,83 @@
cmake_minimum_required(VERSION 3.12)
project(libvhdi C)
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_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(HAVE_LOCAL_LIBFVALUE)
add_compile_definitions(HAVE_LOCAL_LIBFGUID)
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(LIBVHDI_DLL_EXPORT)
set(LIB_RC libvhdi/libvhdi.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 "libvhdi::")
# Source files
file(GLOB LIB_SRC lib*/*.c)
# Headers
file(GLOB LIB_INST_HEADERS include/libvhdi/*.h)
add_library(${PROJECT_NAME} ${LIB_SRC} ${LIB_RC})
target_include_directories(${PROJECT_NAME} PRIVATE ./include ./common)
target_include_directories(${PROJECT_NAME} PRIVATE ./libbfio ./libcdata ./libcerror ./libcfile ./libclocale)
target_include_directories(${PROJECT_NAME} PRIVATE ./libcnotify ./libcpath ./libcsplit ./libcthreads)
target_include_directories(${PROJECT_NAME} PRIVATE ./libfcache ./libfdata ./libfvalue ./libuna ./libfguid)
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
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/libvhdi)
install(FILES include/libvhdi.h DESTINATION include)
# Generate and install libvhdiConfig.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 libvhdiTargets*.cmake
install(EXPORT ${TARGETS_EXPORT_NAME}
NAMESPACE ${NAMESPACE}
DESTINATION "${CONFIG_INSTALL_DIR}")

View File

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

View File

@ -0,0 +1,52 @@
diff --git a/libcfile/libcfile_file.c b/libcfile/libcfile_file.c
index 45e3fc8..5195b7a 100755
--- 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
*/
@@ -4194,6 +4194,12 @@ ssize_t libcfile_file_io_control_read(
return( read_count );
}
+// Force disable on Darwin, it can be erroneously defined
+#if defined ( __APPLE__ )
+#undef HAVE_POSIX_FADVISE
+#endif
+
+
/* Read data from a device file using IO control
* Returns the number of bytes read if successful or -1 on error
*/
diff --git a/libclocale/libclocale_support.c b/libclocale/libclocale_support.c
index f5e29c2..56c4724 100755
--- a/libclocale/libclocale_support.c
+++ b/libclocale/libclocale_support.c
@@ -68,7 +68,7 @@ int libclocale_initialize(
return( -1 );
}
-#if defined( HAVE_BINDTEXTDOMAIN ) && defined( HAVE_TEXTDOMAIN )
+#if !defined( __APPLE__) && defined( HAVE_BINDTEXTDOMAIN ) && defined( HAVE_TEXTDOMAIN )
if( bindtextdomain(
domain_name,
LOCALEDIR ) == NULL )
diff --git a/libvhdi/libvhdi_i18n.c b/libvhdi/libvhdi_i18n.c
index fb33e05..13e8c39 100755
--- a/libvhdi/libvhdi_i18n.c
+++ b/libvhdi/libvhdi_i18n.c
@@ -40,7 +40,7 @@ int libvhdi_i18n_initialize(
if( libvhdi_i18n_initialized == 0 )
{
-#if defined( HAVE_BINDTEXTDOMAIN ) && defined( LOCALEDIR )
+#if !defined( __APPLE__ ) && defined( HAVE_BINDTEXTDOMAIN ) && defined( LOCALEDIR )
if( bindtextdomain(
"libvhdi",
LOCALEDIR ) == NULL )

View File

@ -0,0 +1,33 @@
set(LIB_FILENAME libvhdi-alpha-${VERSION}.tar.gz)
vcpkg_download_distfile(ARCHIVE
URLS "https://github.com/libyal/libvhdi/releases/download/${VERSION}/${LIB_FILENAME}"
FILENAME "${LIB_FILENAME}"
SHA512 5eddbb2ea5800f4427a9763b904b74d1b4a876844f0fb00a8e758c73424171ff7b52a821b1618ea575e9553e6ab357ce80884fab8503dcfc36343a32f80ecd02
)
vcpkg_extract_source_archive(
SOURCE_PATH
ARCHIVE "${ARCHIVE}"
SOURCE_BASE "${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_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/libvhdi)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_install_copyright(
FILE_LIST "${SOURCE_PATH}/COPYING"
)
vcpkg_copy_pdbs()

20
ports/libvhdi/vcpkg.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "libvhdi",
"version": "20231127",
"description": "Library and tools to access the Virtual Hard Disk (VHD) image format ",
"homepage": "https://github.com/libyal/libvhdi",
"license": "LGPL-3.0-or-later",
"supports": "!uwp",
"dependencies": [
"gettext",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"zlib"
]
}

View File

@ -5048,6 +5048,10 @@
"baseline": "0.56.0",
"port-version": 0
},
"libvhdi": {
"baseline": "20231127",
"port-version": 0
},
"libvmdk": {
"baseline": "20221124",
"port-version": 0

9
versions/l-/libvhdi.json Normal file
View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "60ba1f9b6d3e8d3a5543c8f7b85cd42939bb1960",
"version": "20231127",
"port-version": 0
}
]
}