1
0
forked from pool/sysuser-tools

Accepting request 906399 from Base:System

- Use /bin/bash for sysusers-generate-pre

- Remove usage of grep from sysusers-generate-pre
- Add a simple test of sysusers-generate-pre to %check

OBS-URL: https://build.opensuse.org/request/show/906399
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/sysuser-tools?expand=0&rev=19
This commit is contained in:
Dominique Leuenberger 2021-07-17 21:36:21 +00:00 committed by Git OBS Bridge
commit db98027dbb
3 changed files with 38 additions and 2 deletions

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Thu Jul 15 06:45:15 UTC 2021 - Thorsten Kukuk <kukuk@suse.com>
- Use /bin/bash for sysusers-generate-pre
-------------------------------------------------------------------
Tue Jun 29 13:08:44 UTC 2021 - Dan Čermák <dcermak@suse.com>
- Remove usage of grep from sysusers-generate-pre
- Add a simple test of sysusers-generate-pre to %check
-------------------------------------------------------------------
Mon Jun 21 09:56:17 UTC 2021 - Dominique Leuenberger <dimstar@opensuse.org>

View File

@ -31,6 +31,7 @@ BuildArch: noarch
Requires: sysuser-shadow
#!BuildIgnore: sysuser-shadow
#!BuildIgnore: sysuser-tools
BuildRequires: diffutils
%description
Generate auto provides for system users.
@ -65,6 +66,30 @@ install -D -m 755 %{SOURCE2} %{buildroot}%{_prefix}/lib/rpm/sysusers-generate-pr
install -D -m 644 %{SOURCE3} %{buildroot}%{_rpmmacrodir}/macros.sysusers
install -D -m 755 %{SOURCE4} %{buildroot}%{_sbindir}/sysusers2shadow
%check
mkdir -p subdir
cat <<EOF > subdir/me.conf
# Type Name ID GECOS [HOME] Shell
u me - "myself" /dev/null
m me nogroup
# foobar
g asdf
z welp invalid
EOF
cat <<EOFF > expected-account-pre
/usr/sbin/sysusers2shadow me.conf <<"EOF" || [ -f /.buildenv ]
u me - "myself" /dev/null
m me nogroup
g asdf
EOF
EOFF
# copy pasta from macros.sysusers because the script sysusers-generate-pre is not in /usr/lib/rpm yet
sh %{SOURCE2} $(pwd)/subdir/me.conf me.conf > account.pre
diff account.pre expected-account-pre
%files
%defattr(-,root,root)
%{_rpmmacrodir}/macros.sysusers

View File

@ -1,6 +1,6 @@
#!/bin/sh
#!/bin/bash
# pass systemd sysusers config paths as argument to this script.
echo "/usr/sbin/sysusers2shadow $2 <<\"EOF\" || [ -f /.buildenv ]"
grep -he '^[ugmr]' "$1"
(while read -r line; do if [[ $line =~ ^\s*[ugmr] ]]; then echo "$line"; fi; done) < "$1"
echo 'EOF'