Skip to content

RPMBuild

Andy Georges edited this page Apr 6, 2017 · 1 revision

Build instructions to create an RPM for this beat

  1. Create a script called docker and put it in the PATH
#!/bin/bash
fn=${BUILD_DIR}/$(basename "${@: -1}")
if [ -f "$fn" ]; then
    if [[ "$fn" == *centos*amd64* ]]; then
    cp -af $fn $fn-fakedocker
    sed -i 's#/build#./build#' $fn-fakedocker
    for i in "$@"; do
        shift
        case $i in
        -e)
            cmd="$cmd $1"
            export $1
            ;;
        *)
            ;;
        esac
    done
    echo "fakedocker $cmd $fn-fakedocker"
    here=$PWD
    cd ${BUILD_DIR}/..
    $fn-fakedocker
    cd $here
    fi
fi
  1. Execute the following (adjust for your own build host if needed)
BEAT_NAME=gpfsbeat                                                                                                                                   
BEAT_PATH=github.com/hpcugent/gpfsbeat
 
sudo yum install python-virtualenv.noarch golang
export GOPATH=$HOME/gopath
export PATH=$GOPATH/bin:$PATH
rm -Rf $GOPATH
mkdir -p $GOPATH
 
# ignore no buildable errors
ES_BEATS=github.com/elastic/beats
go get $ES_BEATS
cd $GOPATH/src/$ES_BEATS
git fetch -a
git checkout remotes/origin/5.x
 
go get $BEAT_PATH
cd $GOPATH/src/$BEAT_PATH
 
make setup TARGETS=linux/amd64
make TARGETS=linux/amd64
 
cp -a  $BEAT_NAME build/$BEAT_NAME-linux-amd64
 
make -C ./vendor/$ES_BEATS/dev-tools/packer deps TARGETS=linux/amd64
 
gem install --no-ri --no-rdoc fpm
sed 's#/build#./build#;s#/go/bin/##' vendor/$ES_BEATS/dev-tools/packer/xgo-scripts/before_build.sh > ./build/before_build.sh
chmod +x ./build/before_build.sh
for x in `grep 'BEAT_\(NAME\|PATH\)' Makefile `;do export $x;done
# ignore version.asciidoc error
./build/before_build.sh
 
sed 's#/build#./build#;s# /go# ./go#' vendor/$ES_BEATS/dev-tools/packer/docker/go-daemon/build_go_daemon.sh > ./build/god.sh
chmod +x ./build/god.sh
# might fail for 32bit
./build/god.sh
cp -a go-daemon/god-linux-amd64 build/
 
# not in 5.x?
#make vendor/github.com/elastic/beats/dev-tools/cmd/import_dashboards/#import_dashboards
#cp -a vendor/github.com/elastic/beats/dev-tools/cmd/import_dashboards/#import_dashboards build/import_dashboards-linux-amd64
 
# in 5.x
make -C vendor/$ES_BEATS/libbeat/dashboards import_dashboards
cp -a vendor/$ES_BEATS/libbeat/dashboards/import_dashboards build/import_dashboards-linux-amd64
 
# fake docker
 
make package SNAPSHOT=no TARGETS=linux/amd64
 
# Fix any naming issues
gittag=`git log --format=%ct.%h -1`
rpmrebuild --release="$gittag" -p ./build/upload/*rpm
Clone this wiki locally