From bdf6f0dddba1f3e87bee60c44c14acc934e91d0a Mon Sep 17 00:00:00 2001 From: Stas Uschakow <150824261+ThatStasGuy@users.noreply.github.com> Date: Mon, 19 Feb 2024 13:58:39 +0100 Subject: [PATCH 1/3] Make shellcheck to fail on warning only --- .github/workflows/reviewdog.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index a0e3feb..4eec08a 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -21,3 +21,4 @@ jobs: exclude: "./.git/*" # Optional. check_all_files_with_shebangs: "true" # Optional. fail_on_error: "true" + shellcheck_flags: --severity=warning From b7a46984b554c9b407784436e07ae52819097340 Mon Sep 17 00:00:00 2001 From: Stanislav Uschakow Date: Thu, 29 Feb 2024 14:31:40 +0100 Subject: [PATCH 2/3] Minor changes to Makefile so the build system can actually build RPMs --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 26fb666..0f92670 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ MAJOR=0 MINOR=1 RELEASE=1 -VERSION=$(MAJOR).$(MINOR)-$(RELEASE)$(DIST) +VERSION=$(MAJOR).$(MINOR)-$(RELEASE) $(info Building version $(VERSION)) @@ -36,8 +36,10 @@ MAN_FILE_LOCATION=/usr/share/man/man1 all: $(error There is nothing to build here yet. Please use "make install" to install the config files) +srpm: sources + sources: - tar czf ./smart-restart-$(VERSION).tar.gz --transform 's,^,smart-restart-$(VERSION)/,' bin conf Makefile smart-restart.spec doc/smart-restart.man1 + tar czf ./smart-restart-v$(VERSION).tar.gz --transform 's,^,smart-restart-v$(VERSION)/,' bin conf Makefile smart-restart.spec doc/smart-restart.man1 install: $(info Dest: $(DEST_DIR)) From f93db9066c325be2a5efbf1019aa17cb90864193 Mon Sep 17 00:00:00 2001 From: Stanislav Uschakow Date: Wed, 13 Nov 2024 16:24:19 +0100 Subject: [PATCH 3/3] Changing the behavior of distro switching (al2 vs. al2023) Removing the %{dist} dependency from the spec file and adding a proper package manager switch now allows to use the rpmbuild internal functionality `--with` and `--without` to switch the package manager used. The usage is: rpmbuild -bb --with yum smart-restart.spec to build for YUM based distros or: rpmbuild -vv -bb --without yum smart-restart.spec for DNF based. Since I am reworking the pkg manger switches anyways, I also slightly modified the resulting tarball creation. The `make sources` output now doesn't contain the release anymore. --- Makefile | 10 ++++------ smart-restart.spec | 45 ++++++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 0f92670..fc2ecd5 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,11 @@ DEST_DIR?=/ PREFIX?=/usr/bin HOOK_DIR= -DIST?=$(shell cut -d ":" -f6 /etc/system-release-cpe) MAJOR=0 -MINOR=1 -RELEASE=1 +MINOR=2 -VERSION=$(MAJOR).$(MINOR)-$(RELEASE) +VERSION=v$(MAJOR).$(MINOR) $(info Building version $(VERSION)) @@ -16,7 +14,7 @@ $(info Building version $(VERSION)) HOOK_DIR=/etc/dnf/plugins/post-transaction-actions.d HOOK_COMMAND=in -ifeq ($(PKG_MANAGER),yum) +ifeq ($(pkg_manager),yum) HOOK_DIR=/etc/yum/post-actions HOOK_COMMAND=install endif @@ -39,7 +37,7 @@ all: srpm: sources sources: - tar czf ./smart-restart-v$(VERSION).tar.gz --transform 's,^,smart-restart-v$(VERSION)/,' bin conf Makefile smart-restart.spec doc/smart-restart.man1 + tar czf ./smart-restart-$(VERSION).tar.gz --transform 's,^,smart-restart-$(VERSION)/,' bin conf Makefile smart-restart.spec doc/smart-restart.man1 install: $(info Dest: $(DEST_DIR)) diff --git a/smart-restart.spec b/smart-restart.spec index 318fc29..68c60e1 100644 --- a/smart-restart.spec +++ b/smart-restart.spec @@ -1,34 +1,42 @@ +%define _trivial .0 +%define _buildid .3 Name: smart-restart -Version: 0.1 +Version: 0.2 Release: 1%{?dist} Summary: Restarts services after the libs they link against have changed. License: Apache 2.0 -%if "%{dist}" == ".amzn2023" -Requires: dnf-utils -Requires: dnf-plugin-post-transaction-actions -%define _plugin_path dnf/plugins/post-transaction-actions.d/ +%if 0%{?amzn2} +%bcond_without yum %else -%if "%{dist}" == ".amzn2" +%bcond_with yum +%endif + +%if %{with yum} Requires: yum-utils Requires: yum-plugin-post-transaction-actions %define _plugin_path yum/post-actions/ +%define pkg_manager yum %else -%{error Distribution "%{expand:%{?dist}}" not supported} -%endif +Requires: dnf-utils +Requires: dnf-plugin-post-transaction-actions +%define _plugin_path dnf/plugins/post-transaction-actions.d/ +%define pkg_manager dnf %endif -Source: %{name}-%{version}-%{release}.tar.gz + +URL: https://github.com/amazonlinux/smart-restart/archive/v%{version}/ +Source0: %{name}-v%{version}.tar.gz + %description -Hooks dnf and automatically restarts services after updates to their dependencies +Hooks dnf/yum and automatically restarts services after updates to their dependencies %prep -%setup -n %{name}-%{version}-%{release} +%autosetup -n %{name}-v%{version} -$install -# The makefile uses DNF as the default package manager, we can override with yum using PKG_MANAGER=yum -make DEST_DIR=$RPM_BUILD_ROOT DIST=%{?dist} PREFIX=%{_bindir} install +%install +make DEST_DIR=$RPM_BUILD_ROOT pkg_manager=%{pkg_manager} PREFIX=%{_bindir} install %files @@ -36,10 +44,9 @@ make DEST_DIR=$RPM_BUILD_ROOT DIST=%{?dist} PREFIX=%{_bindir} install %{_bindir}/%{name}.sh %config %{_sysconfdir}/%{_plugin_path}/install.action %config %{_sysconfdir}/smart-restart-conf.d/default-denylist -%doc /usr/share/man/man1/smart-restart.man1 - -# Update man db -# %post -# /usr/bin/mandb +%doc %{_mandir}/man1/smart-restart.man1.gz +%changelog +* Wed Mar 06 2024 Stanislav Uschakow - 0.1-1.amzn2023.0.1 +- Initial release of smart-restart-v0.1-1 for al2023