Skip to content

Commit

Permalink
Build release version of GUFI when tagged
Browse files Browse the repository at this point in the history
Miscellaneous changes - capitalization, indentation, ordering, etc
  • Loading branch information
calccrypto committed Jun 26, 2019
1 parent ebdd091 commit 97c13bb
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 67 deletions.
80 changes: 42 additions & 38 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ matrix:
sudo: false
dist: xenial
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-7
packages:
- attr
- cmake
- clang-7
- libattr1-dev
- libfuse-dev
- libpcre3-dev
- pkg-config
update: true
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-7
packages:
- attr
- cmake
- clang-7
- libattr1-dev
- libfuse-dev
- libpcre3-dev
- pkg-config
update: true
env:
- C_COMPILER=clang-7
- CXX_COMPILER=clang++-7
- BUILD=cmake
- C_COMPILER=clang-7
- CXX_COMPILER=clang++-7
- BUILD=cmake
- CMAKE_FLAGS=-DCMAKE_BUILD_TYPE=Debug
script: contrib/travis/xenial.sh

# OpenSUSE 12.3 + Tumbleweed Repo
Expand All @@ -47,6 +48,7 @@ matrix:
- C_COMPILER=clang-7
- CXX_COMPILER=clang++-7
- BUILD=cmake
- CMAKE_FLAGS=-DCMAKE_BUILD_TYPE=Debug
- DOCKER_IMAGE=saltstack/opensuse-12.3-minimal
script: contrib/travis/suse12.3.sh

Expand All @@ -63,6 +65,7 @@ matrix:
- C_COMPILER=clang
- CXX_COMPILER=clang++
- BUILD=cmake
- CMAKE_FLAGS=-DCMAKE_BUILD_TYPE=Debug
- DOCKER_IMAGE=centos:7
script: contrib/travis/centos7.sh

Expand Down Expand Up @@ -114,43 +117,44 @@ matrix:
sudo: false
dist: xenial
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-7
packages:
- attr
- bsd-mailx
- cmake
- clang-7
- libattr1-dev
- libfuse-dev
- libpcre3-dev
update: true
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-7
packages:
- attr
- bsd-mailx
- cmake
- clang-7
- libattr1-dev
- libfuse-dev
- libpcre3-dev
update: true
script:
- true
deploy:
provider: script
skip-cleanup: true
script: bash contrib/travis/deploy.sh
on:
all_branches: true
condition: (("${TRAVIS_EVENT_TYPE}" = "api") || ("${TRAVIS_EVENT_TYPE}" = "cron"))
tags: false
provider: script
skip-cleanup: true
script: bash contrib/travis/deploy.sh
on:
tags: false
all_branches: true
condition: (("${TRAVIS_EVENT_TYPE}" = "api") || ("${TRAVIS_EVENT_TYPE}" = "cron"))

# Build and push release packages
- stage: deploy
os: linux
sudo: true
dist: xenial
addons:
apt:
update: false
apt:
update: false
services: docker
env:
- C_COMPILER=clang
- CXX_COMPILER=clang++
- BUILD=cmake
- CMAKE_FLAGS=-DCMAKE_BUILD_TYPE=Release
- DOCKER_IMAGE=centos:7
script:
- contrib/travis/centos7.sh
Expand Down
53 changes: 30 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

cmake_minimum_required(VERSION 3.0.0)

# don't allow in-source build
# Don't allow in-source build
get_filename_component(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} REALPATH)
get_filename_component(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR} REALPATH)
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
Expand All @@ -88,10 +88,13 @@ project(GUFI VERSION 0.2.0 LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

# define the DEBUG macro when building in debug mode
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -Wall -D_XOPEN_SRC")
# Need _XOPEN_SRC
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SRC")

# only enable C++ if support is found
# Define the DEBUG macro when building in debug mode
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -Wall")

# Only enable C++ if support is found
include(CheckLanguage)
check_language(CXX)
if (CMAKE_CXX_COMPILER)
Expand All @@ -105,12 +108,15 @@ if (CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER false)
message(STATUS "Require Clang version 3.9 or greater: not compiling C++ sources")
else()
# enable C++11
# Require C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# define the DEBUG macro when building in debug mode
# Need _XOPEN_SRC
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_XOPEN_SRC")

# Define the DEBUG macro when building in debug mode
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -Wall")
endif()
else()
Expand All @@ -122,10 +128,10 @@ endif()
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)

# need the PkgConfig module for pkg_search_module
# Need the PkgConfig module for pkg_search_module
find_package(PkgConfig REQUIRED)

# tell CMake to search the contrib/cmake directory cmake modules
# Tell CMake to search the contrib/cmake directory cmake modules
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/contrib/cmake ${CMAKE_MODULE_PATH})

# Detect and handle xattr.h platform specifics
Expand Down Expand Up @@ -156,20 +162,20 @@ else()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DCONFIG_GNU_XATTRS")
endif()

# need pthread
# Need pthread
find_package(Threads REQUIRED)

# load the ExternalProject module
# Load the ExternalProject module
include(ExternalProject)

# need PCRE for linking only
# Need PCRE for linking only
pkg_search_module(PCRE REQUIRED libpcre)
# if (NOT EXISTS PCRE_STATIC_LIBS)
# message(FATAL_ERROR "Could not find static library files for libpcre.")
# endif()
set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}")

# download and build all non-system dependencies
# Download and build all non-system dependencies
set(DEP_DOWNLOAD_PREFIX "${CMAKE_SOURCE_DIR}/contrib/deps" CACHE PATH "Location of dependency sources")
set(DEP_BUILD_PREFIX "${CMAKE_BINARY_DIR}/builds" CACHE PATH "Location of dependency builds")
set(DEP_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/deps" CACHE PATH "Location of dependency binaries")
Expand Down Expand Up @@ -280,7 +286,7 @@ add_subdirectory(test)
# build tarball out of ${CMAKE_SOURCE_DIR}
#

# collect all files into variables
# Collect all files into variables
set(OTHER_FILES
CMakeLists.txt
INSTALL
Expand All @@ -296,7 +302,7 @@ set(PATHS
src
test)

# set the output nemae
# Set the output nemae
set(TARBALL_NAME "${CMAKE_BINARY_DIR}/gufi.tar.gz")

add_custom_target(cp_files COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/contrib/make/root ${CMAKE_SOURCE_DIR}/Makefile
Expand All @@ -306,19 +312,19 @@ add_custom_target(cp_files COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/contrib/make/googletest ${CMAKE_SOURCE_DIR}/test/googletest/Makefile
DEPENDS test/googletest)

# generate the tarball
# Generate the tarball
add_custom_target(create_tarball COMMAND ${CMAKE_COMMAND} -E tar "czf" ${TARBALL_NAME} ${PATHS} ${TOOLS} ${OTHER_FILES} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS cp_files)

# the actual target
# The actual target
add_custom_target(gary COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_SOURCE_DIR}/Makefile
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_SOURCE_DIR}/src/Makefile
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_SOURCE_DIR}/scripts/Makefile
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_SOURCE_DIR}/test/Makefile
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_SOURCE_DIR}/test/googletest/Makefile
DEPENDS create_tarball)

# test the tarball
# Test the tarball
set(TARBALL_TEST_DIR "${CMAKE_BINARY_DIR}/tarball")

add_custom_target(make_tarball_dir COMMAND ${CMAKE_COMMAND} -E remove_directory ${TARBALL_TEST_DIR}
Expand All @@ -334,16 +340,17 @@ add_custom_target(test_gary COMMAND ${CMAKE_COMMAND} -E remove_directory ${TARBA
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS build_gary)

# these variables have to be set before include(CPack)
#
# Generate Packages
#

# These variables have to be set before include(CPack)
set(CPACK_PACKAGE_VERSION_MAJOR ${GUFI_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${GUFI_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${GUFI_VERSION_PATCH})

# generate RPMs
# Generate RPMs
find_program(RPMBUILD REQUIRED rpmbuild)
execute_process(COMMAND ${RPMBUILD} --version
OUTPUT_VARIABLE RPMBUILD_VERSION)

set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_COMPONENT_INSTALL On)
set(CPACK_RPM_PACKAGE_SUMMARY "Grand Unified File Index")
Expand All @@ -365,7 +372,7 @@ if (PARAMIKO)
set(CPACK_RPM_Client_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/contrib/rpm/client_post_install.sh")
endif()

# generate source RPM
# Generate source RPM
set(CPACK_SOURCE_GENERATOR "RPM")
set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/.git/" "${CMAKE_SOURCE_DIR}/.gitignore")

Expand Down
4 changes: 2 additions & 2 deletions contrib/travis/build_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export PATH="${DEP_PATH}/sqlite3/bin:${PATH}"

mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DDEP_INSTALL_PREFIX="${DEP_PATH}" -DPARAMIKO=On ..
cmake ${CMAKE_FLAGS} -DDEP_INSTALL_PREFIX="${DEP_PATH}" -DPARAMIKO=On ..

# use files from the generated tar
if [[ "${BUILD}" = "make" ]]; then
Expand All @@ -20,7 +20,7 @@ if [[ "${BUILD}" = "make" ]]; then
cd tarball
fi

make DEBUG=1
make

if [[ "${BUILD}" = "cmake" ]]; then
ctest --verbose
Expand Down
2 changes: 1 addition & 1 deletion contrib/travis/centos7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ de useradd travis -m -s /sbin/nologin || true
de chown -R travis /GUFI

# build and test GUFI
docker exec --env C_COMPILER="${CENTOS_C_COMPILER}" --env CXX_COMPILER="${CENTOS_CXX_COMPILER}" --env BUILD="${BUILD}" --user travis "${TRAVIS_JOB_NUMBER}" bash -c "cd /GUFI && LD_LIBRARY_PATH=\"/opt/rh/httpd24/root/usr/lib64/:\$(printenv LD_LIBRARY_PATH)\" PKG_CONFIG_PATH=\"/tmp/sqlite3/lib/pkgconfig:\$(printenv PKG_CONFIG_PATH)\" ${SCRIPT_PATH}/build_and_test.sh"
docker exec --env C_COMPILER="${CENTOS_C_COMPILER}" --env CXX_COMPILER="${CENTOS_CXX_COMPILER}" --env BUILD="${BUILD}" --env CMAKE_FLAGS="${CMAKE_FLAGS}" --user travis "${TRAVIS_JOB_NUMBER}" bash -c "cd /GUFI && LD_LIBRARY_PATH=\"/opt/rh/httpd24/root/usr/lib64/:\$(printenv LD_LIBRARY_PATH)\" PKG_CONFIG_PATH=\"/tmp/sqlite3/lib/pkgconfig:\$(printenv PKG_CONFIG_PATH)\" ${SCRIPT_PATH}/build_and_test.sh"
2 changes: 1 addition & 1 deletion contrib/travis/suse12.3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ de useradd travis -m -s /sbin/nologin || true
de chown -R travis /GUFI

# build and test GUFI
docker exec --env C_COMPILER="${SUSE_C_COMPILER}" --env CXX_COMPILER="${SUSE_CXX_COMPILER}" --env BUILD="${BUILD}" --user travis "${TRAVIS_JOB_NUMBER}" bash -c "cd /GUFI && ${SCRIPT_PATH}/build_and_test.sh"
docker exec --env C_COMPILER="${SUSE_C_COMPILER}" --env CXX_COMPILER="${SUSE_CXX_COMPILER}" --env BUILD="${BUILD}" --env CMAKE_FLAGS="${CMAKE_FLAGS}" --user travis "${TRAVIS_JOB_NUMBER}" bash -c "cd /GUFI && ${SCRIPT_PATH}/build_and_test.sh"
9 changes: 7 additions & 2 deletions src/bfwi_ingest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,17 @@ bool processdir(Row & w, std::ifstream & trace) {
incr(duping);
char topath[MAXPATH];
SNPRINTF(topath,MAXPATH,"%s/%s",in.nameto,dir.name);
dupdir(topath, &dir.statuso);
if (dupdir(topath, &dir.statuso)) {
const int err = errno;
fprintf(stderr, "Dupdir failure: %d %s\n", err, strerror(err));
delete_row(w);
return false;
}
decr(duping);

// create the database name
char dbname[MAXPATH];
SNPRINTF(dbname, MAXPATH, "%s/%s/" DBNAME, in.nameto, dir.name);
SNPRINTF(dbname, MAXPATH, "%s/" DBNAME, topath);

// don't bother doing anything if there is nothing to insert
// (the database file will not exist for empty directories)
Expand Down

0 comments on commit 97c13bb

Please sign in to comment.