## START: Set by rpmautospec ## (rpmautospec version 0.3.5) ## RPMAUTOSPEC: autorelease %define autorelease(e:s:pb:n) %{?-p:0.}%{lua: release_number = 1; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} ## END: Set by rpmautospec # Generated by go2rpm 1.9.0 %bcond_without check # https://github.com/mailhog/MailHog %global goipath github.com/mailhog/MailHog Version: 1.0.1 %define relabel_files() \ restorecon -R /usr/bin/mailhog; \ restorecon -R /opt/mailhog; \ %define selinux_policyver 3.14.3-108 # REMOVE BEFORE SUBMITTING THIS FOR REVIEW # --- # New Fedora packages should use %%gometa -f, which makes the package # ExclusiveArch to %%golang_arches_future and thus excludes the package from # %%ix86. If the new package is needed as a dependency for another package, # please consider removing that package from %%ix86 in the same way, instead of # building more go packages for i686. If your package is not a leaf package, # you'll need to coordinate the removal of the package's dependents first. # --- # REMOVE BEFORE SUBMITTING THIS FOR REVIEW %if 0%{?fedora} > 34 || 0%{?rhel} > 8 %gometa -f %else %gometa %endif %global common_description %{expand: Web and API based SMTP testing.} %global golicenses LICENSE.md %global godocs docs README.md %global MAILHOG_USER %{name} %global MAILHOG_GROUP %{name} Name: %{goname} Release: %autorelease Summary: Web and API based SMTP testing License: MIT URL: %{gourl} Source0: %{gosource} Source1: mailhog.sysusers Source2: mailhog.service Source3: mailhog.default Source4: mailhog.pp Source5: mailhog.if Source6: mailhog_selinux.8 BuildRequires: systemd-rpm-macros %{?systemd_requires} Requires: policycoreutils, libselinux-utils Requires(post): selinux-policy-base >= %{selinux_policyver}, policycoreutils, policycoreutils-python-utils Requires(postun): policycoreutils, policycoreutils-python-utils %description %{common_description} %gopkg %prep %goprep -k %autopatch -p1 #generate_buildrequires #go_generate_buildrequires %build %gobuild -o %{gobuilddir}/bin/MailHog %{goipath} %install %gopkginstall install -m 0755 -vd %{buildroot}%{_bindir} install -m 0755 -vp %{gobuilddir}/bin/MailHog %{buildroot}%{_bindir}/mailhog install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/mailhog.conf install -d %{buildroot}%{_unitdir} install -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/ install -d %{buildroot}%{_sysconfdir}/sysconfig install -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/mailhog install -d %{buildroot}%{_datadir}/selinux/packages install -m 644 %{SOURCE4} %{buildroot}%{_datadir}/selinux/packages install -d %{buildroot}%{_datadir}/selinux/devel/include/contrib install -m 644 %{SOURCE5} %{buildroot}%{_datadir}/selinux/devel/include/contrib/ install -d %{buildroot}%{_mandir}/man8/ install -m 644 %{SOURCE6} %{buildroot}%{_mandir}/man8/mailhog_selinux.8 install -d %{buildroot}/opt/mailhog %if %{with check} %check %gocheck %endif %pre %sysusers_create_compat %{SOURCE1} %post %systemd_post mailhog.service semodule -n -i %{_datadir}/selinux/packages/mailhog.pp semanage port -a -t mailhog_http_port_t -p tcp 8025 semanage port -a -t mailhog_smtp_port_t -p tcp 1025 if /usr/sbin/selinuxenabled ; then /usr/sbin/load_policy %relabel_files fi; exit 0 %preun %systemd_preun mailhog.service %postun %systemd_postun_with_restart mailhog.service if [ $1 -eq 0 ]; then semanage port -d -p tcp 1025 semanage port -d -p tcp 8025 semodule -n -r mailhog if /usr/sbin/selinuxenabled ; then /usr/sbin/load_policy %relabel_files fi; fi; exit 0 %files %{_bindir}/* %license LICENSE.md %doc docs README.md %dir %attr(750,mailhog,mailhog) /opt/mailhog %attr(0644,root,root) %{_sysusersdir}/mailhog.conf %attr(0644,root,root) %{_sysconfdir}/sysconfig/mailhog %attr(0644,root,root) %{_unitdir}/mailhog.service %attr(0600,root,root) %{_datadir}/selinux/packages/mailhog.pp %{_datadir}/selinux/devel/include/contrib/mailhog.if %{_mandir}/man8/mailhog_selinux.8.* %gopkgfiles %changelog #autochangelog * Sat Mar 18 2023 Johan Dobbelstein 1.0.1-1 - First release based on upstream v1.0.1 - with its own systemd service unit - and its own SELinux policy