SHA256
1
0
forked from pool/caddy

Accepting request 1113034 from home:avicenzi:branches:server:http

Switch to sysusers

OBS-URL: https://build.opensuse.org/request/show/1113034
OBS-URL: https://build.opensuse.org/package/show/server:http/caddy?expand=0&rev=35
This commit is contained in:
Alexandre Vicenzi 2023-09-22 14:48:31 +00:00 committed by Git OBS Bridge
parent cd383d9776
commit b5bdf64e5e
3 changed files with 11 additions and 8 deletions

View File

@ -1,7 +1,7 @@
-------------------------------------------------------------------
Thu Sep 21 14:20:37 UTC 2023 - Alexandre Vicenzi <alexandre.vicenzi@suse.com>
- Require groupadd and useradd to fix failing build
- Switch to sysuser for user setup
-------------------------------------------------------------------
Thu Aug 17 22:55:36 UTC 2023 - jkowalczyk@suse.com

View File

@ -40,12 +40,13 @@ Source3: caddy.service
Source4: index.html
Source5: bash-completion
Source6: zsh-completion
BuildRequires: /usr/sbin/groupadd
BuildRequires: /usr/sbin/useradd
Source7: caddy.sysusers
BuildRequires: golang-packaging
BuildRequires: systemd-rpm-macros
BuildRequires: sysuser-tools
BuildRequires: golang(API) >= 1.20
%{?systemd_requires}
%{sysusers_requires}
%{go_provides}
# Make sure that the binary is not getting stripped.
%{go_nostrip}
@ -70,6 +71,8 @@ CGO_ENABLED=0
go build -v -buildmode=pie -mod=vendor -ldflags "-s -w" -o caddy cmd/caddy/main.go
%sysusers_generate_pre %{SOURCE7} %{name} %{name}.conf
%install
install -d %{buildroot}/%{_sbindir}
install -D -p -m 0755 %{name} %{buildroot}%{_bindir}/%{name}
@ -80,6 +83,7 @@ install -D -p -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/%{name}/Caddyfile
# service
install -D -p -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}.service
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
install -Dpm0644 %{SOURCE7} %{buildroot}%{_sysusersdir}/%{name}.conf
# data directory
install -d -m 0750 %{buildroot}%{_sharedstatedir}/%{name}
@ -91,9 +95,7 @@ install -D -p -m 0644 %{SOURCE4} %{buildroot}%{_datadir}/%{name}/index.html
install -D -p -m 0644 %{SOURCE5} %{buildroot}%{_datadir}/bash-completion/completions/%{name}
install -D -p -m 0644 %{SOURCE6} %{buildroot}%{_datadir}/zsh/site-functions/_%{name}
%pre
getent group %{name} >/dev/null || %{_sbindir}/groupadd -r %{name}
getent passwd %{name} >/dev/null || %{_sbindir}/useradd -r -g %{name} -d %{_sharedstatedir}/%{name} -s /bin/false -c "Caddy web server" %{name}
%pre -f %{name}.pre
%service_add_pre %{name}.service
%post
@ -111,10 +113,9 @@ getent passwd %{name} >/dev/null || %{_sbindir}/useradd -r -g %{name} -d %{_shar
%doc AUTHORS README.md
%{_bindir}/%{name}
%{_datadir}/%{name}
%{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%{_sysusersdir}/%{name}.conf
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/Caddyfile
%attr(0750,%{name},%{name}) %dir %{_sharedstatedir}/%{name}

2
caddy.sysusers Normal file
View File

@ -0,0 +1,2 @@
# Type Name ID GECOS [HOME]
u caddy - "Caddy web server" /var/lib/caddy