summaryrefslogtreecommitdiff
path: root/.travis/cmake-freebsd-stage1
diff options
context:
space:
mode:
authorMaxim Biro <nurupo.contributions@gmail.com>2018-07-08 10:22:32 -0400
committerMaxim Biro <nurupo.contributions@gmail.com>2018-07-15 18:37:10 -0400
commitc0b4cd156f79f1c7f3ce747a27cae16a78549cc6 (patch)
treecc1254c5c5b2e7fa5cce5415d450b1c6e59de42c /.travis/cmake-freebsd-stage1
parentb4cf9808e972952c003c80b9e766b8e66e671703 (diff)
Simplify Travis-CI FreeBSD build
Diffstat (limited to '.travis/cmake-freebsd-stage1')
-rwxr-xr-x.travis/cmake-freebsd-stage1170
1 files changed, 165 insertions, 5 deletions
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
3ACTION="$1" 3ACTION="$1"
4 4
5set -eu 5set -eux
6 6
7. other/travis/env.sh 7. .travis/cmake-freebsd-env.sh
8. other/travis/env-freebsd.sh
9 8
10travis_install() { 9travis_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
15travis_script() { 175travis_script() {