diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bc829b3d..e582f30d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,4 +41,4 @@ jobs: run: make vet - name: test - run: make test-it + run: make test diff --git a/.gitignore b/.gitignore index 7859c0c0..55581c1c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,38 +5,27 @@ /vendor # binaries -/warewulfd -/wwbuild /wwclient /wwctl -/bash_completion -/man_page -/config_defaults /update_configuration /wwapic /wwapid /wwapird -/print_defaults # other created files -/man_pages -/bash_completion.d -/usr/share/man/man1/ +/docs/man/man1 +/docs/man/man5/*.5.gz /etc/bash_completion.d/ warewulf.spec -internal/pkg/buildconfig/setconfigs.go internal/pkg/config/buildconfig.go include/systemd/warewulfd.service -_dist/ -/config warewulf-*.tar.gz Defaults.mk -/etc/wwapid.config -/etc/wwapic.config -/etc/wwapird.config /etc/wwapid.conf /etc/wwapic.conf /etc/wwapird.conf +/etc/defaults.conf .dist/ userdocs/_* userdocs/reference/* +/warewulf-?.?.?/ diff --git a/CHANGELOG.md b/CHANGELOG.md index df7cede1..e9530dbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Check for formal correct IP and MAC addresses for command line options and when reading in the configurations - Write log messages to stderr rather than stdout. #768 +- Updates to Makefile for clarity, notably removing genconfig and replacing + test-it with test. #890 ## [4.4.0] 2023-01-18 diff --git a/Dockerfile b/Dockerfile index dfffc58e..616c294d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,7 @@ RUN zypper -n install --no-recommends git go1.18 libgpgme-devel &&\ COPY . /warewulf-src RUN cd /warewulf-src &&\ - make contclean &&\ - make genconfig \ + make contclean Defaults.mk \ PREFIX=/usr \ BINDIRa=/usr/bin \ SYSCONFDIR=/etc \ diff --git a/Makefile b/Makefile index 2cb29c9c..3b51f42a 100644 --- a/Makefile +++ b/Makefile @@ -1,175 +1,88 @@ -.PHONY: all clean contclean +include Variables.mk --include Defaults.mk +.PHONY: all +all: config vendor wwctl wwclient man_pages wwapid wwapic wwapird etc/defaults.conf etc/bash_completion.d/wwctl -# Linux distro (try and set to /etc/os-release ID) -OS_REL := $(shell sed -n "s/^ID\s*=\s*['"\""]\(.*\)['"\""]/\1/p" /etc/os-release) -OS ?= $(OS_REL) +.PHONY: build +build: lint test vet all -# List of variables to save and replace in files -VARLIST := OS +.PHONY: setup_tools +setup_tools: $(GO_TOOLS_BIN) $(GOLANGCI_LINT) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) -# Project Information -VARLIST += WAREWULF VERSION RELEASE -WAREWULF ?= warewulf -VERSION ?= 4.4.0 -GIT_TAG := $(shell test -e .git && git log -1 --format="%h") - -ifdef GIT_TAG - ifdef $(filter $(OS),ubuntu debian) - RELEASE ?= 1.git_$(subst -,+,$(GIT_TAG)) - else - RELEASE ?= 1.git_$(subst -,_,$(GIT_TAG)) - endif -else - RELEASE ?= 1 -endif - -# Use LSB-compliant paths if OS is known -ifneq ($(OS),) - USE_LSB_PATHS := true -endif - -# Always default to GNU autotools default paths if PREFIX has been redefined -ifdef PREFIX - USE_LSB_PATHS := false -endif - -# System directory paths -VARLIST += PREFIX BINDIR SYSCONFDIR SRVDIR DATADIR MANDIR DOCDIR LOCALSTATEDIR -PREFIX ?= /usr/local -BINDIR ?= $(PREFIX)/bin -SYSCONFDIR ?= $(PREFIX)/etc -DATADIR ?= $(PREFIX)/share -MANDIR ?= $(DATADIR)/man -DOCDIR ?= $(DATADIR)/doc - -ifeq ($(USE_LSB_PATHS),true) - SRVDIR ?= /srv - LOCALSTATEDIR ?= /var/local -else - SRVDIR ?= $(PREFIX)/srv - LOCALSTATEDIR ?= $(PREFIX)/var -endif - -# OS-Specific Service Locations -VARLIST += TFTPDIR FIREWALLDDIR SYSTEMDDIR BASHCOMPDIR -SYSTEMDDIR ?= /usr/lib/systemd/system -BASHCOMPDIR ?= /etc/bash_completion.d -FIREWALLDDIR ?= /usr/lib/firewalld/services -ifeq ($(OS),suse) - TFTPDIR ?= /srv/tftpboot -endif -ifeq ($(OS),ubuntu) - TFTPDIR ?= /srv/tftp -endif -# Default to Red Hat / Rocky Linux -TFTPDIR ?= /var/lib/tftpboot - -# Warewulf directory paths -VARLIST += WWCLIENTDIR WWCONFIGDIR WWPROVISIONDIR WWOVERLAYDIR WWCHROOTDIR WWTFTPDIR WWDOCDIR WWDATADIR -WWCONFIGDIR := $(SYSCONFDIR)/$(WAREWULF) -WWPROVISIONDIR := $(SRVDIR)/$(WAREWULF) -WWOVERLAYDIR := $(LOCALSTATEDIR)/$(WAREWULF)/overlays -WWCHROOTDIR := $(LOCALSTATEDIR)/$(WAREWULF)/chroots -WWTFTPDIR := $(TFTPDIR)/$(WAREWULF) -WWDOCDIR := $(DOCDIR)/$(WAREWULF) -WWDATADIR := $(DATADIR)/$(WAREWULF) -WWCLIENTDIR ?= /warewulf - -# auto installed tooling -TOOLS_DIR := .tools -TOOLS_BIN := $(TOOLS_DIR)/bin -CONFIG := $(shell pwd) - -# tools -GO_TOOLS_BIN := $(addprefix $(TOOLS_BIN)/, $(notdir $(GO_TOOLS))) -GO_TOOLS_VENDOR := $(addprefix vendor/, $(GO_TOOLS)) -GOLANGCI_LINT := $(TOOLS_BIN)/golangci-lint -GOLANGCI_LINT_VERSION := v1.53.2 - -# helper functions -godeps=$(shell go list -deps -f '{{if not .Standard}}{{ $$dep := . }}{{range .GoFiles}}{{$$dep.Dir}}/{{.}} {{end}}{{end}}' $(1) | sed "s%${PWD}/%%g") -WWCTL_DEPS:=$(call godeps,cmd/wwctl/main.go) -WWCLIENT_DEPS:=$(call godeps,cmd/wwclient/main.go) - -# use GOPROXY for older git clients and speed up downloads -GOPROXY ?= https://proxy.golang.org -export GOPROXY - -# built tags needed for wwbuild binary -WW_GO_BUILD_TAGS := containers_image_openpgp containers_image_ostree - -# Default target -all: config vendor wwctl wwclient man_pages wwapid wwapic wwapird - -# Validate source and build all packages -build: lint test-it vet all - -# set the go tools into the tools bin. -setup_tools: $(GO_TOOLS_BIN) $(GOLANGCI_LINT) - -# install go tools into TOOLS_BIN $(GO_TOOLS_BIN): - @GOBIN="$(PWD)/$(TOOLS_BIN)" go install -mod=vendor $(GO_TOOLS) + GOBIN="$(PWD)/$(TOOLS_BIN)" go install -mod=vendor $(GO_TOOLS) -# install golangci-lint into TOOLS_BIN $(GOLANGCI_LINT): - @curl -qq -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TOOLS_BIN) $(GOLANGCI_LINT_VERSION) + curl -qq -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TOOLS_BIN) $(GOLANGCI_LINT_VERSION) +$(PROTOC): + cd $(PWD)/$(TOOLS_DIR) && curl -LO $(PROTOC_URL) && unzip protoc-24.0-linux-aarch_64.zip + +$(PROTOC_GEN_GRPC_GATEWAY): + curl -L $(PROTOC_GEN_GRPC_GATEWAY_URL) -o $(PROTOC_GEN_GRPC_GATEWAY) + chmod +x $(PROTOC_GEN_GRPC_GATEWAY) + +$(PROTOC_GEN_GO): + GOBIN="$(PWD)/$(TOOLS_BIN)" go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 + +$(PROTOC_GEN_GO_GRPC): + GOBIN="$(PWD)/$(TOOLS_BIN)" go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 + +.PHONY: setup setup: vendor $(TOOLS_DIR) setup_tools vendor: ifndef OFFLINE_BUILD - go mod tidy -v - go mod vendor + go mod tidy -v + go mod vendor endif $(TOOLS_DIR): - @mkdir -p $@ + mkdir -p $@ -# Pre-build steps for source, such as "go generate" -config: -# Store configuration for subsequent runs - printf " $(foreach V,$(VARLIST),$V := $(strip $($V))\n)" > Defaults.mk - # Global variable search and replace for all *.in files - find . -type f -name "*.in" -not -path "./vendor/*" \ - -exec sh -c 'sed -ne "$(foreach V,$(VARLIST),s,@$V@,$(strip $($V)),g;)p" $${0} > $${0%.in}' {} \; - touch config +.PHONY: config +config: etc/wwapic.conf \ + etc/wwapid.conf \ + etc/wwapird.conf \ + include/systemd/warewulfd.service \ + internal/pkg/config/buildconfig.go \ + warewulf.spec -rm_config: - rm -f config +etc/defaults.conf: wwctl + ./wwctl --emptyconf genconfig defaults >etc/defaults.conf -genconfig: rm_config config +%: %.in + sed -ne "$(foreach V,$(VARLIST),s,@$V@,$(strip $($V)),g;)p" $@.in >$@ -# Lint +.PHONY: lint lint: setup_tools - @echo Running golangci-lint... - @$(GOLANGCI_LINT) run --build-tags "$(WW_GO_BUILD_TAGS)" --skip-dirs internal/pkg/staticfiles ./... + $(GOLANGCI_LINT) run --build-tags "$(WW_GO_BUILD_TAGS)" --skip-dirs internal/pkg/staticfiles ./... -vet: +.PHONY: vet +vet: config go vet ./... -test-it: - go test -v ./... +.PHONY: test +test: config + go test ./... -# Generate test coverage -test-cover: ## Run test coverage and generate html report - rm -fr coverage +.PHONY: test-cover +test-cover: config + rm -rf coverage mkdir coverage go list -f '{{if gt (len .TestGoFiles) 0}}"go test -covermode count -coverprofile {{.Name}}.coverprofile -coverpkg ./... {{.ImportPath}}"{{end}}' ./... | xargs -I {} bash -c {} - echo "mode: count" > coverage/cover.out - grep -h -v "^mode:" *.coverprofile >> "coverage/cover.out" + echo "mode: count" >coverage/cover.out + grep -h -v "^mode:" *.coverprofile >>"coverage/cover.out" rm *.coverprofile go tool cover -html=coverage/cover.out -o=coverage/cover.html -debian: all - -files: all +.PHONY: install +install: all install -d -m 0755 $(DESTDIR)$(BINDIR) install -d -m 0755 $(DESTDIR)$(WWCHROOTDIR) install -d -m 0755 $(DESTDIR)$(WWPROVISIONDIR) install -d -m 0755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/$(WWCLIENTDIR) + install -d -m 0755 $(DESTDIR)$(WWCONFIGDIR)/examples install -d -m 0755 $(DESTDIR)$(WWCONFIGDIR)/ipxe install -d -m 0755 $(DESTDIR)$(BASHCOMPDIR) install -d -m 0755 $(DESTDIR)$(MANDIR)/man1 @@ -178,23 +91,22 @@ files: all install -d -m 0755 $(DESTDIR)$(FIREWALLDDIR) install -d -m 0755 $(DESTDIR)$(SYSTEMDDIR) install -d -m 0755 $(DESTDIR)$(WWDATADIR)/ipxe - test -f $(DESTDIR)$(WWCONFIGDIR)/warewulf.conf || install -m 644 etc/warewulf.conf $(DESTDIR)$(WWCONFIGDIR) - test -f $(DESTDIR)$(WWCONFIGDIR)/nodes.conf || install -m 644 etc/nodes.conf $(DESTDIR)$(WWCONFIGDIR) - test -f $(DESTDIR)$(WWCONFIGDIR)/wwapic.conf || install -m 644 etc/wwapic.conf $(DESTDIR)$(WWCONFIGDIR) - test -f $(DESTDIR)$(WWCONFIGDIR)/wwapid.conf || install -m 644 etc/wwapid.conf $(DESTDIR)$(WWCONFIGDIR) - test -f $(DESTDIR)$(WWCONFIGDIR)/wwapird.conf || install -m 644 etc/wwapird.conf $(DESTDIR)$(WWCONFIGDIR) - test -f $(DESTDIR)$(DATADIR)/warewulf/defaults.conf || ./wwctl --emptyconf genconfig defaults > $(DESTDIR)$(DATADIR)/warewulf/defaults.conf - cp -r etc/examples $(DESTDIR)$(WWCONFIGDIR)/ - cp -r etc/ipxe $(DESTDIR)$(WWCONFIGDIR)/ - cp -r overlays/* $(DESTDIR)$(WWOVERLAYDIR)/ - chmod 755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/init - find $(DESTDIR)$(WWOVERLAYDIR) -type f -name "*.in" -exec rm -f {} \; - chmod 755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/$(WWCLIENTDIR)/wwinit - chmod 600 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/etc/ssh/ssh* - chmod 600 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/etc/NetworkManager/system-connections/ww4-managed.ww - chmod 644 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/etc/ssh/ssh*.pub.ww - chmod 600 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/warewulf/config.ww - chmod 750 $(DESTDIR)$(WWOVERLAYDIR)/host + test -f $(DESTDIR)$(WWCONFIGDIR)/warewulf.conf || install -m 0644 etc/warewulf.conf $(DESTDIR)$(WWCONFIGDIR) + test -f $(DESTDIR)$(WWCONFIGDIR)/nodes.conf || install -m 0644 etc/nodes.conf $(DESTDIR)$(WWCONFIGDIR) + test -f $(DESTDIR)$(WWCONFIGDIR)/wwapic.conf || install -m 0644 etc/wwapic.conf $(DESTDIR)$(WWCONFIGDIR) + test -f $(DESTDIR)$(WWCONFIGDIR)/wwapid.conf || install -m 0644 etc/wwapid.conf $(DESTDIR)$(WWCONFIGDIR) + test -f $(DESTDIR)$(WWCONFIGDIR)/wwapird.conf || install -m 0644 etc/wwapird.conf $(DESTDIR)$(WWCONFIGDIR) + test -f $(DESTDIR)$(DATADIR)/warewulf/defaults.conf || install -m 0644 etc/defaults.conf $(DESTDIR)$(DATADIR)/warewulf/defaults.conf + for f in etc/examples/*.ww; do install -m 0644 $$f $(DESTDIR)$(WWCONFIGDIR)/examples/; done + for f in etc/ipxe/*.ipxe; do install -m 0644 $$f $(DESTDIR)$(WWCONFIGDIR)/ipxe/; done + (cd overlays && find * -type f -exec install -D -m 0644 {} $(DESTDIR)$(WWOVERLAYDIR)/{} \;) + chmod 0755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/init + chmod 0755 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/$(WWCLIENTDIR)/wwinit + chmod 0600 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/etc/ssh/ssh* + chmod 0600 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/etc/NetworkManager/system-connections/ww4-managed.ww + chmod 0644 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/etc/ssh/ssh*.pub.ww + chmod 0600 $(DESTDIR)$(WWOVERLAYDIR)/wwinit/warewulf/config.ww + chmod 0750 $(DESTDIR)$(WWOVERLAYDIR)/host install -m 0755 wwctl $(DESTDIR)$(BINDIR) install -m 0755 wwclient $(DESTDIR)$(WWOVERLAYDIR)/wwinit/$(WWCLIENTDIR)/wwclient install -m 0755 wwapic $(DESTDIR)$(BINDIR) @@ -203,48 +115,59 @@ files: all install -m 0644 include/firewalld/warewulf.xml $(DESTDIR)$(FIREWALLDDIR) install -m 0644 include/systemd/warewulfd.service $(DESTDIR)$(SYSTEMDDIR) install -m 0644 LICENSE.md $(DESTDIR)$(WWDOCDIR) - ./wwctl --warewulfconf etc/warewulf.conf genconfig completions > $(DESTDIR)$(BASHCOMPDIR)/wwctl - cp man_pages/*.1* $(DESTDIR)$(MANDIR)/man1/ - cp man_pages/*.5* $(DESTDIR)$(MANDIR)/man5/ + install -m 0644 etc/bash_completion.d/wwctl $(DESTDIR)$(BASHCOMPDIR)/wwctl + for f in docs/man/man1/*.1.gz; do install -m 0644 $$f $(DESTDIR)$(MANDIR)/man1/; done + for f in docs/man/man5/*.5.gz; do install -m 0644 $$f $(DESTDIR)$(MANDIR)/man5/; done install -m 0644 staticfiles/README-ipxe.md $(DESTDIR)$(WWDATADIR)/ipxe install -m 0644 staticfiles/arm64.efi $(DESTDIR)$(WWDATADIR)/ipxe install -m 0644 staticfiles/x86_64.efi $(DESTDIR)$(WWDATADIR)/ipxe install -m 0644 staticfiles/x86_64.kpxe $(DESTDIR)$(WWDATADIR)/ipxe +etc/bash_completion.d/wwctl: wwctl + mkdir -p etc/bash_completion.d/ + ./wwctl --emptyconf genconfig completions >etc/bash_completion.d/wwctl + +.PHONY: init init: systemctl daemon-reload cp -r tftpboot/* $(WWTFTPDIR)/ipxe/ restorecon -r $(WWTFTPDIR) -wwctl: config vendor $(WWCTL_DEPS) - @echo Building "$@" - @cd cmd/wwctl; GOOS=linux go build -mod vendor -tags "$(WW_GO_BUILD_TAGS)" \ - -o ../../wwctl +wwctl: config vendor $(call godeps,cmd/wwctl/main.go) + GOOS=linux go build -mod vendor -tags "$(WW_GO_BUILD_TAGS)" -o wwctl cmd/wwctl/main.go -wwclient: config vendor $(WWCLIENT_DEPS) - @echo Building "$@" - @cd cmd/wwclient; CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags "-extldflags -static" \ - -o ../../wwclient +wwclient: config vendor $(call godeps,cmd/wwclient/main.go) + CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags "-extldflags -static" -o wwclient cmd/wwclient/main.go -man_pages: wwctl - @install -d man_pages - @./wwctl --emptyconf genconfig man man_pages - @cp docs/man/man5/*.5 ./man_pages/ - @echo -n "Compressing manpage: " - @cd man_pages; for i in wwctl*1 *.5; do gzip --force $$i; echo -n "$$i "; done; echo +.PHONY: man_pages +man_pages: wwctl $(wildcard docs/man/man5/*.5) + mkdir -p docs/man/man1 + ./wwctl --emptyconf genconfig man docs/man/man1 + gzip --force docs/man/man1/*.1 + gzip --force --keep docs/man/man5/*.5 -update_configuration: vendor cmd/update_configuration/update_configuration.go - cd cmd/update_configuration && go build \ - -X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=./etc/nodes.conf'"\ - -mod vendor -tags "$(WW_GO_BUILD_TAGS)" -o ../../update_configuration +update_configuration: vendor $(call godeps,cmd/update_configuration/update_configuration.go) + go build -X 'github.com/hpcng/warewulf/internal/pkg/node.ConfigFile=./etc/nodes.conf'" \ + -mod vendor -tags "$(WW_GO_BUILD_TAGS)" -o update_configuration cmd/update_configuration/update_configuration.go +wwapid: $(call godeps,internal/app/api/wwapid/wwapid.go) + go build -o ./wwapid internal/app/api/wwapid/wwapid.go + +wwapic: $(call godeps,internal/app/api/wwapic/wwapic.go) + go build -o ./wwapic internal/app/api/wwapic/wwapic.go + +wwapird: $(call godeps,internal/app/api/wwapird/wwapird.go) + go build -o ./wwapird internal/app/api/wwapird/wwapird.go + +.PHONY: dist dist: vendor config - rm -rf .dist/$(WAREWULF)-$(VERSION) $(WAREWULF)-$(VERSION).tar.gz + rm -rf .dist/ $(WAREWULF)-$(VERSION).tar.gz mkdir -p .dist/$(WAREWULF)-$(VERSION) rsync -a --exclude=".*" --exclude "*~" * .dist/$(WAREWULF)-$(VERSION)/ cd .dist; tar -czf ../$(WAREWULF)-$(VERSION).tar.gz $(WAREWULF)-$(VERSION) rm -rf .dist +.PHONY: reference reference: wwctl mkdir -p userdocs/reference ./wwctl --emptyconf genconfig reference userdocs/reference/ @@ -252,68 +175,33 @@ reference: wwctl latexpdf: reference make -C userdocs latexpdf -## wwapi generate code from protobuf. Requires protoc and protoc-grpc-gen-gateway to generate code. -## To setup latest protoc: -## Download the protobuf-all-[VERSION].tar.gz from https://github.com/protocolbuffers/protobuf/releases -## Extract the contents and change in the directory -## ./configure -## make -## make check -## sudo make install -## sudo ldconfig # refresh shared library cache. -## To setup protoc-gen-grpc-gateway, see https://github.com/grpc-ecosystem/grpc-gateway -proto: - protoc -I /usr/include -I internal/pkg/api/routes/v1 -I=. \ +.PHONY: proto +proto: $(PROTOC) $(PROTOC_GEN_GRPC_GATEWAY) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) + PATH=$(TOOLS_BIN):$(PATH) $(PROTOC) -I /usr/include -I internal/pkg/api/routes/v1 -I=. \ --grpc-gateway_out=. \ --grpc-gateway_opt logtostderr=true \ --go_out=. \ --go-grpc_out=. \ routes.proto -wwapid: ## Build the grpc api server. - go build -o ./wwapid internal/app/api/wwapid/wwapid.go - -wwapic: ## Build the sample wwapi client. - go build -o ./wwapic internal/app/api/wwapic/wwapic.go - -wwapird: ## Build the rest api server (revese proxy to the grpc api server). - go build -o ./wwapird internal/app/api/wwapird/wwapird.go - +.PHONY: contclean contclean: - rm -f $(WAREWULF)-$(VERSION).tar.gz - rm -f bash_completion - rm -f config - rm -f config_defaults rm -f Defaults.mk - rm -f etc/wwapi{c,d,rd}.conf - rm -f etc/wwapi{c,d,rd}.config + rm -f $(WAREWULF)-$(VERSION).tar.gz + rm -f wwapi{c,d,rd} etc/wwapi{c,d,rd}.conf rm -f include/systemd/warewulfd.service - rm -f internal/pkg/buildconfig/setconfigs.go rm -f internal/pkg/config/buildconfig.go - rm -f man_page - rm -f print_defaults rm -f update_configuration - rm -f usr/share/man/man1/ rm -f warewulf.spec - rm -f warewulf-*.tar.gz - rm -f wwapic - rm -f wwapid - rm -f wwapird rm -f wwclient rm -f wwctl rm -rf $(TOOLS_DIR) - rm -rf bash_completion.d - rm -rf /config rm -rf .dist/ - rm -rf _dist/ rm -rf etc/bash_completion.d/ - rm -rf man_pages rm -rf userdocs/_* rm -rf userdocs/reference/* + rm -rf etc/defaults.conf +.PHONY: clean clean: contclean rm -rf vendor - -install: files - -debinstall: files debfiles diff --git a/Variables.mk b/Variables.mk new file mode 100644 index 00000000..9e650460 --- /dev/null +++ b/Variables.mk @@ -0,0 +1,108 @@ +-include Defaults.mk + +# Linux distro (try and set to /etc/os-release ID) +OS_REL := $(shell sed -n "s/^ID\s*=\s*['"\""]\(.*\)['"\""]/\1/p" /etc/os-release) +OS ?= $(OS_REL) + +# List of variables to save and replace in files +VARLIST := OS + +# Project Information +VARLIST += WAREWULF VERSION RELEASE +WAREWULF ?= warewulf +VERSION ?= 4.5.x +GIT_TAG := $(shell test -e .git && git log -1 --format="%h") + +ifdef GIT_TAG + ifdef $(filter $(OS),ubuntu debian) + RELEASE ?= 1.git_$(subst -,+,$(GIT_TAG)) + else + RELEASE ?= 1.git_$(subst -,_,$(GIT_TAG)) + endif +else + RELEASE ?= 1 +endif + +# Use LSB-compliant paths if OS is known +ifneq ($(OS),) + USE_LSB_PATHS := true +endif + +# Always default to GNU autotools default paths if PREFIX has been redefined +ifdef PREFIX + USE_LSB_PATHS := false +endif + +# System directory paths +VARLIST += PREFIX BINDIR SYSCONFDIR SRVDIR DATADIR MANDIR DOCDIR LOCALSTATEDIR +PREFIX ?= /usr/local +BINDIR ?= $(PREFIX)/bin +SYSCONFDIR ?= $(PREFIX)/etc +DATADIR ?= $(PREFIX)/share +MANDIR ?= $(DATADIR)/man +DOCDIR ?= $(DATADIR)/doc + +ifeq ($(USE_LSB_PATHS),true) + SRVDIR ?= /srv + LOCALSTATEDIR ?= /var/local +else + SRVDIR ?= $(PREFIX)/srv + LOCALSTATEDIR ?= $(PREFIX)/var +endif + +# OS-Specific Service Locations +VARLIST += TFTPDIR FIREWALLDDIR SYSTEMDDIR BASHCOMPDIR +SYSTEMDDIR ?= /usr/lib/systemd/system +BASHCOMPDIR ?= /etc/bash_completion.d +FIREWALLDDIR ?= /usr/lib/firewalld/services +ifeq ($(OS),suse) + TFTPDIR ?= /srv/tftpboot +endif +ifeq ($(OS),ubuntu) + TFTPDIR ?= /srv/tftp +endif +# Default to Red Hat / Rocky Linux +TFTPDIR ?= /var/lib/tftpboot + +# Warewulf directory paths +VARLIST += WWCLIENTDIR WWCONFIGDIR WWPROVISIONDIR WWOVERLAYDIR WWCHROOTDIR WWTFTPDIR WWDOCDIR WWDATADIR +WWCONFIGDIR := $(SYSCONFDIR)/$(WAREWULF) +WWPROVISIONDIR := $(SRVDIR)/$(WAREWULF) +WWOVERLAYDIR := $(LOCALSTATEDIR)/$(WAREWULF)/overlays +WWCHROOTDIR := $(LOCALSTATEDIR)/$(WAREWULF)/chroots +WWTFTPDIR := $(TFTPDIR)/$(WAREWULF) +WWDOCDIR := $(DOCDIR)/$(WAREWULF) +WWDATADIR := $(DATADIR)/$(WAREWULF) +WWCLIENTDIR ?= /warewulf + +# auto installed tooling +TOOLS_DIR := .tools +TOOLS_BIN := $(TOOLS_DIR)/bin +CONFIG := $(shell pwd) + +# tools +GO_TOOLS_BIN := $(addprefix $(TOOLS_BIN)/, $(notdir $(GO_TOOLS))) +GO_TOOLS_VENDOR := $(addprefix vendor/, $(GO_TOOLS)) +GOLANGCI_LINT := $(TOOLS_BIN)/golangci-lint +GOLANGCI_LINT_VERSION := v1.53.2 +PROTOC_GEN_GO := $(TOOLS_BIN)/protoc-gen-go +PROTOC_GEN_GO_GRPC := $(TOOLS_BIN)/protoc-gen-go-grpc +PROTOC := $(TOOLS_BIN)/protoc +PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v24.0/protoc-24.0-linux-x86_64.zip +#PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v24.0/protoc-24.0-linux-aarch_64.zip +PROTOC_GEN_GRPC_GATEWAY := $(TOOLS_BIN)/protoc-gen-grpc-gateway +PROTOC_GEN_GRPC_GATEWAY_URL := https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v2.16.2/protoc-gen-grpc-gateway-v2.16.2-linux-x86_64 +#PROTOC_GEN_GRPC_GATEWAY_URL := https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v2.16.2/protoc-gen-grpc-gateway-v2.16.2-linux-arm64 + +# helper functions +godeps=$(shell go list -deps -f '{{if not .Standard}}{{ $$dep := . }}{{range .GoFiles}}{{$$dep.Dir}}/{{.}} {{end}}{{end}}' $(1) | sed "s%${PWD}/%%g") + +# use GOPROXY for older git clients and speed up downloads +GOPROXY ?= https://proxy.golang.org +export GOPROXY + +# built tags needed for wwbuild binary +WW_GO_BUILD_TAGS := containers_image_openpgp containers_image_ostree + +Defaults.mk: + printf " $(foreach V,$(VARLIST),$V := $(strip $($V))\n)" >Defaults.mk diff --git a/cmd/update_configuration/vers42/nodes.conf.bak b/cmd/update_configuration/vers42/nodes.conf.bak deleted file mode 100644 index 792e48a2..00000000 --- a/cmd/update_configuration/vers42/nodes.conf.bak +++ /dev/null @@ -1,22 +0,0 @@ -nodeprofiles: - default: - comment: This profile is automatically included for each node - runtime overlay: "generic" - discoverable: false - leap: - comment: openSUSE leap - kernel version: "5.14.21" - ipmi netmask: "255.255.255.0" - keys: - foo: baar - network devices: - lan1: - gateway: 1.1.1.1 -nodes: - node01: - system overlay: "nodeoverlay" - discoverable: true - network devices: - eth0: - ipaddr: 1.2.3.4 - default: true diff --git a/userdocs/contributing/debugging.rst b/userdocs/contributing/debugging.rst index cf1c256d..d32affe0 100644 --- a/userdocs/contributing/debugging.rst +++ b/userdocs/contributing/debugging.rst @@ -21,12 +21,12 @@ vet`` on the full codebase. Running the full test suite =========================== -The Warewulf ``Makefile`` includes a ``test-it`` target which runs the +The Warewulf ``Makefile`` includes a ``test`` target which runs the full test suite. .. code-block:: console - $ make test-it + $ make test Using delve diff --git a/userdocs/contributing/development-environment-vagrant.rst b/userdocs/contributing/development-environment-vagrant.rst index 8b3f0ba4..e437f080 100644 --- a/userdocs/contributing/development-environment-vagrant.rst +++ b/userdocs/contributing/development-environment-vagrant.rst @@ -158,7 +158,7 @@ Vagrantfile git clone https://github.com/hpcng/warewulf.git cd warewulf git checkout v4.4.0 - make genconfig \ + make clean Defaults.mk \ PREFIX=/usr \ BINDIR=/usr/bin \ SYSCONFDIR=/etc \ diff --git a/userdocs/quickstart/el8.rst b/userdocs/quickstart/el8.rst index b2ab3772..4e2e0510 100644 --- a/userdocs/quickstart/el8.rst +++ b/userdocs/quickstart/el8.rst @@ -13,7 +13,7 @@ Install Warewulf and dependencies git clone https://github.com/hpcng/warewulf.git cd warewulf - make genconfig \ + make clean Defaults.mk \ PREFIX=/usr \ BINDIR=/usr/bin \ SYSCONFDIR=/etc \ diff --git a/userdocs/quickstart/el9.rst b/userdocs/quickstart/el9.rst index 575dc2b3..0ad66d77 100644 --- a/userdocs/quickstart/el9.rst +++ b/userdocs/quickstart/el9.rst @@ -14,7 +14,7 @@ Install Warewulf and dependencies git clone https://github.com/hpcng/warewulf.git cd warewulf - make genconfig \ + make clean Defaults.mk \ PREFIX=/usr \ BINDIR=/usr/bin \ SYSCONFDIR=/etc \ diff --git a/userdocs/quickstart/suse15.rst b/userdocs/quickstart/suse15.rst index 7c0c58e2..ad6f8786 100644 --- a/userdocs/quickstart/suse15.rst +++ b/userdocs/quickstart/suse15.rst @@ -16,7 +16,7 @@ Install Warewulf and dependencies git clone https://github.com/hpcng/warewulf.git cd warewulf - PREFIX=/usr SYSCONFDIR=/etc TFTPDIR=/srv/tftproot LOCALSTATEDIR=/var/lib make genconfig + PREFIX=/usr SYSCONFDIR=/etc TFTPDIR=/srv/tftproot LOCALSTATEDIR=/var/lib make clean Defaults.mk make all sudo make install diff --git a/warewulf.spec.in b/warewulf.spec.in index f0208f83..8a6b15bc 100644 --- a/warewulf.spec.in +++ b/warewulf.spec.in @@ -71,7 +71,7 @@ system for large clusters of bare metal and/or virtual systems. %build %{?with_offline:OFFLINE_BUILD=1} # Install to sharedstatedir by redirecting LOCALSTATEDIR -make genconfig \ +make Defaults.mk \ PREFIX=%{_prefix} \ BINDIR=%{_bindir} \ SYSCONFDIR=%{_sysconfdir} \ @@ -92,7 +92,8 @@ make %install export NO_BRP_STALE_LINK_ERROR=yes -make install DESTDIR=%{buildroot} +make install \ + DESTDIR=%{buildroot} %pre