Blame SPECS/osbuild-composer.spec

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