Skip to content

Commit

Permalink
Merge pull request #6 from amazonlinux/dev
Browse files Browse the repository at this point in the history
Introduce a switch to select yum or dnf to be used for yum-based distros
  • Loading branch information
bjoernd authored Nov 19, 2024
2 parents cc5ca50 + 0954807 commit e8f6a0c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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))

Expand All @@ -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
Expand Down
45 changes: 26 additions & 19 deletions smart-restart.spec
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
%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
%defattr(-,root,root,-)
%{_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 <suschako@amazon.de> - 0.1-1.amzn2023.0.1
- Initial release of smart-restart-v0.1-1 for al2023

0 comments on commit e8f6a0c

Please # to comment.