Skip to content

Commit 31046a7

Browse files
committed
fix(packit): generate vendor tarball also in pre-sync
Signed-off-by: Miguel Martín <[email protected]>
1 parent cee7b29 commit 31046a7

File tree

2 files changed

+25
-39
lines changed

2 files changed

+25
-39
lines changed

.packit.yaml

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ files_to_sync:
1010
- ".packit.yaml"
1111
- "build/package/rpm/go-fdo-client.spec"
1212
- "build/package/rpm/go-vendor-tools.toml"
13-
- "build/package/rpm/go-fdo-client-*-vendor.tar.bz2"
1413
dest: .
1514

1615
upstream_package_name: go-fdo-client
@@ -39,32 +38,11 @@ packages:
3938
pkg_tool: centpkg
4039

4140
actions:
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-
'
41+
pre-sync:
42+
- bash -c "make packit-vendor-tarball VERSION=${PACKIT_PROJECT_VERSION}"
5043
post-modifications:
5144
# 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-
'
45+
- bash -c "make packit-vendor-tarball VERSION=${PACKIT_PROJECT_VERSION}"
6846

6947
jobs:
7048

Makefile

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
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
1+
#! /usr/bin/make -f
102

3+
PROJECT := go-fdo-client
114
ARCH := $(shell uname -m)
12-
135
SOURCEDIR := $(CURDIR)/build/package/rpm
146
SPEC_FILE_NAME := $(PROJECT).spec
157
SPEC_FILE := $(SOURCEDIR)/$(SPEC_FILE_NAME)
8+
COMMIT_SHORT := $(shell git rev-parse --short HEAD)
9+
VERSION := $(shell grep 'Version:' $(SPEC_FILE) | awk '{printf "%s", $$2}').git$(COMMIT_SHORT)
10+
1611
GO_VENDOR_TOOLS_FILE_NAME := go-vendor-tools.toml
1712
GO_VENDOR_TOOLS_FILE := $(SOURCEDIR)/$(GO_VENDOR_TOOLS_FILE_NAME)
1813

@@ -120,6 +115,11 @@ $(RPMBUILD_SRPM_FILE): $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLAN
120115
--define "_buildrootdir $(RPMBUILD_BUILDROOT_DIR)" \
121116
$(RPMBUILD_SPECFILE)
122117

118+
# Build SRPM locally (outputs under ./rpmbuild)
119+
.PHONY: srpm
120+
srpm: $(RPMBUILD_SRPM_FILE)
121+
122+
123123
$(RPMBUILD_RPM_FILE): $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
124124
command -v rpmbuild >/dev/null || { echo "rpmbuild missing"; exit 1; }
125125
# Uncomment to auto-install build deps on your host:
@@ -134,10 +134,18 @@ $(RPMBUILD_RPM_FILE): $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG
134134
--define "_buildrootdir $(RPMBUILD_BUILDROOT_DIR)" \
135135
$(RPMBUILD_SPECFILE)
136136

137-
# Build SRPM locally (outputs under ./rpmbuild)
138-
.PHONY: srpm
139-
srpm: $(RPMBUILD_SRPM_FILE)
140-
141137
# Build binary RPM locally (optional)
142138
.PHONY: rpm
143139
rpm: $(RPMBUILD_RPM_FILE)
140+
141+
.PHONY: packit-vendor-tarball
142+
packit-vendor-tarball:
143+
export GOTOOLCHAIN=auto; \
144+
# Download the source tarball (Source0) needed by go_vendor_archive
145+
spectool -g -C $(SOURCEDIR) $(SPEC_FILE); \
146+
go_vendor_archive create --config ${GO_VENDOR_TOOLS_FILE} ${SPEC_FILE}; \
147+
go_vendor_license \
148+
--config $(GO_VENDOR_TOOLS_FILE) \
149+
--path $(SPEC_FILE) \
150+
report \
151+
--verify-spec;

0 commit comments

Comments
 (0)