]> git.ipfire.org Git - thirdparty/util-linux.git/blob - .travis-functions.sh
po: update es.po (from translationproject.org)
[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 MAKE="make -j4"
16 DUMP_CONFIG_LOG="short"
17
18 # We could test (exotic) out-of-tree build dirs using relative or abs paths.
19 # After sourcing this script we are living in build dir. Tasks for source dir
20 # have to use $SOURCE_DIR.
21 SOURCE_DIR="."
22 BUILD_DIR="."
23 CONFIGURE="$SOURCE_DIR/configure"
24
25 mkdir -p "$BUILD_DIR"
26 cd "$BUILD_DIR" || return 1 || exit 1
27
28 function configure_travis
29 {
30 "$CONFIGURE" "$@"
31 err=$?
32 if [ "$DUMP_CONFIG_LOG" = "short" ]; then
33 grep -B1 -A10000 "^## Output variables" config.log | grep -v "_FALSE="
34 elif [ "$DUMP_CONFIG_LOG" = "full" ]; then
35 cat config.log
36 fi
37 return $err
38 }
39
40 function check_nonroot
41 {
42 configure_travis \
43 --disable-use-tty-group \
44 --with-python \
45 --enable-all-programs \
46 --enable-gtk-doc \
47 || return
48 $MAKE || return
49 $MAKE check || return
50 $MAKE install DESTDIR=/tmp/dest || return
51 }
52
53 function check_root
54 {
55 configure_travis \
56 --with-python \
57 --enable-all-programs \
58 || return
59 $MAKE || return
60 $MAKE check TS_COMMAND="true" || return
61 sudo -E $MAKE check TS_OPTS='--parallel=1' || return
62 sudo $MAKE install || return
63 }
64
65 function check_dist
66 {
67 configure_travis \
68 || return
69 $MAKE distcheck || return
70 }
71
72 function travis_before_script
73 {
74 pushd "$SOURCE_DIR" || return
75 set -o xtrace
76
77 ./autogen.sh
78 ret=$?
79
80 # workaround for broken pylibmount install relink
81 [ $ret -eq 0 ] && \
82 sed -i 's/\(link_all_deplibs\)=no/\1=unknown/' ./configure
83
84 set +o xtrace
85 popd
86 return $ret
87 }
88
89 function travis_script
90 {
91 local ret
92 set -o xtrace
93
94 case "$MAKE_CHECK" in
95 nonroot)
96 check_nonroot
97 ;;
98 root)
99 check_root
100 ;;
101 dist)
102 check_dist
103 ;;
104 *)
105 echo "error, check environment (travis.yml)" >&2
106 false
107 ;;
108 esac
109
110 # We exit here with case-switch return value!
111 ret=$?
112 set +o xtrace
113 return $ret
114 }
115
116 function travis_after_script
117 {
118 local diff_dir
119 local tmp
120
121 # find diff dir from check as well as from distcheck
122 diff_dir=$(find -type d -a -name "diff" | grep "tests/diff" | head -n 1)
123 if [ -d "$diff_dir" ]; then
124 tmp=$(find "$diff_dir" -type f | sort)
125 echo -en "dump test diffs:\n${tmp}\n"
126 echo "$tmp" | xargs -r cat
127 fi
128 }