diff options
author | Maxim Biro <nurupo.contributions@gmail.com> | 2018-07-08 10:22:32 -0400 |
---|---|---|
committer | Maxim Biro <nurupo.contributions@gmail.com> | 2018-07-15 18:37:10 -0400 |
commit | c0b4cd156f79f1c7f3ce747a27cae16a78549cc6 (patch) | |
tree | cc1254c5c5b2e7fa5cce5415d450b1c6e59de42c | |
parent | b4cf9808e972952c003c80b9e766b8e66e671703 (diff) |
Simplify Travis-CI FreeBSD build
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | .travis/cmake-freebsd-env.sh | 10 | ||||
-rwxr-xr-x | .travis/cmake-freebsd-install.sh (renamed from other/travis/freebsd-install) | 7 | ||||
-rwxr-xr-x | .travis/cmake-freebsd-stage1 | 170 | ||||
-rwxr-xr-x | .travis/cmake-freebsd-stage2 | 65 | ||||
-rw-r--r-- | other/travis/env-freebsd.sh | 31 | ||||
-rw-r--r-- | other/travis/env.sh | 17 | ||||
-rwxr-xr-x | other/travis/freebsd-install-stage1 | 164 | ||||
-rwxr-xr-x | other/travis/freebsd-install-stage2 | 32 | ||||
-rwxr-xr-x | other/travis/toxcore-script | 47 |
10 files changed, 240 insertions, 307 deletions
diff --git a/.travis.yml b/.travis.yml index d279c4bc..ea1ffea7 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -74,8 +74,8 @@ matrix: | |||
74 | install: .travis/$JOB install | 74 | install: .travis/$JOB install |
75 | script: .travis/$JOB script | 75 | script: .travis/$JOB script |
76 | - stage: "Stage 1" | 76 | - stage: "Stage 1" |
77 | if: type IN (push, api, cron) | ||
78 | env: JOB=cmake-freebsd | 77 | env: JOB=cmake-freebsd |
78 | if: type IN (push, api, cron) | ||
79 | sudo: required | 79 | sudo: required |
80 | install: .travis/$JOB-stage1 install | 80 | install: .travis/$JOB-stage1 install |
81 | script: .travis/$JOB-stage1 script | 81 | script: .travis/$JOB-stage1 script |
@@ -85,8 +85,8 @@ matrix: | |||
85 | services: [docker] | 85 | services: [docker] |
86 | script: .travis/$JOB | 86 | script: .travis/$JOB |
87 | - stage: "Stage 2" | 87 | - stage: "Stage 2" |
88 | if: type IN (push, api, cron) | ||
89 | env: JOB=cmake-freebsd | 88 | env: JOB=cmake-freebsd |
89 | if: type IN (push, api, cron) | ||
90 | sudo: required | 90 | sudo: required |
91 | install: .travis/$JOB-stage2 install | 91 | install: .travis/$JOB-stage2 install |
92 | script: .travis/$JOB-stage2 script | 92 | script: .travis/$JOB-stage2 script |
diff --git a/.travis/cmake-freebsd-env.sh b/.travis/cmake-freebsd-env.sh new file mode 100644 index 00000000..8ae7e738 --- /dev/null +++ b/.travis/cmake-freebsd-env.sh | |||
@@ -0,0 +1,10 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | NPROC=`nproc` | ||
4 | |||
5 | SCREEN_SESSION=freebsd | ||
6 | SSH_PORT=10022 | ||
7 | |||
8 | RUN() { | ||
9 | ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p $SSH_PORT "$@" | ||
10 | } | ||
diff --git a/other/travis/freebsd-install b/.travis/cmake-freebsd-install.sh index 55ae1c43..59a78965 100755 --- a/other/travis/freebsd-install +++ b/.travis/cmake-freebsd-install.sh | |||
@@ -30,7 +30,7 @@ mkdir -p /opt/freebsd/cache | |||
30 | cd /opt/freebsd/cache | 30 | cd /opt/freebsd/cache |
31 | 31 | ||
32 | # Make sure to update DL_SHA512 when bumping the version | 32 | # Make sure to update DL_SHA512 when bumping the version |
33 | FREEBSD_VERSION="11.1" | 33 | FREEBSD_VERSION="11.2" |
34 | IMAGE_NAME=FreeBSD-${FREEBSD_VERSION}-RELEASE-amd64.raw | 34 | IMAGE_NAME=FreeBSD-${FREEBSD_VERSION}-RELEASE-amd64.raw |
35 | 35 | ||
36 | # Sends keys to the VM as they are | 36 | # Sends keys to the VM as they are |
@@ -56,7 +56,7 @@ start_vm() | |||
56 | # Start emulator. 2000mb RAM should be enough, right? The build machine has over 7gb. | 56 | # Start emulator. 2000mb RAM should be enough, right? The build machine has over 7gb. |
57 | screen -L -S $SCREEN_SESSION -d -m \ | 57 | screen -L -S $SCREEN_SESSION -d -m \ |
58 | qemu-system-x86_64 -curses -m 2000 -smp $NPROC \ | 58 | qemu-system-x86_64 -curses -m 2000 -smp $NPROC \ |
59 | -net user,hostfwd=tcp::${SSH_PORT}-:22 -net nic $IMAGE_NAME | 59 | -net user,hostfwd=tcp::${SSH_PORT}-:22 -net nic "$IMAGE_NAME" |
60 | 60 | ||
61 | # Wait for the boot screen options | 61 | # Wait for the boot screen options |
62 | wait_for "Autoboot in" | 62 | wait_for "Autoboot in" |
@@ -73,7 +73,8 @@ start_vm() | |||
73 | stop_vm() | 73 | stop_vm() |
74 | { | 74 | { |
75 | # Turn it off | 75 | # Turn it off |
76 | RUN poweroff | 76 | send_keys 'poweroff |
77 | ' | ||
77 | 78 | ||
78 | # Wait for qemu process to terminate | 79 | # Wait for qemu process to terminate |
79 | while ps aux | grep qemu | grep -vq grep | 80 | while ps aux | grep qemu | grep -vq grep |
diff --git a/.travis/cmake-freebsd-stage1 b/.travis/cmake-freebsd-stage1 index 3954e2af..d1aeab62 100755 --- a/.travis/cmake-freebsd-stage1 +++ b/.travis/cmake-freebsd-stage1 | |||
@@ -2,14 +2,174 @@ | |||
2 | 2 | ||
3 | ACTION="$1" | 3 | ACTION="$1" |
4 | 4 | ||
5 | set -eu | 5 | set -eux |
6 | 6 | ||
7 | . other/travis/env.sh | 7 | . .travis/cmake-freebsd-env.sh |
8 | . other/travis/env-freebsd.sh | ||
9 | 8 | ||
10 | travis_install() { | 9 | travis_install() { |
11 | . other/travis/freebsd-install | 10 | . .travis/cmake-freebsd-install.sh |
12 | . other/travis/freebsd-install-stage1 | 11 | |
12 | git tag -l --sort=version:refname > GIT_TAGS | ||
13 | |||
14 | OLD_PWD="$PWD" | ||
15 | |||
16 | mkdir -p /opt/freebsd/cache | ||
17 | cd /opt/freebsd/cache | ||
18 | |||
19 | # === Get the VM image, set it up and cache === | ||
20 | |||
21 | # Create image if it's not cached or if this build script has changed | ||
22 | sha256sum "$OLD_PWD/.travis/cmake-freebsd-env.sh" > /tmp/sha | ||
23 | sha256sum "$OLD_PWD/.travis/cmake-freebsd-install.sh" >> /tmp/sha | ||
24 | sha256sum "$OLD_PWD/.travis/cmake-freebsd-stage1" >> /tmp/sha | ||
25 | if [ ! -f "./$IMAGE_NAME.tgz" ] || [ ! -f ./cmake-freebsd-stage1-all.sha256 ] || [ "`cat cmake-freebsd-stage1-all.sha256`" != "`cat /tmp/sha`" ]; then | ||
26 | |||
27 | rm -rf ./* | ||
28 | |||
29 | # https://download.freebsd.org/ftp/releases/VM-IMAGES/11.2-RELEASE/amd64/Latest/ | ||
30 | DL_SHA512="0c3c232c7023c5036daeb5fbf68c2ddecf9703c74e317afcf19da91e83d0afcc526785571e2868894ce15cdb56b74fafa1ce9fd216469db91e021ac2ef8911e5" | ||
31 | # Selecting random mirror from https://www.freebsd.org/doc/handbook/mirrors-ftp.html | ||
32 | # Note that not all mirrors listed on that page are working, so we have removed them | ||
33 | # I'm so sorry, there are no arrays in sh and we are not using bash... | ||
34 | DL_MIRROR_1=1 | ||
35 | DL_MIRROR_2=4 | ||
36 | # There are 2 mirrors | ||
37 | DL_MIRROR_RANDOM=`expr $(date +%s) % 2 + 1` | ||
38 | 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" | ||
39 | |||
40 | wget "$DL_URL" | ||
41 | |||
42 | if ! ( echo "$DL_SHA512 $IMAGE_NAME.xz" | sha512sum -c --status - ) ; then | ||
43 | echo "Error: sha512 of $IMAGE_NAME.xz doesn't match the known one" | ||
44 | exit 1 | ||
45 | fi | ||
46 | |||
47 | unxz "$IMAGE_NAME.xz" | ||
48 | |||
49 | # With this we don't have to guess how long a command will run for and sleeping | ||
50 | # for that amount of time, risking either under sleeping or over sleeping, instead | ||
51 | # we will sleep exactly until the command is finished by printing out a unique | ||
52 | # string after the command is executed and then checking if it was printed. | ||
53 | execute_shell_and_wait() | ||
54 | { | ||
55 | # $RANDOM is a bash built-in, so we try to avoid name collision here by using ugly RANDOM_STR name | ||
56 | RANDOM_STR=$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c16) | ||
57 | send_keys "$1;echo $RANDOM_STR | ||
58 | |||
59 | " | ||
60 | # \[1B is a control escape sequence for a new line in the terminal. | ||
61 | # We want to wait for <new-line>$RANDOM_STR instead of just $RANDOM_STR because | ||
62 | # $RANDOM_STR we have inputted with send_keys above would appear in the screenlog.0 | ||
63 | # file and we don't want to match our input, we want to match the echo's output. | ||
64 | # The .\? optionally matches any character. Sometimes it happens that there is some | ||
65 | # random character inserved between the new line control escape sequence and $RANDOM_STR. | ||
66 | wait_for "\[1B.\?$RANDOM_STR" | ||
67 | } | ||
68 | |||
69 | start_vm | ||
70 | |||
71 | # Login as root user | ||
72 | send_keys 'root | ||
73 | |||
74 | ' | ||
75 | |||
76 | # Wait for the prompt | ||
77 | wait_for "root@.*:~" | ||
78 | |||
79 | # Configure network, ssh and start changing password | ||
80 | execute_shell_and_wait 'echo "ifconfig_em0=DHCP" >> /etc/rc.conf' | ||
81 | execute_shell_and_wait 'echo "Port 22" >> /etc/ssh/sshd_config' | ||
82 | execute_shell_and_wait 'echo "PermitRootLogin yes" >> /etc/ssh/sshd_config' | ||
83 | execute_shell_and_wait 'echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config' | ||
84 | execute_shell_and_wait 'echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config' | ||
85 | execute_shell_and_wait 'echo "sshd_enable=YES" >> /etc/rc.conf' | ||
86 | send_keys 'sh /etc/rc.d/netif restart && sh /etc/rc.d/sshd start && passwd | ||
87 | ' | ||
88 | |||
89 | # Wait for the password prompt | ||
90 | wait_for "Changing local password for root" | ||
91 | |||
92 | # Reset password to empty for the passwordless ssh to work | ||
93 | send_keys ' | ||
94 | ' | ||
95 | wait_for "New Password" | ||
96 | send_keys ' | ||
97 | ' | ||
98 | |||
99 | # Update system | ||
100 | RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES freebsd-update --not-running-from-cron fetch | ||
101 | # It fails if there is nothing to install, so we make it always succeed with true | ||
102 | RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES freebsd-update --not-running-from-cron install || true | ||
103 | |||
104 | # Update packages | ||
105 | RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES pkg upgrade | ||
106 | |||
107 | # Install and set bash as the default shell for the root user | ||
108 | RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES pkg install bash | ||
109 | RUN chsh -s /usr/local/bin/bash root | ||
110 | |||
111 | # Install required toxcore dependencies | ||
112 | RUN PAGER=cat ASSUME_ALWAYS_YES=YES pkg install git \ | ||
113 | opus \ | ||
114 | libvpx \ | ||
115 | libsodium \ | ||
116 | gmake \ | ||
117 | cmake \ | ||
118 | pkgconf \ | ||
119 | opencv \ | ||
120 | portaudio \ | ||
121 | libsndfile \ | ||
122 | texinfo \ | ||
123 | autotools | ||
124 | |||
125 | # === Cache the VM image === | ||
126 | |||
127 | stop_vm | ||
128 | |||
129 | # Create cache | ||
130 | tar -Sczvf "$IMAGE_NAME.tgz" "$IMAGE_NAME" | ||
131 | rm "$IMAGE_NAME" | ||
132 | rm screenlog.0 | ||
133 | |||
134 | cp "$OLD_PWD/GIT_TAGS" . | ||
135 | sha256sum "$OLD_PWD/.travis/cmake-freebsd-env.sh" > cmake-freebsd-stage1-all.sha256 | ||
136 | sha256sum "$OLD_PWD/.travis/cmake-freebsd-install.sh" >> cmake-freebsd-stage1-all.sha256 | ||
137 | sha256sum "$OLD_PWD/.travis/cmake-freebsd-stage1" >> cmake-freebsd-stage1-all.sha256 | ||
138 | |||
139 | ls -lh | ||
140 | fi | ||
141 | |||
142 | # === Update the image on new version (tag) of toxcore === | ||
143 | |||
144 | if ! diff -u ./GIT_TAGS "$OLD_PWD/GIT_TAGS" ; then | ||
145 | # Extract the cached image | ||
146 | tar -Sxzvf "$IMAGE_NAME.tgz" | ||
147 | |||
148 | start_vm | ||
149 | |||
150 | # Update system | ||
151 | RUN PAGER=cat ASSUME_ALWAYS_YES=YES freebsd-update --not-running-from-cron fetch | ||
152 | RUN PAGER=cat ASSUME_ALWAYS_YES=YES freebsd-update --not-running-from-cron install || true | ||
153 | |||
154 | # Update packages | ||
155 | RUN PAGER=cat ASSUME_ALWAYS_YES=YES pkg upgrade | ||
156 | |||
157 | # === Cache the updated VM image === | ||
158 | |||
159 | stop_vm | ||
160 | |||
161 | # Create/Update cache | ||
162 | rm "$IMAGE_NAME.tgz" | ||
163 | tar -Sczvf "$IMAGE_NAME.tgz" "$IMAGE_NAME" | ||
164 | rm "$IMAGE_NAME" | ||
165 | rm screenlog.0 | ||
166 | |||
167 | cp "$OLD_PWD/GIT_TAGS" . | ||
168 | |||
169 | ls -lh | ||
170 | fi | ||
171 | |||
172 | cd "$OLD_PWD" | ||
13 | } | 173 | } |
14 | 174 | ||
15 | travis_script() { | 175 | travis_script() { |
diff --git a/.travis/cmake-freebsd-stage2 b/.travis/cmake-freebsd-stage2 index 57b8a0f8..92e681f0 100755 --- a/.travis/cmake-freebsd-stage2 +++ b/.travis/cmake-freebsd-stage2 | |||
@@ -2,18 +2,71 @@ | |||
2 | 2 | ||
3 | ACTION="$1" | 3 | ACTION="$1" |
4 | 4 | ||
5 | set -eu | 5 | set -eux |
6 | 6 | ||
7 | . other/travis/env.sh | 7 | . .travis/cmake-freebsd-env.sh |
8 | . other/travis/env-freebsd.sh | ||
9 | 8 | ||
10 | travis_install() { | 9 | travis_install() { |
11 | . other/travis/freebsd-install | 10 | . .travis/cmake-freebsd-install.sh |
12 | . other/travis/freebsd-install-stage2 | 11 | |
12 | OLD_PWD="$PWD" | ||
13 | |||
14 | mkdir -p /opt/freebsd/cache | ||
15 | cd /opt/freebsd/cache | ||
16 | |||
17 | # Extract the cached image | ||
18 | tar -Sxzvf "$IMAGE_NAME.tgz" | ||
19 | |||
20 | # Get the image we will be using out of the cached directory | ||
21 | mv "$IMAGE_NAME" .. | ||
22 | ls -lh | ||
23 | |||
24 | cd .. | ||
25 | |||
26 | ls -lh | ||
27 | |||
28 | # === Get VM ready to build the code === | ||
29 | |||
30 | start_vm | ||
31 | |||
32 | # Display FreeBSD kernel info and last login | ||
33 | RUN uname -a | ||
34 | RUN last | ||
35 | |||
36 | cd "$OLD_PWD" | ||
37 | |||
38 | # Copy over toxcore code from Travis to qemu | ||
39 | scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -P $SSH_PORT -r ./* root@localhost:~ | ||
40 | |||
41 | RUN ls -lh | ||
13 | } | 42 | } |
14 | 43 | ||
15 | travis_script() { | 44 | travis_script() { |
16 | . other/travis/toxcore-script | 45 | CACHEDIR="none" |
46 | . ".travis/flags-$CC.sh" | ||
47 | |||
48 | add_ld_flag -Wl,-z,defs | ||
49 | |||
50 | # Make compilation error on a warning | ||
51 | add_flag -Werror | ||
52 | |||
53 | RUN 'cmake -B_build -H. \ | ||
54 | -DCMAKE_C_FLAGS="$C_FLAGS" \ | ||
55 | -DCMAKE_CXX_FLAGS="$CXX_FLAGS" \ | ||
56 | -DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \ | ||
57 | -DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \ | ||
58 | -DCMAKE_INSTALL_PREFIX:PATH="_install" \ | ||
59 | -DTRACE=ON \ | ||
60 | -DMUST_BUILD_TOXAV=ON \ | ||
61 | -DSTRICT_ABI=ON \ | ||
62 | -DTEST_TIMEOUT_SECONDS=120 \ | ||
63 | -DUSE_IPV6=OFF' | ||
64 | |||
65 | # We created the VM with the same number of cores as the host, so the host-ran `nproc` here is fine | ||
66 | RUN 'gmake "-j$NPROC" -k install -C_build' | ||
67 | RUN 'gmake "-j$NPROC" test ARGS="-j50" -C_build || \ | ||
68 | gmake "-j$NPROC" -C_build test ARGS="-j50 --rerun-failed" CTEST_OUTPUT_ON_FAILURE=1 || \ | ||
69 | true' | ||
17 | } | 70 | } |
18 | 71 | ||
19 | if [ "-z" "$ACTION" ]; then | 72 | if [ "-z" "$ACTION" ]; then |
diff --git a/other/travis/env-freebsd.sh b/other/travis/env-freebsd.sh deleted file mode 100644 index 882e9da5..00000000 --- a/other/travis/env-freebsd.sh +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | CMAKE=cmake | ||
4 | NPROC=`nproc` | ||
5 | CURDIR=/root | ||
6 | RUN_TESTS=true | ||
7 | MAKE=gmake | ||
8 | # A lot of tests fail and run for the full 2 minutes allowed, resulting in | ||
9 | # Travis build timing out, so we restrict it to just 1 test run until enough | ||
10 | # tests are fixed so that they succeed and don't run the full 2 minutes. | ||
11 | MAX_TEST_RETRIES=1 | ||
12 | |||
13 | SCREEN_SESSION=freebsd | ||
14 | SSH_PORT=10022 | ||
15 | |||
16 | RUN() { | ||
17 | ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p $SSH_PORT "$@" | ||
18 | } | ||
19 | |||
20 | TESTS() { | ||
21 | COUNT="$1"; shift | ||
22 | RUN "$@" || { | ||
23 | if [ $COUNT -gt 1 ]; then | ||
24 | TESTS `expr $COUNT - 1` "$@" | ||
25 | else | ||
26 | # FIXME: We allow the tests to fail for now, but this should be changed to | ||
27 | # "false" once we fix tests under FreeBSD | ||
28 | true | ||
29 | fi | ||
30 | } | ||
31 | } | ||
diff --git a/other/travis/env.sh b/other/travis/env.sh deleted file mode 100644 index 2d3e646c..00000000 --- a/other/travis/env.sh +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Globally used environment variables. | ||
4 | export CACHE_DIR=$HOME/cache | ||
5 | export OPAMROOT=$CACHE_DIR/.opam | ||
6 | export LD_LIBRARY_PATH=$CACHE_DIR/lib | ||
7 | export PKG_CONFIG_PATH=$CACHE_DIR/lib/pkgconfig | ||
8 | export ASTYLE=$CACHE_DIR/astyle/build/gcc/bin/astyle | ||
9 | export CFLAGS="-O3 -DTRAVIS_ENV=1" | ||
10 | export CXXFLAGS="-O3 -DTRAVIS_ENV=1" | ||
11 | export MAKE=make | ||
12 | |||
13 | BUILD_DIR=_build | ||
14 | MAX_TEST_RETRIES=10 | ||
15 | |||
16 | # Workaround for broken Travis image. | ||
17 | export TERM=xterm | ||
diff --git a/other/travis/freebsd-install-stage1 b/other/travis/freebsd-install-stage1 deleted file mode 100755 index 46b40374..00000000 --- a/other/travis/freebsd-install-stage1 +++ /dev/null | |||
@@ -1,164 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | git tag -l --sort=version:refname > GIT_TAGS | ||
4 | |||
5 | OLD_PWD="$PWD" | ||
6 | |||
7 | mkdir -p /opt/freebsd/cache | ||
8 | cd /opt/freebsd/cache | ||
9 | |||
10 | # === Get the VM image, set it up and cache === | ||
11 | |||
12 | # Create image if it's not cached or if this build script has changed | ||
13 | if [ ! -f ./$IMAGE_NAME.tgz ] || [ ! -f ./freebsd-install-stage1.sha256 ] || [ "`cat freebsd-install-stage1.sha256`" != "`sha256sum $OLD_PWD/other/travis/freebsd-install-stage1`" ]; then | ||
14 | |||
15 | rm -rf ./* | ||
16 | |||
17 | # https://download.freebsd.org/ftp/releases/VM-IMAGES/11.1-RELEASE/amd64/Latest/ | ||
18 | DL_SHA512="c569776334131fdc85cd25a2a0d5aecafdc3e4b2e6e010dffaa2488d934293ce4f091f23481079dd91ad20dfd2dfc3d3487707096c59448f1d8914c5d7d6b582" | ||
19 | # Selecting random mirror from https://www.freebsd.org/doc/handbook/mirrors-ftp.html | ||
20 | # Note that not all mirrors listed on that page are working, so we have removed them | ||
21 | # I'm so sorry, there are no arrays in sh and we are not using bash... | ||
22 | DL_MIRROR_1=1 | ||
23 | DL_MIRROR_2=4 | ||
24 | DL_MIRROR_3=5 | ||
25 | DL_MIRROR_4=6 | ||
26 | DL_MIRROR_5=8 | ||
27 | DL_MIRROR_6=10 | ||
28 | DL_MIRROR_7=14 | ||
29 | DL_MIRROR_8=15 | ||
30 | # There are 8 mirrors | ||
31 | DL_MIRROR_RANDOM=`expr $(date +%s) % 8 + 1` | ||
32 | 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 | ||
33 | |||
34 | wget $DL_URL | ||
35 | |||
36 | if ! ( echo "$DL_SHA512 $IMAGE_NAME.xz" | sha512sum -c --status - ) ; then | ||
37 | echo "Error: sha512 of $IMAGE_NAME.xz doesn't match the known one" | ||
38 | exit 1 | ||
39 | fi | ||
40 | |||
41 | unxz $IMAGE_NAME.xz | ||
42 | |||
43 | # With this we don't have to guess how long a command will run for and sleeping | ||
44 | # for that amount of time, risking either under sleeping or over sleeping, instead | ||
45 | # we will sleep exactly until the command is finished by printing out a unique | ||
46 | # string after the command is executed and then checking if it was printed. | ||
47 | execute_shell_and_wait() | ||
48 | { | ||
49 | # $RANDOM is a bash built-in, so we try to avoid name collision here by using ugly RANDOM_STR name | ||
50 | RANDOM_STR=$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c16) | ||
51 | send_keys "$1;echo $RANDOM_STR | ||
52 | |||
53 | " | ||
54 | # \[1B is a control escape sequence for a new line in the terminal. | ||
55 | # We want to wait for <new-line>$RANDOM_STR instead of just $RANDOM_STR because | ||
56 | # $RANDOM_STR we have inputted with send_keys above would appear in the screenlog.0 | ||
57 | # file and we don't want to match our input, we want to match the echo's output. | ||
58 | # The .\? optionally matches any character. Sometimes it happens that there is some | ||
59 | # random character inserved between the new line control escape sequence and $RANDOM_STR. | ||
60 | wait_for "\[1B.\?$RANDOM_STR" | ||
61 | } | ||
62 | |||
63 | start_vm | ||
64 | |||
65 | # Login as root user | ||
66 | send_keys 'root | ||
67 | |||
68 | ' | ||
69 | |||
70 | # Wait for the prompt | ||
71 | wait_for "root@:~" | ||
72 | |||
73 | # Configure network, ssh and start changing password | ||
74 | execute_shell_and_wait 'echo "ifconfig_em0=DHCP" >> /etc/rc.conf' | ||
75 | execute_shell_and_wait 'echo "Port 22" >> /etc/ssh/sshd_config' | ||
76 | execute_shell_and_wait 'echo "PermitRootLogin yes" >> /etc/ssh/sshd_config' | ||
77 | execute_shell_and_wait 'echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config' | ||
78 | execute_shell_and_wait 'echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config' | ||
79 | execute_shell_and_wait 'echo "sshd_enable=YES" >> /etc/rc.conf' | ||
80 | send_keys 'sh /etc/rc.d/netif restart && sh /etc/rc.d/sshd start && passwd | ||
81 | ' | ||
82 | |||
83 | # Wait for the password prompt | ||
84 | wait_for "Changing local password for root" | ||
85 | |||
86 | # Reset password to empty for the passwordless ssh to work | ||
87 | send_keys ' | ||
88 | ' | ||
89 | wait_for "New Password" | ||
90 | send_keys ' | ||
91 | ' | ||
92 | |||
93 | # Update system | ||
94 | RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES freebsd-update --not-running-from-cron fetch | ||
95 | # It fails if there is nothing to install, so we make it always succeed with true | ||
96 | RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES freebsd-update --not-running-from-cron install || true | ||
97 | |||
98 | # Update packages | ||
99 | RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES pkg upgrade | ||
100 | |||
101 | # Install and set bash as the default shell for the root user | ||
102 | RUN env PAGER=cat env ASSUME_ALWAYS_YES=YES pkg install bash | ||
103 | RUN chsh -s /usr/local/bin/bash root | ||
104 | |||
105 | # Install required toxcore dependencies | ||
106 | RUN PAGER=cat ASSUME_ALWAYS_YES=YES pkg install git \ | ||
107 | opus \ | ||
108 | libvpx \ | ||
109 | libsodium \ | ||
110 | gmake \ | ||
111 | cmake \ | ||
112 | pkgconf \ | ||
113 | opencv \ | ||
114 | portaudio \ | ||
115 | libsndfile \ | ||
116 | texinfo \ | ||
117 | autotools | ||
118 | |||
119 | # === Cache the VM image === | ||
120 | |||
121 | stop_vm | ||
122 | |||
123 | # Create cache | ||
124 | tar -Sczvf $IMAGE_NAME.tgz $IMAGE_NAME | ||
125 | rm $IMAGE_NAME | ||
126 | rm screenlog.0 | ||
127 | |||
128 | cp "$OLD_PWD/GIT_TAGS" . | ||
129 | sha256sum "$OLD_PWD/other/travis/freebsd-install-stage1" > freebsd-install-stage1.sha256 | ||
130 | |||
131 | ls -lh | ||
132 | fi | ||
133 | |||
134 | # === Update the image on new version (tag) of toxcore === | ||
135 | |||
136 | if ! diff -u ./GIT_TAGS "$OLD_PWD/GIT_TAGS" ; then | ||
137 | # Extract the cached image | ||
138 | tar -Sxzvf $IMAGE_NAME.tgz | ||
139 | |||
140 | start_vm | ||
141 | |||
142 | # Update system | ||
143 | RUN PAGER=cat ASSUME_ALWAYS_YES=YES freebsd-update --not-running-from-cron fetch | ||
144 | RUN PAGER=cat ASSUME_ALWAYS_YES=YES freebsd-update --not-running-from-cron install || true | ||
145 | |||
146 | # Update packages | ||
147 | RUN PAGER=cat ASSUME_ALWAYS_YES=YES pkg upgrade | ||
148 | |||
149 | # === Cache the updated VM image === | ||
150 | |||
151 | stop_vm | ||
152 | |||
153 | # Create/Update cache | ||
154 | rm $IMAGE_NAME.tgz | ||
155 | tar -Sczvf $IMAGE_NAME.tgz $IMAGE_NAME | ||
156 | rm $IMAGE_NAME | ||
157 | rm screenlog.0 | ||
158 | |||
159 | cp "$OLD_PWD/GIT_TAGS" . | ||
160 | |||
161 | ls -lh | ||
162 | fi | ||
163 | |||
164 | cd "$OLD_PWD" | ||
diff --git a/other/travis/freebsd-install-stage2 b/other/travis/freebsd-install-stage2 deleted file mode 100755 index 61f8d013..00000000 --- a/other/travis/freebsd-install-stage2 +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | OLD_PWD="$PWD" | ||
4 | |||
5 | mkdir -p /opt/freebsd/cache | ||
6 | cd /opt/freebsd/cache | ||
7 | |||
8 | # Extract the cached image | ||
9 | tar -Sxzvf $IMAGE_NAME.tgz | ||
10 | |||
11 | # Get the image we will be using out of the cached directory | ||
12 | mv $IMAGE_NAME .. | ||
13 | ls -lh | ||
14 | |||
15 | cd .. | ||
16 | |||
17 | ls -lh | ||
18 | |||
19 | # === Get VM ready to build the code === | ||
20 | |||
21 | start_vm | ||
22 | |||
23 | # Display FreeBSD kernel info and last login | ||
24 | RUN uname -a | ||
25 | RUN last | ||
26 | |||
27 | cd "$OLD_PWD" | ||
28 | |||
29 | # Copy over toxcore code from Travis to qemu | ||
30 | scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -P $SSH_PORT -r ./* root@localhost:~ | ||
31 | |||
32 | RUN ls -lh | ||
diff --git a/other/travis/toxcore-script b/other/travis/toxcore-script deleted file mode 100755 index ae2af416..00000000 --- a/other/travis/toxcore-script +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Enable test coverage recording. | ||
4 | export CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage" | ||
5 | export CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage" | ||
6 | |||
7 | set_opt() { | ||
8 | opts="$opts -D$1="`expr ON \& \( $i % 2 \) \| OFF` | ||
9 | set +e # result can be 0 | ||
10 | i=`expr $i / 2` | ||
11 | set -e | ||
12 | } | ||
13 | |||
14 | if perl -e ' | ||
15 | use Socket qw(PF_INET6 SOCK_STREAM pack_sockaddr_in6 IN6ADDR_LOOPBACK); | ||
16 | |||
17 | socket(S, PF_INET6, SOCK_STREAM, 0) || exit 1; | ||
18 | bind(S, pack_sockaddr_in6(0, IN6ADDR_LOOPBACK)) || exit 1; | ||
19 | '; then | ||
20 | USE_IPV6=yes | ||
21 | else | ||
22 | USE_IPV6=no | ||
23 | fi | ||
24 | |||
25 | |||
26 | # Build toxcore and run tests. | ||
27 | RUN $CMAKE \ | ||
28 | -B$BUILD_DIR \ | ||
29 | -H. \ | ||
30 | -DCMAKE_INSTALL_PREFIX:PATH=$CURDIR/_install \ | ||
31 | -DDEBUG=ON \ | ||
32 | -DMUST_BUILD_TOXAV=ON \ | ||
33 | -DSTRICT_ABI=ON \ | ||
34 | -DTEST_TIMEOUT_SECONDS=120 \ | ||
35 | -DTRACE=ON \ | ||
36 | -DUSE_IPV6=$USE_IPV6 | ||
37 | |||
38 | export CTEST_OUTPUT_ON_FAILURE=1 | ||
39 | |||
40 | RUN $MAKE -C$BUILD_DIR -j$NPROC -k install | ||
41 | if $RUN_TESTS; then | ||
42 | TESTS $MAX_TEST_RETRIES $MAKE -C$BUILD_DIR -j$NPROC test ARGS="-j50 --rerun-failed" CTEST_OUTPUT_ON_FAILURE="$CTEST_OUTPUT_ON_FAILURE" | ||
43 | fi | ||
44 | |||
45 | if [ -f "$ASTYLE" ]; then | ||
46 | other/astyle/format-source . $ASTYLE | ||
47 | fi | ||