]> git.ipfire.org Git - thirdparty/util-linux.git/blob - .travis-functions.sh
Merge branch 'help-description' of https://github.com/rudimeier/util-linux
[thirdparty/util-linux.git] / .travis-functions.sh
1 #!/bin/bash
2
3 #
4 # .travis-functions.sh:
5 # - helper functions to be sourced from .travis.yml
6 # - designed to respect travis' environment but testing locally is possible
7 #
8
9 if [ ! -f "configure.ac" ]; then
10 echo ".travis-functions.sh must be sourced from source dir" >&2
11 return 1 || exit 1
12 fi
13
14 ## some config settings
15 # travis docs say we get 1.5 CPUs
16 MAKE="make -j2"
17 DUMP_CONFIG_LOG="short"
18 export TS_OPT_parsable="yes"
19
20 # workaround ugly warning on travis OSX,
21 # see https://github.com/direnv/direnv/issues/210
22 shell_session_update() { :; }
23
24 function xconfigure
25 {
26 which "$CC"
27 "$CC" --version
28
29 ./configure "$@" $OSX_CONFOPTS
30 err=$?
31 if [ "$DUMP_CONFIG_LOG" = "short" ]; then
32 grep -B1 -A10000 "^## Output variables" config.log | grep -v "_FALSE="
33 elif [ "$DUMP_CONFIG_LOG" = "full" ]; then
34 cat config.log
35 fi
36 return $err
37 }
38
39 function check_nonroot
40 {
41 local opts="$MAKE_CHECK_OPTS --show-diff"
42
43 xconfigure \
44 --disable-use-tty-group \
45 --disable-makeinstall-chown \
46 --enable-all-programs \
47 || return
48 $MAKE || return
49
50 osx_prepare_check
51 $MAKE check TS_OPTS="$opts" || return
52
53 $MAKE install DESTDIR=/tmp/dest || return
54 }
55
56 function check_root
57 {
58 local opts="$MAKE_CHECK_OPTS --parallel=1 --show-diff"
59
60 xconfigure \
61 --enable-all-programs \
62 || return
63 $MAKE || return
64
65 $MAKE check TS_COMMAND="true" || return
66 osx_prepare_check
67 sudo -E $MAKE check TS_OPTS="$opts" || return
68
69 # keep PATH to make sure sudo would find $CC
70 sudo env "PATH=$PATH" $MAKE install || return
71 }
72
73 function check_dist
74 {
75 xconfigure \
76 || return
77 $MAKE distcheck || return
78 }
79
80 function travis_install_script
81 {
82 if [ "$TRAVIS_OS_NAME" = "osx" ]; then
83 osx_install_script
84 return
85 fi
86
87 # install required packages
88 sudo apt-get -qq update --fix-missing
89 sudo apt-get install -qq >/dev/null \
90 bc \
91 btrfs-tools \
92 dnsutils \
93 libcap-ng-dev \
94 libncursesw5-dev \
95 libpam-dev \
96 libudev-dev \
97 gtk-doc-tools \
98 mdadm \
99 ntp \
100 socat \
101 || return
102
103 # install only if available (e.g. Ubuntu Trusty)
104 sudo apt-get install -qq >/dev/null \
105 libsystemd-daemon-dev \
106 libsystemd-journal-dev \
107 || true
108 }
109
110 function osx_install_script
111 {
112 brew update >/dev/null
113 brew tap homebrew/dupes
114
115 brew install gettext ncurses socat xz
116 brew link --force gettext
117 brew link --force ncurses
118
119 OSX_CONFOPTS="
120 --disable-ipcrm \
121 --disable-ipcs \
122 "
123
124 # workaround: glibtoolize could not find sed
125 export SED="sed"
126 }
127
128 function osx_prepare_check
129 {
130 [ "$TRAVIS_OS_NAME" = "osx" ] || return 0
131
132 # these ones only need to be gnu for our test-suite
133 brew install coreutils findutils gnu-tar gnu-sed
134
135 # symlink minimally needed gnu commands into PATH
136 mkdir ~/bin
137 for cmd in readlink seq timeout truncate find xargs tar sed; do
138 ln -s /usr/local/bin/g$cmd $HOME/bin/$cmd
139 done
140 hash -r
141
142 export TS_OPT_col_multibyte_known_fail=yes
143 export TS_OPT_colcrt_regressions_known_fail=yes
144 export TS_OPT_column_invalid_multibyte_known_fail=yes
145 }
146
147 function travis_before_script
148 {
149 set -o xtrace
150
151 ./autogen.sh
152 ret=$?
153
154 set +o xtrace
155 return $ret
156 }
157
158 function travis_script
159 {
160 local ret
161 set -o xtrace
162
163 case "$MAKE_CHECK" in
164 nonroot)
165 check_nonroot
166 ;;
167 root)
168 check_root
169 ;;
170 dist)
171 check_dist
172 ;;
173 *)
174 echo "error, check environment (travis.yml)" >&2
175 false
176 ;;
177 esac
178
179 # We exit here with case-switch return value!
180 ret=$?
181 set +o xtrace
182 return $ret
183 }
184
185 function travis_after_script
186 {
187 local diff_dir
188 local tmp
189
190 # find diff dir from check as well as from distcheck
191 diff_dir=$(find . -type d -name "diff" | grep "tests/diff" | head -n 1)
192 if [ -d "$diff_dir" ]; then
193 tmp=$(find "$diff_dir" -type f | sort)
194 echo -en "dump test diffs:\n${tmp}\n"
195 echo "$tmp" | xargs cat
196 fi
197 }