]> git.ipfire.org Git - thirdparty/util-linux.git/blob - .travis-functions.sh
travis: minor cleanup
[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
19 function xconfigure
20 {
21 ./configure "$@"
22 err=$?
23 if [ "$DUMP_CONFIG_LOG" = "short" ]; then
24 grep -B1 -A10000 "^## Output variables" config.log | grep -v "_FALSE="
25 elif [ "$DUMP_CONFIG_LOG" = "full" ]; then
26 cat config.log
27 fi
28 return $err
29 }
30
31 function check_nonroot
32 {
33 local opts="$MAKE_CHECK_OPTS"
34
35 xconfigure \
36 --disable-use-tty-group \
37 --with-python \
38 --enable-all-programs \
39 --enable-gtk-doc \
40 || return
41 $MAKE || return
42 $MAKE check TS_OPTS="$opts" || return
43 $MAKE install DESTDIR=/tmp/dest || return
44 }
45
46 function check_root
47 {
48 local opts="$MAKE_CHECK_OPTS --parallel=1"
49
50 xconfigure \
51 --with-python \
52 --enable-all-programs \
53 || return
54 $MAKE || return
55 $MAKE check TS_COMMAND="true" || return
56 sudo -E $MAKE check TS_OPTS="$opts" || return
57 sudo $MAKE install || return
58 }
59
60 function check_dist
61 {
62 xconfigure \
63 || return
64 $MAKE distcheck || return
65 }
66
67 function travis_install_script
68 {
69 # install some packages from Ubuntu's default sources
70 sudo apt-get -qq update || return
71 sudo apt-get install -qq >/dev/null \
72 bc \
73 dnsutils \
74 libcap-ng-dev \
75 libpam-dev \
76 libudev-dev \
77 gtk-doc-tools \
78 mdadm \
79 ntp \
80 || return
81
82 # install/upgrade custom stuff from non-official sources
83 sudo add-apt-repository -y ppa:malcscott/socat || return
84 sudo apt-get -qq update || return
85 sudo apt-get install -qq >/dev/null \
86 socat \
87 || return
88 }
89
90 function travis_before_script
91 {
92 set -o xtrace
93
94 ./autogen.sh
95 ret=$?
96
97 set +o xtrace
98 return $ret
99 }
100
101 function travis_script
102 {
103 local ret
104 set -o xtrace
105
106 case "$MAKE_CHECK" in
107 nonroot)
108 check_nonroot
109 ;;
110 root)
111 check_root
112 ;;
113 dist)
114 check_dist
115 ;;
116 *)
117 echo "error, check environment (travis.yml)" >&2
118 false
119 ;;
120 esac
121
122 # We exit here with case-switch return value!
123 ret=$?
124 set +o xtrace
125 return $ret
126 }
127
128 function travis_after_script
129 {
130 local diff_dir
131 local tmp
132
133 # find diff dir from check as well as from distcheck
134 diff_dir=$(find . -type d -name "diff" | grep "tests/diff" | head -n 1)
135 if [ -d "$diff_dir" ]; then
136 tmp=$(find "$diff_dir" -type f | sort)
137 echo -en "dump test diffs:\n${tmp}\n"
138 echo "$tmp" | xargs cat
139 fi
140 }