Skip to content

Commit

Permalink
(#277) All filesystem paths can be passed via cmdline
Browse files Browse the repository at this point in the history
Paths can also be given in jobber.conf, but those on cmdline
take precedence.
  • Loading branch information
dshearer committed May 10, 2020
1 parent fdcfb51 commit 6d60633
Show file tree
Hide file tree
Showing 59 changed files with 2,816 additions and 550 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ jobs:
apk add make
apk add alpine-sdk
apk add go
adduser -G abuild -D jobber
sudo -u jobber abuild-keygen -an
find "/home/jobber/.abuild" -name '*.rsa.pub' -exec mv {} /etc/apk/keys/ ';'
chown root:root /etc/apk/keys/*
- name: Clone repo
uses: actions/checkout@v2
Expand Down Expand Up @@ -93,7 +97,7 @@ jobs:
run: |
python --version
brew install socat
sudo pip install robotframework
sudo pip install robotframework pyyaml
sudo sysadminctl -addUser normuser -home /Users/normuser
sudo createhomedir -c
Expand Down Expand Up @@ -137,7 +141,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y python-pip socat
sudo pip install robotframework
sudo pip install robotframework pyyaml
sudo useradd normuser -m
- name: Download package
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ results
*.pyc
*.pyo
*cloudimg-console.log
mk/config.mk
86 changes: 63 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# GNU-standard vars (cf. http://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html)
SHELL = /bin/sh
prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
libexecdir = ${exec_prefix}/libexec
sysconfdir = /etc

# Paths may be loaded from mk/config.mk, whcih is made by configure
-include mk/config.mk
prefix ?= /usr/local
bindir ?= ${prefix}/bin
libexecdir ?= ${prefix}/libexec
sysconfdir ?= /etc
localstatedir ?= ${prefix}/var

srcdir = .
INSTALL = install
INSTALL_PROGRAM = ${INSTALL}
Expand All @@ -18,11 +22,16 @@ OUTPUT_DIR = bin
GO = go
GO_VERSION = 1.11
# NOTE: '-mod=vendor' prevents go from downloading dependencies
GO_BUILD := ${GO} build -mod=vendor -ldflags "-X github.com/dshearer/jobber/common.jobberVersion=${JOBBER_VERSION}"
GO_BUILD_BASE_FLAGS := -mod=vendor
COMPILETIME_VARS := \
-X 'github.com/dshearer/jobber/common.jobberVersion=${JOBBER_VERSION}' \
-X 'github.com/dshearer/jobber/common.etcDirPath=${sysconfdir}'

GO_BUILD := ${GO} build ${GO_BUILD_BASE_FLAGS} -ldflags "${COMPILETIME_VARS}"
GO_VET = ${GO} vet -mod=vendor
GO_TEST = ${GO} test -mod=vendor
GO_GEN = ${GO_WITH_TOOLS} generate -mod=vendor
GO_CLEAN = ${GO} clean
GO_CLEAN = ${GO} clean -mod=vendor

PACKAGES = \
github.com/dshearer/jobber/common \
Expand All @@ -39,15 +48,43 @@ default : build

include mk/buildtools.mk # defines 'GO_WITH_TOOLS' and 'GOYACC'

################################################################################
# BUILD
################################################################################

.PHONY : build
build : ${OUTPUT_DIR}/jobber ${OUTPUT_DIR}/jobbermaster \
${OUTPUT_DIR}/jobberrunner
${OUTPUT_DIR}/jobberrunner ${OUTPUT_DIR}/jobber.conf
@echo
@echo "Built with these paths:"
@echo "localstatedir: ${localstatedir}"
@echo "libexecdir: ${libexecdir}"
@echo "sysconfdir: ${sysconfdir}"

.PHONY : check
check : ${TEST_SOURCES} jobfile/parse_time_spec.go
@go version
${GO_VET} ${PACKAGES}
${GO_TEST} ${PACKAGES}
@echo GO TEST
@${GO_TEST} ${PACKAGES}

${OUTPUT_DIR}/% : ${MAIN_SOURCES} jobfile/parse_time_spec.go
@$(call checkGoVersion)
@echo GO VET
@${GO_VET} ${PACKAGES}
@echo BUILD $*
@${GO_BUILD} -o "$@" "github.com/dshearer/jobber/$*"

${OUTPUT_DIR}/jobber.conf : ${OUTPUT_DIR}/jobbermaster
@echo BUILD $@
@${OUTPUT_DIR}/jobbermaster defprefs --var "${localstatedir}" --libexec "${libexecdir}" > "$@"

jobfile/parse_time_spec.go : ${GOYACC} ${JOBFILE_SOURCES}
@echo GEN SRC
@${GO_GEN} -mod=vendor github.com/dshearer/jobber/jobfile

################################################################################
# INSTALL
################################################################################

install : \
${DESTDIR}${libexecdir}/jobbermaster \
Expand All @@ -56,19 +93,19 @@ install : \
${DESTDIR}${sysconfdir}/jobber.conf

${DESTDIR}${libexecdir}/% : ${OUTPUT_DIR}/%
@echo INSTALL "$@"
@echo INSTALL $@
@mkdir -p "${dir $@}"
@${INSTALL_PROGRAM} "$<" "$@"

${DESTDIR}${bindir}/% : ${OUTPUT_DIR}/%
@echo INSTALL "$@"
@echo INSTALL $@
@mkdir -p "${dir $@}"
@${INSTALL_PROGRAM} "$<" "$@"

${DESTDIR}${sysconfdir}/jobber.conf : ${OUTPUT_DIR}/jobbermaster
@echo INSTALL "$@"
${DESTDIR}${sysconfdir}/jobber.conf : ${OUTPUT_DIR}/jobber.conf
@echo INSTALL $@
@mkdir -p "${dir $@}"
@"$<" defprefs > "$@"
@cp "$<" "$@"

.PHONY : uninstall
uninstall :
Expand All @@ -86,18 +123,21 @@ dist :
"${SRC_TARBALL_DIR}"
rm -rf "${DESTDIR}dist-tmp"

${OUTPUT_DIR}/% : ${MAIN_SOURCES} jobfile/parse_time_spec.go
@${srcdir}/buildtools/versionge "$$(go version | egrep -o '[[:digit:].]+' | head -n 1)" "${GO_VERSION}"
@echo BUILD $*
@${GO_BUILD} -o "$@" "github.com/dshearer/jobber/$*"

jobfile/parse_time_spec.go : ${GOYACC} ${JOBFILE_SOURCES}
@echo GEN SRC
@${GO_GEN} -mod=vendor github.com/dshearer/jobber/jobfile
################################################################################
# CLEAN
################################################################################

.PHONY : clean
clean : clean-buildtools
@echo CLEAN
@-${GO_CLEAN} -i ${PACKAGES}
@rm -rf "${DESTDIR}${SRC_TARBALL}.tgz" jobfile/parse_time_spec.go \
jobfile/y.output "${OUTPUT_DIR}"

################################################################################
# MISC
################################################################################

define checkGoVersion
${srcdir}/buildtools/versionge "$$(go version | egrep -o '[[:digit:].]+' | head -n 1)" "${GO_VERSION}"
endef
9 changes: 9 additions & 0 deletions common/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ func saveLogFileHandles(handles ...*os.File) {
}
}

func LogAllToStderr() {
// close old file handle
saveLogFileHandles()

// make new loggers
Logger = log.New(os.Stderr, "", 0)
ErrLogger = log.New(os.Stderr, "", 0)
}

func LogToStdoutStderr() {
// close old file handle
saveLogFileHandles()
Expand Down
69 changes: 0 additions & 69 deletions common/path.go

This file was deleted.

Loading

0 comments on commit 6d60633

Please sign in to comment.