Blame SPECS/osbuild-composer.spec

478111
# Do not build with tests by default
478111
# Pass --with tests to rpmbuild to override
478111
%bcond_with tests
478111
478111
%global goipath         github.com/osbuild/osbuild-composer
478111
478111
Version:        20.1
478111
478111
%gometa
478111
478111
%global common_description %{expand:
478111
An image building service based on osbuild
478111
It is inspired by lorax-composer and exposes the same API.
478111
As such, it is a drop-in replacement.
478111
}
478111
478111
Name:           osbuild-composer
478111
Release:        1%{?dist}
478111
Summary:        An image building service based on osbuild
478111
478111
# osbuild-composer doesn't have support for building i686 images
478111
# and also RHEL and Fedora has now only limited support for this arch.
478111
ExcludeArch:    i686
478111
478111
# Upstream license specification: Apache-2.0
478111
License:        ASL 2.0
478111
URL:            %{gourl}
478111
Source0:        %{gosource}
478111
478111
478111
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
478111
BuildRequires:  systemd
478111
%if 0%{?fedora}
478111
BuildRequires:  systemd-rpm-macros
478111
BuildRequires:  git
478111
BuildRequires:  golang(github.com/aws/aws-sdk-go)
478111
BuildRequires:  golang(github.com/Azure/azure-sdk-for-go)
478111
BuildRequires:  golang(github.com/Azure/azure-storage-blob-go/azblob)
478111
BuildRequires:  golang(github.com/BurntSushi/toml)
478111
BuildRequires:  golang(github.com/coreos/go-semver/semver)
478111
BuildRequires:  golang(github.com/coreos/go-systemd/activation)
478111
BuildRequires:  golang(github.com/google/uuid)
478111
BuildRequires:  golang(github.com/julienschmidt/httprouter)
478111
BuildRequires:  golang(github.com/gobwas/glob)
478111
BuildRequires:  golang(github.com/google/go-cmp/cmp)
478111
BuildRequires:  golang(github.com/gophercloud/gophercloud)
478111
BuildRequires:  golang(github.com/stretchr/testify/assert)
478111
BuildRequires:  golang(github.com/vmware/govmomi)
478111
%endif
478111
478111
Requires: %{name}-worker = %{version}-%{release}
478111
Requires: systemd
478111
Requires: osbuild >= 18
478111
Requires: osbuild-ostree >= 18
478111
Requires: qemu-img
478111
478111
Provides: weldr
478111
478111
%if 0%{?rhel}
478111
Obsoletes: lorax-composer <= 29
478111
Conflicts: lorax-composer
478111
%endif
478111
478111
# remove in F34
478111
Obsoletes: golang-github-osbuild-composer < %{version}-%{release}
478111
Provides:  golang-github-osbuild-composer = %{version}-%{release}
478111
478111
%description
478111
%{common_description}
478111
478111
%prep
478111
%if 0%{?rhel}
478111
%forgeautosetup -p1
478111
%else
478111
%goprep
478111
%endif
478111
478111
%build
478111
%if 0%{?rhel}
478111
GO_BUILD_PATH=$PWD/_build
478111
install -m 0755 -vd $(dirname $GO_BUILD_PATH/src/%{goipath})
478111
ln -fs $PWD $GO_BUILD_PATH/src/%{goipath}
478111
cd $GO_BUILD_PATH/src/%{goipath}
478111
install -m 0755 -vd _bin
478111
export PATH=$PWD/_bin${PATH:+:$PATH}
478111
export GOPATH=$GO_BUILD_PATH:%{gopath}
478111
export GOFLAGS=-mod=vendor
478111
%endif
478111
478111
%gobuild -o _bin/osbuild-composer %{goipath}/cmd/osbuild-composer
478111
%gobuild -o _bin/osbuild-worker %{goipath}/cmd/osbuild-worker
478111
478111
478111
%if %{with tests} || 0%{?rhel}
478111
478111
# Build test binaries with `go test -c`, so that they can take advantage of
478111
# golang's testing package. The golang rpm macros don't support building them
478111
# directly. Thus, do it manually, taking care to also include a build id.
478111
#
478111
# On Fedora, also turn off go modules and set the path to the one into which
478111
# the golang-* packages install source code.
478111
%if 0%{?fedora}
478111
export GO111MODULE=off
478111
export GOPATH=%{gobuilddir}:%{gopath}
478111
%endif
478111
478111
TEST_LDFLAGS="${LDFLAGS:-} -B 0x$(od -N 20 -An -tx1 -w100 /dev/urandom | tr -d ' ')"
478111
478111
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-tests %{goipath}/cmd/osbuild-tests
478111
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-dnf-json-tests %{goipath}/cmd/osbuild-dnf-json-tests
478111
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-weldr-tests %{goipath}/internal/client/
478111
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-image-tests %{goipath}/cmd/osbuild-image-tests
478111
478111
%endif
478111
478111
%install
478111
install -m 0755 -vd                                         %{buildroot}%{_libexecdir}/osbuild-composer
478111
install -m 0755 -vp _bin/osbuild-composer                   %{buildroot}%{_libexecdir}/osbuild-composer/
478111
install -m 0755 -vp _bin/osbuild-worker                     %{buildroot}%{_libexecdir}/osbuild-composer/
478111
install -m 0755 -vp dnf-json                                %{buildroot}%{_libexecdir}/osbuild-composer/
478111
478111
install -m 0755 -vd                                         %{buildroot}%{_datadir}/osbuild-composer/repositories
478111
install -m 0644 -vp repositories/*                          %{buildroot}%{_datadir}/osbuild-composer/repositories/
478111
478111
install -m 0755 -vd                                         %{buildroot}%{_unitdir}
478111
install -m 0644 -vp distribution/*.{service,socket}         %{buildroot}%{_unitdir}/
478111
478111
install -m 0755 -vd                                         %{buildroot}%{_sysusersdir}
478111
install -m 0644 -vp distribution/osbuild-composer.conf      %{buildroot}%{_sysusersdir}/
478111
478111
install -m 0755 -vd                                         %{buildroot}%{_localstatedir}/cache/osbuild-composer/dnf-cache
478111
478111
%if %{with tests} || 0%{?rhel}
478111
478111
install -m 0755 -vd                                         %{buildroot}%{_libexecdir}/tests/osbuild-composer
478111
install -m 0755 -vp _bin/osbuild-tests                      %{buildroot}%{_libexecdir}/tests/osbuild-composer/
478111
install -m 0755 -vp _bin/osbuild-weldr-tests                %{buildroot}%{_libexecdir}/tests/osbuild-composer/
478111
install -m 0755 -vp _bin/osbuild-dnf-json-tests             %{buildroot}%{_libexecdir}/tests/osbuild-composer/
478111
install -m 0755 -vp _bin/osbuild-image-tests                %{buildroot}%{_libexecdir}/tests/osbuild-composer/
478111
install -m 0755 -vp tools/image-info                        %{buildroot}%{_libexecdir}/osbuild-composer/
478111
478111
install -m 0755 -vd                                         %{buildroot}%{_datadir}/tests/osbuild-composer
478111
install -m 0644 -vp test/azure-deployment-template.json     %{buildroot}%{_datadir}/tests/osbuild-composer/
478111
478111
install -m 0755 -vd                                         %{buildroot}%{_datadir}/tests/osbuild-composer/cases
478111
install -m 0644 -vp test/cases/*                            %{buildroot}%{_datadir}/tests/osbuild-composer/cases/
478111
install -m 0755 -vd                                         %{buildroot}%{_datadir}/tests/osbuild-composer/keyring
478111
install -m 0600 -vp test/keyring/*                          %{buildroot}%{_datadir}/tests/osbuild-composer/keyring/
478111
478111
install -m 0755 -vd                                         %{buildroot}%{_datadir}/tests/osbuild-composer/cloud-init
478111
install -m 0644 -vp test/cloud-init/*                       %{buildroot}%{_datadir}/tests/osbuild-composer/cloud-init/
478111
478111
%endif
478111
478111
%check
478111
%if 0%{?rhel}
478111
export GOFLAGS=-mod=vendor
478111
export GOPATH=$PWD/_build:%{gopath}
478111
%gotest ./...
478111
%else
478111
%gocheck
478111
%endif
478111
478111
%post
478111
%systemd_post osbuild-composer.service osbuild-composer.socket osbuild-remote-worker.socket
478111
478111
%preun
478111
%systemd_preun osbuild-composer.service osbuild-composer.socket osbuild-remote-worker.socket
478111
478111
%postun
478111
%systemd_postun_with_restart osbuild-composer.service osbuild-composer.socket osbuild-remote-worker.socket
478111
478111
%files
478111
%license LICENSE
478111
%doc README.md
478111
%{_libexecdir}/osbuild-composer/osbuild-composer
478111
%{_libexecdir}/osbuild-composer/dnf-json
478111
%{_datadir}/osbuild-composer/
478111
%{_unitdir}/osbuild-composer.service
478111
%{_unitdir}/osbuild-composer.socket
478111
%{_unitdir}/osbuild-remote-worker.socket
478111
%{_sysusersdir}/osbuild-composer.conf
478111
478111
%package worker
478111
Summary:    The worker for osbuild-composer
478111
Requires:   systemd
478111
Requires:   osbuild
478111
478111
# remove in F34
478111
Obsoletes: golang-github-osbuild-composer-worker < %{version}-%{release}
478111
Provides:  golang-github-osbuild-composer-worker = %{version}-%{release}
478111
478111
%description worker
478111
The worker for osbuild-composer
478111
478111
%files worker
478111
%{_libexecdir}/osbuild-composer/osbuild-worker
478111
%{_unitdir}/osbuild-worker@.service
478111
%{_unitdir}/osbuild-remote-worker@.service
478111
478111
%post worker
478111
%systemd_post osbuild-worker@.service osbuild-remote-worker@.service
478111
478111
%preun worker
478111
# systemd_preun uses systemctl disable --now which doesn't work well with template services.
478111
# See https://github.com/systemd/systemd/issues/15620
478111
# The following lines mimicks its behaviour by running two commands:
478111
478111
# disable and stop all the worker services
478111
systemctl --no-reload disable osbuild-worker@.service osbuild-remote-worker@.service
478111
systemctl stop "osbuild-worker@*.service" "osbuild-remote-worker@*.service"
478111
478111
%postun worker
478111
# restart all the worker services
478111
%systemd_postun_with_restart "osbuild-worker@*.service" "osbuild-remote-worker@*.service"
478111
478111
%if %{with tests} || 0%{?rhel}
478111
478111
%package tests
478111
Summary:    Integration tests
478111
Requires:   %{name} = %{version}-%{release}
478111
Requires:   composer-cli
478111
Requires:   createrepo_c
478111
Requires:   genisoimage
478111
Requires:   qemu-kvm-core
478111
Requires:   systemd-container
478111
%ifarch %{arm}
478111
Requires:   edk2-aarch64
478111
%endif
478111
478111
%description tests
478111
Integration tests to be run on a pristine-dedicated system to test the osbuild-composer package.
478111
478111
%files tests
478111
%{_libexecdir}/tests/osbuild-composer/
478111
%{_datadir}/tests/osbuild-composer/
478111
%{_libexecdir}/osbuild-composer/image-info
478111
478111
%endif
478111
478111
%changelog
478111
* Thu Sep 03 2020 Tom Gundersen <tgunders@redhat.com> - 20.1-1
478111
- New upstream release 20.1 (rhbz#1872370)
478111
478111
* Sun Aug 23 2020 Tom Gundersen <tgunders@redhat.com> - 20-1
478111
- New upstream release 20 (rhbz#1871184 and rhbz#1871179)
478111
478111
* Thu Aug 13 2020 Tom Gundersen <tgunders@redhat.com> - 19-1
478111
- New upstream release 19 (rhbz#1866015 and rhbz#1866013)
478111
478111
* Thu Jul 09 2020 Ondrej Budai <obudai@redhat.com> - 17-1
478111
- New upstream release 17 (rhbz#1831653)
478111
- Obsolete lorax-composer in favor of osbuild-composer (rhbz#1836844)
478111
478111
* Mon Jun 29 2020 Ondrej Budai <obudai@redhat.com> - 16-1
478111
- New upstream release 16 (rhbz#1831653)
478111
478111
* Fri Jun 12 2020 Ondrej Budai <obudai@redhat.com> - 15-1
478111
- New upstream release 15 (rhbz#1831653)
478111
478111
* Thu Jun 04 2020 Ondrej Budai <obudai@redhat.com> - 14-1
478111
- New upstream release 14 (rhbz#1831653)
478111
478111
* Thu May 28 2020 Ondrej Budai <obudai@redhat.com> - 13-1
478111
- New upstream release 13 (rhbz#1831653)
478111
478111
* Tue May 05 2020 Ondrej Budai <obudai@redhat.com> - 11-1
478111
- Initial package (renamed from golang-github-osbuild-composer) (rhbz#1771887)