Skip to content

Commit

Permalink
chore: unit file and packaging
Browse files Browse the repository at this point in the history
Added spec file for packaging greenboot and healthcheck
greenboot-healthcheck.service runs the health-check scripts which
runs on every boot and is orchestrated before
systemd-update-done.services
greenboot-rollback.service bindsto the systemd-update-done.services
to ensure that rollback only runs when a system is updated.

Signed-off-by: Sayan Paul <saypaul@redhat.com>
  • Loading branch information
say-paul committed Aug 7, 2023
1 parent e26f6b5 commit f83722a
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 98 deletions.
17 changes: 17 additions & 0 deletions dist/systemd/system/greenboot-healthcheck.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=greenboot Health Checks Runner
DefaultDependencies=no
Before=boot-complete.target systemd-update-done.service
OnFailureJobMode=fail
RequiresMountsFor=/boot
RequiresMountsFor=/etc

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/libexec/greenboot/greenboot health-check
Restart=no

[Install]
RequiredBy=boot-complete.target
WantedBy=multi-user.target
16 changes: 16 additions & 0 deletions dist/systemd/system/greenboot-rollback.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

[Unit]
Description=Greenboot rollback
Requires=dbus.service
RequiresMountsFor=/boot
After=systemd-update-done.service
BindsTo=systemd-update-done.service

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/libexec/greenboot/greenboot rollback
Restart=no

[Install]
WantedBy=multi-user.target
21 changes: 0 additions & 21 deletions dist/systemd/system/greenboot-trigger.service

This file was deleted.

13 changes: 0 additions & 13 deletions dist/systemd/system/greenboot.service

This file was deleted.

163 changes: 99 additions & 64 deletions greenboot.spec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
%global debug_package %{nil}
%bcond_without check
%global with_bundled 1
%global with_packit 1
%global with_packit 0
%global __cargo_skip_build 0
%global __cargo_is_lib() false
%global forgeurl https://github.com/fedora-iot/greenboot

Version: 0.99.0
Version: 1.1.12

%forgemeta

Expand Down Expand Up @@ -41,99 +41,122 @@ Requires: rpm-ostree
Requires: pam >= 1.4.0
# While not strictly necessary to generate the motd, the main use-case of this package is to display it on SSH login
Recommends: openssh
Provides: greenboot-auto-update-fallback
Obsoletes: greenboot-auto-update-fallback <= 0.12.0
Provides: greenboot-grub2
Obsoletes: greenboot-grub2 <= 0.12.0
Provides: greenboot-reboot
Obsoletes: greenboot-reboot <= 0.12.0
Provides: greenboot-status
Obsoletes: greenboot-status <= 0.12.0
Provides: greenboot-rpm-ostree-grub2
Obsoletes: greenboot-rpm-ostree-grub2 <= 0.12.0
# List of bundled crate in vendor tarball, generated with:
# cargo metadata --locked --format-version 1 | CRATE_NAME="greenboot" ./bundled-provides.jq
Provides: bundled(crate(ahash)) = 0.7.6
Provides: bundled(crate(aho-corasick)) = 0.7.19
Provides: bundled(crate(anyhow)) = 1.0.65
Provides: bundled(crate(async-trait)) = 0.1.57
Provides: bundled(crate(aho-corasick)) = 0.7.20
Provides: bundled(crate(anstream)) = 0.2.6
Provides: bundled(crate(anstyle)) = 0.3.5
Provides: bundled(crate(anstyle-parse)) = 0.1.1
Provides: bundled(crate(anstyle-wincon)) = 0.2.0
Provides: bundled(crate(anyhow)) = 1.0.70
Provides: bundled(crate(async-trait)) = 0.1.68
Provides: bundled(crate(atty)) = 0.2.14
Provides: bundled(crate(autocfg)) = 1.1.0
Provides: bundled(crate(base64)) = 0.13.0
Provides: bundled(crate(base64)) = 0.13.1
Provides: bundled(crate(bitflags)) = 1.3.2
Provides: bundled(crate(block-buffer)) = 0.10.3
Provides: bundled(crate(block-buffer)) = 0.10.4
Provides: bundled(crate(cc)) = 1.0.79
Provides: bundled(crate(cfg-if)) = 1.0.0
Provides: bundled(crate(clap)) = 4.0.4
Provides: bundled(crate(clap_derive)) = 4.0.1
Provides: bundled(crate(clap_lex)) = 0.3.0
Provides: bundled(crate(config)) = 0.13.2
Provides: bundled(crate(cpufeatures)) = 0.2.5
Provides: bundled(crate(clap)) = 4.2.0
Provides: bundled(crate(clap_builder)) = 4.2.0
Provides: bundled(crate(clap_derive)) = 4.2.0
Provides: bundled(crate(clap_lex)) = 0.4.1
Provides: bundled(crate(concolor-override)) = 1.0.0
Provides: bundled(crate(concolor-query)) = 0.3.3
Provides: bundled(crate(config)) = 0.13.3
Provides: bundled(crate(cpufeatures)) = 0.2.6
Provides: bundled(crate(crypto-common)) = 0.1.6
Provides: bundled(crate(digest)) = 0.10.5
Provides: bundled(crate(digest)) = 0.10.6
Provides: bundled(crate(dlv-list)) = 0.3.0
Provides: bundled(crate(env_logger)) = 0.7.1
Provides: bundled(crate(generic-array)) = 0.14.6
Provides: bundled(crate(getrandom)) = 0.2.7
Provides: bundled(crate(glob)) = 0.3.0
Provides: bundled(crate(errno)) = 0.3.0
Provides: bundled(crate(errno-dragonfly)) = 0.1.2
Provides: bundled(crate(figlet-rs)) = 0.1.5
Provides: bundled(crate(generic-array)) = 0.14.7
Provides: bundled(crate(getrandom)) = 0.2.8
Provides: bundled(crate(glob)) = 0.3.1
Provides: bundled(crate(hashbrown)) = 0.12.3
Provides: bundled(crate(heck)) = 0.4.0
Provides: bundled(crate(heck)) = 0.4.1
Provides: bundled(crate(hermit-abi)) = 0.1.19
Provides: bundled(crate(hermit-abi)) = 0.3.1
Provides: bundled(crate(humantime)) = 1.3.0
Provides: bundled(crate(itoa)) = 1.0.3
Provides: bundled(crate(io-lifetimes)) = 1.0.9
Provides: bundled(crate(is-terminal)) = 0.4.6
Provides: bundled(crate(itoa)) = 1.0.6
Provides: bundled(crate(json5)) = 0.4.1
Provides: bundled(crate(lazy_static)) = 1.4.0
Provides: bundled(crate(libc)) = 0.2.133
Provides: bundled(crate(libc)) = 0.2.140
Provides: bundled(crate(linked-hash-map)) = 0.5.6
Provides: bundled(crate(linux-raw-sys)) = 0.3.0
Provides: bundled(crate(log)) = 0.4.17
Provides: bundled(crate(memchr)) = 2.5.0
Provides: bundled(crate(memoffset)) = 0.6.5
Provides: bundled(crate(minimal-lexical)) = 0.2.1
Provides: bundled(crate(nix)) = 0.25.0
Provides: bundled(crate(nom)) = 7.1.1
Provides: bundled(crate(once_cell)) = 1.15.0
Provides: bundled(crate(nix)) = 0.25.1
Provides: bundled(crate(nom)) = 7.1.3
Provides: bundled(crate(once_cell)) = 1.17.1
Provides: bundled(crate(ordered-multimap)) = 0.4.3
Provides: bundled(crate(os_str_bytes)) = 6.3.0
Provides: bundled(crate(pathdiff)) = 0.2.1
Provides: bundled(crate(pest)) = 2.3.1
Provides: bundled(crate(pest_derive)) = 2.3.1
Provides: bundled(crate(pest_generator)) = 2.3.1
Provides: bundled(crate(pest_meta)) = 2.3.1
Provides: bundled(crate(pest)) = 2.5.6
Provides: bundled(crate(pest_derive)) = 2.5.6
Provides: bundled(crate(pest_generator)) = 2.5.6
Provides: bundled(crate(pest_meta)) = 2.5.6
Provides: bundled(crate(pin-utils)) = 0.1.0
Provides: bundled(crate(pretty_env_logger)) = 0.4.0
Provides: bundled(crate(proc-macro-error)) = 1.0.4
Provides: bundled(crate(proc-macro-error-attr)) = 1.0.4
Provides: bundled(crate(proc-macro2)) = 1.0.43
Provides: bundled(crate(proc-macro2)) = 1.0.54
Provides: bundled(crate(quick-error)) = 1.2.3
Provides: bundled(crate(quote)) = 1.0.21
Provides: bundled(crate(regex)) = 1.6.0
Provides: bundled(crate(regex-syntax)) = 0.6.27
Provides: bundled(crate(quote)) = 1.0.26
Provides: bundled(crate(regex)) = 1.7.3
Provides: bundled(crate(regex-syntax)) = 0.6.29
Provides: bundled(crate(ron)) = 0.7.1
Provides: bundled(crate(rust-ini)) = 0.18.0
Provides: bundled(crate(ryu)) = 1.0.11
Provides: bundled(crate(serde)) = 1.0.144
Provides: bundled(crate(serde_derive)) = 1.0.144
Provides: bundled(crate(serde_json)) = 1.0.85
Provides: bundled(crate(sha1)) = 0.10.5
Provides: bundled(crate(rustix)) = 0.37.4
Provides: bundled(crate(ryu)) = 1.0.13
Provides: bundled(crate(serde)) = 1.0.159
Provides: bundled(crate(serde_derive)) = 1.0.159
Provides: bundled(crate(serde_json)) = 1.0.95
Provides: bundled(crate(sha2)) = 0.10.6
Provides: bundled(crate(strsim)) = 0.10.0
Provides: bundled(crate(syn)) = 1.0.100
Provides: bundled(crate(termcolor)) = 1.1.3
Provides: bundled(crate(thiserror)) = 1.0.35
Provides: bundled(crate(thiserror-impl)) = 1.0.35
Provides: bundled(crate(toml)) = 0.5.9
Provides: bundled(crate(typenum)) = 1.15.0
Provides: bundled(crate(syn)) = 1.0.109
Provides: bundled(crate(syn)) = 2.0.11
Provides: bundled(crate(termcolor)) = 1.2.0
Provides: bundled(crate(thiserror)) = 1.0.40
Provides: bundled(crate(thiserror-impl)) = 1.0.40
Provides: bundled(crate(toml)) = 0.5.11
Provides: bundled(crate(typenum)) = 1.16.0
Provides: bundled(crate(ucd-trie)) = 0.1.5
Provides: bundled(crate(unicode-ident)) = 1.0.4
Provides: bundled(crate(unicode-ident)) = 1.0.8
Provides: bundled(crate(utf8parse)) = 0.2.1
Provides: bundled(crate(version_check)) = 0.9.4
Provides: bundled(crate(wasi)) = 0.11.0+wasi_snapshot_preview1
Provides: bundled(crate(winapi)) = 0.3.9
Provides: bundled(crate(winapi-i686-pc-windows-gnu)) = 0.4.0
Provides: bundled(crate(winapi-util)) = 0.1.5
Provides: bundled(crate(winapi-x86_64-pc-windows-gnu)) = 0.4.0
Provides: bundled(crate(windows-sys)) = 0.45.0
Provides: bundled(crate(windows-targets)) = 0.42.2
Provides: bundled(crate(windows_aarch64_gnullvm)) = 0.42.2
Provides: bundled(crate(windows_aarch64_msvc)) = 0.42.2
Provides: bundled(crate(windows_i686_gnu)) = 0.42.2
Provides: bundled(crate(windows_i686_msvc)) = 0.42.2
Provides: bundled(crate(windows_x86_64_gnu)) = 0.42.2
Provides: bundled(crate(windows_x86_64_gnullvm)) = 0.42.2
Provides: bundled(crate(windows_x86_64_msvc)) = 0.42.2
Provides: bundled(crate(yaml-rust)) = 0.4.5

%description
%{summary}.

%package default-health-checks
Summary: Series of optional and curated health checks
Requires: %{name} = %{version}-%{release}
Requires: util-linux
Requires: jq

%description default-health-checks
%{summary}.

%prep
%forgeautosetup
%if ! 0%{?with_packit}
Expand All @@ -147,7 +170,11 @@ cat >.cargo/config << EOF
[build]
rustc = "%{__rustc}"
rustdoc = "%{__rustdoc}"
%if 0%{?rhel} && !0%{?eln}
rustflags = %{__global_rustflags_toml}
%else
rustflags = "%{__global_rustflags_toml}"
%endif
[install]
root = "%{buildroot}%{_prefix}"
Expand Down Expand Up @@ -182,6 +209,7 @@ install -Dpm0644 -t %{buildroot}%{_unitdir} \
# add config
mkdir -p %{buildroot}%{_exec_prefix}/lib/motd.d/
mkdir -p %{buildroot}%{_libexecdir}/%{name}
install -Dpm0644 -t %{buildroot}%{_sysconfdir}/%{name} etc/greenboot/greenboot.conf
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/check/required.d
mkdir %{buildroot}%{_sysconfdir}/%{name}/check/wanted.d
mkdir %{buildroot}%{_sysconfdir}/%{name}/green.d
Expand All @@ -191,28 +219,30 @@ mkdir %{buildroot}%{_prefix}/lib/%{name}/check/wanted.d
mkdir %{buildroot}%{_prefix}/lib/%{name}/green.d
mkdir %{buildroot}%{_prefix}/lib/%{name}/red.d
mkdir -p %{buildroot}%{_unitdir}
mkdir -p %{buildroot}%{_unitdir}/greenboot-healthcheck.service.d
mkdir -p %{buildroot}%{_tmpfilesdir}
install -DpZm 0755 usr/lib/greenboot/check/required.d/* %{buildroot}%{_prefix}/lib/%{name}/check/required.d
install -DpZm 0755 usr/lib/greenboot/check/wanted.d/* %{buildroot}%{_prefix}/lib/%{name}/check/wanted.d

%post
%systemd_post greenboot.service
%systemd_post greenboot-trigger.service
%systemd_post greenboot-healthcheck.service
%systemd_post greenboot-rollback.service

%preun
%systemd_preun greenboot.service
%systemd_preun greenboot-trigger.service
%systemd_preun greenboot-healthcheck.service
%systemd_preun greenboot-rollback.service

%postun
%systemd_postun greenboot.service
%systemd_postun greenboot-trigger.service
%systemd_postun greenboot-healthcheck.service
%systemd_postun greenboot-rollback.service

%files
%doc README.md
%license LICENSE
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/%{name}
%{_unitdir}/greenboot.service
%{_unitdir}/greenboot-trigger.service
%{_unitdir}/greenboot-healthcheck.service
%{_unitdir}/greenboot-rollback.service
%{_sysconfdir}/%{name}/greenboot.conf
%dir %{_prefix}/lib/%{name}
%dir %{_prefix}/lib/%{name}/check
%dir %{_prefix}/lib/%{name}/check/required.d
Expand All @@ -226,6 +256,11 @@ mkdir -p %{buildroot}%{_tmpfilesdir}
%dir %{_sysconfdir}/%{name}/green.d
%dir %{_sysconfdir}/%{name}/red.d

%files default-health-checks
%{_prefix}/lib/%{name}/check/required.d/01_repository_dns_check.sh
%{_prefix}/lib/%{name}/check/wanted.d/01_update_platforms_check.sh
%{_prefix}/lib/%{name}/check/required.d/02_watchdog.sh

%changelog
* Thu Sep 08 2022 Peter Robinson <pbrobinson@fedoraproject.org> - 0.15.2-1
- The 0.15.2 release
Expand Down

0 comments on commit f83722a

Please sign in to comment.