diff --git a/.gitignore b/.gitignore index ae20bd4..5edc0d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ -lql_api +_build +lql-api .pc + +debian/debhelper-build-stamp +debian/lql-api.debhelper.log +debian/lql-api +debian/.debhelper diff --git a/Makefile b/Makefile index 0f62f9e..fd66983 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # This how we want to name the binary output -BINARY=lql_api - +BINARY := lql-api +SHELL := /bin/bash TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1) TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true) @@ -19,15 +19,24 @@ ifneq ($(shell git status --porcelain),) endif # Setup the -ldflags option for go build here, interpolate the variable values -LDFLAGS=-ldflags "-w -s -X github.com/webmeisterei/lql_api/version.Version=${VERSION}" +LDFLAGS=-ldflags '-w -s -X github.com/webmeisterei/lql_api/version.Version=${VERSION}' +LDFLAGS_STATIC=-ldflags '-extldflags "-static" -w -s -X github.com/webmeisterei/lql_api/version.Version=${VERSION}' -# Builds the project build: - go build ${LDFLAGS} -o ${BINARY} + go build -o ${BINARY} -a ${LDFLAGS} + + +# Builds the project +build_static: + CGO_ENABLED=0 GOOS=linux go build -o ${BINARY} -a ${LDFLAGS_STATIC} # Installs our project: copies binaries install: - go install ${LDFLAGS_f1} + go install ${LDFLAGS} + +.PHONY: debian +debian: + GOPROXY= dpkg-buildpackage -us -uc # Cleans our project: deletes binaries clean: diff --git a/debian/lql-api@.service b/debian/lql-api@.service index 88fc102..764afef 100644 --- a/debian/lql-api@.service +++ b/debian/lql-api@.service @@ -3,10 +3,11 @@ Description=LQL API Server After=network.target [Service] +EnvironmentFile=/etc/lql-api/%i Type=simple User=%i Group=%i -ExecStart=/usr/local/bin/lql_api localserver %i --listen localhost:8080 -d +ExecStart=/usr/bin/lql-api localserver %i --listen $LISTEN $DEBUG [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/debian/rules b/debian/rules index 16a5511..ae1a9c7 100755 --- a/debian/rules +++ b/debian/rules @@ -5,4 +5,4 @@ override_dh_auto_install: dh_auto_install -- --no-source - dh_installsystemd –no-start + dh_installsystemd --no-start -- lql-api@.service