diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2016-03-04 16:45:54 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2016-03-04 16:45:54 +0100 |
commit | 5460cc187513c48661d8b6b2bc0251c8900d44a0 (patch) | |
tree | 95d74b84fcebb00be0d53a49afb9fbe79120958a | |
parent | c0326277fc2ee0436621904c9f968a3312ae9c10 (diff) | |
download | fastwriter-5460cc187513c48661d8b6b2bc0251c8900d44a0.tar.gz fastwriter-5460cc187513c48661d8b6b2bc0251c8900d44a0.tar.bz2 fastwriter-5460cc187513c48661d8b6b2bc0251c8900d44a0.tar.xz fastwriter-5460cc187513c48661d8b6b2bc0251c8900d44a0.zip |
RPM support
-rw-r--r-- | .bzrignore | 4 | ||||
-rw-r--r-- | CMakeLists.txt | 30 | ||||
-rw-r--r-- | fastwriter.c | 4 | ||||
-rw-r--r-- | fastwriter.spec.in | 75 | ||||
-rw-r--r-- | sysinfo.c | 4 |
5 files changed, 111 insertions, 6 deletions
@@ -7,3 +7,7 @@ Makefile cmake_install.cmake CMakeCache.txt *.so.* +CPackConfig.cmake +CPackSourceConfig.cmake +_CPack_Packages +fastwriter.spec diff --git a/CMakeLists.txt b/CMakeLists.txt index 19fa71c..2adae92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ -project(fastwriter) +project(fastwriter C) +set(RELEASE "0") set(FASTWRITER_VERSION "0.0.2") set(FASTWRITER_ABI_VERSION "0") @@ -60,12 +61,36 @@ set(PACKAGE_TARNAME "${TARNAME}") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "http://ufo.kit.edu/ufo/newticket") + +set(CPACK_SOURCE_GENERATOR "TBZ2") +set(CPACK_PACKAGE_CONTACT "Suren A. Chilingaryan <csa@suren.me>") +if (${RELEASE} GREATER 0) + set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}.${RELEASE}") +else (${RELEASE} GREATER 0) + set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}") +endif (${RELEASE} GREATER 0) +set(CPACK_SOURCE_IGNORE_FILES "/.bzr/;CMakeFiles;_CPack_Packages;cmake_install.cmake;CPack.*.cmake;CMakeCache.txt;install_manifest.txt;config.h$;.pc$;Makefile;.tar.bz2$;~$;${CPACK_SOURCE_IGNORE_FILES}") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}") +include(CPack) + +add_custom_target(dist_clean COMMAND ${CMAKE_MAKE_PROGRAM} clean WORKING_DIRECTORY ${CMAKE_CURRENT_DIR}) +add_custom_target(dist DEPENDS dist_clean COMMAND ${CMAKE_MAKE_PROGRAM} package_source) + + if(NOT DEFINED BIN_INSTALL_DIR) set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin") endif(NOT DEFINED BIN_INSTALL_DIR) +if(NOT DEFINED LIB_SUFFIX) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(LIB_SUFFIX "64") + else (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(LIB_SUFFIX "") + endif (CMAKE_SIZEOF_VOID_P EQUAL 8) +endif(NOT DEFINED LIB_SUFFIX) + if(NOT DEFINED LIB_INSTALL_DIR) - set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib") + set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}") endif(NOT DEFINED LIB_INSTALL_DIR) if(NOT DEFINED INCLUDE_INSTALL_DIR) @@ -77,6 +102,7 @@ if(NOT DEFINED LOCALE_INSTALL_DIR) endif(NOT DEFINED LOCALE_INSTALL_DIR) configure_file(fastwriter.pc.in ${CMAKE_CURRENT_BINARY_DIR}/fastwriter.pc) +configure_file(fastwriter.spec.in ${CMAKE_CURRENT_BINARY_DIR}/fastwriter.spec) configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) install(TARGETS fastwriter diff --git a/fastwriter.c b/fastwriter.c index 08722fa..dd48493 100644 --- a/fastwriter.c +++ b/fastwriter.c @@ -64,8 +64,8 @@ int fastwriter_open(fastwriter_t *ctx, const char *name, fastwriter_flags_t flag break; case FASTWRITER_BUFFER_MAX: ctx->size = fastwriter_get_free_memory(); - - if ((ctx->size - FASTWRITER_RESERVE_MEMORY) < FASTWRITER_DEFAULT_BUFFER_SIZE) + + if ((ctx->size == (size_t)-1)||((ctx->size - FASTWRITER_RESERVE_MEMORY) < FASTWRITER_DEFAULT_BUFFER_SIZE)) ctx->size = FASTWRITER_DEFAULT_BUFFER_SIZE; else ctx->size -= FASTWRITER_RESERVE_MEMORY; diff --git a/fastwriter.spec.in b/fastwriter.spec.in new file mode 100644 index 0000000..489013a --- /dev/null +++ b/fastwriter.spec.in @@ -0,0 +1,75 @@ +Summary: Fast data streaming library +Name: ${PACKAGE_NAME} +Version: ${CPACK_PACKAGE_VERSION} +Release: csa +License: GPL-3.0 +Group: Development/Libraries +Source: ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 +BuildRoot: %{_tmppath}/%{name}-%{version}-root +URL: http://darksoft.org +Prefix: %{_prefix} +Docdir: %{_docdir} +BuildRequires: xfsprogs-devel libuuid-devel +BuildRequires: pkg-config libtool cmake +Vendor: Institute for Data Processing and Electronics, KIT +Packager: Suren A. Chilingaryan <csa@suren.me> + +%description +Fast data streaming library (nothing goes here...) + +%package -n lib${PACKAGE_NAME}${FASTWRITER_ABI_VERSION} +Summary: Fast data streaming library +Group: Development/Libraries +Requires: xfsprogs + +%description -n lib${PACKAGE_NAME}${FASTWRITER_ABI_VERSION} +Standard C storage routines are not efficient if a single, but fast stream of +data have to be written on the disk. The fastwriter is optimized for this use +case. The following methods are used to speed-up writting. + * Linux AIO is used to avoid intermediate file caches + * The large extents are pre-allocated and the file system is hinted that more + data will follow + * For XFS volumes, the real-time mode can be used + + +%package -n lib${PACKAGE_NAME}-devel +Summary: Fast data streaming library +Group: Development/Libraries +Requires: lib${PACKAGE_NAME}${FASTWRITER_ABI_VERSION} = %{version} + +%description -n lib${PACKAGE_NAME}-devel +Development files for fastwriter + + +%prep +%setup -q + +%build +cmake -DCMAKE_INSTALL_PREFIX=/usr -DLIB_INSTALL_DIR=%{_libdir} -DBIN_INSTALL_DIR=%{_bindir} -DDATA_INSTALL_DIR=%{_datadir} -DINCLUDE_INSTALL_DIR=%{_includedir} -DCMAKE_BUILD_TYPE=Release . +make + +%install +rm -rf $RPM_BUILD_ROOT +make install DESTDIR=$RPM_BUILD_ROOT + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -n lib${PACKAGE_NAME}${FASTWRITER_ABI_VERSION} -p /sbin/ldconfig + +%postun -n lib${PACKAGE_NAME}${FASTWRITER_ABI_VERSION} -p /sbin/ldconfig + +%files -n lib${PACKAGE_NAME}${FASTWRITER_ABI_VERSION} +%defattr(-, root, root) +%{_libdir}/lib${PACKAGE_NAME}.so.* + +%files -n lib${PACKAGE_NAME}-devel +%defattr(-, root, root) +%{_includedir}/* +%{_libdir}/lib*.so +%{_libdir}/pkgconfig/*.pc +%exclude %{_libdir}/*.a + +%changelog +* Fri Mar 4 2016 Suren A. Chilingaryan <csa@suren.me> - ${CPACK_PACKAGE_VERSION} +- Added spec file to the sources @@ -26,13 +26,13 @@ if ((fd = open(filename, O_RDONLY)) == -1) { \ fputs(BAD_OPEN_MESSAGE, stderr); \ fflush(NULL); \ - _exit(102); \ + return -102; \ } \ lseek(fd, 0L, SEEK_SET); \ if ((local_n = read(fd, buf, sizeof buf - 1)) < 0) { \ perror(filename); \ fflush(NULL); \ - _exit(103); \ + return -103; \ } \ buf[local_n] = '\0'; \ close(fd); \ |