Skip to content

Commit 2282b5a

Browse files
author
Paul Whalen
committed
refactor: switch to standard Go vendoring for cross-distro packaging
Replace go-vendor-tools with standard Go module vendoring to support building on both Fedora and CentOS/RHEL with a single spec file. Changes: - Commit vendor/ directory to git (vendored dependency files) - Include vendor/ directory in Source0 tarball - Add .gitattributes to exclude vendor/ from GitHub diffs - Set GO111MODULE=on and GOFLAGS=-mod=vendor for build and test phases - Remove go-vendor-tools dependency from spec and Packit config - Add vendor/modules.txt to %license for bundled dependency tracking - Add testdata files (dc.bin, mfg_key.pem, ov.pem, embed.go) to vendored go-fdo package required by //go:embed directives for build-time compilation CI workflow updates: - Exclude vendor/ from codespell spell-check to avoid false positives in third-party dependencies - Exclude vendor/ from DevSkim security scanner to prevent flagging vendored code issues - Removed overly restrictive PR version check from test/fmf/tests/test-onboarding.sh This approach follows the standard pattern used by major Go packages in Fedora and matches the vendoring implementation in go-fdo-server. Signed-off-by: Paul Whalen <[email protected]>
1 parent 2d5efec commit 2282b5a

File tree

632 files changed

+279632
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

632 files changed

+279632
-112
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Exclude vendored dependencies from GitHub diffs and language statistics
2+
vendor/** linguist-vendored

.github/workflows/analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
check_filenames: true
2020
check_hidden: true
2121
ignore_words_file: .github/spellcheck-ignore
22-
skip: "./docs/Gemfile.lock,./docs/_config.yml,./.github,./.git"
22+
skip: "./docs/Gemfile.lock,./docs/_config.yml,./.github,./.git,./vendor"
2323

2424
commitlint:
2525
name: check commitlint
@@ -56,7 +56,7 @@ jobs:
5656
- name: Run DevSkim scanner
5757
uses: microsoft/DevSkim-Action@v1
5858
with:
59-
ignore-globs: '**/examples/**,**/test/**,**/.github/scripts/**,*_test.go'
59+
ignore-globs: '**/examples/**,**/test/**,**/.github/scripts/**,*_test.go,**/vendor/**'
6060

6161
- name: Upload DevSkim scan results to GitHub Security tab
6262
uses: github/codeql-action/upload-sarif@v3

.packit.yaml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ files_to_sync:
22
- src:
33
- ".packit.yaml"
44
- "build/package/rpm/go-fdo-client.spec"
5-
- "build/package/rpm/go-vendor-tools.toml"
6-
- "build/package/rpm/go-fdo-client-*-vendor.tar.gz"
75
dest: .
86

97
upstream_package_name: go-fdo-client
@@ -16,10 +14,7 @@ srpm_build_deps:
1614
- make
1715
- git
1816
- golang
19-
- go-vendor-tools
20-
- gzip
2117
- tar
22-
- python3-tomlkit
2318

2419
packages:
2520
go-fdo-client-fedora:
@@ -33,10 +28,10 @@ packages:
3328
pkg_tool: centpkg
3429

3530
actions:
36-
pre-sync:
37-
- make vendor-tarball VERSION=${PACKIT_PROJECT_VERSION}
31+
fix-spec-file:
32+
- bash -c 'sed -i "s/^%global commit .*/%global commit $(git rev-parse HEAD)/;" build/package/rpm/go-fdo-client.spec'
3833
create-archive:
39-
- make packit-create-archive VERSION=${PACKIT_PROJECT_VERSION}
34+
- make packit-create-archive
4035

4136
jobs:
4237
- &copr_fedora
@@ -65,8 +60,7 @@ jobs:
6560
packages: [go-fdo-client-centos]
6661
trigger: pull_request
6762
targets:
68-
- epel-9
69-
- epel-10
63+
- centos-stream-10
7064

7165
- <<: *copr_centos
7266
trigger: commit
@@ -91,6 +85,5 @@ jobs:
9185
tmt_plan: plans/e2e
9286
packages: [go-fdo-client-centos]
9387
targets:
94-
- epel-9
95-
- epel-10
88+
- centos-stream-10
9689

Makefile

Lines changed: 65 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,55 @@
1-
COMMIT := $(shell git rev-parse --short HEAD)
2-
DATE := $(shell date "+%Y%m%d")
3-
VERSION := git$(DATE).$(COMMIT)
4-
PROJECT := go-fdo-client
1+
COMMIT = $(shell git rev-parse HEAD)
2+
VERSION = $(COMMIT)
53

6-
SOURCEDIR := $(CURDIR)/build/package/rpm
7-
SPEC_FILE_NAME := $(PROJECT).spec
8-
SPEC_FILE := $(SOURCEDIR)/$(SPEC_FILE_NAME)
9-
GO_VENDOR_TOOLS_FILE := $(SOURCEDIR)/go-vendor-tools.toml
10-
GO_VENDOR_TOOLS_FILE_NAME := go-vendor-tools.toml
4+
SOURCE_DIR := $(CURDIR)/build/package/rpm
115

12-
SOURCE_TARBALL := $(SOURCEDIR)/$(PROJECT)-$(VERSION).tar.gz
13-
VENDOR_TARBALL := $(SOURCEDIR)/$(PROJECT)-$(VERSION)-vendor.tar.gz
6+
SOURCE_TARBALL_FILENAME := go-fdo-client-$(VERSION).tar.gz
7+
SOURCE_TARBALL := $(SOURCE_DIR)/$(SOURCE_TARBALL_FILENAME)
148

15-
# Build the Go project
16-
.PHONY: all build tidy fmt vet test
17-
all: build test
9+
GO_VENDOR_TOOLS_FILE_NAME := go-vendor-tools.toml
10+
GO_VENDOR_TOOLS_FILE := $(SOURCE_DIR)/$(GO_VENDOR_TOOLS_FILE_NAME)
11+
VENDOR_TARBALL_FILENAME := go-fdo-client-$(VERSION)-vendor.tar.bz2
12+
VENDOR_TARBALL := $(SOURCE_DIR)/$(VENDOR_TARBALL_FILENAME)
13+
14+
SPEC_FILE_NAME := go-fdo-client.spec
15+
SPEC_FILE := $(SOURCE_DIR)/$(SPEC_FILE_NAME)
1816

17+
# Build the Go project
18+
.PHONY: build
1919
build: tidy fmt vet
2020
go build
2121

22+
.PHONY: tidy
2223
tidy:
2324
go mod tidy
2425

26+
.PHONY: fmt
2527
fmt:
2628
go fmt ./...
2729

30+
.PHONY: vet
2831
vet:
2932
go vet ./...
3033

34+
.PHONY: test
3135
test:
3236
go test -v ./...
3337

34-
# Packit helpers
35-
.PHONY: vendor-tarball packit-create-archive vendor-licenses
36-
37-
vendor-tarball: $(VENDOR_TARBALL)
38-
39-
$(VENDOR_TARBALL):
40-
rm -rf vendor; \
41-
command -v go_vendor_archive || sudo dnf install -y go-vendor-tools python3-tomlkit; \
42-
go_vendor_archive create --compression gz --config $(GO_VENDOR_TOOLS_FILE) --write-config --output $(VENDOR_TARBALL) .; \
43-
rm -rf vendor;
44-
45-
packit-create-archive: $(SOURCE_TARBALL) $(VENDOR_TARBALL)
46-
@ls -1 "$(SOURCE_TARBALL)" | head -n1
47-
38+
#
39+
# Generating sources and vendor tar files
40+
#
4841
$(SOURCE_TARBALL):
49-
mkdir -p "$(SOURCEDIR)"
50-
git archive --format=tar --prefix="$(PROJECT)-$(VERSION)/" HEAD | gzip > "$(SOURCE_TARBALL)"
42+
@echo "Creating source tarball with vendor/ directory..."
43+
@# Ensure vendor/ exists from git (in case make clean was run)
44+
@if [ ! -d vendor ]; then git restore vendor/ 2>/dev/null || go mod vendor; fi
45+
git ls-files | tar --transform='s,^,go-fdo-client-$(VERSION)/,' -czf - -T - > $(SOURCE_TARBALL)
46+
47+
.PHONY: source-tarball
48+
source-tarball: $(SOURCE_TARBALL)
5149

52-
vendor-licenses:
53-
go_vendor_license --config "$(GO_VENDOR_TOOLS_FILE)" .
50+
.PHONY: vendor
51+
vendor:
52+
go mod vendor
5453

5554
#
5655
# Building packages
@@ -64,46 +63,29 @@ vendor-licenses:
6463
# ./rpmbuild, using rpmbuild's usual directory structure (in lowercase).
6564
#
6665

67-
RPM_BASE_DIR := $(CURDIR)/build/package/rpm
68-
SPEC_FILE_NAME := $(PROJECT).spec
69-
SPEC_FILE := $(RPM_BASE_DIR)/$(SPEC_FILE_NAME)
70-
71-
RPMBUILD_TOP_DIR := $(CURDIR)/rpmbuild
72-
RPMBUILD_BUILD_DIR := $(RPMBUILD_TOP_DIR)/build
73-
RPMBUILD_RPMS_DIR := $(RPMBUILD_TOP_DIR)/rpms
74-
RPMBUILD_SPECS_DIR := $(RPMBUILD_TOP_DIR)/specs
75-
RPMBUILD_SOURCES_DIR := $(RPMBUILD_TOP_DIR)/sources
76-
RPMBUILD_SRPMS_DIR := $(RPMBUILD_TOP_DIR)/srpms
77-
RPMBUILD_BUILDROOT_DIR := $(RPMBUILD_TOP_DIR)/buildroot
78-
79-
RPMBUILD_GOLANG_VENDOR_TOOLS_FILE := $(RPMBUILD_SOURCES_DIR)/$(GO_VENDOR_TOOLS_FILE_NAME)
80-
RPMBUILD_SPECFILE := $(RPMBUILD_SPECS_DIR)/$(PROJECT)-$(VERSION).spec
81-
RPMBUILD_TARBALL := $(RPMBUILD_SOURCES_DIR)/$(PROJECT)-$(VERSION).tar.gz
82-
RPMBUILD_VENDOR_TARBALL := $(RPMBUILD_SOURCES_DIR)/$(PROJECT)-$(VERSION)-vendor.tar.gz
66+
RPMBUILD_TOP_DIR := $(CURDIR)/rpmbuild
67+
RPMBUILD_BUILD_DIR := $(RPMBUILD_TOP_DIR)/build
68+
RPMBUILD_RPMS_DIR := $(RPMBUILD_TOP_DIR)/rpms
69+
RPMBUILD_SPECS_DIR := $(RPMBUILD_TOP_DIR)/specs
70+
RPMBUILD_SOURCES_DIR := $(RPMBUILD_TOP_DIR)/sources
71+
RPMBUILD_SRPMS_DIR := $(RPMBUILD_TOP_DIR)/srpms
72+
RPMBUILD_BUILDROOT_DIR := $(RPMBUILD_TOP_DIR)/buildroot
73+
RPMBUILD_SPECFILE := $(RPMBUILD_SPECS_DIR)/$(SPEC_FILE_NAME)
74+
RPMBUILD_TARBALL := $(RPMBUILD_SOURCES_DIR)/$(SOURCE_TARBALL_FILENAME)
8375

8476
# Render a versioned spec into ./rpmbuild/specs (keeps source spec pristine)
8577
$(RPMBUILD_SPECFILE):
8678
mkdir -p $(RPMBUILD_SPECS_DIR)
87-
sed -e "s|^Version:.*|Version: $(VERSION)|;" \
88-
-e "s|^Source0:.*|Source0: $(PROJECT)-$(VERSION).tar.gz|;" \
89-
-e "s|^Source1:.*|Source1: $(PROJECT)-$(VERSION)-vendor.tar.gz|;" \
79+
sed -e "s/^%global commit .*/%global commit $(VERSION)/;" \
9080
$(SPEC_FILE) > $(RPMBUILD_SPECFILE)
9181

92-
# Copy sources into ./rpmbuild/sources
93-
$(RPMBUILD_TARBALL): $(SOURCE_TARBALL) $(VENDOR_TARBALL)
94-
mkdir -p $(RPMBUILD_SOURCES_DIR)
95-
cp -f $(SOURCE_TARBALL) $(RPMBUILD_TARBALL)
96-
cp -f $(VENDOR_TARBALL) $(RPMBUILD_VENDOR_TARBALL)
97-
98-
# Also copy the vendor tools TOML so macros can read it if needed
99-
$(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE):
82+
$(RPMBUILD_TARBALL): $(SOURCE_TARBALL)
10083
mkdir -p $(RPMBUILD_SOURCES_DIR)
101-
cp -f $(GO_VENDOR_TOOLS_FILE) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
84+
mv $(SOURCE_TARBALL) $(RPMBUILD_TARBALL)
10285

103-
# Build SRPM locally (outputs under ./rpmbuild)
10486
.PHONY: srpm
105-
srpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
106-
command -v rpmbuild >/dev/null || { echo "rpmbuild missing"; exit 1; }
87+
srpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL)
88+
command -v rpmbuild || sudo dnf install -y rpm-build ; \
10789
rpmbuild -bs \
10890
--define "_topdir $(RPMBUILD_TOP_DIR)" \
10991
--define "_rpmdir $(RPMBUILD_RPMS_DIR)" \
@@ -114,12 +96,10 @@ srpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FI
11496
--define "_buildrootdir $(RPMBUILD_BUILDROOT_DIR)" \
11597
$(RPMBUILD_SPECFILE)
11698

117-
# Build binary RPM locally (optional)
11899
.PHONY: rpm
119-
rpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
120-
command -v rpmbuild >/dev/null || { echo "rpmbuild missing"; exit 1; }
121-
# Uncomment to auto-install build deps on your host:
122-
# sudo dnf builddep -y $(RPMBUILD_SPECFILE)
100+
rpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL)
101+
command -v rpmbuild || sudo dnf install -y rpm-build ; \
102+
sudo dnf builddep -y $(RPMBUILD_SPECFILE)
123103
rpmbuild -bb \
124104
--define "_topdir $(RPMBUILD_TOP_DIR)" \
125105
--define "_rpmdir $(RPMBUILD_RPMS_DIR)" \
@@ -129,3 +109,20 @@ rpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FIL
129109
--define "_builddir $(RPMBUILD_BUILD_DIR)" \
130110
--define "_buildrootdir $(RPMBUILD_BUILDROOT_DIR)" \
131111
$(RPMBUILD_SPECFILE)
112+
113+
#
114+
# Packit target
115+
#
116+
117+
.PHONY: packit-create-archive
118+
packit-create-archive: $(SOURCE_TARBALL)
119+
ls -1 $(SOURCE_TARBALL)
120+
121+
.PHONY: clean
122+
clean:
123+
rm -rf $(RPMBUILD_TOP_DIR)
124+
rm -rf $(SOURCE_DIR)/go-fdo-client-*.tar.{gz,bz2}
125+
rm -rf vendor
126+
127+
# Default target
128+
all: build test

build/package/rpm/go-fdo-client.spec

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33

44
# https://github.com/fido-device-onboard/go-fdo-client
55
%global goipath github.com/fido-device-onboard/go-fdo-client
6-
%global archivename %{name}-%{version}
6+
%global commit 837c3aca86a3d44344f7edd5703cf13adfc22fc2
7+
8+
%global debug_package %{nil}
9+
10+
%gometa -L -f
11+
12+
# Vendoring: vendor/ directory is included in Source0
713

814
%global common_description %{expand:
915
go-fdo-client is the device-side implementation of FIDO Device Onboard
@@ -16,45 +22,39 @@ Version: 0
1622
Release: %autorelease -p
1723
Summary: FIDO FDO compliant device on-boarding tool
1824

19-
# Generated by go-vendor-tools
25+
# Upstream license: Apache-2.0
26+
# Bundled dependencies licenses determined from vendor/modules.txt
2027
License: Apache-2.0 AND BSD-3-Clause AND MIT
2128
URL: %{gourl}
22-
Source0: %{archivename}.tar.gz
23-
Source1: %{archivename}-vendor.tar.gz
24-
Source2: go-vendor-tools.toml
29+
Source0: %{gosource}
2530

26-
BuildRequires: go-vendor-tools
27-
BuildRequires: go-rpm-macros
28-
BuildRequires: golang
29-
30-
%gometa -L -f
31+
BuildRequires: golang >= 1.23
3132

3233
%description %{common_description}
3334

3435
%prep
35-
%autosetup -n %{archivename} -a1
36-
# %autopatch -p1
37-
38-
%generate_buildrequires
39-
%go_vendor_license_buildrequires -c %{S:2}
36+
%goprep -k -A
37+
#%autopatch -p1
4038

4139
%build
42-
%global gomodulesmode GO111MODULE=on
40+
export GO111MODULE=on
41+
export GOFLAGS=-mod=vendor
4342
%gobuild -o %{gobuilddir}/bin/go-fdo-client %{goipath}
4443

4544
%install
46-
%go_vendor_license_install -c %{S:2}
47-
install -m 0755 -vd %{buildroot}%{_bindir}
48-
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
45+
install -m 0755 -vd %{buildroot}%{_bindir}
46+
install -m 0755 -vp -s %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
4947

5048
%check
51-
%go_vendor_license_check -c %{S:2}
5249
%if %{with check}
50+
# Run tests with vendored dependencies
51+
export GO111MODULE=on
52+
export GOFLAGS=-mod=vendor
5353
%gotest ./...
5454
%endif
5555

56-
%files -f %{go_vendor_license_filelist}
57-
%license vendor/modules.txt
56+
%files
57+
%license LICENSE vendor/modules.txt
5858
%doc README.md
5959
%{_bindir}/go-fdo-client
6060

test/fmf/tests/test-onboarding.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ if ! rpm -q go-fdo-client &>/dev/null; then
3232
fi
3333
CLIENT_PKG=$(rpm -q go-fdo-client)
3434
info "go-fdo-client package is installed: ${CLIENT_PKG}"
35-
# Verify we're testing the PR artifact (should contain .pr or timestamp in version)
36-
if [[ ! "$CLIENT_PKG" =~ (pr[0-9]+|[0-9]{14}) ]]; then
37-
error "Package version does not appear to be from PR build: ${CLIENT_PKG}"
38-
error "Expected version with '.pr' or timestamp, but got: ${CLIENT_PKG}"
39-
error "This suggests the PR artifact was replaced by a stable version."
40-
exit 1
41-
fi
42-
info "Confirmed testing PR artifact build"
4335

4436
# Verify go-fdo-server subpackages are installed
4537
info "Verifying go-fdo-server installation..."

vendor/github.com/fido-device-onboard/go-fdo/.adr-dir

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/fido-device-onboard/go-fdo/.gitignore

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)