Skip to content

Commit 4021c4f

Browse files
committed
use a proper randomly named temporary directory
Still will use the CWD but, just in case, won't overwrite/remove ./tmp if it exists.
1 parent cc59489 commit 4021c4f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

custom-coreos-disk-images.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ main() {
114114
fi
115115

116116
# Make a local tmpdir
117-
mkdir -p tmp; rm -f tmp/*
117+
tmpdir=$(mktemp -d ./tmp-osbuild-XXX)
118118

119119
# Freeze on specific version for now to increase stability.
120120
#gitreporef="main"
121121
gitreporef="3a76784b37fe073718a7f9d9d67441d9d8b34c10"
122122
gitrepotld="https://raw.githubusercontent.com/coreos/coreos-assembler/${gitreporef}/"
123-
pushd ./tmp
123+
pushd "${tmpdir}"
124124
curl -LO --fail "${gitrepotld}/src/runvm-osbuild"
125125
chmod +x runvm-osbuild
126126
for manifest in "coreos.osbuild.${ARCH}.mpp.yaml" platform.{applehv,gcp,hyperv,metal,qemu}.ipp.yaml; do
@@ -154,7 +154,7 @@ main() {
154154
# on RHCOS but we may want to start picking it up from inside
155155
# the container image (/usr/share/coreos-assembler/image.json)
156156
# in the future. https://github.com/openshift/os/blob/master/image.yaml
157-
cat > tmp/diskvars.json << EOF
157+
cat > "${tmpdir}/diskvars.json" << EOF
158158
{
159159
"osname": "${osname}",
160160
"deploy-via-container": "true",
@@ -167,14 +167,14 @@ main() {
167167
"extra-kargs-string": ""
168168
}
169169
EOF
170-
./tmp/runvm-osbuild \
171-
--config tmp/diskvars.json \
172-
--filepath "./${outfile}" \
173-
--mpp "tmp/coreos.osbuild.${ARCH}.mpp.yaml"
170+
"${tmpdir}/runvm-osbuild" \
171+
--config "${tmpdir}/diskvars.json" \
172+
--filepath "./${outfile}" \
173+
--mpp "${tmpdir}/coreos.osbuild.${ARCH}.mpp.yaml"
174174
echo "Created $platform image file at: ${outfile}"
175175
done
176176

177-
rm -f tmp/*; rmdir tmp # Cleanup
177+
rm -f "${tmpdir}"/*; rmdir "${tmpdir}" # Cleanup
178178
}
179179

180180
main "$@"

0 commit comments

Comments
 (0)