Skip to content
Snippets Groups Projects
Unverified Commit 2cc99006 authored by Jakob Blomer's avatar Jakob Blomer Committed by GitHub
Browse files

Merge pull request #3016 from cvmfs/fix-cmake

Streamline main CMakeLists.txt
parents 1a133b8c 616bc1db
No related branches found
No related tags found
No related merge requests found
......@@ -32,23 +32,23 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
#
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (MACOSX TRUE)
else (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
else ()
set (MACOSX FALSE)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set (LINUX TRUE)
if (EXISTS /etc/debian_version)
set (DEBIAN TRUE)
endif (EXISTS /etc/debian_version)
endif ()
if (EXISTS /etc/arch-release OR EXISTS /etc/manjaro-release)
set (ARCHLINUX TRUE)
endif (EXISTS /etc/arch-release OR EXISTS /etc/manjaro-release)
else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
endif ()
else ()
set (LINUX FALSE)
set (DEBIAN FALSE)
set (ARCHLINUX FALSE)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
endif ()
#
# Set install prefix to /usr by default.
......@@ -56,7 +56,7 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (LINUX AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "CVMFS install path default is /usr" FORCE)
message("Setting default install prefix to ${CMAKE_INSTALL_PREFIX} on Linux")
endif (LINUX AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif ()
#
# Explicitly check that the install prefix is not /usr/local.
......@@ -65,7 +65,7 @@ if (LINUX AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
message("######################################################################")
message(WARNING "The installation path has been set to ${CMAKE_INSTALL_PREFIX}.")
message("######################################################################")
endif (LINUX AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
endif ()
#
# check if we use Clang
......@@ -81,18 +81,18 @@ endif (CMAKE_CXX_COMPILER MATCHES ".*clang")
#
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set (IS_64_BIT FALSE)
else (CMAKE_SIZEOF_VOID_P EQUAL 4)
else ()
set (IS_64_BIT TRUE)
endif (CMAKE_SIZEOF_VOID_P EQUAL 4)
endif ()
#
# check if we are compiling on ARM
#
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm.*$")
set (ARM TRUE)
else (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm.*$")
else ()
set (ARM FALSE)
endif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm.*$")
endif ()
#
# define the installation location of the shared library files
......@@ -134,12 +134,12 @@ message ("Installing shared libraries to: ${CMAKE_INSTALL_LIBDIR}")
if (NOT DEFINED SYSCONF_INSTALL_DIR)
if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
set (SYSCONF_INSTALL_DIR "/etc") # conform to LFSH
else ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
else ()
set(SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc")
endif ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
else (NOT DEFINED SYSCONF_INSTALL_DIR)
endif ()
else ()
set (SYSCONF_INSTALL_DIR "${SYSCONF_INSTALL_DIR}" CACHE STRING "The sysconfig install dir")
endif (NOT DEFINED SYSCONF_INSTALL_DIR)
endif ()
#
# include file with user-defined options
......@@ -158,8 +158,8 @@ include (cvmfs_compiler)
#
set (EXTERNALS_LIB_LOCATION "${CMAKE_SOURCE_DIR}/externals")
if (NOT EXTERNALS_PREFIX)
set(EXTERNALS_PREFIX ${CMAKE_SOURCE_DIR})
endif(NOT EXTERNALS_PREFIX)
set(EXTERNALS_PREFIX ${CMAKE_SOURCE_DIR})
endif()
set (EXTERNALS_BUILD_LOCATION "${EXTERNALS_PREFIX}/externals_build")
set (EXTERNALS_INSTALL_LOCATION "${EXTERNALS_PREFIX}/externals_install")
......@@ -177,25 +177,25 @@ if (BUILTIN_EXTERNALS)
if (BUILD_UBENCHMARKS)
set(ENV{BUILD_UBENCHMARKS} "true")
endif(BUILD_UBENCHMARKS)
endif ()
if (BUILD_SERVER OR BUILD_SERVER_DEBUG)
set(ENV{BUILD_SERVER} "true")
endif (BUILD_SERVER OR BUILD_SERVER_DEBUG)
endif ()
if (BUILD_GEOAPI)
set(ENV{BUILD_GEOAPI} "true")
endif (BUILD_GEOAPI)
endif ()
if (BUILD_QC_TESTS)
set(ENV{BUILD_QC_TESTS} "true")
endif(BUILD_QC_TESTS)
endif()
if (BUILD_GATEWAY)
set(ENV{BUILD_GATEWAY} "true")
endif(BUILD_GATEWAY)
endif ()
if (BUILD_DUCC)
set(ENV{BUILD_DUCC} "true")
endif(BUILD_DUCC)
endif ()
if (BUILD_SNAPSHOTTER)
set(ENV{BUILD_SNAPSHOTTER} "true")
endif(BUILD_SNAPSHOTTER)
endif()
message (STATUS "running bootstrap.sh ...")
execute_process (
......@@ -205,7 +205,7 @@ if (BUILTIN_EXTERNALS)
)
if (BOOTSTRAPPING_RESULT GREATER 0)
message (FATAL_ERROR "bootstrapping failed")
endif (BOOTSTRAPPING_RESULT GREATER 0)
endif ()
# Unset environment variables after the bootstrap script was executed
set(ENV{EXTERNALS_LIB_LOCATION} "")
......@@ -246,7 +246,7 @@ macro (pedantic_include_check HEADERFILE VARIABLENAME)
check_include_file (${HEADERFILE} ${VARIABLENAME})
if (NOT ${VARIABLENAME})
message (FATAL_ERROR "${HEADERFILE} is missing on your system")
endif (NOT ${VARIABLENAME})
endif ()
endmacro (pedantic_include_check)
macro (permissive_include_check HEADERFILE VARIABLENAME)
......@@ -254,7 +254,7 @@ macro (permissive_include_check HEADERFILE VARIABLENAME)
if (${VARIABLENAME})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${VARIABLENAME}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${VARIABLENAME}")
endif (${VARIABLENAME})
endif ()
endmacro (permissive_include_check)
macro (look_for_required_include_files)
......@@ -319,16 +319,16 @@ set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${CMAKE_BINARY_DIR})
find_package (Valgrind)
if (VALGRIND_FOUND)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${VALGRIND_INCLUDE_DIR})
add_definitions(-DHAS_VALGRIND_HEADERS)
endif (VALGRIND_FOUND)
add_definitions (-DHAS_VALGRIND_HEADERS)
endif ()
if (NOT MACOSX)
set (HAVE_LIB_RT TRUE)
set (RT_LIBRARY "rt")
else (NOT MACOSX)
else ()
set (HAVE_LIB_RT FALSE)
set (RT_LIBRARY "")
endif (NOT MACOSX)
endif ()
# Required libraries depending on build target
......@@ -359,14 +359,13 @@ if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_SERVER OR BUILD_SERVER_DEBUG OR
find_package (SHA3 REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${SHA3_INCLUDE_DIRS})
endif (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_SERVER OR BUILD_SERVER_DEBUG OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_PRELOADER OR
BUILD_UBENCHMARKS OR BUILD_SHRINKWRAP)
endif ()
# Most build target require also curl/c-ares, sqlite, uuid, leveldb
if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_SERVER OR BUILD_SERVER_DEBUG OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_PRELOADER OR BUILD_SHRINKWRAP)
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_PRELOADER OR
BUILD_SHRINKWRAP)
find_package (CARES REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${CARES_INCLUDE_DIRS})
......@@ -383,11 +382,11 @@ if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_SERVER OR BUILD_SERVER_DEBUG OR
)
if (NOT ${_libcurl_features} MATCHES AsynchDNS)
message(FATAL_ERROR "libcurl was not compiled with c-ares")
endif (NOT ${_libcurl_features} MATCHES AsynchDNS)
endif ()
else (CURL_CONFIG_EXEC)
message(SEND_ERROR "Command \"${CURL_CONFIG_EXEC} --features\" failed with output:\n${_libcurl_features_error}")
endif (CURL_CONFIG_EXEC)
endif(CURL_INCLUDE_DIRS)
endif ()
endif (CURL_INCLUDE_DIRS)
find_package (SQLite3 REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${SQLITE3_INCLUDE_DIR})
......@@ -396,8 +395,7 @@ if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_SERVER OR BUILD_SERVER_DEBUG OR
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${LEVELDB_INCLUDE_DIR})
find_package (UUID REQUIRED)
endif (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_SERVER OR BUILD_SERVER_DEBUG OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_PRELOADER OR BUILD_SHRINKWRAP)
endif ()
# Client/libcvmfs/preloader only: pacparser, sparsehash
if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_PRELOADER OR
......@@ -407,15 +405,14 @@ if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_PRELOADER OR
find_package(Sparsehash)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${SPARSEHASH_INCLUDE_DIR})
endif (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_PRELOADER OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_SHRINKWRAP)
endif ()
if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_LIBCVMFS_CACHE OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_UBENCHMARKS OR BUILD_SHRINKWRAP)
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_UBENCHMARKS OR
BUILD_SHRINKWRAP)
find_package(Protobuf REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${PROTOBUF_INCLUDE_DIRS})
endif (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_LIBCVMFS_CACHE OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_UBENCHMARKS OR BUILD_SHRINKWRAP)
endif ()
# Fuse client only
if (BUILD_CVMFS)
......@@ -432,7 +429,7 @@ if (BUILD_CVMFS)
add_definitions(-DHAS_FUSE3)
endif ()
endif (MACOSX)
endif (BUILD_CVMFS)
endif ()
# Server only: unzip, libcap
if (BUILD_SERVER OR BUILD_SERVER_DEBUG)
......@@ -441,15 +438,15 @@ if (BUILD_SERVER OR BUILD_SERVER_DEBUG)
find_program(UNZIP_EXE NAMES unzip)
if (${UNZIP_EXE} STREQUAL "UNZIP_EXE-NOTFOUND")
message(FATAL_ERROR "unzip utility missing. Please install unzip...")
endif (${UNZIP_EXE} STREQUAL "UNZIP_EXE-NOTFOUND")
endif (BUILD_SERVER OR BUILD_SERVER_DEBUG)
endif ()
endif ()
# Only micro benchmarks need google bench
if (BUILD_UBENCHMARKS)
find_package(GOOGLEBENCH REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GOOGLEBENCH_INCLUDE_DIRS})
endif (BUILD_UBENCHMARKS)
endif ()
include_directories (${INCLUDE_DIRECTORIES})
......@@ -460,7 +457,7 @@ add_subdirectory (cvmfs)
if (INSTALL_MOUNT_SCRIPTS)
add_subdirectory (mount)
endif (INSTALL_MOUNT_SCRIPTS)
endif ()
#
# compile the unit tests, if necessary
......@@ -469,17 +466,17 @@ if (BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG)
enable_testing ()
add_custom_target (check ${CMAKE_CTEST_COMMAND} -VV)
add_subdirectory (test/unittests)
endif (BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG)
endif ()
if (BUILD_UBENCHMARKS)
add_subdirectory (test/micro-benchmarks)
endif (BUILD_UBENCHMARKS)
endif ()
if (BUILD_QC_TESTS)
find_package(RapidCheck REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${RAPIDCHECK_INCLUDE_DIRS})
add_subdirectory (test/quickcheck)
endif(BUILD_QC_TESTS)
endif ()
if (BUILD_GATEWAY OR BUILD_DUCC OR BUILD_SNAPSHOTTER)
find_program(GO_COMPILER go)
......@@ -488,32 +485,32 @@ if (BUILD_GATEWAY OR BUILD_DUCC OR BUILD_SNAPSHOTTER)
else()
message("Found go compiler: ${GO_COMPILER}")
endif()
endif(BUILD_GATEWAY OR BUILD_DUCC OR BUILD_SNAPSHOTTER)
endif ()
if (BUILD_GATEWAY)
add_subdirectory (gateway)
endif(BUILD_GATEWAY)
endif ()
if (BUILD_DUCC)
add_subdirectory (ducc)
endif(BUILD_DUCC)
endif ()
if (BUILD_SNAPSHOTTER)
add_subdirectory (snapshotter)
endif(BUILD_SNAPSHOTTER)
endif ()
if (BUILD_STRESS_TESTS)
include(test/stress/CMakeLists.txt)
endif (BUILD_STRESS_TESTS)
endif ()
#
# Documentation
#
install (
FILES README.md AUTHORS ChangeLog COPYING
DESTINATION share/doc/cvmfs-${CernVM-FS_VERSION_STRING}
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ
)
FILES README.md AUTHORS ChangeLog COPYING
DESTINATION share/doc/cvmfs-${CernVM-FS_VERSION_STRING}
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ
)
#
# Generate the documentation using doxygen
......@@ -534,4 +531,4 @@ if (BUILD_DOCUMENTATION)
COMMAND sh -c "/bin/sed -i -e 's,@SRC_DIR@,${CMAKE_SOURCE_DIR},g' ${CMAKE_BINARY_DIR}/Doxyfile.in"
)
include (cmake/Modules/UseDoxygen)
endif (BUILD_DOCUMENTATION)
endif ()
#
# CMake build script to configure and build CernVM-FS and all it's
# external dependencies, if they are statically linked into the binaries
#
# See externals/CMake-Register_External_Lib.txt for details on external inclusion
#
cmake_minimum_required (VERSION 2.6.2...3.12)
set (PROJECT_NAME "CernVM-FS")
project (${PROJECT_NAME})
message ("Running CMake version ${CMAKE_VERSION}")
#
# The version numbers
#
# DON'T DELETE
## CVMFS_VERSION 2.9.4
#---------------------
set (CernVM-FS_VERSION_MAJOR 2)
set (CernVM-FS_VERSION_MINOR 9)
set (CernVM-FS_VERSION_PATCH 3)
set (CernVM-FS_VERSION_STRING "${CernVM-FS_VERSION_MAJOR}.${CernVM-FS_VERSION_MINOR}.${CernVM-FS_VERSION_PATCH}")
#
# set the path where cmake looks for additional modules
#
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
#
# detect the operating system and the distribution we are compiling on
#
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (MACOSX TRUE)
else (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (MACOSX FALSE)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set (LINUX TRUE)
if (EXISTS /etc/debian_version)
set (DEBIAN TRUE)
endif (EXISTS /etc/debian_version)
if (EXISTS /etc/arch-release OR EXISTS /etc/manjaro-release)
set (ARCHLINUX TRUE)
endif (EXISTS /etc/arch-release OR EXISTS /etc/manjaro-release)
else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set (LINUX FALSE)
set (DEBIAN FALSE)
set (ARCHLINUX FALSE)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
#
# Set install prefix to /usr by default.
#
if (LINUX AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "CVMFS install path default is /usr" FORCE)
message("Setting default install prefix to ${CMAKE_INSTALL_PREFIX} on Linux")
endif (LINUX AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
#
# Explicitly check that the install prefix is not /usr/local.
#
if (LINUX AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
message("######################################################################")
message(WARNING "The installation path has been set to ${CMAKE_INSTALL_PREFIX}.")
message("######################################################################")
endif (LINUX AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
#
# check if we use Clang
#
if (CMAKE_CXX_COMPILER MATCHES ".*clang")
set(USING_CLANG 1)
else (CMAKE_CXX_COMPILER MATCHES ".*clang")
set(USING_CLANG 0)
endif (CMAKE_CXX_COMPILER MATCHES ".*clang")
#
# figure out if we are on a 64bit system
#
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set (IS_64_BIT FALSE)
else (CMAKE_SIZEOF_VOID_P EQUAL 4)
set (IS_64_BIT TRUE)
endif (CMAKE_SIZEOF_VOID_P EQUAL 4)
#
# check if we are compiling on ARM
#
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm.*$")
set (ARM TRUE)
else (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm.*$")
set (ARM FALSE)
endif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm.*$")
#
# define the installation location of the shared library files
# Note: We do not support multi-arch on Debian systems for the time being and
# hence cannot use GNUInstallDirs as this would assume multi-arch.
# (https://wiki.debian.org/Multiarch)
#
if (MACOSX)
set (CMAKE_INSTALL_LIBDIR "lib")
set (CMAKE_MOUNT_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}/sbin")
set (CVMFS_LIBEXEC_DIR "libexec/cvmfs")
set (CMAKE_MACOSX_RPATH false)
else (MACOSX) # --> Linux
if (DEBIAN OR ARCHLINUX)
if (ARCHLINUX)
set (CMAKE_MOUNT_INSTALL_BINDIR "/usr/bin")
set (CVMFS_LIBEXEC_DIR "lib/cvmfs")
else (ARCHLINUX)
set (CMAKE_MOUNT_INSTALL_BINDIR "/sbin")
set (CVMFS_LIBEXEC_DIR "libexec/cvmfs")
endif (ARCHLINUX)
set (CMAKE_INSTALL_LIBDIR "lib")
else (DEBIAN OR ARCHLINUX) # --> RedHat, Fedora, CentOS, SuSE
set (CMAKE_MOUNT_INSTALL_BINDIR "/sbin")
set (CVMFS_LIBEXEC_DIR "libexec/cvmfs")
if (IS_64_BIT)
set (CMAKE_INSTALL_LIBDIR "lib64")
else (IS_64_BIT) # --> 32 Bit
set (CMAKE_INSTALL_LIBDIR "lib")
endif (IS_64_BIT)
endif (DEBIAN OR ARCHLINUX)
endif (MACOSX)
message ("Installing shared libraries to: ${CMAKE_INSTALL_LIBDIR}")
#
# set the system configuration directory depending on CMAKE_INSTALL_PREFIX
# Note: Found here http://osdir.com/ml/kde-commits/2011-05/msg01375.html
#
if (NOT DEFINED SYSCONF_INSTALL_DIR)
if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
set (SYSCONF_INSTALL_DIR "/etc") # conform to LFSH
else ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
set(SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc")
endif ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
else (NOT DEFINED SYSCONF_INSTALL_DIR)
set (SYSCONF_INSTALL_DIR "${SYSCONF_INSTALL_DIR}" CACHE STRING "The sysconfig install dir")
endif (NOT DEFINED SYSCONF_INSTALL_DIR)
#
# include file with user-defined options
#
include (cvmfs_options)
#
# set some default flags
#
# flags in CMAKE_C**_FLAGS are always passed to the compiler
#
include (cvmfs_compiler)
#
# define where to find the external dependencies
#
set (EXTERNALS_LIB_LOCATION "${CMAKE_SOURCE_DIR}/externals")
if (NOT EXTERNALS_PREFIX)
set(EXTERNALS_PREFIX ${CMAKE_SOURCE_DIR})
endif(NOT EXTERNALS_PREFIX)
set (EXTERNALS_BUILD_LOCATION "${EXTERNALS_PREFIX}/externals_build")
set (EXTERNALS_INSTALL_LOCATION "${EXTERNALS_PREFIX}/externals_install")
#
# run the bootstrap shellscript (not needed in the distributed version of the source)
#
if (BUILTIN_EXTERNALS)
if (EXISTS "${CMAKE_SOURCE_DIR}/bootstrap.sh")
# Set some environment variables for the bootstrap script
set(ENV{EXTERNALS_LIB_LOCATION} ${EXTERNALS_LIB_LOCATION})
set(ENV{EXTERNALS_BUILD_LOCATION} ${EXTERNALS_BUILD_LOCATION})
set(ENV{EXTERNALS_INSTALL_LOCATION} ${EXTERNALS_INSTALL_LOCATION})
set(ENV{CVMFS_BASE_C_FLAGS} ${CVMFS_BASE_C_FLAGS})
set(ENV{CVMFS_BASE_CXX_FLAGS} ${CVMFS_BASE_CXX_FLAGS})
if (BUILD_UBENCHMARKS)
set(ENV{BUILD_UBENCHMARKS} "true")
endif(BUILD_UBENCHMARKS)
if (BUILD_SERVER OR BUILD_SERVER_DEBUG)
set(ENV{BUILD_SERVER} "true")
endif (BUILD_SERVER OR BUILD_SERVER_DEBUG)
if (BUILD_GEOAPI)
set(ENV{BUILD_GEOAPI} "true")
endif (BUILD_GEOAPI)
if (BUILD_QC_TESTS)
set(ENV{BUILD_QC_TESTS} "true")
endif(BUILD_QC_TESTS)
if (BUILD_GATEWAY)
set(ENV{BUILD_GATEWAY} "true")
endif(BUILD_GATEWAY)
if (BUILD_DUCC)
set(ENV{BUILD_DUCC} "true")
endif(BUILD_DUCC)
if (BUILD_SNAPSHOTTER)
set(ENV{BUILD_SNAPSHOTTER} "true")
endif(BUILD_SNAPSHOTTER)
message (STATUS "running bootstrap.sh ...")
execute_process (
COMMAND sh ${CMAKE_SOURCE_DIR}/bootstrap.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE BOOTSTRAPPING_RESULT
)
if (BOOTSTRAPPING_RESULT GREATER 0)
message (FATAL_ERROR "bootstrapping failed")
endif (BOOTSTRAPPING_RESULT GREATER 0)
# Unset environment variables after the bootstrap script was executed
set(ENV{EXTERNALS_LIB_LOCATION} "")
set(ENV{EXTERNALS_BUILD_LOCATION} "")
set(ENV{EXTERNALS_INSTALL_LOCATION} "")
set(ENV{CVMFS_BASE_C_FLAGS} "")
set(ENV{CVMFS_BASE_CXX_FLAGS} "")
set(ENV{BUILD_UBENCHMARKS} "")
set(ENV{BUILD_SERVER} "")
set(ENV{BUILD_QC_TESTS} "")
set(ENV{BUILD_GATEWAY} "")
set(ENV{BUILD_DUCC} "")
set(ENV{BUILD_SNAPSHOTTER} "")
endif (EXISTS "${CMAKE_SOURCE_DIR}/bootstrap.sh")
# In the case of built-in external libraries, we need to set CMAKE_PREFIX_PATH to
# point to the prefix where the libraries are installed. This path will take precedence
# over the system prefix when find_package(****) is called later
set(CMAKE_PREFIX_PATH ${EXTERNALS_INSTALL_LOCATION})
message("Project prefix path: ${CMAKE_PREFIX_PATH}")
message("System prefix path: ${CMAKE_SYSTEM_PREFIX_PATH}")
endif(BUILTIN_EXTERNALS)
#
# include some common functionality
#
include (FindPythonModule)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} cvmfs)
#
# check existence of include files
#
include (CheckIncludeFile)
macro (pedantic_include_check HEADERFILE VARIABLENAME)
check_include_file (${HEADERFILE} ${VARIABLENAME})
if (NOT ${VARIABLENAME})
message (FATAL_ERROR "${HEADERFILE} is missing on your system")
endif (NOT ${VARIABLENAME})
endmacro (pedantic_include_check)
macro (permissive_include_check HEADERFILE VARIABLENAME)
check_include_file (${HEADERFILE} ${VARIABLENAME})
if (${VARIABLENAME})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${VARIABLENAME}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${VARIABLENAME}")
endif (${VARIABLENAME})
endmacro (permissive_include_check)
macro (look_for_required_include_files)
foreach (HEADER ${ARGV})
string (REGEX REPLACE "/|\\." "_" HEADER_VAR_LOWER ${HEADER})
string (TOUPPER "have_${HEADER_VAR_LOWER}" HEADER_VAR)
pedantic_include_check (${HEADER} ${HEADER_VAR})
endforeach (HEADER IN ITEMS ${ARGV})
endmacro (look_for_required_include_files)
macro (look_for_optional_include_files)
foreach (HEADER ${ARGV})
string (REGEX REPLACE "/|\\." "_" HEADER_VAR_LOWER ${HEADER})
string (TOUPPER "have_${HEADER_VAR_LOWER}" HEADER_VAR)
permissive_include_check (${HEADER} ${HEADER_VAR})
endforeach (HEADER IN ITEMS ${ARGV})
endmacro (look_for_optional_include_files)
set (REQUIRED_HEADERS sys/xattr.h zlib.h netinet/in.h arpa/inet.h sys/socket.h
sys/un.h sys/time.h sys/uio.h sys/stat.h sys/types.h
sys/wait.h sys/select.h pthread.h termios.h utime.h
signal.h errno.h dirent.h unistd.h fcntl.h netdb.h
syslog.h sys/resource.h execinfo.h poll.h pwd.h grp.h)
set (OPTIONAL_HEADERS )
if (NOT MACOSX)
set (REQUIRED_HEADERS ${REQUIRED_HEADERS}
sys/statfs.h)
# As of attr-2.4.48, the attr/xattr.h header disappeard in favor of sys/xattr.h
#
# Unfortunately, attr/xattr.h fails to compile without including sys/types.h
# before including attr/xattr.h (it uses size_t and ssize_t).
# CMake searches for include files by compiling a minimal *.c file like:
# #include <${SEARCHED_HEADER_FILE}>
# int main(int argc, char **argv) { return 0; }
#
# We pre-define the include guard of attr/xattr.h and thus still check, if the
# file is found by the compiler but mitigating the compiler errors caused by
# a standalone inclusion of attr/xattr.h
set (CMAKE_REQUIRED_DEFINITIONS "-D__XATTR_H__")
set (OPTIONAL_HEADERS ${OPTIONAL_HEADERS}
attr/xattr.h)
endif (NOT MACOSX)
look_for_required_include_files (${REQUIRED_HEADERS})
look_for_optional_include_files (${OPTIONAL_HEADERS})
#
# configure the config.h.in file
#
configure_file (
"${CMAKE_SOURCE_DIR}/config_cmake.h.in"
"${CMAKE_BINARY_DIR}/cvmfs_config.h"
)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${CMAKE_BINARY_DIR})
#
# set properties for configurable libraries
#
find_package (Valgrind)
if (VALGRIND_FOUND)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${VALGRIND_INCLUDE_DIR})
add_definitions(-DHAS_VALGRIND_HEADERS)
endif (VALGRIND_FOUND)
if (NOT MACOSX)
set (HAVE_LIB_RT TRUE)
set (RT_LIBRARY "rt")
else (NOT MACOSX)
set (HAVE_LIB_RT FALSE)
set (RT_LIBRARY "")
endif (NOT MACOSX)
# Required libraries depending on build target
find_package (OpenSSL REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${OPENSSL_INCLUDE_DIR})
find_package (GTest REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GTEST_INCLUDE_DIRS})
find_package (GMock REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GMOCK_INCLUDE_DIRS})
find_package (VJSON REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${VJSON_INCLUDE_DIRS})
find_package (LibArchive REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${LibArchive_INCLUDE_DIRS})
# Almost all build targets require zlib, sha2/3
if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_SERVER OR BUILD_SERVER_DEBUG OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_PRELOADER OR
BUILD_UBENCHMARKS OR BUILD_SHRINKWRAP)
find_package (ZLIB REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS})
find_package (SHA2 REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${SHA2_INCLUDE_DIRS})
find_package (SHA3 REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${SHA3_INCLUDE_DIRS})
endif (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_SERVER OR BUILD_SERVER_DEBUG OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_PRELOADER OR
BUILD_UBENCHMARKS OR BUILD_SHRINKWRAP)
# Most build target require also curl/c-ares, sqlite, uuid, leveldb
if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_SERVER OR BUILD_SERVER_DEBUG OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_PRELOADER OR BUILD_SHRINKWRAP)
find_package (CARES REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${CARES_INCLUDE_DIRS})
find_package (CURL REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${CURL_INCLUDE_DIRS})
if (CURL_INCLUDE_DIRS)
find_program(CURL_CONFIG_EXEC NAMES curl-config)
if (CURL_CONFIG_EXEC)
execute_process(
COMMAND ${CURL_CONFIG_EXEC} --features
OUTPUT_VARIABLE _libcurl_features
ERROR_VARIABLE _libcurl_features_error
)
if (NOT ${_libcurl_features} MATCHES AsynchDNS)
message(FATAL_ERROR "libcurl was not compiled with c-ares")
endif (NOT ${_libcurl_features} MATCHES AsynchDNS)
else (CURL_CONFIG_EXEC)
message(SEND_ERROR "Command \"${CURL_CONFIG_EXEC} --features\" failed with output:\n${_libcurl_features_error}")
endif (CURL_CONFIG_EXEC)
endif(CURL_INCLUDE_DIRS)
find_package (SQLite3 REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${SQLITE3_INCLUDE_DIR})
find_package(leveldb)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${LEVELDB_INCLUDE_DIR})
find_package (UUID REQUIRED)
endif (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_SERVER OR BUILD_SERVER_DEBUG OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_PRELOADER OR BUILD_SHRINKWRAP)
# Client/libcvmfs/preloader only: pacparser, sparsehash
if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_PRELOADER OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_SHRINKWRAP)
find_package (pacparser REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${PACPARSER_INCLUDE_DIR})
find_package(Sparsehash)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${SPARSEHASH_INCLUDE_DIR})
endif (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_PRELOADER OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_SHRINKWRAP)
if (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_LIBCVMFS_CACHE OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_UBENCHMARKS OR BUILD_SHRINKWRAP)
find_package(Protobuf REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${PROTOBUF_INCLUDE_DIRS})
endif (BUILD_CVMFS OR BUILD_LIBCVMFS OR BUILD_LIBCVMFS_CACHE OR
BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG OR BUILD_UBENCHMARKS OR BUILD_SHRINKWRAP)
# Fuse client only
if (BUILD_CVMFS)
if (MACOSX)
find_package (OSXFuse REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${OSXFUSE_INCLUDE_DIR})
set (FUSE_LIBRARIES ${OSXFUSE_LIBRARIES}) # just abstract the difference here... they are compatible
else (MACOSX)
find_package (FUSE REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${FUSE_INCLUDE_DIR})
find_package (FUSE3)
if (FUSE3_FOUND)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${FUSE3_INCLUDE_DIR})
add_definitions(-DHAS_FUSE3)
endif ()
endif (MACOSX)
endif (BUILD_CVMFS)
# Server only: unzip, libcap
if (BUILD_SERVER OR BUILD_SERVER_DEBUG)
find_package(PythonLibs REQUIRED)
find_package(LibCAP REQUIRED)
find_program(UNZIP_EXE NAMES unzip)
if (${UNZIP_EXE} STREQUAL "UNZIP_EXE-NOTFOUND")
message(FATAL_ERROR "unzip utility missing. Please install unzip...")
endif (${UNZIP_EXE} STREQUAL "UNZIP_EXE-NOTFOUND")
endif (BUILD_SERVER OR BUILD_SERVER_DEBUG)
# Only micro benchmarks need google bench
if (BUILD_UBENCHMARKS)
find_package(GOOGLEBENCH REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GOOGLEBENCH_INCLUDE_DIRS})
endif (BUILD_UBENCHMARKS)
include_directories (${INCLUDE_DIRECTORIES})
#
# go for the actual compilation
#
add_subdirectory (cvmfs)
if (INSTALL_MOUNT_SCRIPTS)
add_subdirectory (mount)
endif (INSTALL_MOUNT_SCRIPTS)
#
# compile the unit tests, if necessary
#
if (BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG)
enable_testing ()
add_custom_target (check ${CMAKE_CTEST_COMMAND} -VV)
add_subdirectory (test/unittests)
endif (BUILD_UNITTESTS OR BUILD_UNITTESTS_DEBUG)
if (BUILD_UBENCHMARKS)
add_subdirectory (test/micro-benchmarks)
endif (BUILD_UBENCHMARKS)
if (BUILD_QC_TESTS)
find_package(RapidCheck REQUIRED)
set (INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${RAPIDCHECK_INCLUDE_DIRS})
add_subdirectory (test/quickcheck)
endif(BUILD_QC_TESTS)
if (BUILD_GATEWAY OR BUILD_DUCC OR BUILD_SNAPSHOTTER)
find_program(GO_COMPILER go)
if(NOT GO_COMPILER)
message(FATAL_ERROR "go compiler not found")
else()
message("Found go compiler: ${GO_COMPILER}")
endif()
endif(BUILD_GATEWAY OR BUILD_DUCC OR BUILD_SNAPSHOTTER)
if (BUILD_GATEWAY)
add_subdirectory (gateway)
endif(BUILD_GATEWAY)
if (BUILD_DUCC)
add_subdirectory (ducc)
endif(BUILD_DUCC)
if (BUILD_SNAPSHOTTER)
add_subdirectory (snapshotter)
endif(BUILD_SNAPSHOTTER)
if (BUILD_STRESS_TESTS)
include(test/stress/CMakeLists.txt)
endif (BUILD_STRESS_TESTS)
#
# Documentation
#
install (
FILES README.md AUTHORS ChangeLog COPYING
DESTINATION share/doc/cvmfs-${CernVM-FS_VERSION_STRING}
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ
)
#
# Generate the documentation using doxygen
#
if (BUILD_DOCUMENTATION)
message (STATUS "Generating Doxygen configuration ...")
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set (DOXYFILE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/cvmfs")
set (DOXYFILE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/")
set (DOXYFILE_LATEX "OFF")
execute_process (
COMMAND sh -c "cp ${CMAKE_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile.in"
)
execute_process (
COMMAND sh -c "/bin/sed -i -e 's/@VERSION@/${CernVM-FS_VERSION_STRING}/g' ${CMAKE_BINARY_DIR}/Doxyfile.in"
)
execute_process (
COMMAND sh -c "/bin/sed -i -e 's,@SRC_DIR@,${CMAKE_SOURCE_DIR},g' ${CMAKE_BINARY_DIR}/Doxyfile.in"
)
include (cmake/Modules/UseDoxygen)
endif (BUILD_DOCUMENTATION)
This diff is collapsed.
/**
* This file is part of the CernVM File System.
*
* NOTE: when adding or removing public symbols, you must also update the list
* in libcvmfs_public_syms.txt.
*
* Not supported in the library:
* - Quota management
* - Asynchronous HTTP I/O
* - Automatic update of root file catalog
* - Tracer
* - Authz helper
*/
#ifndef CVMFS_LIBCVMFS_H_
#define CVMFS_LIBCVMFS_H_
#define LIBCVMFS_VERSION 2
#define LIBCVMFS_VERSION_MAJOR LIBCVMFS_VERSION
#define LIBCVMFS_VERSION_MINOR 9
// Revision Changelog
// 13: revision introduced
// 14: fix expand_path for absolute paths, add mountpoint to cvmfs_context
// 15: remove counting of open file descriptors
// 16: remove unnecessary free
// 17: apply new classes around the cache manager
// 18: add cvmfs_pread and support for chunked files
// 19: CernVM-FS 2.2.0
// 20: fix reading of chunked files
// 21: CernVM-FS 2.2.3
// 22: CernVM-FS 2.3.0
// 23: update initialization code
// 24: add LIBCVMFS_ERR_REVISION_BLACKLISTED
// 25: CernVM-FS 2.4.0
// 26: CernVM-FS 2.5.0
// 27: Add cvmfs_options_init_v2
// 28: CernVM-FS 2.6.0
// 29: CernVM-FS 2.8
// * Add cvmfs_options_parse_default
// * Add cvmfs_listdir_stat
// * Add catalog counters to struct cvmfs_nc_attr
// 30: CernVM-FS 2.8
// * Implement cvmfs_remount()
// * Add cvmfs_get_revision()
#define LIBCVMFS_REVISION 30
#include <stdint.h>
#include <sys/stat.h>
#include <unistd.h>
// Legacy error codes
#define LIBCVMFS_FAIL_OK 0
#define LIBCVMFS_FAIL_NOFILES -1
#define LIBCVMFS_FAIL_MKCACHE -2
#define LIBCVMFS_FAIL_OPENCACHE -3
#define LIBCVMFS_FAIL_LOCKFILE -4
#define LIBCVMFS_FAIL_INITCACHE -5
#define LIBCVMFS_FAIL_INITQUOTA -6
#define LIBCVMFS_FAIL_BADOPT -7
#ifdef __cplusplus
extern "C" {
// Map C++ clases to their C interface names
typedef class LibContext cvmfs_context;
typedef class SimpleOptionsParser cvmfs_option_map;
#else
typedef struct LibContext cvmfs_context;
typedef struct OptionsManager cvmfs_option_map;
#endif
/**
* Error codes for cvmfs_init_v2() and cvmfs_attach_repo_v2(). Mirrors the
* failure codes in loader.h
*/
typedef enum {
LIBCVMFS_ERR_OK = 0,
LIBCVMFS_ERR_UNKNOWN,
LIBCVMFS_ERR_OPTIONS,
LIBCVMFS_ERR_PERMISSION,
LIBCVMFS_ERR_MOUNT, // unused in the library
LIBCVMFS_ERR_LOADER_TALK, // unused in the library
LIBCVMFS_ERR_FUSE_LOOP, // unused in the library
LIBCVMFS_ERR_LOAD_LIBRARY, // unused in the library
LIBCVMFS_ERR_INCOMPATIBLE_VERSIONS, // unused
LIBCVMFS_ERR_CACHE_DIR,
LIBCVMFS_ERR_PEERS, // unused
LIBCVMFS_ERR_NFS_MAPS,
LIBCVMFS_ERR_QUOTA,
LIBCVMFS_ERR_MONITOR, // unused in the library
LIBCVMFS_ERR_TALK, // unused in the library
LIBCVMFS_ERR_SIGNATURE,
LIBCVMFS_ERR_CATALOG,
LIBCVMFS_ERR_MAINTENANCE_MODE, // unused in the library
LIBCVMFS_ERR_SAVE_STATE, // unused in the library
LIBCVMFS_ERR_RESTORE_STATE, // unused in the library
LIBCVMFS_ERR_OTHER_MOUNT, // unused in the library
LIBCVMFS_ERR_DOUBLE_MOUNT, // unused in the library
LIBCVMFS_ERR_HISTORY,
LIBCVMFS_ERR_WPAD,
LIBCVMFS_ERR_LOCK_WORKSPACE,
LIBCVMFS_ERR_REVISION_BLACKLISTED,
} cvmfs_errors;
/**
* Stat struct for a Nested Catalog.
*
* mountpoint is allocated by called function
* should be freed by caller
* hash is allocated by the called function
* should be freed by caller
*
*/
struct cvmfs_nc_attr {
char *mountpoint;
char *hash;
uint64_t size;
// Catalog counters
uint64_t ctr_regular;
uint64_t ctr_symlink;
uint64_t ctr_special;
uint64_t ctr_dir;
uint64_t ctr_nested;
uint64_t ctr_chunked;
uint64_t ctr_chunks;
uint64_t ctr_file_size;
uint64_t ctr_chunked_size;
uint64_t ctr_xattr;
uint64_t ctr_external;
uint64_t ctr_external_file_size;
};
/**
* Creates an empty cvmfs_nc_attr struct and
* returns the pointer to the user.
* \return pointer to newly created cvmfs_nc_attr struct
*/
struct cvmfs_nc_attr* cvmfs_nc_attr_init();
/**
* Frees the cvmfs_nc_attr struct passed, including
* freeing the mountpoint and hash.
* @param[in] nc_attr, pointer the cvmfs_nc_attr to be destroyed
*/
void cvmfs_nc_attr_free(struct cvmfs_nc_attr *nc_attr);
struct cvmfs_attr {
/* Struct definition information */
unsigned version;
uint64_t size;
/* Contents of stat, mapped from DirectoryEntry */
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
time_t mtime;
/* CVMFS related content */
int cvm_nchunks;
int cvm_is_hash_artificial;
/* This information is allocated and should be freed */
// For chunked files without bulk hash: hash of chunk hashes
char * cvm_checksum;
char * cvm_symlink;
char * cvm_parent;
char * cvm_name;
void * cvm_xattrs;
};
/**
* Struct for storing stat info about an object.
*/
struct cvmfs_stat_t {
// name of the object, owned by the struct (needs to be freed)
char * name;
struct stat info;
};
/**
* Create the cvmfs_attr struct which contains the same information
* as a stat, but also has pointers to the hash, symlink, and name.
* \Return pointer to a cvmfs_attr struct
*/
struct cvmfs_attr* cvmfs_attr_init();
/**
* Destroy the cvmfs_attr struct and frees the checksum, symlink,
* parent, name, and xattrs.
* @param attr, pointer to a cvmfs_attr struct to be deleted.
*/
void cvmfs_attr_free(struct cvmfs_attr *attr);
/**
* Send syslog and debug messages to log_fn instead. This may (and probably
* should) be called before any other routine. Setting this to NULL restores
* the default logging behavior.
*/
void cvmfs_set_log_fn( void (*log_fn)(const char *msg) );
/**
* Get runtime statistics formatted as a string. The raw counters
* are also available via @p cvmfs_talk when using the FUSE module.
* @p cvmfs_statistics() allocates a new string, which the caller must free.
* Returns NULL if insufficient memory was available.
*/
char *cvmfs_statistics_format(cvmfs_context *ctx);
/**
* An option map must be created an populated before calling cvmfs_init_v2().
*/
cvmfs_option_map *cvmfs_options_init();
/**
* Like cvmfs_options_init but let decide whether or not cvmfs options make it
* to the process environment. Relevant for resolving symbolic links.
*/
cvmfs_option_map *cvmfs_options_init_v2(int taint_environ);
void cvmfs_enable_threaded(cvmfs_context *ctx);
/**
* Creates a new option map based on the legacy option string that would be
* passed to the legacy function cvmfs_init(). Returns NULL if legacy_options
* is invalid.
*/
cvmfs_option_map *cvmfs_options_init_legacy(const char *legacy_options);
/**
* Creates a new option map based on an existing one. Should be used to add
* repository specific options passed to cvmfs_attach_repo_v2() based on the
* global options that were passed to cvmfs_init_v2().
*/
cvmfs_option_map *cvmfs_options_clone(cvmfs_option_map *opts);
/**
* Derives an option map based on the legacy option string that would be passed
* to the legacy function cvmfs_attach_repo(). Returns NULL if legacy_options
* is invalid. On success, the repository name is in the CVMFS_FQRN key in the
* options manager.
*/
cvmfs_option_map *cvmfs_options_clone_legacy(cvmfs_option_map *opts,
const char *legacy_options);
/**
* Frees the resources of a cvmfs_options_map, which was created either by a
* call to cvmfs_options_init() or by a call to cvmfs_options_clone().
*/
void cvmfs_options_fini(cvmfs_option_map *opts);
/**
* Fills a cvmfs_options_map. Use the same key/value pairs as the configuration
* parameters used by the fuse module in /etc/cvmfs/...
*/
void cvmfs_options_set(cvmfs_option_map *opts,
const char *key, const char *value);
/**
* Sets options from a file with linewise KEY=VALUE pairs. Returns 0 on success
* and -1 otherwise.
*/
int cvmfs_options_parse(cvmfs_option_map *opts, const char *path);
/**
* Sets default options from repository defaults in /etc/cvmfs.
* Returns 0 on success and -1 otherwise.
*/
void cvmfs_options_parse_default(cvmfs_option_map *opts, const char *fqrn);
/**
* Removes a key-value pair from a cvmfs_options_map. The key may or may not
* exist before the call.
*/
void cvmfs_options_unset(cvmfs_option_map *opts, const char *key);
/**
* Retrieves the value for a given key or NULL of the key does not exist. If
* the result is not NULL, it must be freed by a call to cvmfs_options_free().
*/
char *cvmfs_options_get(cvmfs_option_map *opts, const char *key);
/**
* Prints the key-value pairs of cvmfs_option_map line-by-line. The resulting
* string needs to be freed by a call to cvmfs_options_free().
*/
char *cvmfs_options_dump(cvmfs_option_map *opts);
/**
* Frees a string returned from cvmfs_options_get() or cvmfs_options_dump().
*/
void cvmfs_options_free(char *value);
/**
* Initialize global CVMFS library structures. Legacy. Use cvmfs_init_v2().
* Note: this _must_ be called before any of the following functions.
*
* @param[in] options, option1,option2,...
* \return 0 on success
*/
int cvmfs_init(char const *options);
/**
* Initializes the global cvmfs state based on a cvmfs_options_map. The
* cvmfs_fini() function works for both cvmfs_init() and cvmfs_init_v2()
*/
cvmfs_errors cvmfs_init_v2(cvmfs_option_map *opts);
/**
* Shut down the CVMFS library and release all resources. The cvmfs_option_map
* object passed to cvmfs_init_v2 must be deleted afterwards by a call to
* cvmfs_options_fini().
*/
void cvmfs_fini();
/**
* Initialize a CVMFS remote repository. Legacy. Use cvmfs_attach_repo_v2().
*
* @param[in] options, option1,option2,...
* \return 0 on success
*/
cvmfs_context* cvmfs_attach_repo(char const *options);
/**
* Creates a new repository context. On successful return, *ctx is not NULL and
* must be freed by a call to cvmfs_detach_repo(). Otherwise *ctx is NULL.
*
* The cvmfs_option_map can be the global cvmfs_option_map pointer or a new
* pointer retrieved from cvmfs_options_clone(). If it is a new pointer,
* ownership can be transferred to the context by a call to
* cvmfs_adopt_options() so that the options map is free by cvmfs_detach_repo().
*/
cvmfs_errors cvmfs_attach_repo_v2(const char *fqrn, cvmfs_option_map *opts,
cvmfs_context **ctx);
/**
* Transfer ownership of opts to the context ctx. The option map is
* automatically freed by cvmfs_detach_repo.
*/
void cvmfs_adopt_options(cvmfs_context *ctx, cvmfs_option_map *opts);
/**
* Uninitialize a cvmfs remote repository and release all resources for it.
* Works with both cvmfs_attach_repo() and cvmfs_attach_repo_v2().
*/
void cvmfs_detach_repo(cvmfs_context *ctx);
/**
* Load a new catalog if there is one.
* \return 0 on success (up to date or new catalog loaded), -1 otherwise
*/
int cvmfs_remount(cvmfs_context *ctx);
/**
* Open a file in the cvmfs cache.
*
* @param[in] path, path to open (e.g. /dir/file, not /cvmfs/repo/dir/file)
* \return read-only file descriptor, -1 on failure (sets errno)
*/
int cvmfs_open(cvmfs_context *ctx, const char *path);
/**
* Read from a file descriptor returned by cvmfs_open(). File descriptors that
* have bit 30 set indicate chunked files.
*/
ssize_t cvmfs_pread(cvmfs_context *ctx,
int fd, void *buf, size_t size, off_t off);
/**
* Close a file previously opened with cvmfs_open().
*
* @param[in] fd, file descriptor to close
* \return 0 on success, -1 on failure (sets errno)
*/
int cvmfs_close(cvmfs_context *ctx, int fd);
/**
* Read a symlink from the catalog. Environment variables in the symlink that
* are of the form $(varname) are expanded according to the process' environment
* variables. If the provided buffer is not long enough for the null-terminated
* value of the symlink, -1 is returned and errno is set to ERANGE.
*
* @param[in] path, path of symlink (e.g. /dir/file, not /cvmfs/repo/dir/file)
* @param[out] buf, buffer in which to write the null-terminated value of the symlink
* @param[in] size, size of buffer
* \return 0 on success, -1 on failure (sets errno)
*/
int cvmfs_readlink(cvmfs_context *ctx,
const char *path,
char *buf,
size_t size);
/**
* Get information about a file. If the file is a symlink, return info about
* the file it points to, not the symlink itself.
*
* @param[in] path, path of file (e.g. /dir/file, not /cvmfs/repo/dir/file)
* @param[out] st, stat buffer in which to write the result
* \return 0 on success, -1 on failure (sets errno)
*/
int cvmfs_stat(cvmfs_context *ctx, const char *path, struct stat *st);
/**
* Get information about a file. If the file is a symlink, return info about
* the link, not the file it points to.
*
* @param[in] path, path of file (e.g. /dir/file, not /cvmfs/repo/dir/file)
* @param[out] st, stat buffer in which to write the result
* \return 0 on success, -1 on failure (sets errno)
*/
int cvmfs_lstat(cvmfs_context *ctx, const char *path, struct stat *st);
/**
* Get the extended CVMFS information about a file. If the file is a symlink,
* return info about the link, not the file it points to.
*
* @param[in] path, path of file (e.g. /dir/file, not /cvmfs/repo/dir/file)
* @param[out] attr, cvmfs_attr struct in which to write the result
* \return 0 on success, -1 on failure
*/
int cvmfs_stat_attr(
cvmfs_context *ctx,
const char *path,
struct cvmfs_attr *attr);
/**
* Get list of directory contents. The directory contents includes "." and
* "..".
*
* On return, the array will contain a NULL-terminated list of strings. The
* caller must free the strings and the array containing them. The array (*buf)
* may be NULL when this function is called.
*
* @param[in] path, path of directory (e.g. /dir, not /cvmfs/repo/dir)
* @param[out] buf, pointer to dynamically allocated NULL-terminated array of
* strings
* @param[in] buflen, pointer to variable containing size of array
* \return 0 on success, -1 on failure (sets errno)
*/
int cvmfs_listdir(
cvmfs_context *ctx,
const char *path,
char ***buf,
size_t *buflen);
/**
* Get list of directory contents. The list does not include "." or "..".
*
* On return, the array will contain a NULL-terminated list of strings. The
* caller must free the strings and the array containing them. The array (*buf)
* may be NULL when this function is called.
*
* @param[in] path, path of directory (e.g. /dir, not /cvmfs/repo/dir)
* @param[out] buf, pointer to dynamically allocated NULL-terminated array of
* strings
* @param[in] buflen, pointer to variable containing size of array
* \return 0 on success, -1 on failure (sets errno)
*/
int cvmfs_listdir_contents(
cvmfs_context *ctx,
const char *path,
char ***buf,
size_t *listlen,
size_t *buflen);
/**
* Get list of directory contents' stat info.
* The list does not include "." or "..".
*
* On return, @param buf will contain list of cvmfs_stat_t objects.
* The caller must free the cvmfs_stat_t::name and the array containing
* cvmfs_stat_t objects (*buf).
* The array (*buf) may be NULL when this function is called.
*
* @param[in] path, path of directory (e.g. /dir, not /cvmfs/repo/dir)
* @param[out] buf, pointer to dynamically allocated array of cvmfs_stat_t
* @param[in] buflen, pointer to variable containing size of @param buf
* @param[in/out] listlen, pointer to number of entries in @param buf.
* Set @param listlen to 0 before to fill @param buf from index 0.
* \return 0 on success, -1 on failure (sets errno)
*/
int cvmfs_listdir_stat(
cvmfs_context *ctx,
const char *path,
struct cvmfs_stat_t **buf,
size_t *listlen,
size_t *buflen);
/**
* Get the CVMFS information about a nested catalog. The information returned
* pertains to the catalog that serves this path, if this path is a transition
* point, then the information is about this transition point.
*
*
* @param[in] path, path of nested catalog (e.g. /dir, not /cvmfs/repo/dir)
* @param[out] ncst, cvmfs_nc_attr buffer in which to write the result
* \return 0 on success, -1 on failure
*/
int cvmfs_stat_nc(
cvmfs_context *ctx,
const char *path,
struct cvmfs_nc_attr *ncst);
/**
* Get list of nested catalog at path. The list contents includes the empty string
* for the base and each nested catalog needed to reach this location. It also
* contains the list of nested catalogs reachable directly from the nested catalog
* serving this location. If this is a transition point, the nested catalog at this
* location is used.
*
* On return, the array will contain a NULL-terminated list of strings. The
* caller must free the strings and the array containing them. The array (*buf)
* may be NULL when this function is called.
*
* @param[in] path, path of nested catalog (e.g. /dir, not /cvmfs/repo/dir)
* @param[out] buf, pointer to dynamically allocated NULL-terminated array of
* strings
* @param[in] buflen, pointer to variable containing size of array
* \return 0 on success, -1 on failure (sets errno)
*/
int cvmfs_list_nc(
cvmfs_context *ctx,
const char *path,
char ***buf,
size_t *buflen);
/**
* Free the items contained in list and then the list.
* @param[in] buf, pointer to the list that was allocated.
*/
void cvmfs_list_free(char **buf);
/**
* Return the root file catalog revision
*/
uint64_t cvmfs_get_revision(cvmfs_context *ctx);
#ifdef __cplusplus
}
#endif
#endif // CVMFS_LIBCVMFS_H_
......@@ -14,11 +14,7 @@ set (LIBCVMFS_UTIL_SOURCES
util/string.cc
)
set (LIBCVMFS_UTIL_CFLAGS "${CMAKE_CXX_FLAGS} \
-D_FILE_OFFSET_BITS=64 \
-DCVMFS_LIBRARY \
-DCVMFS_RAISE_EXCEPTIONS \
-fexceptions")
set (LIBCVMFS_UTIL_CFLAGS "-D_FILE_OFFSET_BITS=64 -DCVMFS_LIBRARY -DCVMFS_RAISE_EXCEPTIONS -fexceptions")
set (LIBCVMFS_UTIL_LINK_LIBRARIES "")
list (APPEND LIBCVMFS_UTIL_LINK_LIBRARIES
${RT_LIBRARY}
......
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var Version = "development"
func init() {
rootCmd.AddCommand(versionCmd)
}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version of ducc",
Aliases: []string{"v"},
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(Version)
},
}
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment