Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ go-fdo-server
go-fdo-server-*.tar.gz
rpmbuild
test/workdir
vendor/
21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ SOURCE_DIR := $(CURDIR)/build/package/rpm
SOURCE_TARBALL_FILENAME := go-fdo-server-$(VERSION).tar.gz
SOURCE_TARBALL := $(SOURCE_DIR)/${SOURCE_TARBALL_FILENAME}
$(SOURCE_TARBALL):
@echo "Creating source tarball..."
git archive --prefix=go-fdo-server-$(VERSION)/ --format=tar.gz HEAD > $(SOURCE_TARBALL)

.PHONY: source-tarball
source-tarball: $(SOURCE_TARBALL)

GO_VENDOR_TOOLS_FILE_NAME := go-vendor-tools.toml
GO_VENDOR_TOOLS_FILE := $(SOURCE_DIR)/$(GO_VENDOR_TOOLS_FILE_NAME)
VENDOR_TARBALL_FILENAME := go-fdo-server-$(VERSION)-vendor.tar.bz2
VENDOR_TARBALL := $(SOURCE_DIR)/$(VENDOR_TARBALL_FILENAME)
$(VENDOR_TARBALL):
@echo "Creating vendor tarball..."
rm -rf vendor; \
command -v go_vendor_archive || sudo dnf install -y go-vendor-tools python3-tomlkit; \
go_vendor_archive create --config $(GO_VENDOR_TOOLS_FILE) --write-config --output $(VENDOR_TARBALL) .; \
rm -rf vendor;
go mod vendor; \
tar -cjf $(VENDOR_TARBALL) vendor/; \
rm -rf vendor
Comment on lines -49 to +51
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is the spec file depending on go-vendor-tools, not its use in the Makefile. We can keep the current vendor tarball generation I believe


.PHONY: vendor-tarball
vendor-tarball: $(VENDOR_TARBALL)
Expand Down Expand Up @@ -88,7 +88,6 @@ RPMBUILD_SOURCES_DIR := $(RPMBUILD_TOP_DIR)/sources
RPMBUILD_SRPMS_DIR := $(RPMBUILD_TOP_DIR)/srpms
RPMBUILD_BUILD_DIR := $(RPMBUILD_TOP_DIR)/build
RPMBUILD_BUILDROOT_DIR := $(RPMBUILD_TOP_DIR)/buildroot
RPMBUILD_GOLANG_VENDOR_TOOLS_FILE := $(RPMBUILD_SOURCES_DIR)/$(GO_VENDOR_TOOLS_FILE_NAME)
RPMBUILD_SPECFILE := $(RPMBUILD_SPECS_DIR)/$(SPEC_FILE_NAME)
RPMBUILD_TARBALL := $(RPMBUILD_SOURCES_DIR)/$(SOURCE_TARBALL_FILENAME)
RPMBUILD_VENDOR_TARBALL := ${RPMBUILD_SOURCES_DIR}/$(VENDOR_TARBALL_FILENAME)
Expand All @@ -108,9 +107,6 @@ $(RPMBUILD_TARBALL): $(SOURCE_TARBALL) $(VENDOR_TARBALL)
mv $(SOURCE_TARBALL) $(RPMBUILD_TARBALL)
mv $(VENDOR_TARBALL) $(RPMBUILD_VENDOR_TARBALL);

$(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE):
cp $(GO_VENDOR_TOOLS_FILE) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)

$(RPMBUILD_GROUP_FILE):
cp $(GROUP_FILE) $(RPMBUILD_GROUP_FILE)

Expand All @@ -124,7 +120,7 @@ $(RPMBUILD_OWNER_USER_FILE):
cp $(OWNER_USER_FILE) $(RPMBUILD_OWNER_USER_FILE)

.PHONY: srpm
srpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE) $(RPMBUILD_GROUP_FILE) $(RPMBUILD_MANUFACTURER_USER_FILE) $(RPMBUILD_RENDEZVOUS_USER_FILE) $(RPMBUILD_OWNER_USER_FILE)
srpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GROUP_FILE) $(RPMBUILD_MANUFACTURER_USER_FILE) $(RPMBUILD_RENDEZVOUS_USER_FILE) $(RPMBUILD_OWNER_USER_FILE)
command -v rpmbuild || sudo dnf install -y rpm-build ; \
rpmbuild -bs \
--define "_topdir $(RPMBUILD_TOP_DIR)" \
Expand All @@ -137,7 +133,7 @@ srpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FI
$(RPMBUILD_SPECFILE)

.PHONY: rpm
rpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE) $(RPMBUILD_GROUP_FILE) $(RPMBUILD_MANUFACTURER_USER_FILE) $(RPMBUILD_RENDEZVOUS_USER_FILE) $(RPMBUILD_OWNER_USER_FILE)
rpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GROUP_FILE) $(RPMBUILD_MANUFACTURER_USER_FILE) $(RPMBUILD_RENDEZVOUS_USER_FILE) $(RPMBUILD_OWNER_USER_FILE)
command -v rpmbuild || sudo dnf install -y rpm-build ; \
sudo dnf builddep -y $(RPMBUILD_SPECFILE)
rpmbuild -bb \
Expand All @@ -156,12 +152,13 @@ rpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FIL

.PHONY: packit-create-archive
packit-create-archive: $(SOURCE_TARBALL) $(VENDOR_TARBALL)
ls -1 $(SOURCE_TARBALL)
ls -1 $(SOURCE_TARBALL) $(VENDOR_TARBALL)

.PHONY: clean
clean:
rm -rf $(RPMBUILD_TOP_DIR)
rm -rf $(SOURCE_DIR)/go-fdo-server-*.tar.{gz,bz2}
rm -rf vendor

# Default target
all: build test
39 changes: 16 additions & 23 deletions build/package/rpm/go-fdo-server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ Version: 0
Release: %autorelease -p
Summary: A Go implementation of the FIDO Device Onboard Specification

# Generated by go-vendor-tools
License: Apache-2.0 AND BSD-3-Clause AND MIT
URL: %{gourl}
Source0: %{gosource}
# Generated by go-vendor-tools
Source1: %{archivename}-vendor.tar.bz2
Source2: go-vendor-tools.toml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although we are not going to use the go-vendor-tools.toml file from within the spec file, it might worth it to maintain it in the sources so it's possible to generate the vendor tarball externally with go-vendor-tools. ??

Source3: go-fdo-server-group.conf
Source4: go-fdo-server-manufacturer-user.conf
Source5: go-fdo-server-rendezvous-user.conf
Source6: go-fdo-server-owner-user.conf
Source2: go-fdo-server-group.conf
Source3: go-fdo-server-manufacturer-user.conf
Source4: go-fdo-server-rendezvous-user.conf
Source5: go-fdo-server-owner-user.conf

BuildRequires: go-vendor-tools
BuildRequires: golang >= 1.25
# Systemd units
BuildRequires: systemd-rpm-macros
# Sysusers
Expand All @@ -43,24 +40,20 @@ devices when they are first powered on in their final location.
%setup -q -T -D -a1 %{forgesetupargs}
#%%autopatch -p1

%generate_buildrequires
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we replace this with %go_generate_buildrequires from the go-rpm-macros package? not sure if that would work though

%go_vendor_license_buildrequires -c %{S:2}

%build
%global gomodulesmode GO111MODULE=on
%gobuild -o %{gobuilddir}/bin/go-fdo-server %{goipath}

%install
%go_vendor_license_install -c %{S:2}
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp -s %{gobuilddir}/bin/* %{buildroot}%{_bindir}
# Configuration dir
install -m 0755 -vd %{buildroot}%{_sysconfdir}/%{name}
# Sysusers
install -m 0644 -vp -D %{SOURCE3} %{buildroot}/%{_sysusersdir}/go-fdo-server.conf
install -m 0644 -vp -D %{SOURCE4} %{buildroot}/%{_sysusersdir}/go-fdo-server-manufacturer.conf
install -m 0644 -vp -D %{SOURCE5} %{buildroot}/%{_sysusersdir}/go-fdo-server-rendezvous.conf
install -m 0644 -vp -D %{SOURCE6} %{buildroot}/%{_sysusersdir}/go-fdo-server-owner.conf
install -m 0644 -vp -D %{SOURCE2} %{buildroot}/%{_sysusersdir}/go-fdo-server.conf
install -m 0644 -vp -D %{SOURCE3} %{buildroot}/%{_sysusersdir}/go-fdo-server-manufacturer.conf
install -m 0644 -vp -D %{SOURCE4} %{buildroot}/%{_sysusersdir}/go-fdo-server-rendezvous.conf
install -m 0644 -vp -D %{SOURCE5} %{buildroot}/%{_sysusersdir}/go-fdo-server-owner.conf
# Sysconfig files
install -m 0755 -vd %{buildroot}%{_sysconfdir}/sysconfig
install -m 0644 -vp -D configs/sysconfig/* %{buildroot}%{_sysconfdir}/sysconfig/
Expand All @@ -72,12 +65,12 @@ install -m 0755 -vd %{buildroot}%{_datadir}/%{name}
install -m 0755 -vp -D scripts/* %{buildroot}%{_datadir}/%{name}

%check
%go_vendor_license_check -c %{S:2}
%if %{with check}
%gotest ./...
%endif
%files -f %{go_vendor_license_filelist}
%license vendor/modules.txt

%files
%license LICENSE vendor/modules.txt
%doc DOCKERFILE_USAGE.md FSIM_USAGE.md README.md SECURITY.md
%{_bindir}/go-fdo-server
%config(noreplace) %attr(770, root, go-fdo-server) %{_sysconfdir}/%{name}
Expand All @@ -90,7 +83,7 @@ install -m 0755 -vp -D scripts/* %{buildroot}%{_datadir}/%{name}
%{_datadir}/%{name}/generate-owner-certs.sh

%pre
%sysusers_create_compat %{SOURCE3}
%sysusers_create_compat %{SOURCE2}

%package manufacturer
Requires: go-fdo-server
Expand All @@ -110,7 +103,7 @@ preparing devices for the on-boarding process during the manufacturing phase.
# Sysuser
%{_sysusersdir}/go-fdo-server-manufacturer.conf
%pre manufacturer
%sysusers_create_compat %{SOURCE4}
%sysusers_create_compat %{SOURCE3}

%post manufacturer
%systemd_post go-fdo-server-manufacturer.service
Expand Down Expand Up @@ -139,7 +132,7 @@ voucher.
# Sysuser
%{_sysusersdir}/go-fdo-server-rendezvous.conf
%pre rendezvous
%sysusers_create_compat %{SOURCE5}
%sysusers_create_compat %{SOURCE4}

%post rendezvous
%systemd_post go-fdo-server-rendezvous.service
Expand Down Expand Up @@ -168,7 +161,7 @@ necessary credentials and configuration for operation.
# Sysuser
%{_sysusersdir}/go-fdo-server-owner.conf
%pre owner
%sysusers_create_compat %{SOURCE6}
%sysusers_create_compat %{SOURCE5}

%post owner
%systemd_post go-fdo-server-owner.service
Expand Down
Loading