Skip to content

Instantly share code, notes, and snippets.

@yookoala
Last active April 16, 2020 10:01
Show Gist options
  • Save yookoala/b324cee824cf1cccabbe603782eca33e to your computer and use it in GitHub Desktop.
Save yookoala/b324cee824cf1cccabbe603782eca33e to your computer and use it in GitHub Desktop.
SPEC file refactored with macro
# Variables that might be modified by maintainer easily.
%define name tick5
%define version 0.1
%define release 1
%define systemdinstalldir /etc/systemd/system
%define message come on, James
# Some metadata required by an RPM package
Name: %name
Summary: Print a message every 5s
Version: %version
Release: %release
License: MIT
%description
tick5 is a simple useless script that echos a message every 5 seconds.
%install
# copy the executable to buildroot.
%{__mkdir} -p %{buildroot}%{_prefix}/bin
%{__cp} -pdf tick5 %{buildroot}%{_prefix}/bin/%{name}
%{__chmod} 755 %{buildroot}%{_prefix}/bin/%{name}
# generate the systemd unit file to buildroot.
%{__mkdir} -p %{buildroot}%{systemdinstalldir}
%{__cat} <<EOF> %{buildroot}%{systemdinstalldir}/%{name}.service
[Unit]
[Install]
WantedBy=multi-user.target
[Service]
ExecStart=%{_prefix}/bin/%{name} %{message}
Restart=always
RestartSec=5
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n
EOF
%files
%{_prefix}/bin/%{name}
%{systemdinstalldir}/tick5.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment