Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ weldr-client-*.tar.gz
container_cli_built.info
weldr-client.spec
rpmbuild/
clog
gpg-*.key
3 changes: 2 additions & 1 deletion Containerfile.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM registry.fedoraproject.org/fedora:rawhide
RUN dnf -y install make tar python3-dnf-plugins-core go-rpm-macros git rpm-build dnf5-plugins
RUN dnf -y install make tar python3-dnf-plugins-core \
go-rpm-macros git rpm-build dnf5-plugins go-vendor-tools
ARG VERSION
COPY weldr-client-*.tar.gz .
RUN mkdir /source && tar --strip=1 -C /source -xvf weldr-client-*.tar.gz
Expand Down
23 changes: 16 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ install-tests: composer-cli-tests

weldr-client.spec: weldr-client.spec.in
sed -e "s/%%VERSION%%/$(VERSION)/g" -e "s/%%GPGKEY%%/$(GPGKEY)/g" < $< > $@
$(MAKE) -s changelog >> $@
$(MAKE) -s changelog >> clog
@echo "Use the contents of ./clog when committing the new spec file"

tag:
@if [ -z "$(GPGKEY)" ]; then echo "ERROR: The git config user.signingkey must be set" ; exit 1; fi
Expand Down Expand Up @@ -67,6 +68,11 @@ bumpver:
archive:
git archive --prefix=weldr-client-$(VERSION)/ --format=tar.gz HEAD > weldr-client-$(VERSION).tar.gz

vendor-archive:
go_vendor_archive create --config ./tools/go-vendor-tools.toml weldr-client.spec
go_vendor_license --config ./tools/go-vendor-tools.toml --path weldr-client.spec \
report --update-spec --prompt --autofill=auto

RPM_SPECFILE=rpmbuild/SPECS/weldr-client.spec
RPM_TARBALL=rpmbuild/SOURCES/weldr-client-$(VERSION).tar.gz
RPM_TARBALL_SIG=rpmbuild/SOURCES/weldr-client-$(VERSION).tar.gz.asc
Expand All @@ -75,9 +81,10 @@ $(RPM_SPECFILE): weldr-client.spec
mkdir -p $(CURDIR)/rpmbuild/SPECS
cp weldr-client.spec $(CURDIR)/rpmbuild/SPECS

$(RPM_TARBALL): archive sign
$(RPM_TARBALL): archive vendor-archive sign
mkdir -p $(CURDIR)/rpmbuild/SOURCES
cp weldr-client-$(VERSION).tar.gz* gpg-$(GPGKEY).key rpmbuild/SOURCES/
cp weldr-client-$(VERSION).tar.gz* weldr-client-$(VERSION)-vendor.tar.bz2 \
gpg-$(GPGKEY).key ./tools/go-vendor-tools.toml rpmbuild/SOURCES/

builddep: $(RPM_SPECFILE)
dnf builddep -y -D 'with 1' $(RPM_SPECFILE)
Expand All @@ -96,19 +103,21 @@ rpm: $(RPM_SPECFILE) $(RPM_TARBALL)
--with tests \
$(RPM_SPECFILE)

scratch-srpm: $(RPM_SPECFILE) archive
scratch-srpm: $(RPM_SPECFILE) archive vendor-archive
mkdir -p $(CURDIR)/rpmbuild/SOURCES
cp weldr-client-$(VERSION).tar.gz* rpmbuild/SOURCES/
cp weldr-client-$(VERSION).tar.gz* weldr-client-$(VERSION)-vendor.tar.bz2 \
./tools/go-vendor-tools.toml rpmbuild/SOURCES/
rpmbuild -bs \
--define "_topdir $(CURDIR)/rpmbuild" \
--define "commit $(VERSION)" \
--with tests \
--without signed \
$(RPM_SPECFILE)

scratch-rpm: $(RPM_SPECFILE) archive
scratch-rpm: $(RPM_SPECFILE) archive vendor-archive
mkdir -p $(CURDIR)/rpmbuild/SOURCES
cp weldr-client-$(VERSION).tar.gz* rpmbuild/SOURCES/
cp weldr-client-$(VERSION).tar.gz* weldr-client-$(VERSION)-vendor.tar.bz2 \
./tools/go-vendor-tools.toml rpmbuild/SOURCES/
rpmbuild -bb \
--define "_topdir $(CURDIR)/rpmbuild" \
--define "commit $(VERSION)" \
Expand Down
19 changes: 12 additions & 7 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,21 @@ click on 'Publish release'

## Create a Fedora release

Run `make weldr-client.spec` to generate a new .spec file that includes the
changelog. Copy it to your weldr-client dist-git repo. Also copy the
`gpg-KEYID.key` file if it isn't already there.
Run `make weldr-client.spec` to generate a new .spec file. The changelog is in
`./clog` and should be used as the commit message for the spec change. Copy
the new `weldr-client.spec` and `./clog` to your weldr-client dist-git repo.
Also copy the `gpg-KEYID.key` file if it isn't already there.

Add the archive, signature, and public key:
In the dist-git repo update the vendor archive. This requires that the
`go-vendor-tools` package be installed. Run this to create the vendor archive:

fedpkg new-sources weldr-client-35.6.tar.gz* gpg-*key
make update-vendor

Generate commit message with `fedpkg clog --raw` and edit it to your liking. Commit the
changes with `git add -u && git commit -F clog`.
Add the source archive, vendor archive, signature, and public key:

fedpkg new-sources weldr-client-36.1.tar.gz* weldr-client-36.1-vendor.tar.bz2 gpg-*key

Commit the changes with `git add -u && git commit -F clog`.

Check that the changes look ok with `git show`, do a mock build with `fedpkg mockbuild`
and if that all looks ok, push and build:
Expand Down
4 changes: 4 additions & 0 deletions tools/go-vendor-tools.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[archive]

[licensing]
detector = "askalono"
111 changes: 42 additions & 69 deletions weldr-client.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,111 +3,85 @@
# Pass --without signed to skip gpg signed tar.gz (DO NOT DO THAT IN PRODUCTION)
%bcond_without signed

# https://github.com/osbuild/weldr-client
%global goipath github.com/osbuild/weldr-client/v2
Version: %%VERSION%%

Name: weldr-client
Version: %%VERSION%%
Release: 1%{?dist}
# Upstream license specification: Apache-2.0
License: Apache-2.0
Summary: Command line utility to control osbuild-composer
%gometa -L -f

%gometa
Url: %{gourl}
Source0: https://github.com/osbuild/weldr-client/releases/download/v%{version}/%{name}-%{version}.tar.gz

Name: weldr-client
Release: %autorelease
Summary: Go client library and cmdline tool for WELDR API servers like lorax-composer and osbuild-composer

# Generated by go-vendor-tools
License: Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT
URL: %{gourl}
Source0: %{gosource}
# Generated by go-vendor-tools
Source1: %{archivename}-vendor.tar.bz2
Source2: go-vendor-tools.toml
%if %{with signed}
Source1: https://github.com/osbuild/weldr-client/releases/download/v%{version}/%{name}-%{version}.tar.gz.asc
Source2: https://keys.openpgp.org/vks/v1/by-fingerprint/%%GPGKEY%%#/gpg-%%GPGKEY%%.key
Source3: %{gosource}.asc
Source4: https://keys.openpgp.org/vks/v1/by-fingerprint/%%GPGKEY%%#/gpg-%%GPGKEY%%.key
%endif

Obsoletes: composer-cli < 35.0
Provides: composer-cli = %{version}-%{release}

Requires: diffutils

BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
%if 0%{?fedora}
BuildRequires: golang(github.com/BurntSushi/toml)
BuildRequires: golang(github.com/spf13/cobra)
# Required for tests and %check
BuildRequires: golang(github.com/stretchr/testify/assert)
BuildRequires: golang(github.com/stretchr/testify/require)
%endif

BuildRequires: go-vendor-tools
BuildRequires: git-core
BuildRequires: make
BuildRequires: gnupg2


%description
Command line utility to control osbuild-composer
Go client library and cmdline tool for WELDR API servers like lorax-composer
and osbuild-composer.

%prep
%if %{with signed}
%{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}'
%endif
%if 0%{?rhel}
%forgeautosetup -p1
%else
%goprep
%{gpgverify} --keyring='%{SOURCE4}' --signature='%{SOURCE3}' --data='%{SOURCE0}'
%endif
%goprep -p1
tar -xf %{S:1}

%build
export LDFLAGS="-X %{goipath}/cmd/composer-cli/root.Version=%{version} "

%if 0%{?rhel}
GO_BUILD_PATH=$PWD/_build
install -m 0755 -vd $(dirname $GO_BUILD_PATH/src/%{goipath})
ln -fs $PWD $GO_BUILD_PATH/src/%{goipath}
cd $GO_BUILD_PATH/src/%{goipath}
install -m 0755 -vd _bin
export PATH=$PWD/_bin${PATH:+:$PATH}
export GOPATH=$GO_BUILD_PATH:%{gopath}
export GOFLAGS=-mod=vendor
%else
export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"
export GO111MODULE=off
%endif
%gobuild -o composer-cli %{goipath}/cmd/composer-cli
%generate_buildrequires
%go_vendor_license_buildrequires -c %{S:2}

%build
%global gomodulesmode GO111MODULE=on
export GO_LDFLAGS="-X %{goipath}/cmd/composer-cli/root.Version=%{version} "
%gobuild -o composer-cli ./cmd/composer-cli

## TODO
##make man

%if %{with tests} || 0%{?rhel}
export BUILDTAGS="integration"

# Build test binaries with `go test -c`, so that they can take advantage of
# golang's testing package. The RHEL golang rpm macros don't support building them
# directly. Thus, do it manually, taking care to also include a build id.
#
# On Fedora go modules have already been turned off, and the path set to the one into which
# the golang-* packages install source code.
export LDFLAGS="${LDFLAGS:-} -linkmode=external -compressdwarf=false -B 0x$(od -N 20 -An -tx1 -w100 /dev/urandom | tr -d ' ')"
go test -c -tags=integration -buildmode pie -compiler gc -ldflags="${LDFLAGS}" -o composer-cli-tests %{goipath}/weldr
export LDFLAGS="-linkmode=external -compressdwarf=false -B 0x$(od -N 20 -An -tx1 -w100 /dev/urandom | tr -d ' ') ${LDFLAGS:-}"
go test -c -tags=integration -buildmode pie -compiler gc -ldflags "${LDFLAGS}" -o composer-cli-tests ./weldr
%endif


%install
%go_vendor_license_install -c %{S:2}
make DESTDIR=%{buildroot} install

%if %{with tests} || 0%{?rhel}
make DESTDIR=%{buildroot} install-tests
%endif

%check
%if 0%{?fedora}
export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"
export GO111MODULE=off
%go_vendor_license_check -c %{S:2}
%if %{with tests}
export GO_LDFLAGS="-X %{goipath}/cmd/composer-cli/root.Version=%{version} "
%gocheck2
%endif

# Run the unit tests
export LDFLAGS="-X %{goipath}/cmd/composer-cli/root.Version=%{version} "
make test


%files
%license LICENSE
%doc examples HACKING.md README.md
%files -f %{go_vendor_license_filelist}
%doc examples HACKING.md README.md RELEASE.md
%{_bindir}/composer-cli
%dir %{_sysconfdir}/bash_completion.d
%{_sysconfdir}/bash_completion.d/composer-cli
Expand All @@ -121,12 +95,11 @@ Requires: createrepo_c

%description tests
Integration tests to be run on a pristine-dedicated system to test the
composer-cli package.
composer-cli package against a running osbuild-composer service.

%files tests
%license LICENSE
%files -f %{go_vendor_license_filelist} tests
%{_libexecdir}/tests/composer-cli/
%endif


%changelog
%autochangelog