diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..4f74202 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,64 @@ +# Maintainer: surefire@cryptomile.net +pkgname=cpu_ctrl +pkgver=0+be2e961+ +pkgrel=1 +pkgdesc="ipmi cpu fan control with core sensor" +arch=('i686' 'x86_64') +url="https://amuz.es/src/infra/cpu_ctrl" +license=('GPL') +conflicts=('cpu_ctrl') +provides=('cpu_ctrl') +replaces=('cpu_ctrl') +options=('!buildflags') +makedepends=('go' 'git') +source=('git+https://amuz.es/src/infra/cpu_ctrl.git' + 'cpu_ctrl.service' +) +md5sums=('SKIP' + '979850d8d2adb3ef068c4c08b351ecef') + +prepare() { + + export GOPATH="${srcdir}/gopath" + export GOBIN="$GOPATH/bin" + export PATH=$GOBIN:$PATH + mkdir -p "$GOPATH/src/amuz.es/src/infra" + + go get -u github.com/kardianos/govendor + + ln -sfT "$srcdir/$pkgname" "$GOPATH/src/amuz.es/src/infra/$pkgname" +} + +pkgver() { + cd "${srcdir}/${pkgname}" + printf '%s+%s+%s' \ + $(sed -e 's,/,+,g; s, ,,g' templates/.VERSION) \ + $(git rev-list --count HEAD...$(git log --pretty=format:%H -n 1 -- templates/.VERSION)) \ + $(git rev-parse --short HEAD) \ + ; +} + +build() { + cd "${GOPATH}/src/amuz.es/src/infra/$pkgname" + + rm -rf vendor + mkdir vendor + govendor init + govendor fetch -v +missing + + BINARY=cpu_ctrl + VERSION=`git describe --always` + BUILD=`date +%FT%T%z` + export LDFLAGS= + export CGO_ENABLED=0 + + go build -o ${BINARY} + strip -x ${BINARY} +} + +package() { + cd "${GOPATH}/src/amuz.es/src/infra/$pkgname" + + install -Dm0755 -t "$pkgdir/usr/bin" ./cpu_ctrl + install -Dm0644 -t "$pkgdir/usr/lib/systemd/system" "$srcdir/cpu_ctrl.service" +} diff --git a/main.go b/main.go index 68cb921..4286e3a 100644 --- a/main.go +++ b/main.go @@ -31,12 +31,13 @@ var ( ) +type notifyType string + const ( DaemonStarted notifyType = "READY=1" DaemonStopping notifyType = "STOPPING=1" ) -var sockPath string func NotifyDaemon(status notifyType) { daemon.SdNotify(false, string(status))