From 23f13efc5d967abefd807d9d5f4fb8c44535f9f2 Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Mon, 4 Jul 2016 14:43:22 +0900 Subject: [PATCH] added build recipe --- PKGBUILD | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ gnatsd.conf | 31 ++++++++++++++++++++++++++ gnatsd.install | 11 ++++++++++ gnatsd.service | 34 +++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+) create mode 100644 PKGBUILD create mode 100644 gnatsd.conf create mode 100644 gnatsd.install create mode 100644 gnatsd.service diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..ed37086 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,59 @@ +pkgname=gnatsd +pkgver=v0.8.1.r0.g86e883c +_pkgver=0.8.1 +pkgrel=1 +pkgdesc="Analyzes resource usage and performance characteristics of running containers." +depends=('glibc' 'bash') +makedepends=('go' 'rsync' 'godep') +arch=('x86_64' 'i686') +source=( + "$pkgname::git+https://github.com/nats-io/gnatsd.git#tag=v$_pkgver" + "gnatsd.service" + "gnatsd.install" + "gnatsd.conf" +) +url="http://nats.io/" +license=("APACHE") +install=gnatsd.install + +sha512sums=('SKIP' + '0c4d71b35c00289e330e939a6500664aac066e654e7381c4a0d87d97ba595e635a5f5770e52197fec8ea8a29fcd2fad98a24deff80c3bdbedf6d927eeac96d26' + 'c55320053e34b10b2d94627cec62242e58fcee72c8cc7eb6efa083b1bc26bedf4ce79efe3fa49bf9e1648c3a1a7b8e9d7bcfce08aa002dc7bfd6c719ad73b5b0' + '7eeef63f6b22a17a07cbc09b302996b12c5ab1e4a04d57e9358e8905374900375c899e9f05c0a845c4c071e3f546b5e831f3336f8cdb83cc8532ada19ac9e13b') + +pkgver() { + cd "$srcdir/$pkgname" + git describe --long --tags | sed -r 's/^go//;s/([^-]*-g)/r\1/;s/-/./g' +} + + +prepare() +{ + export GOPATH="${srcdir}/gopath" + export GOBIN="$GOPATH/bin" + mkdir -p $GOPATH/src/github.com/nats-io/ + ln -sfT $srcdir/gnatsd $GOPATH/src/github.com/nats-io/gnatsd +} +build() +{ + echo "Building gnatsd version=${pkgver} branch=$branch commit=${commit}..." + cd $GOPATH/src/github.com/nats-io/gnatsd + go build +} + +package() { + cd $srcdir/gnatsd + _build_path="${srcdir}/${pkgname}" + + mkdir -p "${pkgdir}/usr/bin" + + install -pm 755 "${_build_path}/gnatsd" "${pkgdir}/usr/bin/gnatsd" + + mkdir -p "${pkgdir}/usr/lib/systemd/system/" + + install -pm 644 "${srcdir}/gnatsd.service" "${pkgdir}/usr/lib/systemd/system/gnatsd.service" + + mkdir -p "${pkgdir}/etc/gnatsd/" + + install -pm 644 "${srcdir}/gnatsd.conf" "${pkgdir}/etc/gnatsd/gnatsd.conf" +} diff --git a/gnatsd.conf b/gnatsd.conf new file mode 100644 index 0000000..dd98e15 --- /dev/null +++ b/gnatsd.conf @@ -0,0 +1,31 @@ +# Sample config file + +port: 4242 +net: 0.0.0.0 + +#authorization { +# user: derek +# password: bella +# timeout: 1 +#} + +cluster { + host: 127.0.0.1 + port: 4244 + +# authorization { +# user: route_user +# password: top_secret +# timeout: 1 +# } + + # Routes are actively solicited and connected to from this server. + # Other servers can connect to us if they supply the correct credentials + # in their routes definitions from above. + +# routes = [ +# nats-route://foo:bar@localhost:4245 +# nats-route://foo:bar@localhost:4246 +# ] + +} diff --git a/gnatsd.install b/gnatsd.install new file mode 100644 index 0000000..6643f59 --- /dev/null +++ b/gnatsd.install @@ -0,0 +1,11 @@ +post_install() { + systemctl daemon-reload +} + +post_upgrade() { + post_install +} + +post_remove() { + systemctl daemon-reload +} diff --git a/gnatsd.service b/gnatsd.service new file mode 100644 index 0000000..3d73ed5 --- /dev/null +++ b/gnatsd.service @@ -0,0 +1,34 @@ +# Copyright 2016 Sangbum Kim / amuz.es +# +# Licensed 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. +[Unit] +Description=gnatsd +Documentation=http://nats.io +After=network.target +After=network-online.target + +[Service] +User=nobody +Group=nobody +Type=simple +PIDFile=/var/run/gnatsd/gnatsd.pid +Restart=on-failure +RestartSec=10s + +PermissionsStartOnly=true +ExecStartPre=-/usr/bin/mkdir -p /var/run/gnatsd +ExecStartPre=/usr/bin/chown -R nobody:nobody /var/run/gnatsd/ +ExecStart=/usr/bin/gnatsd -s -P /var/run/gnatsd/gnatsd.pid -c /etc/gnatsd/gnatsd.conf $EXTRA + +[Install] +WantedBy=multi-user.target