Skip to content

Commit adb264b

Browse files
committed
chore: align with go-fdo-server rpm builds
Signed-off-by: Miguel Martín <[email protected]>
1 parent 21cb545 commit adb264b

File tree

14 files changed

+315
-192
lines changed

14 files changed

+315
-192
lines changed
File renamed without changes.

.github/scripts/fdo-utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,6 @@ test_onboarding () {
172172
get_ov_from_manufacturer ${manufacturer_service} "${guid}" ${owner_ov}
173173
set_owner_redirect_info ${owner_service} ${owner_ip} ${owner_port}
174174
send_ov_to_owner ${owner_service} ${owner_ov}
175-
run_to0 ${owner_service} "${guid}"
175+
sleep 20
176176
run_fido_device_onboard ${owner_onboard_log}
177177
}

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install golang
1919
uses: actions/setup-go@v5
2020
with:
21-
go-version: "1.23"
21+
go-version: "1.25"
2222

2323
- name: Check out repository code
2424
uses: actions/checkout@v4

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ go.work.sum
44
*.db
55
.vscode/*
66
go-fdo-client
7-
go-fdo-client-*.tar.gz
7+
go-fdo-client-*.tar.*
88
rpmbuild

.packit.yaml

Lines changed: 103 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
---
2+
# https://packit.dev/docs/configuration/
3+
4+
# We want to generate packages with the original commit sha
5+
# https://packit.dev/docs/configuration#merge_pr_in_ci
6+
merge_pr_in_ci: false
7+
18
files_to_sync:
29
- src:
310
- ".packit.yaml"
411
- "build/package/rpm/go-fdo-client.spec"
512
- "build/package/rpm/go-vendor-tools.toml"
6-
- "build/package/rpm/go-fdo-client-*-vendor.tar.gz"
13+
- "build/package/rpm/go-fdo-client-*-vendor.tar.bz2"
714
dest: .
815

916
upstream_package_name: go-fdo-client
@@ -13,13 +20,12 @@ upstream_tag_template: v{version}
1320
copy_upstream_release_description: true
1421

1522
srpm_build_deps:
16-
- make
1723
- git
1824
- golang
1925
- go-vendor-tools
20-
- gzip
21-
- tar
2226
- python3-tomlkit
27+
- askalono-cli
28+
- rpmdevtools
2329

2430
packages:
2531
go-fdo-client-fedora:
@@ -33,64 +39,130 @@ packages:
3339
pkg_tool: centpkg
3440

3541
actions:
36-
pre-sync:
37-
- make vendor-tarball VERSION=${PACKIT_PROJECT_VERSION}
38-
create-archive:
39-
- make packit-create-archive VERSION=${PACKIT_PROJECT_VERSION}
42+
post-upstream-clone:
43+
- |
44+
bash -xc '
45+
#! /bin/bash
46+
export SPEC_FILE="${PACKIT_UPSTREAM_REPO}/build/package/rpm/go-fdo-client.spec"
47+
export COMMIT="$(GIT_DIR="${PACKIT_UPSTREAM_REPO}"/.git git rev-parse HEAD)"
48+
sed -i "s/^%global commit\(\s*\).*/%global commit\1${COMMIT}/" ${SPEC_FILE}
49+
'
50+
post-modifications:
51+
# https://fedora.gitlab.io/sigs/go/go-vendor-tools/scenarios/#manual-update
52+
- |
53+
bash -xc '
54+
#! /bin/bash
55+
export GOTOOLCHAIN=auto
56+
export BASE_DIR=${PACKIT_UPSTREAM_REPO}/build/package/rpm
57+
export GO_VENDOR_TOOLS_CONFIG=${BASE_DIR}/go-vendor-tools.toml
58+
export SPEC_FILE=${BASE_DIR}/go-fdo-client.spec
59+
# Download the source tarball (Source0) needed by go_vendor_archive
60+
spectool -g -C ${BASE_DIR} ${SPEC_FILE} || exit 1
61+
go_vendor_archive create --config ${GO_VENDOR_TOOLS_CONFIG} ${SPEC_FILE}
62+
go_vendor_license \
63+
--config ${GO_VENDOR_TOOLS_CONFIG} \
64+
--path ${SPEC_FILE} \
65+
report \
66+
--verify-spec
67+
'
4068
4169
jobs:
70+
71+
# Fedora jobs
72+
73+
# We build and test Fedora 43 ('latest-stable'), Fedora 44 ('latest' when branched) and Fedora Rawhide
74+
# because they are the only ones officially released with golang >= 1.25.0
4275
- &copr_fedora
4376
job: copr_build
4477
packages: [go-fdo-client-fedora]
4578
trigger: pull_request
46-
targets:
47-
- fedora-stable
48-
- fedora-development
79+
targets: &copr_fedora_targets
80+
- "fedora-latest-stable-x86_64"
81+
- "fedora-latest-stable-aarch64"
82+
- "fedora-latest-x86_64"
83+
- "fedora-latest-aarch64"
84+
- "fedora-rawhide-x86_64"
85+
- "fedora-rawhide-aarch64"
4986

87+
# Build all versions in '@fedora-iot/copr' copr because it's possible to add golang >= 1.25.0
88+
# see: https://copr.fedorainfracloud.org/coprs/g/fedora-iot/fedora-iot/edit_chroot/fedora-42-x86_64/
5089
- <<: *copr_fedora
5190
trigger: commit
5291
branch: main
5392
owner: "@fedora-iot"
5493
project: fedora-iot
94+
targets:
95+
- "fedora-stable-x86_64"
96+
- "fedora-stable-aarch64"
97+
- "fedora-development-x86_64"
98+
- "fedora-development-aarch64"
99+
- "fedora-eln-x86_64"
100+
- "fedora-eln-aarch64"
55101

102+
# Only Fedora >= 43 have golang >= 1.25.0
56103
- job: propose_downstream
57104
trigger: release
58105
packages: [go-fdo-client-fedora]
106+
# Avoid divergent branches: https://packit.dev/docs/fedora-releases-guide/non-divergent-dist-git-branches
59107
dist_git_branches:
60-
- fedora-stable
61-
- fedora-development
108+
rawhide:
109+
fast_forward_merge_into: ["fedora-latest-stable","fedora-latest"]
110+
111+
- job: koji_build
112+
trigger: commit
113+
allowed_pr_authors: [all_committers]
114+
dist_git_branches: &fedora_dist_git_branches
115+
- "fedora-latest-stable"
116+
- "fedora-latest"
117+
- "fedora-rawhide"
118+
119+
- job: bodhi_update
120+
trigger: commit
121+
allowed_builders: [all_committers]
122+
dist_git_branches: *fedora_dist_git_branches
123+
124+
# Fedora E2E Testing jobs
125+
# We build and test Fedora 43 ('latest-stable'), Fedora 44 ('latest' when branched) and Fedora Rawhide
126+
# because they are the only ones officially released with golang >= 1.25.0
127+
- job: tests
128+
trigger: pull_request
129+
identifier: e2e-fedora
130+
tmt_plan: test/fmf/plans/e2e
131+
packages: [go-fdo-client-fedora]
132+
targets: *copr_fedora_targets
133+
134+
# CentOS jobs
62135

63136
- &copr_centos
64137
job: copr_build
65138
packages: [go-fdo-client-centos]
66139
trigger: pull_request
67-
targets:
68-
- epel-9
69-
- epel-10
140+
targets: &copr_centos_targets
141+
- "centos-stream-9-x86_64"
142+
- "centos-stream-9-aarch64"
143+
- "centos-stream-10-x86_64"
144+
- "centos-stream-10-aarch64"
70145

71146
- <<: *copr_centos
72147
trigger: commit
73148
branch: main
74149
owner: "@fedora-iot"
75150
project: fedora-iot
76-
77-
- job: tests
78-
trigger: pull_request
79-
identifier: e2e-fedora
80-
fmf_path: test/fmf
81-
tmt_plan: plans/e2e
82-
packages: [go-fdo-client-fedora]
83151
targets:
84-
- fedora-stable
85-
- fedora-development
152+
- "centos-stream-9-x86_64"
153+
- "centos-stream-9-aarch64"
154+
- "centos-stream-10-x86_64"
155+
- "centos-stream-10-aarch64"
156+
- "epel-9-x86"
157+
- "epel-9-aarch64"
158+
- "epel-10-x86"
159+
- "epel-10-aarch64"
86160

161+
# CentOS E2E Testing jobs
162+
#
87163
- job: tests
88164
trigger: pull_request
89165
identifier: e2e-centos
90-
fmf_path: test/fmf
91-
tmt_plan: plans/e2e
166+
tmt_plan: test/fmf/plans/e2e
92167
packages: [go-fdo-client-centos]
93-
targets:
94-
- epel-9
95-
- epel-10
96-
168+
targets: *copr_centos_targets

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: Apache 2.0
22

3-
FROM golang:1.23-alpine AS builder
3+
FROM golang:1.25-alpine AS builder
44

55
WORKDIR /go/src/app
66
COPY . .

Makefile

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,65 @@
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
5-
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
1+
PROJECT := go-fdo-client
2+
RPM_BASE_DIR := $(CURDIR)/build/package/rpm
3+
SPEC_FILE_NAME := $(PROJECT).spec
4+
SPEC_FILE := $(RPM_BASE_DIR)/$(SPEC_FILE_NAME)
5+
COMMIT_SHORT := $(shell git rev-parse --short HEAD)
6+
VERSION := $(shell bash -c "set -o pipefail; git describe --tags | sed -e 's/^v//' -e 's/-.*//'")
7+
ifeq ($(VERSION),)
8+
VERSION := $(shell grep 'Version:' $(SPEC_FILE) | awk '{printf "%s", $$2}')
9+
endif
10+
11+
ARCH := $(shell uname -m)
12+
13+
SOURCEDIR := $(CURDIR)/build/package/rpm
14+
SPEC_FILE_NAME := $(PROJECT).spec
15+
SPEC_FILE := $(SOURCEDIR)/$(SPEC_FILE_NAME)
1016
GO_VENDOR_TOOLS_FILE_NAME := go-vendor-tools.toml
17+
GO_VENDOR_TOOLS_FILE := $(SOURCEDIR)/$(GO_VENDOR_TOOLS_FILE_NAME)
1118

1219
SOURCE_TARBALL := $(SOURCEDIR)/$(PROJECT)-$(VERSION).tar.gz
13-
VENDOR_TARBALL := $(SOURCEDIR)/$(PROJECT)-$(VERSION)-vendor.tar.gz
20+
VENDOR_TARBALL := $(SOURCEDIR)/$(PROJECT)-$(VERSION)-vendor.tar.bz2
1421

1522
# Build the Go project
16-
.PHONY: all build tidy fmt vet test
23+
.PHONY: all
1724
all: build test
1825

26+
.PHONY: build
1927
build: tidy fmt vet
20-
go build -ldflags="-X github.com/fido-device-onboard/go-fdo-client/internal/version.VERSION=${VERSION}"
28+
go build -ldflags="-X github.com/fido-device-onboard/go-fdo-client/internal/version.VERSION=$(VERSION)"
2129

30+
.PHONY: tidy
2231
tidy:
2332
go mod tidy
2433

34+
.PHONY: fmt
2535
fmt:
2636
go fmt ./...
2737

38+
.PHONY: vet
2839
vet:
2940
go vet ./...
3041

42+
.PHONY: test
3143
test:
3244
go test -v ./...
3345

34-
# Packit helpers
35-
.PHONY: vendor-tarball packit-create-archive vendor-licenses
36-
46+
.PHONY: vendor-tarball
3747
vendor-tarball: $(VENDOR_TARBALL)
3848

3949
$(VENDOR_TARBALL):
4050
rm -rf vendor; \
4151
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) .; \
52+
go_vendor_archive create --config $(GO_VENDOR_TOOLS_FILE) --write-config --output $(VENDOR_TARBALL) .; \
4353
rm -rf vendor;
4454

45-
packit-create-archive: $(SOURCE_TARBALL) $(VENDOR_TARBALL)
46-
@ls -1 "$(SOURCE_TARBALL)" | head -n1
55+
.PHONY: source-tarball
56+
source-tarball: $(SOURCE_TARBALL)
4757

4858
$(SOURCE_TARBALL):
4959
mkdir -p "$(SOURCEDIR)"
5060
git archive --format=tar --prefix="$(PROJECT)-$(VERSION)/" HEAD | gzip > "$(SOURCE_TARBALL)"
5161

62+
.PHONY: vendor-licenses
5263
vendor-licenses:
5364
go_vendor_license --config "$(GO_VENDOR_TOOLS_FILE)" .
5465

@@ -64,10 +75,6 @@ vendor-licenses:
6475
# ./rpmbuild, using rpmbuild's usual directory structure (in lowercase).
6576
#
6677

67-
RPM_BASE_DIR := $(CURDIR)/build/package/rpm
68-
SPEC_FILE_NAME := $(PROJECT).spec
69-
SPEC_FILE := $(RPM_BASE_DIR)/$(SPEC_FILE_NAME)
70-
7178
RPMBUILD_TOP_DIR := $(CURDIR)/rpmbuild
7279
RPMBUILD_BUILD_DIR := $(RPMBUILD_TOP_DIR)/build
7380
RPMBUILD_RPMS_DIR := $(RPMBUILD_TOP_DIR)/rpms
@@ -79,14 +86,15 @@ RPMBUILD_BUILDROOT_DIR := $(RPMBUILD_TOP_DIR)/buildroot
7986
RPMBUILD_GOLANG_VENDOR_TOOLS_FILE := $(RPMBUILD_SOURCES_DIR)/$(GO_VENDOR_TOOLS_FILE_NAME)
8087
RPMBUILD_SPECFILE := $(RPMBUILD_SPECS_DIR)/$(PROJECT)-$(VERSION).spec
8188
RPMBUILD_TARBALL := $(RPMBUILD_SOURCES_DIR)/$(PROJECT)-$(VERSION).tar.gz
82-
RPMBUILD_VENDOR_TARBALL := $(RPMBUILD_SOURCES_DIR)/$(PROJECT)-$(VERSION)-vendor.tar.gz
89+
RPMBUILD_VENDOR_TARBALL := $(RPMBUILD_SOURCES_DIR)/$(PROJECT)-$(VERSION)-vendor.tar.bz2
90+
RPMBUILD_SRPM_FILE := $(RPMBUILD_SRPMS_DIR)/$(PROJECT)-$(VERSION)-git$(COMMIT_SHORT).src.rpm
91+
RPMBUILD_RPM_FILE := $(RPMBUILD_RPMS_DIR)/$(ARCH)/$(PROJECT)-$(VERSION)-git$(COMMIT_SHORT).$(ARCH).rpm
8392

8493
# Render a versioned spec into ./rpmbuild/specs (keeps source spec pristine)
8594
$(RPMBUILD_SPECFILE):
8695
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|;" \
96+
sed -e "s/^Version:\(\s*\).*/Version:\1$(VERSION)/;" \
97+
-e "s/^Release:\(\s*\).*/Release:\1git$(COMMIT_SHORT)/;" \
9098
$(SPEC_FILE) > $(RPMBUILD_SPECFILE)
9199

92100
# Copy sources into ./rpmbuild/sources
@@ -100,9 +108,7 @@ $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE):
100108
mkdir -p $(RPMBUILD_SOURCES_DIR)
101109
cp -f $(GO_VENDOR_TOOLS_FILE) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
102110

103-
# Build SRPM locally (outputs under ./rpmbuild)
104-
.PHONY: srpm
105-
srpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
111+
$(RPMBUILD_SRPM_FILE): $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
106112
command -v rpmbuild >/dev/null || { echo "rpmbuild missing"; exit 1; }
107113
rpmbuild -bs \
108114
--define "_topdir $(RPMBUILD_TOP_DIR)" \
@@ -114,9 +120,7 @@ srpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FI
114120
--define "_buildrootdir $(RPMBUILD_BUILDROOT_DIR)" \
115121
$(RPMBUILD_SPECFILE)
116122

117-
# Build binary RPM locally (optional)
118-
.PHONY: rpm
119-
rpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
123+
$(RPMBUILD_RPM_FILE): $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
120124
command -v rpmbuild >/dev/null || { echo "rpmbuild missing"; exit 1; }
121125
# Uncomment to auto-install build deps on your host:
122126
# sudo dnf builddep -y $(RPMBUILD_SPECFILE)
@@ -129,3 +133,11 @@ rpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FIL
129133
--define "_builddir $(RPMBUILD_BUILD_DIR)" \
130134
--define "_buildrootdir $(RPMBUILD_BUILDROOT_DIR)" \
131135
$(RPMBUILD_SPECFILE)
136+
137+
# Build SRPM locally (outputs under ./rpmbuild)
138+
.PHONY: srpm
139+
srpm: $(RPMBUILD_SRPM_FILE)
140+
141+
# Build binary RPM locally (optional)
142+
.PHONY: rpm
143+
rpm: $(RPMBUILD_RPM_FILE)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
## Prerequisites
1010

11-
- Go 1.23.0 or later
11+
- Go 1.25.0 or later
1212
- A Go module initialized with `go mod init`
1313

1414
## Building the Client Application

0 commit comments

Comments
 (0)