From 8827937a9d4d767592fe7eb80b55913f5dcd7ae0 Mon Sep 17 00:00:00 2001 From: jcsiadal Date: Wed, 9 Mar 2022 07:32:02 +0000 Subject: [PATCH] Update for LSB compliance Signed-off-by: jcsiadal --- Makefile | 18 +++++++++--------- internal/app/wwclient/root.go | 4 ++-- internal/pkg/buildconfig/defaults.go | 8 ++++---- internal/pkg/buildconfig/setconfigs.go.in | 2 +- warewulf.spec.in | 5 +++-- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index fe3fb52f..7bf11b7f 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ -include Defaults.mk # Linux distro (try and set to /etc/os-release ID) -OS ?= $(sed -n "s/^ID\s*=\s*['"\""]\(.*\)['"\""]/\1/p" /etc/os-release) +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 @@ -14,7 +15,7 @@ WAREWULF ?= warewulf VERSION ?= 4.2.0 GIT_TAG := $(shell test -e .git && git describe --tags --long --first-parent --always) -ifndef $(GIT_TAG) +ifndef GIT_TAG ifdef $(filter $(OS),ubuntu debian) RELEASE ?= 1.git_$(subst -,+,$(GIT_TAG)) else @@ -30,12 +31,12 @@ ifneq ($(OS),) endif # Always default to GNU autotools default paths if PREFIX has been redefined -ifndef $(PREFIX) +ifdef PREFIX USE_LSB_PATHS := false endif # System directory paths -VARLIST += PREFIX BINDIR SYSCONFDIR SRVDIR DATADIR MANDIR DOCDIR LOCALSTATEDIR SHAREDSTATEDIR +VARLIST += PREFIX BINDIR SYSCONFDIR SRVDIR DATADIR MANDIR DOCDIR LOCALSTATEDIR PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin SYSCONFDIR ?= $(PREFIX)/etc @@ -46,11 +47,9 @@ DOCDIR ?= $(DATADIR)/doc ifeq ($(USE_LSB_PATHS),true) SRVDIR ?= /srv LOCALSTATEDIR ?= /var/local - SHAREDSTATEDIR ?= /var/lib else SRVDIR ?= $(PREFIX)/srv LOCALSTATEDIR ?= $(PREFIX)/var - SHAREDSTATEDIR ?= $(PREFIX)/com endif # OS-Specific Service Locations @@ -70,9 +69,9 @@ TFTPDIR ?= /var/lib/tftpboot # Warewulf directory paths VARLIST += WWCLIENTDIR WWCONFIGDIR WWPROVISIONDIR WWOVERLAYDIR WWCHROOTDIR WWTFTPDIR WWDOCDIR WWDATADIR WWCONFIGDIR := $(SYSCONFDIR)/$(WAREWULF) -WWPROVISIONDIR := $(LOCALSTATEDIR)$(WAREWULF) -WWOVERLAYDIR := $(LOCALSTATEDIR)$(WAREWULF)/overlays -WWCHROOTDIR := $(LOCALSTATEDIR)$(WAREWULF)/chroots +WWPROVISIONDIR := $(LOCALSTATEDIR)/$(WAREWULF) +WWOVERLAYDIR := $(LOCALSTATEDIR)/$(WAREWULF)/overlays +WWCHROOTDIR := $(LOCALSTATEDIR)/$(WAREWULF)/chroots WWTFTPDIR := $(TFTPDIR)/$(WAREWULF) WWDOCDIR := $(DOCDIR)/$(WAREWULF) WWDATADIR := $(DATADIR)/$(WAREWULF) @@ -169,6 +168,7 @@ files: all install -d -m 0755 $(DESTDIR)$(WWDOCDIR) install -d -m 0755 $(DESTDIR)$(FIREWALLDDIR) install -d -m 0755 $(DESTDIR)$(SYSTEMDDIR) + install -d -m 0755 $(DESTDIR)$(WWDATADIR) 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) cp -r etc/examples $(DESTDIR)$(WWCONFIGDIR)/ diff --git a/internal/app/wwclient/root.go b/internal/app/wwclient/root.go index e61534fd..8b6c590c 100644 --- a/internal/app/wwclient/root.go +++ b/internal/app/wwclient/root.go @@ -63,7 +63,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { return errors.New("found pidfile " + PIDFile + " not starting") } - if os.Args[0] == path.Join(buildconfig.WWCLIENTLOC(), "wwclient") { + if os.Args[0] == path.Join(buildconfig.WWCLIENTDIR(), "wwclient") { err := os.Chdir("/") if err != nil { wwlog.Printf(wwlog.ERROR, "failed to change dir: %s", err) @@ -75,7 +75,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } else { fmt.Printf("Called via: %s\n", os.Args[0]) fmt.Printf("Runtime overlay is being put in '/warewulf/wwclient-test' rather than '/'\n") - fmt.Printf("For full functionality call with: %s\n", path.Join(buildconfig.WWCLIENTLOC(), "wwclient")) + fmt.Printf("For full functionality call with: %s\n", path.Join(buildconfig.WWCLIENTDIR(), "wwclient")) err := os.MkdirAll("/warewulf/wwclient-test", 0755) if err != nil { wwlog.Printf(wwlog.ERROR, "failed to create dir: %s", err) diff --git a/internal/pkg/buildconfig/defaults.go b/internal/pkg/buildconfig/defaults.go index a648346b..fc714a3d 100644 --- a/internal/pkg/buildconfig/defaults.go +++ b/internal/pkg/buildconfig/defaults.go @@ -15,7 +15,7 @@ var ( wwprovisiondir string = "UNDEF" version string = "UNDEF" release string = "UNDEF" - wwclientloc string = "UNDEF" + wwclientdir string = "UNDEF" datadir string = "UNDEF" ) @@ -84,7 +84,7 @@ func RELEASE() string { return release } -func WWCLIENTLOC() string { - wwlog.Printf(wwlog.DEBUG, "WWCLIENTLOC = '%s'\n", wwclientloc) - return wwclientloc +func WWCLIENTDIR() string { + wwlog.Printf(wwlog.DEBUG, "WWCLIENTDIR = '%s'\n", wwclientdir) + return wwclientdir } diff --git a/internal/pkg/buildconfig/setconfigs.go.in b/internal/pkg/buildconfig/setconfigs.go.in index 43c9f87c..e10303e3 100644 --- a/internal/pkg/buildconfig/setconfigs.go.in +++ b/internal/pkg/buildconfig/setconfigs.go.in @@ -14,5 +14,5 @@ func init() { wwprovisiondir = "@WWPROVISIONDIR@" version = "@VERSION@" release = "@RELEASE@" - wwclientloc = "@WWCLIENTLOC@" + wwclientdir = "@WWCLIENTDIR@" } diff --git a/warewulf.spec.in b/warewulf.spec.in index 2bb82d81..a4b2dbac 100644 --- a/warewulf.spec.in +++ b/warewulf.spec.in @@ -61,12 +61,13 @@ system for large clusters of bare metal and/or virtual systems. %build +# Install to sharedstatedir by redirecting LOCALSTATEDIR make genconfig \ PREFIX=%{_prefix} \ BINDIR=%{_bindir} \ SYSCONFDIR=%{_sysconfdir} \ DATADIR=%{_datadir} \ - LOCALSTATEDIR=%{_localstatedir} \ + LOCALSTATEDIR=%{_sharedstatedir} \ SHAREDSTATEDIR=%{_sharedstatedir} \ MANDIR=%{_mandir} \ INFODIR=%{_infodir} \ @@ -76,7 +77,7 @@ make genconfig \ SYSTEMDDIR=%{_unitdir} \ BASHCOMPDIR=/etc/bash_completion.d/ \ FIREWALLDDIR=/usr/lib/firewalld/services \ - WWCLIENTDIR=%{_libexecdir}/warewulf + WWCLIENTDIR=/warewulf make