Skip to content

Commit e304d15

Browse files
committed
docker: Fix and extend setup.sh.example
1 parent 031eddd commit e304d15

File tree

1 file changed

+62
-13
lines changed

1 file changed

+62
-13
lines changed

setup.sh.example

+62-13
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ setup_hosts() {
1919
"93.184.216.34 example.com"
2020
)
2121

22-
cat /etc/hosts >> /tmp/hosts
22+
echo "Extending /etc/hosts file."
23+
cp /etc/hosts /tmp/hosts.bak
2324
for line in $HOSTS; do
24-
echo $line >> /tmp/hosts
25+
echo $line >> /etc/hosts
2526
done
26-
mount -o bind /tmp/hosts /etc/hosts
2727

2828
CLEANUP_FUNCTIONS+=(cleanup_hosts)
2929
}
3030

3131
cleanup_hosts() {
32-
umount /etc/hosts
32+
echo "Restoring /etc/hosts file."
33+
mv /tmp/hosts.bak /etc/hosts
3334
}
3435

3536
setup_ssh() {
@@ -46,6 +47,7 @@ setup_ssh() {
4647
"-p 80 github.com"
4748
)
4849

50+
echo "Performing keyscan for expected hosts."
4951
for host in $HOSTS; do
5052
if grep -vqF "$host" ~/.ssh/known_hosts; then
5153
ssh-keyscan $host >> ~/.ssh/known_hosts
@@ -75,17 +77,20 @@ setup_conan() {
7577
local CONAN_LOGIN_USERNAME=
7678
local CONAN_PASSWORD=
7779

78-
if network_available; then
79-
# Set the request timeout to 360 seconds to work-around slow servers.
80-
conan config set general.request_timeout=360
8180

82-
if [ "${CONAN_REMOTE}" != "" ]; then
83-
conan remote add default "${CONAN_REMOTE}" "${CONAN_REMOTE_VERIFY_SSL}"
84-
fi
81+
# Set the request timeout to 360 seconds to work-around slow servers.
82+
conan config set general.request_timeout=360
8583

86-
if [ "${CONAN_LOGIN_USERNAME}" != "" ]; then
87-
conan user --remote=default -p
88-
fi
84+
if [ "${CONAN_REMOTE}" != "" ]; then
85+
echo "Adding Conan 'default' remote."
86+
conan remote add default "${CONAN_REMOTE}" "${CONAN_REMOTE_VERIFY_SSL}"
87+
fi
88+
89+
if [ "${CONAN_LOGIN_USERNAME}" != "" ]; then
90+
echo "Authenticating with 'default' remote."
91+
export CONAN_LOGIN_USERNAME CONAN_PASSWORD
92+
conan user --remote=default -p
93+
unset CONAN_LOGIN_USERNAME CONAN_PASSWORD
8994
fi
9095

9196
CLEANUP_FUNCTIONS+=(cleanup_conan)
@@ -101,6 +106,50 @@ setup_vtd() {
101106
export VI_LIC_SERVER="vtd-licenses.example.com"
102107
}
103108

109+
indent_lines() {
110+
sed -r -e 's/[[:cntrl:]]//g' -e 's/^/\t/g'
111+
}
112+
113+
upload_package() {
114+
pkgref="$1"
115+
pkgname="$(echo "$pkgref" | sed -r 's/#.*$//')"
116+
faillog="$2"
117+
118+
conan upload -r default --all --force -c "$pkgname"
119+
if [ $? -ne 0 ]; then
120+
echo "INFO: attempting recipe-download work-around"
121+
conan download -r conancenter -re "$pkgref"
122+
if [ $? -ne 0 ]; then
123+
echo "CRITICAL: recipe download failed, skipping"
124+
echo "$pkgref" >> "$faillog"
125+
return
126+
fi
127+
128+
echo "INFO: attempting upload for second time"
129+
conan upload -r default --all --force -c "$pkgname"
130+
if [ $? -ne 0 ]; then
131+
echo "CRITICAL: package upload failed, skipping"
132+
echo "$pkgref" >> "$faillog"
133+
return
134+
fi
135+
fi
136+
echo "INFO: upload successful"
137+
}
138+
139+
release_packages() {
140+
echo "Uploading packages..."
141+
faillog=/tmp/conan-upload-failures.log
142+
conan search --raw --rev | sed -r '/^[^@]+$/ { s!#!@_/_#! }' | while read line; do
143+
echo "Upload: $line"
144+
upload_package "$line" $faillog 2>&1 | indent_lines
145+
done
146+
147+
if [ $(cat $faillog 2>/dev/null | wc -l) -gt 0 ]; then
148+
echo "Failure uploading:"
149+
cat $faillog | indent_lines
150+
fi
151+
}
152+
104153
upload_conan_packages() {
105154
# Prequisites:
106155
# 1. You need to add a 'default' remote and authenticate with it.

0 commit comments

Comments
 (0)