Skip to content

Commit 594f284

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
server: handle repo urls with same file name
I tool I am experimenting with automatically creates .repo files for you but they're all named the same. Make sure we don't overwrite repo files with the same url when setting up a custom repo. Signed-off-by: John Mulligan <[email protected]>
1 parent 675dc0a commit 594f284

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

images/server/install-packages.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ get_custom_repo() {
1414
url="$1"
1515
fname="$(basename "$url")"
1616
dest="/etc/yum.repos.d/${fname}"
17+
while [ -e "$dest" ]; do
18+
u="$(echo "${url}" | sha256sum | head -c12)"
19+
if [ -z "$u" ]; then
20+
echo "failed to uniquify repo file name"
21+
exit 2
22+
fi
23+
dest="/etc/yum.repos.d/${u}-${fname}"
24+
done
1725
need_curl
1826
curl -L "$url" -o "$dest"
1927
}

0 commit comments

Comments
 (0)