Spec URL: https://bcl.fedorapeople.org/weldr-client/weldr-client.spec SRPM URL: https://bcl.fedorapeople.org/weldr-client/weldr-client-35.0-1.fc32.src.rpm Description: Command line utility to control osbuild-composer Fedora Account System Username: bcl
- License seems to be ASL 2.0 https://github.com/osbuild/weldr-client/blob/master/LICENSE - git-core is generally sufficient: BuildRequires: git-core - I don't see how the build can work on EPEL7 or 8 - gobuildflags and gometa are not available on EPEL - %if 0%{?fedora} BuildRequires: golang(github.com/BurntSushi/toml) BuildRequires: golang(github.com/spf13/cobra) %endif How do you get these deps on EPEL? Build fails because no deps are found: + make 'GOBUILDFLAGS=%{gobuildflags}' build fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git go build -ldflags="-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=35.0" %{gobuildflags} ./cmd/composer-cli go: inconsistent vendoring in /builddir/build/BUILD/weldr-client-35.0/_build/src/github.com/osbuild/weldr-client: github.com/BurntSushi/toml.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt github.com/niemeyer/pretty.0-20200227124842-a10e7caefd8e: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt github.com/spf13/cobra.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt github.com/stretchr/testify.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt gopkg.in/check.v1.0-20200227125254-8fa46927fb4f: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt gopkg.in/yaml.v2.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory make: *** [Makefile:14: composer-cli] Error 1 - You've added the asc but haven't verified it https://docs.fedoraproject.org/en-US/packaging-guidelines/#_verifying_signatures Here is the SPEC I suggest you: # Generated by go2rpm 1.3 # Pass --with tests to rpmbuild to build composer-cli-tests %bcond_with tests %if 0%{?rhel} %bcond_without vendor %ifnarch ppc64 %global gobuildflags -buildmode pie -compiler gc -tags=\\\"rpm_crashtraceback ${BUILDTAGS:-}\\\" -ldflags \\\"${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}' -compressdwarf=false\\\" -a -v -x %else %global gobuildflags -compiler gc -tags=\\\"rpm_crashtraceback ${BUILDTAGS:-}\\\" -ldflags \\\"${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}' -compressdwarf=false\\\" -a -v -x %endif %endif %define setgoconfig() %{expand: # On Fedora, turn off go modules and set the path to the one into which # the golang-* packages install source code. %if %{without vendor} export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}" export GO111MODULE=off %else export GO111MODULE=on export GOFLAGS=-mod=vendor %endif export LDFLAGS="-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=%{version} " export GOBUILDFLAGS="%{gobuildflags}" } # https://github.com/osbuild/weldr-client %global goipath github.com/osbuild/weldr-client Version: 35.0 %if %{without vendor} %gometa %endif %global common_description %{expand: Command line utility to control osbuild-composer.} Name: weldr-client Release: 1%{?dist} Summary: Command line utility to control osbuild-composer # Upstream license specification: Apache-2.0 License: ASL 2.0 URL: https://github.com/osbuild/weldr-client Source0: https://github.com/osbuild/weldr-client/releases/download/v%{version}/%{name}-%{version}.tar.gz Source1: https://github.com/osbuild/weldr-client/releases/download/v%{version}/%{name}-%{version}.tar.gz.asc Source2: https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB4C6B451E4FA8B4232CA191E117E8C168EFE3A7F#/bcl-gpg.key # git clone https://github.com/osbuild/weldr-client # cd weldr-client # git checkout v%%{version} # go mod vendor # tar czvf vendor-%%{version}.tar.gz vendor/ Source10: vendor-%{version}.tar.gz Obsoletes: composer-cli < 34.0 Provides: composer-cli = %{version}-%{release} %if %{without vendor} BuildRequires: golang(github.com/BurntSushi/toml) BuildRequires: golang(github.com/spf13/cobra) BuildRequires: golang(github.com/spf13/cobra/doc) %if %{with tests} # Tests BuildRequires: golang(github.com/stretchr/testify/assert) BuildRequires: golang(github.com/stretchr/testify/require) %endif %else BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} %endif BuildRequires: git-core BuildRequires: make BuildRequires: gnupg2 %description %{common_description} %prep %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}' %if %{without vendor} %goprep %else %forgeautosetup -p1 %setup -q -T -D -a 10 -n %{name}-%{version} %endif # Makefile modification # 1. We pass tags already through BUILDTAGS in gobuildflags # 2. We export LDFLAGS in the SPEC so it is used in gobuildflags # 3. -v is already present in gobuildflags sed -i "s|go test -c -tags=integration|go test -c |; \ s|\${BUILDFLAGS}||; \ s|-v -covermode=atomic |-covermode=atomic |;" \ Makefile %build %setgoconfig %make_build # TODO # make man %if %{with tests} || 0%{?rhel} # Build test binaries with `go test -c`, so that they can take advantage of # golang's testing package. The golang rpm macros don't support building them # directly. Thus, do it manually, taking care to also include a build id. export BUILDTAGS=integration %make_build integration %endif %install %make_install %if %{with tests} || 0%{?rhel} make DESTDIR=%{buildroot} install-tests %endif %if %{with tests} %check %setgoconfig make test %endif %files %license LICENSE %doc examples HACKING.md README.md %{_bindir}/composer-cli %dir %{_sysconfdir}/bash_completion.d %{_sysconfdir}/bash_completion.d/composer-cli %{_mandir}/man1/composer-cli* %if %{with tests} || 0%{?rhel} %package tests Summary: Integration tests for composer-cli %description tests Integration tests to be run on a pristine-dedicated system to test the composer-cli package. %files tests %license LICENSE %{_libexecdir}/tests/composer-cli/ %endif %changelog * Thu Apr 01 2021 Brian C. Lane <bcl> - 35.0-1 - spec: Update Source urls with new project location (bcl) - Makefile: Start with version 35.0 (bcl) - Makefile: Move test binary to an install-tests target (bcl) - Makefile: Drop -race from test target, conflicts with -pie in Fedora build (bcl) - Move the project to github.com/osbuild/weldr-client/ (bcl) - README: Add documentation and examples (bcl) - composer-cli: Update the json output with more details (bcl) - composer-cli: Add sources commands and tests (bcl) - weldr: Add sources functions and tests (bcl) - composer-cli: Add modules info command and test (bcl) - weldr: Add ModulesInfo function and tests (bcl) - composer-cli: Add projects info command and tests (bcl) - weldr: Add ProjectsInfo function and tests (bcl) - composer-cli: Add projects list command (bcl) - weldr: Add ListProjects function (bcl) - composer-cli: Add helper function to word-wrap output (bcl) - composer-cli: Add support for modules list command (bcl) - weldr: Add ListModules function and tests (bcl) - actions: Install golangci-lint (bcl) - actions: Move to go 1.14 (bcl) - weldr: Remove unused code from GetComposeTypes (bcl) - Makefile: Add golangci-lint to make check, and coverage to make test (bcl) - composer-cli: Add compose info output (bcl) - weldr: Add ComposeInfo function and tests (bcl) - weldr: Add Compose Info structs to apischema (bcl) - composer-cli: Add compose image command and tests (bcl) - weldr: Add ComposeImage function and tests (bcl) - composer-cli: Add compose results command and test (bcl) - weldr: Add ComposeResults function and tests (bcl) - maint: Update go.mod with 'go mod tidy' and set version to 1.14 (bcl) - composer-cli: Add compose metadata command and test (bcl) - weldr: Add ComposeMetadata function and tests (bcl) - weldr: Use http for ostree url tests (bcl) - composer-cli: Add compose logs command to download log tarfile (bcl) - weldr: Add MoveFile function (bcl) - weldr: Use GetContentFilename in ComposeLogs (bcl) - weldr: Add GetContentFilename helper function and tests (bcl) - weldr: Add ComposeLogs function and testing (bcl) - weldr: Add GetFile and tests (bcl) - composer-cli: Add compose log command (bcl) - weldr: Add support for retrieving running compose's log (bcl) - composer-cli: Fix compose list handling of multiple filters (bcl) - weldr: Add test for IsStringInSlice (bcl) - weldr: Make IsStringInSlice public (bcl) - weldr: Some errors use http.StatusInternalServerError(500) (bcl) - composer-cli: Add compose start-ostree command (bcl) - composer-cli: Add upload support to compose start (bcl) - weldr: Add upload functions to ComposeStart (bcl) - weldr: Add functions to start ostree composes (bcl) - Fix running composer-cli with no arguments (bcl) - Add manpages to the rpm (bcl) - Add composer-cli bash completion support (bcl) - Makefile: Adding release, srpm, and rpm creation support (bcl) - Set repo to github.com/weldr/weldr-client (bcl) - tests: Remove localtime from compose status test (bcl) - blueprints: Add json output to freeze, show, and changes (bcl) - compose: Clean up error handling (bcl) - blueprints: Add blueprints undo command and tests (bcl) - blueprints: Add blueprints tag command and tests (bcl) - blueprints: Add test for blueprints workspace command (bcl) - blueprints: Clean up error handling (bcl) - blueprints: Add test for blueprints show (bcl) - blueprints: Add test for blueprints save (bcl) - blueprints: Add test for blueprints push (bcl) - weldr: Add tests for Frozen TOML and JSON functions (bcl) - Cleanup some make check complaints (bcl) - blueprints: Add depsolve command and test (bcl) - weldr: Add DepsolveBlueprints function and test (bcl) - blueprints: Add tests for blueprints delete command (bcl) - blueprints: Add test for changes command (bcl) - Add HACKING.md document for developers (bcl) - weldr: Convert compose tests to integration tests (bcl) - weldr: Catch HTTP Status 500 and decode an APIError response (bcl) - weldr: Use integration tests for status test (bcl) - weldr: Use GetJSONAllFnTotal for changes and add cmdline use of it (bcl) - weldr: Add new GetJSONAllFnTotal function (bcl) - blueprints: Convert blueprint tests to integration tests (bcl) - weldr: Add GetBlueprintsChanges function (bcl) - composer-cli: Print uuid when compose started (bcl) - weldr: Add json output to DELETE requests (bcl) - composer-cli: Add cancel command and tests (bcl) - weldr: Add CancelCompose and tests (bcl) - composer-cli: Add compose status command and test (bcl) - weldr: Add function to sort ComposeStatusV0 structs (bcl) - Cleanup lint warnings for weldr/ (bcl) - Cleanup lint warnings for root.go (bcl) - check: Exit with a 1 if golint finds problems (bcl) - Setup github actions for make check and make test (bcl) - composer-cli: Add compose delete command and tests (bcl) - weldr: Add DeleteComposes function and tests (bcl) - composer-cli: Add compose start command and tests (bcl) - weldr: Add StartCompose function and tests (bcl) - composer-cli: Add compose types command and test (bcl) - weldr: Add GetComposeTypes function and test (bcl) - composer-cli: Sort the output of blueprints list (bcl) - composer-cli: Add compose list command (bcl) - weldr: Add ListComposes function and test (bcl) - Add a .gitignore file (bcl) - Add Apache 2.0 License file (bcl) - Add blueprints subcommands (bcl) - Add status show command and test (bcl) - composer-cli: Add the core command processing code (bcl) - weldr: Add blueprint functions (bcl) - weldr: Add server status function (bcl) - weldr: Add API schema for error responses, status, and blueprint lists (bcl)
Slight change so that the integration tag is not left off: # Generated by go2rpm 1.3 # Pass --with tests to rpmbuild to build composer-cli-tests %bcond_with tests %if 0%{?rhel} %bcond_without vendor %ifnarch ppc64 %global gobuildflags -buildmode pie -compiler gc -tags=\\\"rpm_crashtraceback ${BUILDTAGS:-}\\\" -ldflags \\\"${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}' -compressdwarf=false\\\" -a -v -x %else %global gobuildflags -compiler gc -tags=\\\"rpm_crashtraceback ${BUILDTAGS:-}\\\" -ldflags \\\"${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}' -compressdwarf=false\\\" -a -v -x %endif %endif %define setgoconfig() %{expand: # On Fedora, turn off go modules and set the path to the one into which # the golang-* packages install source code. %if %{without vendor} export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}" export GO111MODULE=off %else export GO111MODULE=on export GOFLAGS=-mod=vendor %endif export LDFLAGS="-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=%{version} " } # https://github.com/osbuild/weldr-client %global goipath github.com/osbuild/weldr-client Version: 35.0 %if %{without vendor} %gometa %endif %global common_description %{expand: Command line utility to control osbuild-composer.} Name: weldr-client Release: 1%{?dist} Summary: Command line utility to control osbuild-composer # Upstream license specification: Apache-2.0 License: ASL 2.0 URL: https://github.com/osbuild/weldr-client Source0: https://github.com/osbuild/weldr-client/releases/download/v%{version}/%{name}-%{version}.tar.gz Source1: https://github.com/osbuild/weldr-client/releases/download/v%{version}/%{name}-%{version}.tar.gz.asc Source2: https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB4C6B451E4FA8B4232CA191E117E8C168EFE3A7F#/bcl-gpg.key # git clone https://github.com/osbuild/weldr-client # cd weldr-client # git checkout v%%{version} # go mod vendor # tar czvf vendor-%%{version}.tar.gz vendor/ Source10: vendor-%{version}.tar.gz Obsoletes: composer-cli < 34.0 Provides: composer-cli = %{version}-%{release} %if %{without vendor} BuildRequires: golang(github.com/BurntSushi/toml) BuildRequires: golang(github.com/spf13/cobra) BuildRequires: golang(github.com/spf13/cobra/doc) %if %{with tests} # Tests BuildRequires: golang(github.com/stretchr/testify/assert) BuildRequires: golang(github.com/stretchr/testify/require) %endif %else BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} %endif BuildRequires: git-core BuildRequires: make BuildRequires: gnupg2 %description %{common_description} %prep %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}' %if %{without vendor} %goprep %else %forgeautosetup -p1 %setup -q -T -D -a 10 -n %{name}-%{version} %endif # Makefile modification # 1. We pass tags already through BUILDTAGS in gobuildflags # 2. We export LDFLAGS in the SPEC so it is used in gobuildflags # 3. -v is already present in gobuildflags sed -i "s|go test -c -tags=integration|go test -c |; \ s|\${BUILDFLAGS}||; \ s|-v -covermode=atomic |-covermode=atomic |;" \ Makefile %build %setgoconfig export GOBUILDFLAGS="%{gobuildflags}" %make_build # TODO # make man %if %{with tests} || 0%{?rhel} # Build test binaries with `go test -c`, so that they can take advantage of # golang's testing package. The golang rpm macros don't support building them # directly. Thus, do it manually, taking care to also include a build id. export BUILDTAGS="integration" export GOBUILDFLAGS="%{gobuildflags}" %make_build integration %endif %install %make_install %if %{with tests} || 0%{?rhel} make DESTDIR=%{buildroot} install-tests %endif %if %{with tests} %check %setgoconfig export GOBUILDFLAGS="%{gobuildflags}" make test %endif %files %license LICENSE %doc examples HACKING.md README.md %{_bindir}/composer-cli %dir %{_sysconfdir}/bash_completion.d %{_sysconfdir}/bash_completion.d/composer-cli %{_mandir}/man1/composer-cli* %if %{with tests} || 0%{?rhel} %package tests Summary: Integration tests for composer-cli %description tests Integration tests to be run on a pristine-dedicated system to test the composer-cli package. %files tests %license LICENSE %{_libexecdir}/tests/composer-cli/ %endif %changelog * Thu Apr 01 2021 Brian C. Lane <bcl> - 35.0-1 - spec: Update Source urls with new project location (bcl) - Makefile: Start with version 35.0 (bcl) - Makefile: Move test binary to an install-tests target (bcl) - Makefile: Drop -race from test target, conflicts with -pie in Fedora build (bcl) - Move the project to github.com/osbuild/weldr-client/ (bcl) - README: Add documentation and examples (bcl) - composer-cli: Update the json output with more details (bcl) - composer-cli: Add sources commands and tests (bcl) - weldr: Add sources functions and tests (bcl) - composer-cli: Add modules info command and test (bcl) - weldr: Add ModulesInfo function and tests (bcl) - composer-cli: Add projects info command and tests (bcl) - weldr: Add ProjectsInfo function and tests (bcl) - composer-cli: Add projects list command (bcl) - weldr: Add ListProjects function (bcl) - composer-cli: Add helper function to word-wrap output (bcl) - composer-cli: Add support for modules list command (bcl) - weldr: Add ListModules function and tests (bcl) - actions: Install golangci-lint (bcl) - actions: Move to go 1.14 (bcl) - weldr: Remove unused code from GetComposeTypes (bcl) - Makefile: Add golangci-lint to make check, and coverage to make test (bcl) - composer-cli: Add compose info output (bcl) - weldr: Add ComposeInfo function and tests (bcl) - weldr: Add Compose Info structs to apischema (bcl) - composer-cli: Add compose image command and tests (bcl) - weldr: Add ComposeImage function and tests (bcl) - composer-cli: Add compose results command and test (bcl) - weldr: Add ComposeResults function and tests (bcl) - maint: Update go.mod with 'go mod tidy' and set version to 1.14 (bcl) - composer-cli: Add compose metadata command and test (bcl) - weldr: Add ComposeMetadata function and tests (bcl) - weldr: Use http for ostree url tests (bcl) - composer-cli: Add compose logs command to download log tarfile (bcl) - weldr: Add MoveFile function (bcl) - weldr: Use GetContentFilename in ComposeLogs (bcl) - weldr: Add GetContentFilename helper function and tests (bcl) - weldr: Add ComposeLogs function and testing (bcl) - weldr: Add GetFile and tests (bcl) - composer-cli: Add compose log command (bcl) - weldr: Add support for retrieving running compose's log (bcl) - composer-cli: Fix compose list handling of multiple filters (bcl) - weldr: Add test for IsStringInSlice (bcl) - weldr: Make IsStringInSlice public (bcl) - weldr: Some errors use http.StatusInternalServerError(500) (bcl) - composer-cli: Add compose start-ostree command (bcl) - composer-cli: Add upload support to compose start (bcl) - weldr: Add upload functions to ComposeStart (bcl) - weldr: Add functions to start ostree composes (bcl) - Fix running composer-cli with no arguments (bcl) - Add manpages to the rpm (bcl) - Add composer-cli bash completion support (bcl) - Makefile: Adding release, srpm, and rpm creation support (bcl) - Set repo to github.com/weldr/weldr-client (bcl) - tests: Remove localtime from compose status test (bcl) - blueprints: Add json output to freeze, show, and changes (bcl) - compose: Clean up error handling (bcl) - blueprints: Add blueprints undo command and tests (bcl) - blueprints: Add blueprints tag command and tests (bcl) - blueprints: Add test for blueprints workspace command (bcl) - blueprints: Clean up error handling (bcl) - blueprints: Add test for blueprints show (bcl) - blueprints: Add test for blueprints save (bcl) - blueprints: Add test for blueprints push (bcl) - weldr: Add tests for Frozen TOML and JSON functions (bcl) - Cleanup some make check complaints (bcl) - blueprints: Add depsolve command and test (bcl) - weldr: Add DepsolveBlueprints function and test (bcl) - blueprints: Add tests for blueprints delete command (bcl) - blueprints: Add test for changes command (bcl) - Add HACKING.md document for developers (bcl) - weldr: Convert compose tests to integration tests (bcl) - weldr: Catch HTTP Status 500 and decode an APIError response (bcl) - weldr: Use integration tests for status test (bcl) - weldr: Use GetJSONAllFnTotal for changes and add cmdline use of it (bcl) - weldr: Add new GetJSONAllFnTotal function (bcl) - blueprints: Convert blueprint tests to integration tests (bcl) - weldr: Add GetBlueprintsChanges function (bcl) - composer-cli: Print uuid when compose started (bcl) - weldr: Add json output to DELETE requests (bcl) - composer-cli: Add cancel command and tests (bcl) - weldr: Add CancelCompose and tests (bcl) - composer-cli: Add compose status command and test (bcl) - weldr: Add function to sort ComposeStatusV0 structs (bcl) - Cleanup lint warnings for weldr/ (bcl) - Cleanup lint warnings for root.go (bcl) - check: Exit with a 1 if golint finds problems (bcl) - Setup github actions for make check and make test (bcl) - composer-cli: Add compose delete command and tests (bcl) - weldr: Add DeleteComposes function and tests (bcl) - composer-cli: Add compose start command and tests (bcl) - weldr: Add StartCompose function and tests (bcl) - composer-cli: Add compose types command and test (bcl) - weldr: Add GetComposeTypes function and test (bcl) - composer-cli: Sort the output of blueprints list (bcl) - composer-cli: Add compose list command (bcl) - weldr: Add ListComposes function and test (bcl) - Add a .gitignore file (bcl) - Add Apache 2.0 License file (bcl) - Add blueprints subcommands (bcl) - Add status show command and test (bcl) - composer-cli: Add the core command processing code (bcl) - weldr: Add blueprint functions (bcl) - weldr: Add server status function (bcl) - weldr: Add API schema for error responses, status, and blueprint lists (bcl)
Spec URL: https://bcl.fedorapeople.org/weldr-client/weldr-client.spec SRPM URL: https://bcl.fedorapeople.org/weldr-client/weldr-client-35.0-2.fc32.src.rpm Description: Command line utility to control osbuild-composer Fedora Account System Username: bcl weldr-client doesn't need to work on EPEL so I don't think it needs the vendor changes so I left those out. FWIW I'm trying to make this so that the spec is auto-generated from a template when I run 'make srpm', you can see the template input here: https://github.com/osbuild/weldr-client/blob/master/weldr-client.spec.in Also, the spec should not be editing the Makefile. If there are changes needed then they should be passed in the environment. I may be missing the reasoning behind some of your changes, so if this still needs work please explain in a bit more detail. Thanks, Brian
(In reply to Brian Lane from comment #3) > Spec URL: https://bcl.fedorapeople.org/weldr-client/weldr-client.spec > SRPM URL: > https://bcl.fedorapeople.org/weldr-client/weldr-client-35.0-2.fc32.src.rpm > Description: Command line utility to control osbuild-composer > Fedora Account System Username: bcl > > > weldr-client doesn't need to work on EPEL so I don't think it needs the > vendor changes so I left those out. > I don't get why you have %if 0%{?rhel} everywhere then?
> I may be missing the reasoning behind some of your changes, so if this still needs work please explain in a bit more detail. Most of the change are related to the fact we don't have macros on RHEL/EPEL so we set up the gobuildflags manually: %if 0%{?rhel} %bcond_without vendor %ifnarch ppc64 %global gobuildflags -buildmode pie -compiler gc -tags=\\\"rpm_crashtraceback ${BUILDTAGS:-}\\\" -ldflags \\\"${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}' -compressdwarf=false\\\" -a -v -x %else %global gobuildflags -compiler gc -tags=\\\"rpm_crashtraceback ${BUILDTAGS:-}\\\" -ldflags \\\"${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}' -compressdwarf=false\\\" -a -v -x %endif %endif and then use vendoring + go modules for RHEL/EPEL: %define setgoconfig() %{expand: # On Fedora, turn off go modules and set the path to the one into which # the golang-* packages install source code. %if %{without vendor} export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}" export GO111MODULE=off %else export GO111MODULE=on export GOFLAGS=-mod=vendor %endif export LDFLAGS="-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=%{version} " } About the Makefile: BUILDFLAGS ?= -ldflags="-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=${VERSION}" GOBUILDFLAGS ?= build: composer-cli composer-cli: go build ${BUILDFLAGS} ${GOBUILDFLAGS} ./cmd/composer-cli Here you pass ldflags via the variable BUILDFLAGS, however %GOBUILDFLAGS already defines -ldflags, so it overwrites your BUILDFLAGS The solution is to erase the BUILDTAGS from go build ${BUILDFLAGS} ${GOBUILDFLAGS} ./cmd/composer-cli and pass: export LDFLAGS="-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=%{version} " before the build in the spec so it will be passed to GOBUILDFLAGS at -ldflags "${LDFLAGS:-} We have the same issue here: integration: composer-cli-tests composer-cli-tests: go test -c -tags=integration ${BUILDFLAGS} ${GOBUILDFLAGS} -o composer-cli-tests ./weldr/ you are passing -tags=integration but %gobuildflags already contains -tags="rpm_crashtraceback ${BUILDTAGS:-}", so it erasing this tag. The solution is to remove -tags=integration in the Makefile and define the $BUILDTAGS="integration" in the SPEC: =================================================================================================================== - This is only needed for EPEL: BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} - Please specify all the import paths used: %if 0%{?fedora} BuildRequires: golang(github.com/BurntSushi/toml) BuildRequires: golang(github.com/spf13/cobra) %endif %if %{with tests} || 0%{?rhel} BuildRequires: golang(github.com/stretchr/testify) %endif → BuildRequires: golang(github.com/BurntSushi/toml) BuildRequires: golang(github.com/spf13/cobra) BuildRequires: golang(github.com/spf13/cobra/doc) %if %{with tests} # Tests BuildRequires: golang(github.com/stretchr/testify/assert) BuildRequires: golang(github.com/stretchr/testify/require) %endif - Not needed if you do not support EPEL: %if 0%{?rhel} %forgeautosetup -p1 %else %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 %endif - Please set the GOPATH and GO111MODULE manually since you don't use %gobuild: export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}" export GO111MODULE=off - You'll also need it in tests: %check export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}" export GO111MODULE=off - Split the description to stay below 80 characters per line: %description tests Integration tests to be run on a pristine-dedicated system to test the composer-cli package. ================================================================================================= Proposed spec without EPEL: # Generated by go2rpm 1.3 # Pass --with tests to rpmbuild to build composer-cli-tests %bcond_with tests # https://github.com/osbuild/weldr-client %global goipath github.com/osbuild/weldr-client Version: 35.0 %gometa %global common_description %{expand: Command line utility to control osbuild-composer.} Name: weldr-client Release: 1%{?dist} Summary: Command line utility to control osbuild-composer # Upstream license specification: Apache-2.0 License: ASL 2.0 URL: https://github.com/osbuild/weldr-client Source0: https://github.com/osbuild/weldr-client/releases/download/v%{version}/%{name}-%{version}.tar.gz Source1: https://github.com/osbuild/weldr-client/releases/download/v%{version}/%{name}-%{version}.tar.gz.asc Source2: https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB4C6B451E4FA8B4232CA191E117E8C168EFE3A7F#/bcl-gpg.key Obsoletes: composer-cli < 34.0 Provides: composer-cli = %{version}-%{release} BuildRequires: golang(github.com/BurntSushi/toml) BuildRequires: golang(github.com/spf13/cobra) BuildRequires: golang(github.com/spf13/cobra/doc) %if %{with tests} # Tests BuildRequires: golang(github.com/stretchr/testify/assert) BuildRequires: golang(github.com/stretchr/testify/require) %endif BuildRequires: git-core BuildRequires: make BuildRequires: gnupg2 %description %{common_description} %prep %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}' %goprep # Makefile modification # 1. We pass tags already through BUILDTAGS in gobuildflags # 2. We export LDFLAGS in the SPEC so it is used in gobuildflags # 3. -v is already present in gobuildflags sed -i "s|go test -c -tags=integration|go test -c |; \ s|\${BUILDFLAGS}||; \ s|-v -covermode=atomic |-covermode=atomic |;" \ Makefile %build export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}" export GO111MODULE=off export LDFLAGS="-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=%{version} " export GOBUILDFLAGS="%{gobuildflags}" %make_build # TODO # make man %if %{with tests} # Build test binaries with `go test -c`, so that they can take advantage of # golang's testing package. The golang rpm macros don't support building them # directly. Thus, do it manually, taking care to also include a build id. export BUILDTAGS="integration" export GOBUILDFLAGS="%{gobuildflags}" %make_build integration %endif %install %make_install %if %{with tests} make DESTDIR=%{buildroot} install-tests %endif %if %{with tests} %check export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}" export GO111MODULE=off export GOBUILDFLAGS="%{gobuildflags}" make test %endif %files %license LICENSE %doc examples HACKING.md README.md %{_bindir}/composer-cli %dir %{_sysconfdir}/bash_completion.d %{_sysconfdir}/bash_completion.d/composer-cli %{_mandir}/man1/composer-cli* %if %{with tests} %package tests Summary: Integration tests for composer-cli %description tests Integration tests to be run on a pristine-dedicated system to test the composer-cli package. %files tests %license LICENSE %{_libexecdir}/tests/composer-cli/ %endif %changelog
The other way: define LDFLAGS and BUILDTAGS directly in the SPEC: DESTDIR ?= / VERSION ?= 35.0 TAG = v$(VERSION) PREVTAG := $(shell git tag --sort=-creatordate | head -n 2 | tail -n 1) COMMITS := $(shell git log --pretty=oneline --no-merges ${PREVTAG}..HEAD | wc -l) GPGKEY ?= $(shell git config user.signingkey) GITEMAIL := $(shell git config user.email) GITNAME := $(shell git config user.name) LDFLAGS ?= "-X github.com/osbuild/weldr-client/cmd/composer-cli/root.Version=${VERSION} " GOBUILDFLAGS ?= build: composer-cli composer-cli: go build ${GOBUILDFLAGS} ./cmd/composer-cli check: go vet ./... && golint -set_exit_status ./... && golangci-lint --build-tags=integration run ./... test: go test ${GOBUILDFLAGS} -covermode=atomic -coverprofile=coverage.txt -coverpkg=./... ./... integration: composer-cli-tests composer-cli-tests: export BUILDTAGS="integration" go test -c ${GOBUILDFLAGS} -o composer-cli-tests ./weldr/ install: composer-cli install -m 0755 -vd ${DESTDIR}/usr/bin/ install -m 0755 -vp composer-cli ${DESTDIR}/usr/bin/ install -m 0755 -vd ${DESTDIR}/etc/bash_completion.d/ install -m 0755 -vp etc/bash_completion.d/composer-cli ${DESTDIR}/etc/bash_completion.d/ install -m 0755 -vd ${DESTDIR}/usr/share/man/man1/ ./composer-cli doc ${DESTDIR}/usr/share/man/man1/ install-tests: composer-cli-tests install -m 0755 -vd ${DESTDIR}/usr/libexec/tests/composer-cli/ install -m 0755 -vp composer-cli-tests ${DESTDIR}/usr/libexec/tests/composer-cli/ weldr-client.spec: weldr-client.spec.in sed -e "s/%%VERSION%%/$(VERSION)/g" -e "s/%%GPGKEY%%/$(GPGKEY)/g" < $< > $@ $(MAKE) -s changelog >> $@ tag: @if [ -z "$(GPGKEY)" ]; then echo "ERROR: The git config user.signingkey must be set" ; exit 1; fi git tag -u $(GPGKEY) -m "Tag as $(TAG)" -f $(TAG) @echo "Tagged as $(TAG)" # Order matters, so run make for each step instead of declaring them as dependencies release: @if [ -z "$(GPGKEY)" ]; then echo "ERROR: The git config user.signingkey must be set" ; exit 1; fi $(MAKE) test && $(MAKE) bumpver && $(MAKE) tag && $(MAKE) archive && $(MAKE) sign sign: @if [ -z "$(GPGKEY)" ]; then echo "ERROR: The git config user.signingkey must be set" ; exit 1; fi gpg --armor --detach-sign -u $(GPGKEY) weldr-client-$(VERSION).tar.gz gpg2 --export --export-options export-minimal $(GPGKEY) > gpg-$(GPGKEY).key changelog: @echo "* $(shell date '+%a %b %d %Y') ${GITNAME} <${GITEMAIL}> - ${VERSION}-1" @git log --no-merges --pretty="format:- %s (%ae)" ${PREVTAG}..HEAD |sed -e 's/@.*)/)/' bumpver: @NEWSUBVER=$$((`echo $(VERSION) |cut -d . -f 2` + 1)) ; \ NEWVERSION=`echo $(VERSION).$$NEWSUBVER |cut -d . -f 1,3` ; \ sed -i "s/VERSION ?= $(VERSION)/VERSION ?= $$NEWVERSION/" Makefile ; \ git add Makefile; \ git commit -m "New release: $$NEWVERSION" archive: git archive --prefix=weldr-client-$(VERSION)/ --format=tar.gz HEAD > weldr-client-$(VERSION).tar.gz 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 $(RPM_SPECFILE): weldr-client.spec mkdir -p $(CURDIR)/rpmbuild/SPECS cp weldr-client.spec $(CURDIR)/rpmbuild/SPECS $(RPM_TARBALL): archive sign mkdir -p $(CURDIR)/rpmbuild/SOURCES cp weldr-client-$(VERSION).tar.gz* gpg-$(GPGKEY).key rpmbuild/SOURCES/ srpm: $(RPM_SPECFILE) $(RPM_TARBALL) rpmbuild -bs \ --define "_topdir $(CURDIR)/rpmbuild" \ --define "commit $(VERSION)" \ --with tests \ $(RPM_SPECFILE) rpm: $(RPM_SPECFILE) $(RPM_TARBALL) dnf builddep -y --spec -D 'with 1' $(RPM_SPECFILE) rpmbuild -bb \ --define "_topdir $(CURDIR)/rpmbuild" \ --define "commit $(VERSION)" \ --with tests \ $(RPM_SPECFILE) .PHONY: build check test integration install srpm rpm weldr-client.spec
s/in the SPEC/in the Makefile/
Spec URL: https://bcl.fedorapeople.org/weldr-client/weldr-client.spec SRPM URL: https://bcl.fedorapeople.org/weldr-client/weldr-client-35.0-3.fc32.src.rpm Description: Command line utility to control osbuild-composer Fedora Account System Username: bcl Thanks for your patience, I think this is now all cleaned up for Fedora at least. The rhel checks are there for RHEL9, which I hope is closer to Fedora behavior than RHEL8 was, but I haven't had a chance to setup a VM to test it on yet so I didn't change any of that. I don't think cobra/doc needs to be a separate BuildRequire, it comes from the same package as cobra. I did fix the testify modules though. In general how do you decide what to list in BuildRequires? I was using the go.mod direct dependencies as my guide, but obviously that doesn't match how Fedora is packaging things. Thanks for the explanation of the build flags, I rearranged the way I did because the Makefile needs to also work standalone so it's better to just duplicate things in the spec and pass them as part of GOBUILDFLAGS.
(In reply to Brian Lane from comment #8) > Spec URL: https://bcl.fedorapeople.org/weldr-client/weldr-client.spec > SRPM URL: > https://bcl.fedorapeople.org/weldr-client/weldr-client-35.0-3.fc32.src.rpm > Description: Command line utility to control osbuild-composer > Fedora Account System Username: bcl > > > > Thanks for your patience, I think this is now all cleaned up for Fedora at > least. > > The rhel checks are there for RHEL9, which I hope is closer to Fedora > behavior than RHEL8 was, but I haven't had a chance to setup a VM to test it > on yet so I didn't change any of that. > I hope so. > I don't think cobra/doc needs to be a separate BuildRequire, it comes from > the same package as cobra. I did fix the testify modules though. In general > how do you decide what to list in BuildRequires? I was using the go.mod > direct dependencies as my guide, but obviously that doesn't match how Fedora > is packaging things. > With go2rpm you can list all import path used. Sometimes we have to split a package/import path into separate subpackages to work around cyclic dependencies. > Thanks for the explanation of the build flags, I rearranged the way I did > because the Makefile needs to also work standalone so it's better to just > duplicate things in the spec and pass them as part of GOBUILDFLAGS. Package approved.
(fedscm-admin): The Pagure repository was created at https://src.fedoraproject.org/rpms/weldr-client