Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPM packaging via CPack #310

Merged
merged 4 commits into from
Aug 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 40 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ set (CMAKE_MODULE_PATH_orig ${CMAKE_MODULE_PATH})
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
include (cmake/prevent_in_source_builds.cmake)

project (clickhouse-odbc VERSION 1.1.8.20200710 LANGUAGES C CXX)
project (
clickhouse-odbc
VERSION 1.1.8.20200710
DESCRIPTION "The official ODBC driver implementation for accessing ClickHouse as a data source."
HOMEPAGE_URL "https://github.com/ClickHouse/clickhouse-odbc"
LANGUAGES C CXX
)

set (CMAKE_C_STANDARD 11)
#set (CMAKE_C_EXTENSIONS 0)
Expand Down Expand Up @@ -226,37 +232,43 @@ if (CH_ODBC_ENABLE_INSTALL)
DESCRIPTION "ClickHouse ODBC Driver (ANSI, ${ARCH_BITS}-bit)"
EXPANDED
)

cpack_add_component (ANSIDriver
DISPLAY_NAME "Driver"
DESCRIPTION "ClickHouse ODBC Driver (ANSI, ${ARCH_BITS}-bit)"
REQUIRED
GROUP ANSIGroup
)

cpack_add_component (ANSIDriverDebugSymbols
DISPLAY_NAME "Debug symbols"
DESCRIPTION "Debug symbols (PDB) for the Driver (ANSI, ${ARCH_BITS}-bit)"
DISABLED
DEPENDS ANSIDriver
GROUP ANSIGroup
)

cpack_add_component_group (UnicodeGroup
DISPLAY_NAME "Unicode ${ARCH_BITS}-bit Driver"
DESCRIPTION "ClickHouse ODBC Driver (Unicode, ${ARCH_BITS}-bit)"
EXPANDED
)

cpack_add_component (UnicodeDriver
DISPLAY_NAME "Driver"
DESCRIPTION "ClickHouse ODBC Driver (Unicode, ${ARCH_BITS}-bit)"
DEPENDS ANSIDriver
GROUP UnicodeGroup
)

cpack_add_component (UnicodeDriverDebugSymbols
DISPLAY_NAME "Debug symbols"
DESCRIPTION "Debug symbols (PDB) for Driver (Unicode, ${ARCH_BITS}-bit)"
DISABLED
DEPENDS UnicodeDriver
GROUP UnicodeGroup
)

cpack_add_component (RuntimeLibraries
DISPLAY_NAME "Runtime Libraries"
DESCRIPTION "System/language redistributable runtime libraries"
Expand All @@ -267,10 +279,10 @@ if (CH_ODBC_ENABLE_INSTALL)
set (CPACK_GENERATOR "ZIP;WIX")
elseif (APPLE)
set (CPACK_GENERATOR "TXZ")
elseif (UNIX_RHEL OR UNIX_FEDORA)
set (CPACK_GENERATOR "TXZ;RPM")
elseif (UNIX_RHEL OR UNIX_FEDORA OR UNIX_CENTOS)
set (CPACK_GENERATOR "TGZ;TXZ;RPM")
elseif (UNIX_DEBIAN OR UNIX_UBUNTU)
set (CPACK_GENERATOR "TXZ;DEB")
set (CPACK_GENERATOR "TGZ;TXZ") # TODO: add DEB
else ()
set (CPACK_GENERATOR "TGZ")
endif ()
Expand All @@ -281,15 +293,36 @@ if (CH_ODBC_ENABLE_INSTALL)
set (CPACK_PACKAGE_INSTALL_DIRECTORY "/usr/local")
endif ()

set (CPACK_PROJECT_CONFIG_FILE "${PROJECT_SOURCE_DIR}/CPackLists.txt")

set (CPACK_PACKAGE_VENDOR "Yandex LLC")
set (CPACK_PACKAGE_DESCRIPTION "ClickHouse ODBC Driver (${ARCH_BITS}-bit)")
set (CPACK_PACKAGE_DESCRIPTION "The official ODBC driver implementation for accessing ClickHouse as a data source.")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "ClickHouse ODBC Driver (${ARCH_BITS}-bit)")
set (CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/packaging/Readme.rtf")
set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/packaging/License.rtf")
set (CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/ClickHouse/clickhouse-odbc")
set (CPACK_PACKAGE_CHECKSUM "SHA256")
set (CPACK_PACKAGE_RELOCATABLE ON)

set (CPACK_RPM_COMPONENT_INSTALL OFF)
set (CPACK_RPM_FILE_NAME RPM-DEFAULT)
set (CPACK_RPM_PACKAGE_RELEASE_DIST ON)
set (CPACK_RPM_PACKAGE_LICENSE "ASL 2.0")
set (CPACK_RPM_PACKAGE_GROUP "Applications/Databases")
set (CPACK_RPM_COMPRESSION_TYPE "gzip")
set (CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}")
set (CPACK_RPM_CHANGELOG_FILE "${PROJECT_SOURCE_DIR}/packaging/Changelog.txt")

if ("${ODBC_PROVIDER}" STREQUAL "UnixODBC")
set (CPACK_RPM_PACKAGE_REQUIRES "unixODBC")
elseif ("${ODBC_PROVIDER}" STREQUAL "iODBC")
set (CPACK_RPM_PACKAGE_REQUIRES "libiodbc")
endif ()

set (CPACK_RPM_DEBUGINFO_PACKAGE OFF)
set (CPACK_RPM_PACKAGE_SOURCES OFF)

set (CPACK_WIX_ROOT_FEATURE_TITLE "ClickHouse ODBC Driver")
set (CPACK_WIX_ROOT_FEATURE_DESCRIPTION "ClickHouse ODBC Driver (${ARCH_BITS}-bit)")
set (CPACK_WIX_ROOT_FEATURE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
set (CPACK_WIX_PATCH_FILE "${PROJECT_SOURCE_DIR}/packaging/RegConfig.patch.wxs")
if ("${ARCH_BITS}" STREQUAL "32")
set (CPACK_WIX_PRODUCT_GUID "9FCA44DB-6963-4EBF-87A6-279331C139EB")
Expand Down
9 changes: 9 additions & 0 deletions CPackLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

# This file will be included at CPack-time, once per generator after CPack has set CPACK_GENERATOR to the actual generator being used.

if (
CPACK_GENERATOR MATCHES "RPM" OR
CPACK_GENERATOR MATCHES "DEB"
)
set (CPACK_PACKAGING_INSTALL_PREFIX "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
endif ()
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ You can find sample configuration for this driver here:
- [odbcinst.ini.sample](packaging/odbcinst.ini.sample)
- [odbc.ini.sample](packaging/odbc.ini.sample)

These samples can be added to the corresponding configuration files using the `odbcinst` tool (assuming the package is installed under `/usr/local`):

```sh
odbcinst -i -d -f /usr/local/share/doc/clickhouse-odbc/config/odbcinst.ini.sample
odbcinst -i -s -l -f /usr/local/share/doc/clickhouse-odbc/config/odbc.ini.sample
```

### Configuration: iODBC

In short, usually you will end up editing `/etc/odbcinst.ini` and `/etc/odbc.ini` for system-wide driver and DSN entries, and `~/.odbcinst.ini` and `~/.odbc.ini` for user-wide driver and DSN entries.
Expand Down Expand Up @@ -432,7 +439,7 @@ sudo yum install epel-release
sudo yum groupinstall "Development Tools"
sudo yum install centos-release-scl
sudo yum install devtoolset-8
sudo yum install git cmake3 openssl-devel libicu-devel unixODBC-devel
sudo yum install git cmake3 rpm-build openssl-devel libicu-devel unixODBC-devel
```

#### Build-time dependencies: iODBC <!-- omit in toc -->
Expand All @@ -444,7 +451,7 @@ sudo yum install epel-release
sudo yum groupinstall "Development Tools"
sudo yum install centos-release-scl
sudo yum install devtoolset-8
sudo yum install git cmake3 openssl-devel libicu-devel libiodbc-devel
sudo yum install git cmake3 rpm-build openssl-devel libicu-devel libiodbc-devel
```

#### Build steps <!-- omit in toc -->
Expand Down
5 changes: 4 additions & 1 deletion cmake/Modules/FindMDAC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# ODBC_MDAC_DIR
#
# Defines (some of) the following vars:
# MDAC_FOUND
# ODBC_MDAC_FOUND
#
# ODBC_MDAC_APP_DEFINES
Expand Down Expand Up @@ -130,4 +131,6 @@ unset (_role_lc)
unset (_role_uc)

include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (ODBC_MDAC REQUIRED_VARS ODBC_MDAC_FOUND)
find_package_handle_standard_args (MDAC REQUIRED_VARS ODBC_MDAC_FOUND)

set (ODBC_MDAC "${MDAC_FOUND}")
5 changes: 4 additions & 1 deletion cmake/Modules/FindUnixODBC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# ODBC_UNIXODBC_SKIP_BREW
#
# Defines (some of) the following vars:
# UnixODBC_FOUND
# ODBC_UNIXODBC_FOUND
#
# ODBC_UNIXODBC_DIR
Expand Down Expand Up @@ -407,4 +408,6 @@ unset (_role_lc)
unset (_role_uc)

include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (ODBC_UNIXODBC REQUIRED_VARS ODBC_UNIXODBC_FOUND)
find_package_handle_standard_args (UnixODBC REQUIRED_VARS ODBC_UNIXODBC_FOUND)

set (ODBC_UNIXODBC_FOUND "${UnixODBC_FOUND}")
5 changes: 4 additions & 1 deletion cmake/Modules/FindiODBC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# ODBC_IODBC_SKIP_BREW
#
# Defines (some of) the following vars:
# iODBC_FOUND
# ODBC_IODBC_FOUND
#
# ODBC_IODBC_DIR
Expand Down Expand Up @@ -353,4 +354,6 @@ unset (_role_lc)
unset (_role_uc)

include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (ODBC_IODBC REQUIRED_VARS ODBC_IODBC_FOUND)
find_package_handle_standard_args (iODBC REQUIRED_VARS ODBC_IODBC_FOUND)

set (ODBC_IODBC_FOUND "${iODBC_FOUND}")
31 changes: 31 additions & 0 deletions cmake/arch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ endif ()
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
set (ARCH_AARCH64 1)
endif ()

if (ARCH_AARCH64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
set (ARCH_ARM 1)
endif ()

if (CMAKE_LIBRARY_ARCHITECTURE MATCHES "i386")
set (ARCH_I386 1)
endif ()

if ( ( ARCH_ARM AND NOT ARCH_AARCH64 ) OR ARCH_I386)
set (ARCH_32 1)
message (WARNING "Support for 32bit platforms is highly experimental")
endif ()

if (CMAKE_SYSTEM MATCHES "Linux")
set (ARCH_LINUX 1)
endif ()

if (CMAKE_SYSTEM MATCHES "FreeBSD")
set (ARCH_FREEBSD 1)
endif ()
Expand All @@ -37,3 +42,29 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (COMPILER_CLANG 1)
endif ()

if (ARCH_LINUX)
if (EXISTS "/etc/os-release")
find_program (AWK awk)

if (AWK)
execute_process (
COMMAND ${AWK} "-F=" "$1==\"ID\" { gsub(/\"/, \"\", $2); print tolower($2) ;}" "/etc/os-release"
OUTPUT_VARIABLE _os_release_id
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if (_os_release_id STREQUAL "rhel")
set (UNIX_RHEL 1)
elseif (_os_release_id STREQUAL "fedora")
set (UNIX_FEDORA 1)
elseif (_os_release_id STREQUAL "centos")
set (UNIX_CENTOS 1)
elseif (_os_release_id STREQUAL "debian")
set (UNIX_DEBIAN 1)
elseif (_os_release_id STREQUAL "ubuntu")
set (UNIX_UBUNTU 1)
endif ()
endif ()
endif ()
endif ()
Empty file added packaging/Changelog.txt
Empty file.
10 changes: 5 additions & 5 deletions packaging/odbcinst.ini.sample
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Insert the content of this file into ~/.odbcinst.ini or /etc/odbcinst.ini files,
# and append absolute paths to libclickhouseodbc.so and libclickhouseodbcw.so files.
# and fix the absolute paths to libclickhouseodbc.so and libclickhouseodbcw.so files.

[ODBC Drivers]
ClickHouse ODBC Driver (ANSI) = Installed
ClickHouse ODBC Driver (Unicode) = Installed

[ClickHouse ODBC Driver (ANSI)]
Description = ODBC Driver (ANSI) for ClickHouse
Driver = libclickhouseodbc.so
Setup = libclickhouseodbc.so
Driver = /usr/local/lib64/libclickhouseodbc.so
Setup = /usr/local/lib64/libclickhouseodbc.so
UsageCount = 1

[ClickHouse ODBC Driver (Unicode)]
Description = ODBC Driver (Unicode) for ClickHouse
Driver = libclickhouseodbcw.so
Setup = libclickhouseodbcw.so
Driver = /usr/local/lib64/libclickhouseodbcw.so
Setup = /usr/local/lib64/libclickhouseodbcw.so
UsageCount = 1
4 changes: 2 additions & 2 deletions test/deploy_and_run_clickhouse_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ mkdir -p usr/bin etc/clickhouse-server var/lib/clickhouse

echo 2. Download binaries
# TODO: switch to actual 20.3 binaries once available. Currently, this is master branch.
curl https://clickhouse-builds.s3.yandex.net/0/d147cd646a1e6cc41d42f92d57f016a5c49d04de/clang-10-darwin_relwithdebuginfo_none_bundled_unsplitted_disable_False_binary/clickhouse -o usr/bin/clickhouse
curl https://clickhouse-builds.s3.yandex.net/0/d147cd646a1e6cc41d42f92d57f016a5c49d04de/clang-10-darwin_relwithdebuginfo_none_bundled_unsplitted_disable_False_binary/clickhouse-odbc-bridge -o usr/bin/clickhouse-odbc-bridge
curl https://clickhouse-builds.s3.yandex.net/11870/009ddd5c8d46d1427c2775b67918e0165e50844f/clickhouse_build_check/clang-10-darwin_relwithdebuginfo_none_bundled_unsplitted_disable_False_binary/clickhouse -o usr/bin/clickhouse
curl https://clickhouse-builds.s3.yandex.net/11870/009ddd5c8d46d1427c2775b67918e0165e50844f/clickhouse_build_check/clang-10-darwin_relwithdebuginfo_none_bundled_unsplitted_disable_False_binary/clickhouse-odbc-bridge -o usr/bin/clickhouse-odbc-bridge

echo 3. Download configs
curl https://raw.githubusercontent.com/ClickHouse/ClickHouse/20.5/programs/server/config.xml -o etc/clickhouse-server/config.xml
Expand Down