tests/libtest: Fix logic error in creation test-repo file

`test -n` would always be true.  Also while I have the patient open
let's make writing the file atomic.  Maybe someday I'll be motivated
enough to write an `O_TMPFILE` patch for bash.

Closes: #1103
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-12-01 11:06:35 -05:00 committed by Atomic Bot
parent d9d8eefdc5
commit 42282c0a84

View File

@ -480,12 +480,13 @@ EOF
--define "_rpmdir $test_tmpdir/yumrepo/packages" \
--define "_buildrootdir $PWD")
(cd yumrepo && createrepo_c --no-database .)
if test -n yumrepo.repo; then
cat > yumrepo.repo << EOF
if test '!' -f yumrepo.repo; then
cat > yumrepo.repo.tmp << EOF
[test-repo]
name=test-repo
baseurl=file:///$PWD/yumrepo
EOF
mv yumrepo.repo{.tmp,}
fi
}