From f7396ae5bebc75eb8566ca7e87112030160a238f Mon Sep 17 00:00:00 2001 From: jcsiadal Date: Mon, 1 Nov 2021 11:32:59 -0700 Subject: [PATCH] Updates to build an RPM Signed-off-by: jcsiadal --- Makefile | 23 ++++++--- etc/nodes.conf | 4 ++ internal/pkg/node/datastructure.go | 23 ++------- warewulf.spec.in | 83 +++++++++++++++++++++--------- 4 files changed, 81 insertions(+), 52 deletions(-) create mode 100644 etc/nodes.conf diff --git a/Makefile b/Makefile index 0babd543..053a7d94 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,7 @@ files: all install -d -m 0755 $(DESTDIR)/usr/share/man/man1 test -f $(DESTDIR)/etc/warewulf/warewulf.conf || install -m 644 etc/warewulf.conf $(DESTDIR)/etc/warewulf/ test -f $(DESTDIR)/etc/warewulf/hosts.tmpl || install -m 644 etc/hosts.tmpl $(DESTDIR)/etc/warewulf/ + test -f $(DESTDIR)/etc/warewulf/nodes.conf || install -m 640 etc/nodes.conf $(DESTDIR)/etc/warewulf/ cp -r etc/dhcp $(DESTDIR)/etc/warewulf/ cp -r etc/ipxe $(DESTDIR)/etc/warewulf/ cp -r overlays $(DESTDIR)/var/warewulf/ @@ -74,12 +75,13 @@ files: all install -c -m 0644 include/firewalld/warewulf.xml $(DESTDIR)/usr/lib/firewalld/services mkdir -p $(DESTDIR)/usr/lib/systemd/system install -c -m 0644 include/systemd/warewulfd.service $(DESTDIR)/usr/lib/systemd/system - ./bash_completion $(DESTDIR)/etc/bash_completion.d/warewulf - ./man_page $(DESTDIR)/usr/share/man/man1 - gzip --force $(DESTDIR)/usr/share/man/man1/wwctl*1 -# systemctl daemon-reload -# cp -r tftpboot/* /var/lib/tftpboot/warewulf/ipxe/ -# restorecon -r /var/lib/tftpboot/warewulf + cp etc/bash_completion.d/warewulf $(DESTDIR)/etc/bash_completion.d/ + cp usr/share/man/man1/* $(DESTDIR)/usr/share/man/man1/ + +init: + systemctl daemon-reload + cp -r tftpboot/* /var/lib/tftpboot/warewulf/ipxe/ + restorecon -r /var/lib/tftpboot/warewulf debfiles: debian chmod +x $(DESTDIR)/var/warewulf/overlays/system/debian/init @@ -95,10 +97,15 @@ wwclient: cd cmd/wwclient; CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags '-extldflags -static' -o ../../wwclient bash_completion: - cd cmd/bash_completion; go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../bash_completion + cd cmd/bash_completion && go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../bash_completion + install -d -m 0755 ./etc/bash_completion.d/ + ./bash_completion ./etc/bash_completion.d/warewulf man_page: - cd cmd/man_page; go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../man_page + cd cmd/man_page && go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../man_page + install -d -m 0755 ./usr/share/man/man1 + ./man_page ./usr/share/man/man1 + gzip --force ./usr/share/man/man1/wwctl*1 dist: vendor rm -rf _dist/warewulf-$(VERSION) diff --git a/etc/nodes.conf b/etc/nodes.conf new file mode 100644 index 00000000..3999a8cd --- /dev/null +++ b/etc/nodes.conf @@ -0,0 +1,4 @@ +nodeprofiles: + default: + comment: This profile is automatically included for each node +nodes: {} diff --git a/internal/pkg/node/datastructure.go b/internal/pkg/node/datastructure.go index a7f55ae6..17be4d41 100644 --- a/internal/pkg/node/datastructure.go +++ b/internal/pkg/node/datastructure.go @@ -1,9 +1,6 @@ package node import ( - "fmt" - "os" - "github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/wwlog" ) @@ -104,22 +101,10 @@ type NetDevEntry struct { } func init() { - //TODO: Check to make sure nodes.conf is found + // Check that nodes.conf is found if !util.IsFile(ConfigFile) { - c, err := os.OpenFile(ConfigFile, os.O_RDWR|os.O_CREATE, 0640) - if err != nil { - wwlog.Printf(wwlog.ERROR, "Could not create new configuration file: %s\n", err) - // just return silently, as init is also called for bash_completion - return - } - - fmt.Fprintf(c, "nodeprofiles:\n") - fmt.Fprintf(c, " default:\n") - fmt.Fprintf(c, " comment: This profile is automatically included for each node\n") - fmt.Fprintf(c, "nodes: {}\n") - - c.Close() - - wwlog.Printf(wwlog.INFO, "Created default node configuration\n") + wwlog.Printf(wwlog.WARN, "Missing node configuration file\n") + // just return silently, as init is also called for bash_completion + return } } diff --git a/warewulf.spec.in b/warewulf.spec.in index 7e771cc1..eca239a7 100644 --- a/warewulf.spec.in +++ b/warewulf.spec.in @@ -1,74 +1,107 @@ +%global wwgroup warewulf +%{!?wwshared: %global wwshared %{_localstatedir}} %define debug_package %{nil} Name: warewulf -Summary: A suite of tools for bare metal provisioning of containers +Summary: A provisioning system for large clusters of bare metal and/or virtual systems Version: @VERSION@ -Release: 1%{?dist} -License: BSD -Source: https://github.com/hpcng/warewulf/archive/refs/tags/%{name}-%{version}.tar.gz +Release: 1 +License: BSD-3-Clause +URL: https://github.com/hpcng/warewulf +Source: https://github.com/hpcng/warewulf/archive/refs/tags/v%{version}.tar.gz + ExclusiveOS: linux +Conflicts: warewulf < 4 +Conflicts: warewulf-common +Conflicts: warewulf-cluster +Conflicts: warewulf-vnfs +Conflicts: warewulf-provision +Conflicts: warewulf-ipmi + BuildRequires: make -BuildRequires: golang %if 0%{?rhel} BuildRequires: systemd +BuildRequires: golang +Requires: tftp-server +Requires: nfs-utils %else +# sle_version BuildRequires: systemd-rpm-macros +BuildRequires: go +Requires: tftp +Requires: nfs-kernel-server %endif -%if 0%{?rhel} > 7 +%if 0%{?rhel} >= 8 || 0%{?sle_version} Requires: dhcp-server %else +# rhel < 8 Requires: dhcp %endif -Requires: tftp-server -Requires: nfs-utils - %description -Warewulf is a bare metal container provisioning system. +Warewulf is a stateless and diskless container operating system provisioning +system for large clusters of bare metal and/or virtual systems. + %prep -%setup -q +%setup -q -n %{name}-%{version} + %build make all + %install %make_install DESTDIR=%{buildroot} %{?mflags_install} + %pre -getent group warewulf >/dev/null || groupadd -r warewulf +getent group %{wwgroup} >/dev/null || groupadd -r %{wwgroup} + %post %systemd_post warewulfd.service + %preun %systemd_preun warewulfd.service + %postun %systemd_postun_with_restart warewulfd.service -%files -%attr(0755, root, warewulf) %dir %{_sysconfdir}/%{name} -%config(noreplace) %{_sysconfdir}/%{name}/* +%files +%defattr(-, root, %{wwgroup}) +%dir %{_sysconfdir}/%{name} +%config(noreplace) %{_sysconfdir}/%{name}/* +%config(noreplace) %attr(0640,-,-) %{_sysconfdir}/%{name}/nodes.conf %{_sysconfdir}/bash_completion.d/warewulf -%{_bindir}/wwctl +%dir %{wwshared}/%{name} +%{wwshared}/%{name}/overlays/runtime/* +%{wwshared}/%{name}/overlays/system/* -%{_prefix}/lib/firewalld/services/warewulf.xml - -%{_unitdir}/warewulfd.service - -%attr(0755, root, warewulf) %dir %{_localstatedir}/%{name} -%{_localstatedir}/%{name}/overlays/runtime/* -%{_localstatedir}/%{name}/overlays/system/* - -%{_mandir}/man1/wwctl* +%attr(-, root, root) %{_bindir}/wwctl +%if 0%{?rhel} +%attr(-, root, root) %{_prefix}/lib/firewalld/services/warewulf.xml +%else +# sle_version +%attr(-, root, root) %{_libexecdir}/firewalld/services/warewulf.xml +%endif +%attr(-, root, root) %{_unitdir}/warewulfd.service +%attr(-, root, root) %{_mandir}/man1/wwctl* %changelog +* Mon Nov 1 2021 Jeremy Siadal - 4.2.0-1 +- Add support for OpenSUSE +- Update file attribs +- Update license string +- Make shared store relocatable + * Fri Sep 24 2021 Michael L. Young - 4.2.0-1 - Update spec file to use systemd macros - Use macros to refer to system paths