Skip to content

Commit 3b13132

Browse files
authored
Aligning spec file with fedora review guideline (#98)
* add release * License: updated and added to each code files * Added: ownership of health-check network dropin default healtcheck scripts requires network.target, So added that as a drop in to greenboot-healtcheck. * Added bootupd dependency * Added no-replace for greenboot.conf * remove %global debug_package %{nil} from spec fedora packaging guidelines require debuginfo. * Use cargo_buildrequires macro to resolve build dependencies * fix: packit,make rpm,clippy,CI containers remove all forge and fix packit config re-aligning saypaul git username fix clippy warnings CI containers to have the necessary packages
1 parent d598ab4 commit 3b13132

13 files changed

Lines changed: 88 additions & 64 deletions

.packit.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ downstream_package_name: greenboot-rs
1111

1212
upstream_tag_template: v{version}
1313
copy_upstream_release_description: true
14+
sync_changelog: true
15+
16+
# Use clean release string without commit hashes/branch names
17+
release_suffix: ""
1418

1519
srpm_build_deps:
1620
- cargo
@@ -20,11 +24,21 @@ actions:
2024
- grep -oP '^Version:\s+\K\S+' greenboot-rs.spec
2125
create-archive:
2226
- "cargo vendor vendor"
27+
# Create archive with version for spec compatibility
2328
- bash -c "git archive --prefix=greenboot-rs-${PACKIT_PROJECT_VERSION}/ --format=tar HEAD > greenboot-rs-${PACKIT_PROJECT_VERSION}.tar"
2429
- bash -c "tar -xvf greenboot-rs-${PACKIT_PROJECT_VERSION}.tar"
2530
- bash -c "tar -czf greenboot-rs-${PACKIT_PROJECT_VERSION}.tar.gz greenboot-rs-${PACKIT_PROJECT_VERSION}"
2631
- bash -c "rm -rf greenboot-rs-${PACKIT_PROJECT_VERSION} greenboot-rs-${PACKIT_PROJECT_VERSION}.tar vendor"
2732
- bash -c "ls -1 ./greenboot-rs-*.tar.gz"
33+
post-upstream-clone:
34+
- "sed -i '/^%global forgeurl/d' greenboot-rs.spec"
35+
- "sed -i '/^%forgemeta/d' greenboot-rs.spec"
36+
- "sed -i '/^%forgeautosetup/d' greenboot-rs.spec"
37+
- bash -c "git config user.name 'Packit Build' || true"
38+
- bash -c "git config user.email 'packit@fedoraproject.org' || true"
39+
fix-spec-file:
40+
# This runs after Packit's release processing - disable debug package to prevent saypaul error
41+
- "sed -i '/^License:/a\\%global debug_package %{nil}' greenboot-rs.spec"
2842

2943
jobs:
3044
- job: copr_build

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "greenboot"
33
version = "0.1.0"
44
edition = "2024"
5+
license = "BSD-3-Clause"
56

67
[lib]
78
name = "greenboot"

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
BSD 3-Clause License
22

33
Copyright (c) 2022, Antonio Murdaca
4-
All rights reserved.
4+
Copyright (c) 2024, Sayan Paul
55

66
Redistribution and use in source and binary forms, with or without
77
modification, are permitted provided that the following conditions are met:
@@ -26,4 +26,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2626
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2727
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2828
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Makefile

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
RELEASE ?= 0
22
TARGETDIR ?= target
33
SRCDIR ?= .
4-
COMMIT = $(shell (cd "$(SRCDIR)" && git rev-parse HEAD))
4+
VERSION = $(shell grep -oP '^Version:\s+\K\S+' greenboot-rs.spec)
5+
COMMIT = $(shell (cd "$(SRCDIR)" && git rev-parse --short HEAD))
6+
TIMESTAMP = $(shell date +%Y%m%d%H%M%S)
57

6-
RPM_SPECFILE=rpmbuild/SPECS/greenboot-rs-$(COMMIT).spec
7-
RPM_TARBALL=rpmbuild/SOURCES/greenboot-rs-$(COMMIT).tar.gz
8+
# Create unique filenames with version+commit for build isolation
9+
RPM_SPECFILE=rpmbuild/SPECS/greenboot-rs-$(VERSION)-$(COMMIT).spec
10+
RPM_TARBALL=rpmbuild/SOURCES/greenboot-rs-$(VERSION).tar.gz
811

912
ifeq ($(RELEASE),1)
1013
PROFILE ?= release
@@ -19,33 +22,44 @@ all: build check
1922

2023
$(RPM_SPECFILE):
2124
mkdir -p $(CURDIR)/rpmbuild/SPECS
22-
(echo "%global commit $(COMMIT)"; git show HEAD:greenboot-rs.spec) > $(RPM_SPECFILE)
25+
# Copy spec file as-is, no modifications - let the existing release string be used
26+
cp greenboot-rs.spec $(RPM_SPECFILE)
2327

2428
$(RPM_TARBALL):
2529
mkdir -p $(CURDIR)/rpmbuild/SOURCES
26-
git archive --prefix=greenboot-rs-$(COMMIT)/ --format=tar.gz HEAD > $(RPM_TARBALL)
30+
# Create tarball with directory name matching spec file expectations: greenboot-rs-<version>/
31+
git archive --prefix=greenboot-rs-$(VERSION)/ --format=tar.gz HEAD > $(RPM_TARBALL)
2732

2833
.PHONY: build
2934
build:
3035
cargo build "--target-dir=${TARGETDIR}" ${CARGO_ARGS}
3136

32-
.PHONY: install
33-
install: build
34-
install -D -t ${DESTDIR}/usr/libexec "${TARGETDIR}/${PROFILE}/greenboot"
35-
install -D -m 644 -t ${DESTDIR}/usr/lib/systemd/system dist/systemd/system/*.service
36-
3737
.PHONY: check
3838
check:
39-
cargo test "--target-dir=${TARGETDIR}" -- --test-threads=1
39+
cargo test "--target-dir=${TARGETDIR}" ${CARGO_ARGS}
40+
41+
.PHONY: fmt
42+
fmt:
43+
cargo fmt
4044

4145
.PHONY: srpm
4246
srpm: $(RPM_SPECFILE) $(RPM_TARBALL)
43-
rpmbuild -bs \
47+
rpmbuild -bs $(RPM_SPECFILE) \
4448
--define "_topdir $(CURDIR)/rpmbuild" \
45-
$(RPM_SPECFILE)
49+
--define "_sourcedir $(CURDIR)/rpmbuild/SOURCES" \
50+
--define "_specdir $(CURDIR)/rpmbuild/SPECS" \
51+
--define "_srcrpmdir $(CURDIR)/rpmbuild/SRPMS"
4652

4753
.PHONY: rpm
4854
rpm: $(RPM_SPECFILE) $(RPM_TARBALL)
49-
rpmbuild -bb \
55+
rpmbuild -bb $(RPM_SPECFILE) \
5056
--define "_topdir $(CURDIR)/rpmbuild" \
51-
$(RPM_SPECFILE)
57+
--define "_sourcedir $(CURDIR)/rpmbuild/SOURCES" \
58+
--define "_specdir $(CURDIR)/rpmbuild/SPECS" \
59+
--define "_builddir $(CURDIR)/rpmbuild/BUILD" \
60+
--define "_rpmdir $(CURDIR)/rpmbuild/RPMS"
61+
62+
.PHONY: clean
63+
clean:
64+
cargo clean "--target-dir=${TARGETDIR}"
65+
rm -rf rpmbuild

greenboot-rs.spec

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
%global debug_package %{nil}
1+
Name: greenboot-rs
2+
Version: 0.16.0
3+
Release: 2%{?dist}
4+
Summary: Generic Health Check Framework for systemd
5+
License: BSD-3-Clause
6+
27
%bcond_without check
38
%global __cargo_skip_build 0
49
%global __cargo_is_lib() false
5-
%global forgeurl https://github.com/fedora-iot/greenboot-rs
610
%global pkgname greenboot
711

8-
Version: 0.16.0
912

10-
%forgemeta
11-
12-
Name: greenboot-rs
13-
Release: 2%{?dist}
14-
Summary: Generic Health Check Framework for systemd
15-
License: BSD-3-Clause
16-
17-
URL: %{forgeurl}
18-
Source0: %{forgesource}
13+
URL: https://github.com/fedora-iot/greenboot-rs
14+
Source0: %{name}-%{version}.tar.gz
1915

2016
ExcludeArch: s390x i686 %{power64}
2117

@@ -26,23 +22,9 @@ BuildRequires: rust-packaging
2622
%endif
2723
BuildRequires: systemd-rpm-macros
2824

29-
# greenboot dependencies
30-
BuildRequires: rust-anyhow-devel
31-
BuildRequires: rust-clap+default-devel
32-
BuildRequires: rust-clap_derive-devel
33-
BuildRequires: rust-config-devel
34-
BuildRequires: rust-env_logger-devel
35-
BuildRequires: rust-glob-devel
36-
BuildRequires: rust-once_cell-devel
37-
BuildRequires: rust-pretty_env_logger-devel
38-
BuildRequires: rust-serde_json-devel
39-
BuildRequires: rust-tempfile+default-devel
40-
BuildRequires: rust-thiserror-devel
41-
BuildRequires: rust-config+default-devel
42-
BuildRequires: rust-nix-devel
43-
4425
%{?systemd_requires}
4526
Requires: systemd >= 240
27+
Requires: bootupd
4628
Requires: rpm-ostree
4729
# PAM is required to programmatically read motd messages from /etc/motd.d/*
4830
# This causes issues with RHEL-8 as the fix isn't there an el8 is on pam-1.3.x
@@ -78,9 +60,12 @@ Requires: jq
7860
%{summary}.
7961

8062
%prep
81-
%forgeautosetup
63+
%autosetup -n %{name}-%{version}
8264
%cargo_prep
8365

66+
%generate_buildrequires
67+
%cargo_generate_buildrequires -a
68+
8469
%build
8570
%cargo_build
8671

@@ -132,7 +117,7 @@ install -DpZm 0644 usr/lib/systemd/system/greenboot-healthcheck.service.d/10-net
132117
%{_unitdir}/greenboot-healthcheck.service
133118
%{_unitdir}/greenboot-set-rollback-trigger.service
134119
%{_unitdir}/greenboot-success.target
135-
%{_sysconfdir}/%{pkgname}/greenboot.conf
120+
%config(noreplace) %{_sysconfdir}/%{pkgname}/greenboot.conf
136121
%{_prefix}/lib/bootupd/grub2-static/configs.d/08_greenboot.cfg
137122
%dir %{_prefix}/lib/%{pkgname}
138123
%dir %{_prefix}/lib/%{pkgname}/check
@@ -148,6 +133,7 @@ install -DpZm 0644 usr/lib/systemd/system/greenboot-healthcheck.service.d/10-net
148133
%dir %{_sysconfdir}/%{pkgname}/red.d
149134

150135
%files -n %{pkgname}-default-health-checks
136+
%dir %{_unitdir}/greenboot-healthcheck.service.d
151137
%{_prefix}/lib/%{pkgname}/check/wanted.d/01_update_platforms_check.sh
152138
%{_prefix}/lib/%{pkgname}/check/required.d/02_watchdog.sh
153139
%{_prefix}/lib/%{pkgname}/check/required.d/01_repository_dns_check.sh
@@ -158,6 +144,6 @@ install -DpZm 0644 usr/lib/systemd/system/greenboot-healthcheck.service.d/10-net
158144
- Update src to greenboot-rs, binaries remain greenboot
159145
- Obsoletes/Conflicts for bash greenboot, Provides greenboot
160146

161-
* Thu Jul 24 2025 Sayan Paul <paul.sayan@gmail.com> - 0.16.0-1
147+
* Thu Jul 24 2025 Sayan Paul <saypaul@redhat.com> - 0.16.0-1
162148
- Initial Package
163-
- Switched to native Fedora dependencies, removing vendoring.
149+
- Switched to native Fedora dependencies, removing vendoring.

src/lib/greenboot.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
13
use anyhow::{Result, bail};
24
use glob::glob;
35
use std::collections::HashSet;
@@ -136,12 +138,12 @@ fn run_scripts(name: &str, path: &str, disabled_scripts: Option<&[String]>) -> S
136138
};
137139

138140
// Check if script/binary should be skipped
139-
if let Some(disabled) = disabled_scripts {
140-
if disabled.contains(&file_name.to_string()) {
141-
log::info!("Skipping disabled script: {file_name}");
142-
result.skipped.push(file_name.to_string());
143-
continue;
144-
}
141+
if let Some(disabled) = disabled_scripts
142+
&& disabled.contains(&file_name.to_string())
143+
{
144+
log::info!("Skipping disabled script: {file_name}");
145+
result.skipped.push(file_name.to_string());
146+
continue;
145147
}
146148

147149
log::info!("running {} check {}", name, entry.to_string_lossy());

src/lib/grub.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
13
use anyhow::{Context, Result, bail};
24
use std::path::Path;
35
use std::process::Command;

src/lib/handler.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
13
use anyhow::{Context, Result, anyhow, bail};
24
use serde_json::Value;
35
use std::path::Path;
@@ -12,15 +14,12 @@ fn detect_os_deployment() -> Option<&'static str> {
1214
if let Ok(output) = Command::new("bootc")
1315
.args(["status", "--booted", "--json"])
1416
.output()
17+
&& output.status.success()
18+
&& let Ok(json) = serde_json::from_slice::<Value>(&output.stdout)
19+
&& json.get("kind").and_then(|v| v.as_str()) == Some("BootcHost")
1520
{
16-
if output.status.success() {
17-
if let Ok(json) = serde_json::from_slice::<Value>(&output.stdout) {
18-
if json.get("kind").and_then(|v| v.as_str()) == Some("BootcHost") {
19-
log::info!("System detected as bootc-managed host.");
20-
return Some("bootc");
21-
}
22-
}
23-
}
21+
log::info!("System detected as bootc-managed host.");
22+
return Some("bootc");
2423
}
2524

2625
// 2. If not bootc, check if it's an ostree-based OS by looking for /run/ostree-booted.

src/lib/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
13
pub mod greenboot;
24
pub mod grub;
35
pub mod handler;

src/lib/mount.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
13
use log::{info, warn};
24
use std::fs;
35
use std::path::Path;

0 commit comments

Comments
 (0)