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 /other | |
parent | b4cf9808e972952c003c80b9e766b8e66e671703 (diff) |
Simplify Travis-CI FreeBSD build
Diffstat (limited to 'other')
-rw-r--r-- | other/travis/env-freebsd.sh | 31 | ||||
-rw-r--r-- | other/travis/env.sh | 17 | ||||
-rwxr-xr-x | other/travis/freebsd-install | 88 | ||||
-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 |
6 files changed, 0 insertions, 379 deletions
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 b/other/travis/freebsd-install deleted file mode 100755 index 55ae1c43..00000000 --- a/other/travis/freebsd-install +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Travis doesn't provide FreeBSD machines, so we just take a Linux one and run | ||
4 | # FreeBSD in qemu virtual machine. qemu is being ran in curses mode inside a | ||
5 | # screen session, because screen allows to easily send input and read output. | ||
6 | # The input is sent using `screen -S session-name -X stuff ...` and the output | ||
7 | # is read from the screen's log file. Note that for some reason you can't send | ||
8 | # long input lines on Travis (it works just fine when I do it on my machine...), | ||
9 | # but that limitation is not an issue, as we don't really need to send long | ||
10 | # lines of input anyway. Also, note that since we run qemu in curses mode, the | ||
11 | # output contains control characters intended for a terminal emulator telling | ||
12 | # how to position and color the text, so it might be a little tricky to read it | ||
13 | # sometimes. The only time when this script has to send input to and read the | ||
14 | # output from the screen session is during the initial setup when we setup the | ||
15 | # network, install and configure the ssh server, and update the system. After | ||
16 | # this initial setup, ssh is used to communicate with the FreeBSD running in the | ||
17 | # VM, which is a lot friendlier way of communication. Please note that Travis | ||
18 | # doesn't seem to allow KVM passthrough, so qemu has to emulate all the | ||
19 | # hardware, which makes it quite slow compared to the host machine. We cache | ||
20 | # the qemu image since it takes a long time to run the initial system and | ||
21 | # package updates, and we do incremental system and package updates on every | ||
22 | # change to the list of git tags (i.e. on every toxcore release, presumably). | ||
23 | |||
24 | sudo apt-get update | ||
25 | sudo apt-get install -y qemu | ||
26 | |||
27 | OLD_PWD="$PWD" | ||
28 | |||
29 | mkdir -p /opt/freebsd/cache | ||
30 | cd /opt/freebsd/cache | ||
31 | |||
32 | # Make sure to update DL_SHA512 when bumping the version | ||
33 | FREEBSD_VERSION="11.1" | ||
34 | IMAGE_NAME=FreeBSD-${FREEBSD_VERSION}-RELEASE-amd64.raw | ||
35 | |||
36 | # Sends keys to the VM as they are | ||
37 | send_keys() | ||
38 | { | ||
39 | screen -S $SCREEN_SESSION -X stuff "$1" | ||
40 | } | ||
41 | |||
42 | # Blocks until a specific text appears on VM's screen | ||
43 | wait_for() | ||
44 | { | ||
45 | while ! grep -q "$1" screenlog.0 | ||
46 | do | ||
47 | sleep 1 | ||
48 | done | ||
49 | } | ||
50 | |||
51 | # Starts VM and waits until it's fully running (until a login prompt is shown) | ||
52 | start_vm() | ||
53 | { | ||
54 | rm -f screenlog.0 | ||
55 | |||
56 | # Start emulator. 2000mb RAM should be enough, right? The build machine has over 7gb. | ||
57 | screen -L -S $SCREEN_SESSION -d -m \ | ||
58 | qemu-system-x86_64 -curses -m 2000 -smp $NPROC \ | ||
59 | -net user,hostfwd=tcp::${SSH_PORT}-:22 -net nic $IMAGE_NAME | ||
60 | |||
61 | # Wait for the boot screen options | ||
62 | wait_for "Autoboot in" | ||
63 | |||
64 | # Select the 1st option | ||
65 | send_keys ' | ||
66 | ' | ||
67 | |||
68 | # Wait for the system to boot and present the login prompt | ||
69 | wait_for "FreeBSD/amd64 (" | ||
70 | } | ||
71 | |||
72 | # Shuts VM down and waits until its process finishes | ||
73 | stop_vm() | ||
74 | { | ||
75 | # Turn it off | ||
76 | RUN poweroff | ||
77 | |||
78 | # Wait for qemu process to terminate | ||
79 | while ps aux | grep qemu | grep -vq grep | ||
80 | do | ||
81 | sleep 1 | ||
82 | done | ||
83 | } | ||
84 | |||
85 | # Let's see what's in the cache directory | ||
86 | ls -lh | ||
87 | |||
88 | cd "$OLD_PWD" | ||
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 | ||