Support for RHEL building

This commit is contained in:
Javier Marcos 2015-04-03 16:53:02 -07:00
parent 0e2c4a8a89
commit b0e69b7074
6 changed files with 141 additions and 14 deletions

View File

@ -56,6 +56,31 @@ elseif(LINUX)
"epel-release"
)
endif()
elseif(RHEL)
set(PACKAGE_TYPE "rpm")
set(PACKAGE_ITERATION "1.el")
set(PACKAGE_DEPENDENCIES
"glibc >= 2.12"
"openssl >= 1.0"
"bzip2-libs"
"readline"
"zlib"
"rpm-libs"
)
if(OSQUERY_BUILD_DISTRO STREQUAL "RHEL6")
set(PACKAGE_ITERATION "1.el6_6.5")
set(PACKAGE_DEPENDENCIES
"${PACKAGE_DEPENDENCIES}"
"libudev"
)
elseif(OSQUERY_BUILD_DISTRO STREQUAL "RHEL7")
set(PACKAGE_ITERATION "1.el7_7.0")
set(PACKAGE_DEPENDENCIES
"${PACKAGE_DEPENDENCIES}"
"systemd-devel"
"epel-release"
)
endif()
endif()
JOIN("${PACKAGE_DEPENDENCIES}" ", " PACKAGE_DEPENDENCIES)

View File

@ -132,6 +132,9 @@ elseif(OSQUERY_BUILD_OS STREQUAL "UBUNTU")
elseif(OSQUERY_BUILD_OS STREQUAL "CENTOS")
set(CENTOS TRUE)
message("-- Building for CentOS")
elseif(OSQUERY_BUILD_OS STREQUAL "RHEL")
set(CENTOS TRUE)
message("-- Building for RHEL")
elseif(FREEBSD)
message("-- Building for FreeBSD")
endif()

View File

@ -7,13 +7,18 @@ else ifeq ($(PLATFORM),FreeBSD)
BUILD_DIR=freebsd
MAKE=gmake
else
DISTRO := $(shell if [ -f "/etc/redhat-release" ]; then echo "Centos"; fi)
ifeq ($(DISTRO),Centos)
BUILD_DIR := $(shell cat /etc/redhat-release | grep -o "release [6-7]" | sed 's/release /centos/g')
else
DISTRO := $(shell if [ -f "/etc/lsb-release" ]; then echo "Ubuntu"; fi)
DISTRO := $(shell if [[ -f "/etc/lsb-release" ]]; then echo "Ubuntu"; fi)
DISTRO := $(shell if [[ -n `cat /etc/redhat-release | grep -o "CentOS"` ]]; then echo "Centos"; fi)
DISTRO := $(shell if [[ -n `cat /etc/redhat-release | grep -o "Red Hat Enterprise"` ]]; then echo "RHEL"; fi)
ifeq ($(DISTRO),Centos)
BUILD_DIR := $(shell cat /etc/redhat-release | grep -o "release [6-7]" | sed 's/release /centos/g')
endif
ifeq ($(DISTRO),RHEL)
BUILD_DIR := $(shell cat /etc/redhat-release | grep -o "release [6-7]" | sed 's/release /rhel/g')
endif
ifeq ($(DISTRO),Ubuntu)
BUILD_DIR := $(shell lsb_release -sc)
endif
endif
endif
DEFINES := CTEST_OUTPUT_ON_FAILURE=1

View File

@ -9,8 +9,10 @@
function platform() {
local __resultvar=$1
if [[ -f "/etc/redhat-release" ]]; then
if [[ -n `cat /etc/redhat-release | grep -o "CentOS"` ]]; then
eval $__resultvar="centos"
elif [[ -n `cat /etc/redhat-release | grep -o "Red Hat Enterprise"` ]]; then
eval $__resultvar="rhel"
elif [[ -f "/etc/lsb-release" ]]; then
eval $__resultvar="ubuntu"
else
@ -22,6 +24,8 @@ function distro() {
local __resultvar=$2
if [[ $1 = "centos" ]]; then
eval $__resultvar=`cat /etc/redhat-release | grep -o "release [6-7]" | sed 's/release /centos/g'`
elif [[ $1 = "rhel" ]]; then
eval $__resultvar=`cat /etc/redhat-release | grep -o "release [6-7]" | sed 's/release /rhel/g'`
elif [[ $1 = "ubuntu" ]]; then
eval $__resultvar=`cat /etc/*-release | grep DISTRIB_CODENAME | awk -F '=' '{print $2}'`
elif [[ $1 = "darwin" ]]; then
@ -36,7 +40,7 @@ function distro() {
function threads() {
local __resultvar=$1
platform OS
if [ $OS = "centos" ] || [ $OS = "ubuntu" ]; then
if [ $OS = "centos" ] || [ $OS = "rhel" ] || [ $OS = "ubuntu" ]; then
eval $__resultvar=`cat /proc/cpuinfo | grep processor | wc -l`
elif [[ $OS = "darwin" ]]; then
eval $__resultvar=`sysctl hw.ncpu | awk '{print $2}'`

View File

@ -8,7 +8,7 @@
# of patent rights can be found in the PATENTS file in the same directory.
function install_cmake() {
if [ "$OS" = "centos" ] || [ "$OS" = "ubuntu" ] || [ "$OS" = "darwin" ]; then
if [ "$OS" = "centos" ] || [ "$OS" = "rhel" ] || [ "$OS" = "ubuntu" ] || [ "$OS" = "darwin" ]; then
if [[ -f /usr/local/bin/cmake ]]; then
log "cmake is already installed. skipping."
else
@ -61,11 +61,11 @@ function install_rocksdb() {
if [[ ! -d rocksdb-rocksdb-3.5 ]]; then
tar -xf rocksdb-3.5.tar.gz
fi
if [ "$OS" = "ubuntu" ] || [ "$OS" = "centos" ]; then
if [ "$OS" = "ubuntu" ] || [ "$OS" = "centos" ] || [ $OS = "rhel" ]; then
if [[ ! -f rocksdb-rocksdb-3.5/librocksdb.a ]]; then
if [[ $OS = "ubuntu" ]]; then
CLANG_INCLUDE="-I/usr/include/clang/3.4/include"
elif [[ $OS = "centos" ]]; then
elif [ $OS = "centos" ] || [ $OS = "rhel" ]; then
CLANG_VERSION=`clang --version | grep version | cut -d" " -f3`
CLANG_INCLUDE="-I/usr/lib/clang/$CLANG_VERSION/include"
fi
@ -244,7 +244,7 @@ function package() {
log "installing $1"
sudo apt-get install $1 -y
fi
elif [[ $OS = "centos" ]]; then
elif [ $OS = "centos" ] || [ $OS = "rhel" ]; then
if [[ -n "$(rpm -qa | grep $1)" ]]; then
log "$1 is already installed. skipping."
else
@ -276,7 +276,7 @@ function remove_package() {
else
log "Removing: $1 is not installed. skipping."
fi
elif [[ $OS = "centos" ]]; then
elif [ $OS = "centos" ] || [ $OS = "rhel" ]; then
if [[ -n "$(rpm -qa | grep $1)" ]]; then
log "removing $1"
sudo yum remove $1 -y

View File

@ -8,5 +8,95 @@
# of patent rights can be found in the PATENTS file in the same directory.
function main_rhel() {
log "Here there will be magic to compile osquery in RHEL"
sudo yum update -y
package texinfo
package wget
package git
package unzip
package xz
package xz-devel
package subscription-manager
if [[ -z `rpm -qa epel-release` ]]; then
if [[ $DISTRO = "rhel6" ]]; then
sudo rpm -iv https://osquery-packages.s3.amazonaws.com/deps/epel-release-6-8.noarch.rpm
elif [[ $DISTRO = "rhel7" ]]; then
sudo rpm -iv https://osquery-packages.s3.amazonaws.com/deps/epel-release-7-5.noarch.rpm
fi
fi
# This solves a problem with epel and how it retrieves packages
sudo yum clean all
sudo yum --disablerepo="epel" update nss
package python-pip
package python-devel
package rpm-build
package ruby
sudo subscription-manager repos --enable=rhel-7-server-optional-rpms
package ruby-devel
package rubygems
if [[ $DISTRO = "rhel6" ]]; then
package scl-utils
package policycoreutils-python
package
package rhscl-devtoolset-3
package devtoolset-3
sudo scl enable devtoolset-3 bash
elif [[ $DISTRO = "rhel7" ]]; then
package gcc
package binutils
package gcc-c++
fi
package clang
package clang-devel
set_cc clang
set_cxx clang++
package bzip2
package bzip2-devel
package openssl-devel
package readline-devel
package rpm-devel
package rpm-build
package libblkid-devel
install_cmake
install_boost
if [[ $DISTRO = "rhel6" ]]; then
package libudev-devel
elif [[ $DISTRO = "rhel7" ]]; then
package systemd-devel
fi
install_gflags
package doxygen
package byacc
package flex
package bison
remove_package libunwind-devel
if [[ $DISTRO = "rhel6" ]]; then
install_autoconf
install_automake
install_libtool
install_thrift
elif [[ $DISTRO = "rhel7" ]]; then
package autoconf
package automake
package libtool
install_thrift
fi
install_snappy
install_rocksdb
gem_install fpm
}