@@ -32,6 +32,7 @@ restorecon=$(command -v restorecon || echo "true")
3232# generated file path, this avoids interleaving writes to the generated
3333# file by using `mv` to overwrite the file.
3434write_via_tempfile () {
35+ mkdir -p " ${tempfile_dir} "
3536 local generated_file=" $1 "
3637 local staged_file=" $( mktemp --tmpdir=" ${tempfile_dir} " " ${tempfile_template} " ) "
3738 cat > " ${staged_file} "
@@ -40,22 +41,3 @@ write_via_tempfile() {
4041 ${restorecon} " ${generated_file} "
4142}
4243
43- # Write concatenation of all files with a given suffix from a list of
44- # source directories to a target file. The target file is the first
45- # argument; suffix the second; and source directories the remaining,
46- # searched in the given order in the list. Atomicity of the write to
47- # the target file is given by appending file contents to a tempfile
48- # before moving to the target file.
49- cat_via_tempfile () {
50- local generated_file=" $1 "
51- local filter_suffix=" $2 "
52- shift 2
53- local staged_file=" $( mktemp --tmpdir=" ${tempfile_dir} " " ${tempfile_template} " ) "
54- for source_dir in " ${@ } " ; do
55- # Ignore stderr, and let the command succeed if no files are
56- # found in the source directory.
57- cat " ${source_dir} " /* " $filter_suffix " 2> /dev/null >> " ${staged_file} " || :
58- done
59- mv " ${staged_file} " " ${generated_file} "
60- ${restorecon} " ${generated_file} "
61- }
0 commit comments