[PATCH 3/3] reports.mk: use process substitution to dedup
Michael Shigorin
mike at altlinux.org
Wed Apr 28 15:06:57 MSK 2021
The first half of both pipes was clearly a copy-pasted
initial logfile processing; the file can be of considerable
size (e.g. several megabytes) so it might be slightly more
efficient and cool (but a bit more arcane) to use bash(1)'s
process substitution along with good ol' tee(1) like this:
$ echo -e '1\n2\n3' |tee /dev/stderr 2> >(grep 2 >STDERR) |grep 1 >STDOUT
$ head STD*
==> STDERR <==
2
==> STDOUT <==
1
---
reports.mk | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/reports.mk b/reports.mk
index 7b81e785a..247c722b5 100644
--- a/reports.mk
+++ b/reports.mk
@@ -78,11 +78,10 @@ reports/contents: reports/prep
esac
reports/packages: reports/prep
- @grep -E 'chroot/.in/[^/]*.rpm' < $(BUILDLOG) | \
- cut -d' ' -f 1 | tr -d "'"'`' | sed 's,^.*/,,' | \
- sort -u > "$(REPORTDIR)/list-rpms.txt"
@grep -E 'chroot/.in/[^/]*.rpm' < $(BUILDLOG) | \
cut -d' ' -f 1 | tr -d "'"'`' | \
+ tee /dev/stderr 2> >(sed 's,^.*/,,' | \
+ sort -u > "$(REPORTDIR)/list-rpms.txt") | \
xargs rpm -qp --queryformat '%{sourcerpm}\n' | \
sort -u > "$(REPORTDIR)/list-srpms.txt"
--
2.25.4
--vtzGhvizbBRQ85DL--
More information about the devel-distro
mailing list