Repository: madlib Updated Branches: refs/heads/master 24a11c1e5 -> 441f16bd5
Ubuntu support for MADlib JIRA: MADLIB-1256 Adds support for compiling on Ubuntu as well as creating a deb package. Closes #306 Co-authored-by: Domino Valdano <[email protected]> Co-authored-by: Jingyi Mei<[email protected]> Co-authored-by: Nandish Jayaram <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/madlib/repo Commit: http://git-wip-us.apache.org/repos/asf/madlib/commit/441f16bd Tree: http://git-wip-us.apache.org/repos/asf/madlib/tree/441f16bd Diff: http://git-wip-us.apache.org/repos/asf/madlib/diff/441f16bd Branch: refs/heads/master Commit: 441f16bd55d2a26e4dd59df6129c6092f099cbca Parents: 24a11c1 Author: Orhan Kislal <[email protected]> Authored: Thu Aug 16 16:26:25 2018 -0700 Committer: Orhan Kislal <[email protected]> Committed: Thu Aug 16 16:27:11 2018 -0700 ---------------------------------------------------------------------- CMakeLists.txt | 27 ++++++++++++++----------- cmake/LinuxUtils.cmake | 16 +++++++++++++++ deploy/CMakeLists.txt | 43 ++++++++++++++++++++++++++++++--------- deploy/DEB/CMakeLists.txt | 39 +++++++++++++++++++++++++++++++++++ deploy/DEB/config | 32 +++++++++++++++++++++++++++++ deploy/DEB/postinst | 46 ++++++++++++++++++++++++++++++++++++++++++ deploy/DEB/postrm | 37 +++++++++++++++++++++++++++++++++ deploy/DEB/preinst | 34 +++++++++++++++++++++++++++++++ deploy/DEB/templates | 4 ++++ deploy/postflight.sh | 12 +++++------ deploy/rpm_post.sh | 9 ++++----- pom.xml | 1 + 12 files changed, 268 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 9193ac7..8670600 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,10 +124,25 @@ else() set(M4_ARGUMENTS "--prefix-builtins") endif() +# -- Local includes ------------------------------------------------------------ + +list(APPEND CMAKE_MODULE_PATH + "${MAD_BUILD_TOOLS}") + +# -- Include all parts --------------------------------------------------------- + +include(Utils) +include(LinuxUtils) +include(OSXUtils) +include(Options) + +# -- Get madlib version info ---------------------------------------------------- # Read and parse Version.yml file file(READ "${MADLIB_VERSION_YML}" _MADLIB_VERSION_CONTENTS) string(REGEX REPLACE "^.*version:[ \t]*([^\n]*)\n.*" "\\1" MADLIB_VERSION_STRING "${_MADLIB_VERSION_CONTENTS}") + string(REPLACE "-" "_" MADLIB_VERSION_STRING_NO_HYPHEN "${MADLIB_VERSION_STRING}") + string(REGEX REPLACE "([0-9]+).*" "\\1" MADLIB_VERSION_MAJOR "${MADLIB_VERSION_STRING}") string(REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" MADLIB_VERSION_MINOR "${MADLIB_VERSION_STRING}") if("${MADLIB_VERSION_STRING}" MATCHES "[0-9]+\\.[0-9]+\\.([0-9]+).*") @@ -205,18 +220,6 @@ install( COMPONENT core ) -# -- Local includes ------------------------------------------------------------ - -list(APPEND CMAKE_MODULE_PATH - "${MAD_BUILD_TOOLS}") - -include(Utils) -include(LinuxUtils) -include(OSXUtils) -include(Options) - - -# -- Include all parts --------------------------------------------------------- # -- Add subdirectories -------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/cmake/LinuxUtils.cmake ---------------------------------------------------------------------- diff --git a/cmake/LinuxUtils.cmake b/cmake/LinuxUtils.cmake index f30b908..0547ef4 100644 --- a/cmake/LinuxUtils.cmake +++ b/cmake/LinuxUtils.cmake @@ -10,3 +10,19 @@ macro(rh_version OUT_VERSION) endif(EXISTS "/etc/redhat-release") endmacro(rh_version) +# Get the Debian version +# DEB_OUT_VERSION will have a number if /etc/issue exists, with an entry for Debian. +# DEB_OUT_VERSION will have 'DEB_OUT_VERSION-NOTFOUND' if /etc/issue does not exist. +# DEB_OUT_VERSION will be empty if some distribution which has /etc/issue, but not Debian in it. +macro(debian_version DEB_OUT_VERSION) + if(EXISTS "/etc/issue") + file(READ "/etc/issue" _DEB_RELEASE_CONTENT) + string(REGEX REPLACE "Debian[^0-9.]*([0-9.]+)[^0-9.]*\$" "\\1" + ${DEB_OUT_VERSION} + "${_DEB_RELEASE_CONTENT}" + ) + else(EXISTS "/etc/issue") + set(${DEB_OUT_VERSION} "${DEB_OUT_VERSION}-NOTFOUND") + endif(EXISTS "/etc/issue") +endmacro(debian_version) + http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/deploy/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/deploy/CMakeLists.txt b/deploy/CMakeLists.txt index f8000df..8c8dd95 100644 --- a/deploy/CMakeLists.txt +++ b/deploy/CMakeLists.txt @@ -10,9 +10,27 @@ if(APPLE) PackageMaker ) elseif(UNIX) - list(APPEND CPACK_GENERATOR - RPM - ) + + debian_version(DEB_VERSION) + if(DEB_VERSION AND NOT (DEB_VERSION STREQUAL "DEB_VERSION-NOTFOUND")) + set(IS_DEBIAN "True") + endif() + rh_version(IS_REDHAT) + if(RH_VERSION AND NOT (RH_VERSION STREQUAL "RH_VERSION-NOTFOUND")) + set(IS_REDHAT "True") + endif() + + if(IS_REDHAT) + message(STATUS "Detected RH version ${RH_VERSION}") + list(APPEND CPACK_GENERATOR + RPM + ) + elseif(IS_DEBIAN) + message(STATUS "Detected Debian version ${DEB_VERSION}") + list(APPEND CPACK_GENERATOR + DEB + ) + endif() endif() @@ -47,17 +65,24 @@ set(CPACK_RPM_USER_BINARY_SPECFILE ${CMAKE_CURRENT_SOURCE_DIR}/madlib.spec.in) add_subdirectory(PackageMaker) add_subdirectory(PGXN) add_subdirectory(RPM) +add_subdirectory(DEB) # gppkg depends on macros from RPM! add_subdirectory(gppkg) # -- Finally do the packaging! ------------------------------------------------- - -set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/rpm_post.sh") -set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/rpm_post_uninstall.sh") -set(CPACK_PREFLIGHT_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/preflight.sh) -set(CPACK_POSTFLIGHT_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/postflight.sh) -set(CPACK_MONOLITHIC_INSTALL 1) +if(IS_REDHAT) + set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/rpm_post.sh") + set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/rpm_post_uninstall.sh") + set(CPACK_PREFLIGHT_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/preflight.sh) + set(CPACK_POSTFLIGHT_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/postflight.sh) + set(CPACK_MONOLITHIC_INSTALL 1) +elseif(IS_DEBIAN) + set(CPACK_PACKAGE_FILE_NAME + "madlib${_PACKAGE_SUFFIX}-${MADLIB_VERSION_STRING}-${CMAKE_SYSTEM_NAME}") + set(CPACK_PACKAGE_VERSION ${MADLIB_VERSION_STRING}) + set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEB/config;${CMAKE_CURRENT_SOURCE_DIR}/DEB/templates;${CMAKE_CURRENT_SOURCE_DIR}/DEB/preinst;${CMAKE_CURRENT_SOURCE_DIR}/DEB/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEB/postrm") +endif() include(CPack) http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/deploy/DEB/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/deploy/DEB/CMakeLists.txt b/deploy/DEB/CMakeLists.txt new file mode 100644 index 0000000..b0ca9b3 --- /dev/null +++ b/deploy/DEB/CMakeLists.txt @@ -0,0 +1,39 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# ------------------------------------------------------------------------------ +# Packaging with Debian +# ------------------------------------------------------------------------------ +# +# Important: Set variables using set(... PARENT_SCOPE), so that the scope of the +# definition extends to the parent scope + + +# Get information about the environment + +# -- Set Debian package specific variables --------------------------------------- +# get the architecture of Deb package. The name of the architecture is not +# always the same with ${CMAKE_SYSTEM_PROCESSOR} +if(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) + execute_process(COMMAND dpkg --print-architecture + OUTPUT_VARIABLE arch OUTPUT_STRIP_TRAILING_WHITESPACE) + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${arch}" PARENT_SCOPE) +endif() + +set(CPACK_DEBIAN_PACKAGE_VERSION "${MADLIB_VERSION_STRING}" PARENT_SCOPE) +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]" PARENT_SCOPE) +set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local/madlib/Versions/${MADLIB_VERSION_STRING}" PARENT_SCOPE) http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/deploy/DEB/config ---------------------------------------------------------------------- diff --git a/deploy/DEB/config b/deploy/DEB/config new file mode 100755 index 0000000..ce287d2 --- /dev/null +++ b/deploy/DEB/config @@ -0,0 +1,32 @@ +#!/bin/sh + +# coding=utf-8 +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Exit on error +set -e + +# Source debconf library. +. /usr/share/debconf/confmodule + +# Ask user for custom install path +db_input low madlib/installpath || true + +# Show interface +db_go || true http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/deploy/DEB/postinst ---------------------------------------------------------------------- diff --git a/deploy/DEB/postinst b/deploy/DEB/postinst new file mode 100755 index 0000000..c2b6d2c --- /dev/null +++ b/deploy/DEB/postinst @@ -0,0 +1,46 @@ +#!/bin/sh +# +# coding=utf-8 +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Source debconf library. +. /usr/share/debconf/confmodule + +MADLIB_VERSION="1.15-dev" +MADLIB_INSTALL_PATH="InstallPathNotFound" + +# Fetching configuration from debconf +db_get madlib/installpath +MADLIB_INSTALL_PATH=$RET + +# Remove existing soft links +find $MADLIB_INSTALL_PATH/madlib/bin -depth -type l -exec rm {} \; 2>/dev/null +find $MADLIB_INSTALL_PATH/madlib/doc -depth -type l -exec rm {} \; 2>/dev/null +find $MADLIB_INSTALL_PATH/madlib/Current -depth -type l -exec rm {} \; 2>/dev/null + +# Create new soft links +ln -nsf $MADLIB_INSTALL_PATH/madlib/Versions/$MADLIB_VERSION $MADLIB_INSTALL_PATH/madlib/Current +ln -nsf $MADLIB_INSTALL_PATH/madlib/Current/bin $MADLIB_INSTALL_PATH/madlib/bin +ln -nsf $MADLIB_INSTALL_PATH/madlib/Current/doc $MADLIB_INSTALL_PATH/madlib/doc + +if [ -d "$MADLIB_INSTALL_PATH/madlib/Versions.bak" ]; +then + cp -r $MADLIB_INSTALL_PATH/madlib/Versions.bak/* $MADLIB_INSTALL_PATH/madlib/Versions/ + rm -rf $MADLIB_INSTALL_PATH/madlib/Versions.bak +fi http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/deploy/DEB/postrm ---------------------------------------------------------------------- diff --git a/deploy/DEB/postrm b/deploy/DEB/postrm new file mode 100755 index 0000000..79345fe --- /dev/null +++ b/deploy/DEB/postrm @@ -0,0 +1,37 @@ +#!/bin/sh +# +# coding=utf-8 +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# remove symlinks created during rpm install + +# Source debconf library. +. /usr/share/debconf/confmodule + +# Fetching configuration from debconf +db_get madlib/installpath +MADLIB_INSTALL_PATH=$RET + +find $MADLIB_INSTALL_PATH/madlib/Current -depth -type l -exec rm {} \; 2>/dev/null +find $MADLIB_INSTALL_PATH/madlib/bin -depth -type l -exec rm {} \; 2>/dev/null +find $MADLIB_INSTALL_PATH/madlib/doc -depth -type l -exec rm {} \; 2>/dev/null + +# remove "Versions" directory if it's empty +rmdir $MADLIB_INSTALL_PATH/madlib/Versions 2>/dev/null +exit 0 http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/deploy/DEB/preinst ---------------------------------------------------------------------- diff --git a/deploy/DEB/preinst b/deploy/DEB/preinst new file mode 100644 index 0000000..953d21d --- /dev/null +++ b/deploy/DEB/preinst @@ -0,0 +1,34 @@ +#!/bin/sh +# +# coding=utf-8 +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Source debconf library. +. /usr/share/debconf/confmodule + +MADLIB_INSTALL_PATH="InstallPathNotFound" + +# Fetching configuration from debconf +db_get madlib/installpath +MADLIB_INSTALL_PATH=$RET + +if [ -d "$MADLIB_INSTALL_PATH/madlib/Versions" ]; +then + cp -r $MADLIB_INSTALL_PATH/madlib/Versions/ $MADLIB_INSTALL_PATH/madlib/Versions.bak/ +fi http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/deploy/DEB/templates ---------------------------------------------------------------------- diff --git a/deploy/DEB/templates b/deploy/DEB/templates new file mode 100644 index 0000000..2e814f7 --- /dev/null +++ b/deploy/DEB/templates @@ -0,0 +1,4 @@ +Template: madlib/installpath +Type: string +Default: /usr/local +Description: Specify a custom install path if desired; installs to /usr/local by default. http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/deploy/postflight.sh ---------------------------------------------------------------------- diff --git a/deploy/postflight.sh b/deploy/postflight.sh index 2cb5460..b9cfee5 100755 --- a/deploy/postflight.sh +++ b/deploy/postflight.sh @@ -4,17 +4,17 @@ MADLIB_VERSION=1.15.1-dev -find $2/usr/local/madlib/bin -type d -exec cp -RPf {} $2/usr/local/madlib/old_bin \; 2>/dev/null -find $2/usr/local/madlib/bin -depth -type d -exec rm -r {} \; 2>/dev/null - -find $2/usr/local/madlib/doc -type d -exec cp -RPf {} $2/usr/local/madlib/old_doc \; 2>/dev/null -find $2/usr/local/madlib/doc -depth -type d -exec rm -r {} \; 2>/dev/null +# Remove existing soft links +find $2/usr/local/madlib/bin -depth -type l -exec rm {} \; 2>/dev/null +find $2/usr/local/madlib/doc -depth -type l -exec rm {} \; 2>/dev/null +find $2/usr/local/madlib/Current -depth -type l -exec rm {} \; 2>/dev/null +# Create new soft links ln -nsf $2/usr/local/madlib/Versions/$MADLIB_VERSION $2/usr/local/madlib/Current ln -nsf $2/usr/local/madlib/Current/bin $2/usr/local/madlib/bin ln -nsf $2/usr/local/madlib/Current/doc $2/usr/local/madlib/doc -if [ -d "/usr/local/madlib/Versions.bak" ] +if [ -d "$2/usr/local/madlib/Versions.bak" ]; then mv -f $2/usr/local/madlib/Versions.bak/* $2/usr/local/madlib/Versions/ rm -rf $2/usr/local/madlib/Versions.bak http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/deploy/rpm_post.sh ---------------------------------------------------------------------- diff --git a/deploy/rpm_post.sh b/deploy/rpm_post.sh index 9400be8..376e4e8 100755 --- a/deploy/rpm_post.sh +++ b/deploy/rpm_post.sh @@ -1,8 +1,7 @@ -find $RPM_INSTALL_PREFIX/madlib/bin -type d -exec cp -RPf {} $RPM_INSTALL_PREFIX/madlib/old_bin \; 2>/dev/null -find $RPM_INSTALL_PREFIX/madlib/bin -depth -type d -exec rm -r {} \; 2>/dev/null - -find $RPM_INSTALL_PREFIX/madlib/doc -type d -exec cp -RPf {} $RPM_INSTALL_PREFIX/madlib/old_doc \; 2>/dev/null -find $RPM_INSTALL_PREFIX/madlib/doc -depth -type d -exec rm -r {} \; 2>/dev/null +# Remove existing soft links +find $RPM_INSTALL_PREFIX/madlib/bin -depth -type l -exec rm {} \; 2>/dev/null +find $RPM_INSTALL_PREFIX/madlib/doc -depth -type l -exec rm {} \; 2>/dev/null +find $RPM_INSTALL_PREFIX/madlib/Current -depth -type l -exec rm {} \; 2>/dev/null # RPM version is setup with underscore replaced for hyphen but http://git-wip-us.apache.org/repos/asf/madlib/blob/441f16bd/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index e441dbc..91dd189 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,7 @@ <exclude>CMakeLists.txt</exclude> <exclude>deploy/CMakeLists.txt</exclude> <exclude>deploy/description.txt</exclude> + <exclude>deploy/DEB/templates</exclude> <exclude>deploy/gppkg/CMakeLists.txt</exclude> <exclude>deploy/gppkg/gppkg_spec.yml.in</exclude> <exclude>deploy/gppkg/madlib.spec.in</exclude>
