1
0
forked from pool/sysuser-tools

Accepting request 903094 from home:dancermak:branches:Base:System

Remove usage of grep from sysusers-generate-pre

OBS-URL: https://build.opensuse.org/request/show/903094
OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=48
This commit is contained in:
Thorsten Kukuk 2021-07-09 12:08:33 +00:00 committed by Git OBS Bridge
parent 2b923e08d1
commit e4b4911129
3 changed files with 32 additions and 1 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
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

@ -2,5 +2,5 @@
# 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'