Skip to content

Commit 9c1c334

Browse files
authored
Added missing files for deb package (#52)
* Added missing files for deb package Declarative sysusers setup in rpm package Minor fixes to rpm and deb service unit files * Declare provides for opensuse builds * Misc rabbit changes * rabbit fixes * Consistently omit trailing slash for paths in rpm spec
1 parent e127760 commit 9c1c334

File tree

7 files changed

+69
-20
lines changed

7 files changed

+69
-20
lines changed

.gitignore

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,8 @@ tapir-cli
2929
dnstapir-cli
3030
version.go
3131

32-
# Ignore rpm build directory and related stuff
33-
*.tar.gz
34-
*.src.rpm
35-
#rpm/
36-
#!rpm/SOURCES/tapir-renew.service
37-
#!rpm/SOURCES/tapir-renew.timer
38-
#!rpm/SOURCES/tapir-cli.yaml
39-
#!rpm/SPECS/tapir-cli.spec
40-
41-
# Ignore deb build directory and related stuff
42-
*.deb
43-
deb/
44-
!deb/DEBIAN/control.in
45-
!deb/DEBIAN/postinst
46-
!deb/DEBIAN/postrm
47-
4832
# Ignore built stuff
4933
out/
34+
*.tar.gz
35+
*.rpm
36+
*.deb

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,14 @@ srpm: tarball
5757
test -z "$(outdir)" || cp $(OUT)/$(PROG)-$(RPM_VERSION)-*.src.rpm "$(outdir)"
5858

5959
rpm: srpm
60-
rpmbuild --recompile --define "%_topdir $(OUT)/rpm" --undefine=dist $(OUT)/$(PROG)-$(RPM_VERSION)-*.src.rpm
60+
rpmbuild --rebuild --define "%_topdir $(OUT)/rpm" --undefine=dist $(OUT)/$(PROG)-$(RPM_VERSION)-*.src.rpm
61+
cp $(OUT)/rpm/RPMS/*/$(PROG)-$(RPM_VERSION)-*.rpm $(OUT)
62+
test -z "$(outdir)" || cp $(OUT)/$(PROG)-$(RPM_VERSION)-*.rpm "$(outdir)"
6163

6264
deb: build
6365
cp -r deb $(OUT)
6466
mkdir -p $(OUT)/deb/usr/bin
6567
mkdir -p $(OUT)/deb/etc/dnstapir/certs
66-
mkdir -p $(OUT)/deb/usr/lib/systemd/system
6768
cp $(OUT)/$(PROG) $(OUT)/deb/usr/bin
6869
sed -e "s/@@VERSION@@/$(DEB_VERSION)/g" $(OUT)/deb/DEBIAN/control.in > $(OUT)/deb/DEBIAN/control
6970
dpkg-deb -b $(OUT)/deb/ $(OUT)/$(PROG)-$(DEB_VERSION).deb

deb/DEBIAN/postrm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
case "$1" in
5+
remove)
6+
;;
7+
purge)
8+
rm -rf /etc/dnstapir/
9+
;;
10+
esac
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=DNS TAPIR Edge Certificate Renewal
3+
After=network-online.target
4+
5+
[Service]
6+
Type=oneshot
7+
User=dnstapir-renew
8+
Group=dnstapir
9+
ExecStart=/usr/bin/dnstapir-cli --standalone renew \
10+
--renew-datakey /etc/dnstapir/certs/datakey-priv.json \
11+
--renew-cacert-out /etc/dnstapir/certs/ca.crt \
12+
--renew-clientkey /etc/dnstapir/certs/tls.key \
13+
--renew-clientcert-out /etc/dnstapir/certs/tls.crt
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Renew DNS TAPIR mTLS certificate every week
3+
ConditionPathExists=/etc/dnstapir/certs/datakey-priv.json
4+
ConditionPathExists=/etc/dnstapir/certs/ca.crt
5+
ConditionPathExists=/etc/dnstapir/certs/tls.key
6+
ConditionPathExists=/etc/dnstapir/certs/tls.crt
7+
8+
[Timer]
9+
OnCalendar=weekly
10+
AccuracySec=1h
11+
RandomizedDelaySec=100min
12+
13+
[Install]
14+
WantedBy=timers.target
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#Type Name ID GECOS Home directory Shell
2+
u dnstapir-renew -:dnstapir "DNS TAPIR Edge Certificate Renewal" /etc/dnstapir -
3+
g dnstapir -

rpm/SPECS/dnstapir-cli.spec.in

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Disable building of debug packages
22
%global debug_package %{nil}
33

4+
# Handle backwards compat for sysuser creation
5+
%if (0%{?fedora} && 0%{?fedora} < 42) || (0%{?rhel} && 0%{?rhel} <= 10) || (0%{?suse_version} && 0%{?suse_version} < 1660)
6+
%bcond_without sysusers_compat
7+
%else
8+
%bcond_with sysusers_compat
9+
%endif
10+
411
Name: dnstapir-cli
512
Version: @@VERSION@@
613
Release: 1%{?dist}
@@ -11,14 +18,21 @@ URL: https://www.github.com/dnstapir/cli
1118
Source0: %{name}.tar.gz
1219
Source1: dnstapir-renew.service
1320
Source2: dnstapir-renew.timer
21+
Source3: dnstapir-renew.sysusers.conf
1422
BuildRequires: git
1523
BuildRequires: golang
1624

25+
%if %{with sysusers_compat} && 0%{?suse_version}
26+
Provides: user(dnstapir-renew)
27+
Provides: group(dnstapir)
28+
%endif
29+
30+
1731
%description
1832
DNS TAPIR EDGE ClI Tool for managing an EDGE deployment
1933

20-
%{!?_unitdir: %define _unitdir /usr/lib/systemd/system/}
21-
%{!?_sysusersdir: %define _sysusersdir /usr/lib/sysusers.d/}
34+
%{!?_unitdir: %define _unitdir /usr/lib/systemd/system}
35+
%{!?_sysusersdir: %define _sysusersdir /usr/lib/sysusers.d}
2236

2337
%prep
2438
%setup -n %{name}
@@ -35,17 +49,24 @@ DESTDIR=%{buildroot}%{_bindir} make install
3549
install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}
3650
install -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}
3751

52+
# Users and Groups
53+
install -m 0644 -D %{SOURCE3} %{buildroot}%{_sysusersdir}/dnstapir-renew.conf
54+
55+
3856
%files
3957
%attr(0770,root,dnstapir) %dir %{_sysconfdir}/dnstapir
4058
%attr(0770,root,dnstapir) %dir %{_sysconfdir}/dnstapir/certs
4159
%attr(0770,root,dnstapir) %{_bindir}/%{name}
4260
%attr(0660,-,dnstapir) %ghost %{_sysconfdir}/dnstapir/dnstapir-cli.yaml
4361
%attr(0644,root,dnstapir) %{_unitdir}/dnstapir-renew.service
4462
%attr(0644,root,dnstapir) %{_unitdir}/dnstapir-renew.timer
63+
%attr(0644,root,root) %{_sysusersdir}/dnstapir-renew.conf
4564

65+
%if %{with sysusers_compat}
4666
%pre
4767
/usr/bin/getent group dnstapir || /usr/sbin/groupadd -r dnstapir
4868
/usr/bin/getent passwd dnstapir-renew || /usr/sbin/useradd -r -d /etc/dnstapir -G dnstapir -s /sbin/nologin dnstapir-renew
69+
%endif
4970

5071
%post
5172

0 commit comments

Comments
 (0)