forked from ports/contrib
100 lines
2.8 KiB
Plaintext
100 lines
2.8 KiB
Plaintext
# Description: an open-source systems monitoring and alerting toolkit
|
|
# URL: https://prometheus.io
|
|
# Maintainer: Tim Biermann, tbier at posteo dot de
|
|
# Depends on: go npm
|
|
|
|
name=prometheus
|
|
version=2.33.5
|
|
release=1
|
|
source=(https://github.com/prometheus/prometheus/archive/v$version/$name-$version.tar.gz
|
|
prometheus.conf prometheus.service)
|
|
|
|
build() {
|
|
# setup build env {{{
|
|
export LC_ALL=C
|
|
|
|
## Node Setup
|
|
#export NODE_ENV=production
|
|
#[ ! -d $PKGMK_SOURCE_DIR/npm_cache ] && mkdir $PKGMK_SOURCE_DIR/npm_cache
|
|
#export npm_config_cache=$PKGMK_SOURCE_DIR/npm_cache
|
|
export NPM_CONFIG_PREFIX="$SRC/npm"
|
|
export PATH+=":$NPM_CONFIG_PREFIX/bin"
|
|
|
|
## Go Setup
|
|
export GOPATH="$SRC/gopath"
|
|
export PATH+=":$GOPATH/bin"
|
|
mkdir -p "$GOPATH/src/github.com/grafana/"
|
|
ln -fsrT "$SRC/grafana-$version/" "$GOPATH/src/github.com/grafana/grafana"
|
|
export CGO_LDFLAGS="${LDFLAGS}"
|
|
export CGO_CPPFLAGS="${CPPFLAGS}"
|
|
export CGO_CFLAGS="${CFLAGS}"
|
|
export CGO_CXXFLAGS="${CXXFLAGS}"
|
|
export GOFLAGS="-buildmode=pie -trimpath -modcacherw"
|
|
|
|
GOLDFLAGS="-X github.com/prometheus/common/version.Version=$version
|
|
-X github.com/prometheus/common/version.Revision=CRUX
|
|
-X github.com/prometheus/common/version.Branch=master
|
|
-X github.com/prometheus/common/version.BuildUser=$USER@$HOSTNAME
|
|
-X github.com/prometheus/common/version.BuildDate=$(date -u +%Y%m%d-%H:%M:%S)
|
|
"
|
|
|
|
if [ -n $LDFLAGS ]; then
|
|
# LDFLAGS (and only LDFLAGS) should be passed to -extldflags.
|
|
GOLDFLAGS="$GOLDFLAGS -extldflags $LDFLAGS"
|
|
fi
|
|
# }}}
|
|
cd $name-$version
|
|
|
|
cd web/ui
|
|
npm install
|
|
npm run build
|
|
npm run build:module
|
|
npm run lint
|
|
GOOS= GOARCH= go generate -x -v
|
|
cd ../..
|
|
|
|
gofmt -w ./web/ui
|
|
go mod vendor
|
|
go build \
|
|
-trimpath \
|
|
-mod=vendor \
|
|
-ldflags "$GOLDFLAGS" \
|
|
-tags netgo,builtinassets \
|
|
./cmd/prometheus
|
|
go build \
|
|
-trimpath \
|
|
-mod=vendor \
|
|
-ldflags "$GOLDFLAGS" \
|
|
./cmd/promtool
|
|
# install
|
|
install -Dm755 -t $PKG/usr/bin prometheus promtool
|
|
|
|
install -Dm644 $SRC/prometheus.conf \
|
|
$PKG/etc/conf.d/prometheus
|
|
install -dm644 $PKG/var/lib/prometheus/data
|
|
|
|
install -Dm644 -t $PKG/etc/prometheus \
|
|
documentation/examples/prometheus.yml
|
|
|
|
mkdir -p $PKG/etc/prometheus/console_libraries
|
|
for file in console_libraries/*
|
|
do
|
|
install -Dm644 -t $PKG/etc/prometheus/console_libraries/ $file
|
|
done
|
|
|
|
mkdir -p $PKG/etc/prometheus/consoles
|
|
for file in consoles/*
|
|
do
|
|
install -Dm644 -t $PKG/etc/prometheus/consoles/ $file
|
|
done
|
|
|
|
install -dm755 $PKG/usr/share/prometheus/web/ui
|
|
cp -R web/ui/{static,templates} $PKG/usr/share/prometheus/web/ui/
|
|
install -Dm644 $SRC/prometheus.conf $PKG/etc/conf.d/prometheus
|
|
|
|
## install rc file
|
|
install -Dm 755 $SRC/prometheus.service $PKG/etc/rc.d/prometheus
|
|
}
|
|
|
|
# vim: foldmethod=marker foldlevelstart=1
|