File nomad.spec of Package nomad
#
# spec file for package nomad
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: nomad
Version: 1.6.10
Release: 0
Summary: A Distributed, Highly Available, Datacenter-Aware Scheduler
License: BUSL-1.1
Group: System/Management
URL: https://www.nomadproject.io/
Source0: %{name}-%{version}.tar.gz
Source2: sysconfig.%{name}
# we dont use dist/systemd/nomad.service because we
# add more defaults to the command line options
# to avoid having them in the configuration
Source3: nomad.service
# We modify the example configs so that they don't include
# changing /var/lib and /etc paths
Source4: client.hcl
Source5: server.hcl
Source6: README.SUSE.md
Source20: nomad-rpc.xml
Source21: nomad-http.xml
Source22: nomad-serf.xml
Source98: node_modules-%{version}.tar.xz
Source99: vendor.tar.gz
BuildRequires: fillup
BuildRequires: go-bindata-assetfs
BuildRequires: golang(API) >= 1.21
BuildRequires: golang-packaging
BuildRequires: hclfmt
# Ember is currently only support up to NodeJS 14
BuildRequires: nodejs-devel
# BuildRequires: nodejs14-node-sass
BuildRequires: systemd-rpm-macros
BuildRequires: xz
Requires: system-user-nomad
%{go_provides}
%{?systemd_requires}
%description
PLEASE NOTE:
This is Business Source License (BSL, or BUSL) licensed package. If you like to
use Nomad without it please see 1.6.2 version which is MPL-2.0 licensed.
More information see https://www.hashicorp.com/license-faq
Nomad is a cluster manager, designed for both long lived services and short
lived batch processing workloads. Developers use a declarative job
specification to submit work, and Nomad ensures constraints are satisfied and
resource utilization is optimized by efficient task packing. Nomad supports all
major operating systems and virtualized, containerized, or standalone
applications.
%prep
%setup -q
%setup -q -T -D -a 99
cd ui
tar xf %{SOURCE98}
%build
cd ui
# Build embeddable javascript and css which
# contains everything
node_modules/.bin/ember build --environment=production --silent
# Build embeddable go file for compiling
go-bindata-assetfs -pkg agent -prefix ui -modtime 1480000000 -tags ui -o bindata_assetfs.go ./dist/...
mv bindata_assetfs.go ../command/agent
cd ..
%ifnarch ppc64 ppc64le
export GO_FLAGS="-buildmode=pie"
%endif
export NOMAD_UI_TAG="ui"
go build -mod=vendor -tags ui \
-o %{name}-%{version} \
${GO_FLAGS}
%install
mkdir -p %{buildroot}%{_bindir}
install -m755 %{name}-%{version} %{buildroot}%{_bindir}/%{name}
# systemd service
install -D -m 444 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}.service
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
# firewall port
mkdir -p %{buildroot}%{_prefix}/lib/firewalld/services/
# Make sure there is all required port FirewallD files
install -m644 %{SOURCE20} %{buildroot}%{_prefix}/lib/firewalld/services/nomad-rpc.xml
install -m644 %{SOURCE21} %{buildroot}%{_prefix}/lib/firewalld/services/nomad-http.xml
install -m644 %{SOURCE22} %{buildroot}%{_prefix}/lib/firewalld/services/nomad-serf.xml
# Create default configuration file
install -d -m 750 %{buildroot}%{_sysconfdir}/%{name}
echo "# See %{_docdir}/%{name}/server.hcl and %{_docdir}/%{name}/client.hcl" > %{buildroot}%{_sysconfdir}/%{name}/config.hcl
echo "# For example configuration." >> %{buildroot}%{_sysconfdir}/%{name}/config.hcl
# state data
install -d -m 750 %{buildroot}%{_localstatedir}/lib/%{name}
# sysconfig file
install -D -m 644 %{SOURCE2} %{buildroot}%{_fillupdir}/sysconfig.nomad
# doc and examples
mkdir -p %{buildroot}%{_docdir}/%{name}
install -m644 %{SOURCE4} %{buildroot}%{_docdir}/%{name}/client.hcl
install -m644 %{SOURCE5} %{buildroot}%{_docdir}/%{name}/server.hcl
install -m644 %{SOURCE6} %{buildroot}%{_docdir}/%{name}/README.SUSE.md
%pre
%service_add_pre %{name}.service
%post
%service_add_post %{name}.service
%{fillup_only -n %{name}}
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
%files
%license LICENSE
%doc CHANGELOG.md README.md
%{_bindir}/%{name}
%{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%dir %{_prefix}/lib/firewalld
%dir %{_prefix}/lib/firewalld/services
%{_prefix}/lib/firewalld/services/nomad-rpc.xml
%{_prefix}/lib/firewalld/services/nomad-http.xml
%{_prefix}/lib/firewalld/services/nomad-serf.xml
%{_fillupdir}/sysconfig.nomad
%{_docdir}/%{name}/*.hcl
%{_docdir}/%{name}/README.SUSE.md
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/config.hcl
%dir %attr(0750,%{name},root) %{_sysconfdir}/%{name}
%dir %{_localstatedir}/lib/%{name}
%dir %attr(0750,%{name},root) %{_localstatedir}/lib/%{name}
%changelog