blob: 29667e82a975c159b8b7ecc76a9bda0d7c06ced8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#!/bin/bash
# Download and initial setup of the FreeBSD VM
ACTION="$1"
set -eux
. .travis/cmake-freebsd-env.sh
travis_install() {
git tag -l --sort=version:refname >GIT_TAGS
OLD_PWD="$PWD"
mkdir -p /opt/freebsd/cache
cd /opt/freebsd/cache
# === Get the VM image, set it up and cache ===
# Create image if it's not cached, or if this build script has changed, or a new toxcore tag was pushed
sha256sum "$OLD_PWD/.travis/cmake-freebsd-env.sh" >/tmp/sha
sha256sum "$OLD_PWD/.travis/cmake-freebsd-stage1" >>/tmp/sha
sha256sum "$OLD_PWD/.travis/cmake-freebsd-stage1.expect" >>/tmp/sha
if [ ! -f "./$IMAGE_NAME.tgz" ] || [ ! -f ./cmake-freebsd-stage1-all.sha256 ] || [ "$(cat cmake-freebsd-stage1-all.sha256)" != "$(cat /tmp/sha)" ] || ! diff -u ./GIT_TAGS "$OLD_PWD/GIT_TAGS"; then
rm -rf ./*
while true; do
# Selecting random mirror from https://www.freebsd.org/doc/handbook/mirrors-ftp.html
# Note that not all mirrors listed on that page are working, so we have removed them
# There are no arrays in sh so we get a bit clever
DL_MIRROR_1=1
DL_MIRROR_2=2
DL_MIRROR_3=3
DL_MIRROR_4=4
DL_MIRROR_5=5
DL_MIRROR_6=6
DL_MIRROR_7=7
DL_MIRROR_8=10
DL_MIRROR_9=11
DL_MIRROR_10=13
DL_MIRROR_11=14
# There are 11 mirrors
DL_MIRROR_RANDOM=$(expr "$(date +%s)" % 11 + 1)
DL_URL="ftp://ftp$(eval echo \$DL_MIRROR_"$DL_MIRROR_RANDOM").us.freebsd.org/pub/FreeBSD/releases/VM-IMAGES/$FREEBSD_VERSION-RELEASE/amd64/Latest/$IMAGE_NAME.xz"
# Make sure there are no partial downloads from the previous loop iterations
rm -rf ./*
wget --tries 1 "$DL_URL" && break
done
if ! (echo "$IMAGE_SHA512 $IMAGE_NAME.xz" | sha512sum -c --status -); then
echo "Error: sha512 of $IMAGE_NAME.xz doesn't match the known one"
exit 1
fi
unxz "$IMAGE_NAME.xz"
sudo apt-get update
sudo apt-get install -y qemu screen expect
# The downloaded image has little free disk space
qemu-img resize -f raw "$IMAGE_NAME" +5G
NPROC=$NPROC SSH_PORT=$SSH_PORT IMAGE_NAME="$IMAGE_NAME" screen "$OLD_PWD/.travis/cmake-freebsd-stage1.expect"
start_vm
# Update system
RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES freebsd-update --not-running-from-cron fetch
# It fails if there is nothing to install, so we make it always succeed with true
RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES freebsd-update --not-running-from-cron install || true
# Update packages
RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES pkg upgrade
# Install and set bash as the default shell for the root user
RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES pkg install bash
RUN chsh -s /usr/local/bin/bash root
# Install required toxcore dependencies
RUN PAGER=cat ASSUME_ALWAYS_YES=YES pkg install \
git \
opus \
libconfig \
libvpx \
libsodium \
gmake \
cmake \
pkgconf \
portaudio \
libsndfile \
texinfo \
autotools
# === Cache the VM image ===
stop_vm
# Create cache
tar -Sczvf "$IMAGE_NAME.tgz" "$IMAGE_NAME"
rm "$IMAGE_NAME"
cp "$OLD_PWD/GIT_TAGS" .
sha256sum "$OLD_PWD/.travis/cmake-freebsd-env.sh" >cmake-freebsd-stage1-all.sha256
sha256sum "$OLD_PWD/.travis/cmake-freebsd-stage1" >>cmake-freebsd-stage1-all.sha256
sha256sum "$OLD_PWD/.travis/cmake-freebsd-stage1.expect" >>cmake-freebsd-stage1-all.sha256
ls -lh
fi
cd "$OLD_PWD"
}
travis_script() {
echo "Nothing to do here. Building happens in stage 2."
}
if [ "-z" "$ACTION" ]; then
"travis_script"
else
"travis_$ACTION"
fi
|