blob: 5c9d6fbbe92569f2f3cfa45809ce77dade00aba7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
{#
Copyright (C) 2010-2022 Gentoo tatt project
https://gitweb.gentoo.org/proj/tatt.git/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
#}
#!/bin/bash
main() {
trap "echo 'signal captured, exiting the entire script...'; exit" SIGHUP SIGINT SIGTERM
echo -e "USE tests started on $(date)\n" >> "{{ report_file }}"
local test_ret=0
{% for atom, is_test, use_flags in jobs %}
{% if is_test %}
TUSE="{{ use_flags }}" tatt_test_pkg '{{ atom }}' --test || test_ret=1
{% else %}
TUSE="{{ use_flags }}" tatt_test_pkg '{{ atom }}' || test_ret=1
{% endif %}
{% endfor %}
exit ${test_ret}
}
cleanup() {
echo "Cleaning up"
{% for file in cleanup_files %}
rm -v -f -r '{{ file }}'
{% endfor %}
rm -v -f $0
}
tatt_pkg_error() {
local eout=${2}
echo "${eout}"
if [[ -n ${TUSE} ]]; then
echo -n "USE='${TUSE}'" >> "{{ report_file }}"
fi
if [[ -n ${FEATURES} ]]; then
echo -n " FEATURES='${FEATURES}'" >> "{{ report_file }}"
fi
if [[ ${eout} =~ REQUIRED_USE ]] ; then
echo " : REQUIRED_USE not satisfied (probably) for ${1:?}" >> "{{ report_file }}"
elif [[ ${eout} =~ USE\ changes ]] ; then
echo " : USE dependencies not satisfied (probably) for ${1:?}" >> "{{ report_file }}"
elif [[ ${eout} =~ keyword\ changes ]]; then
echo " : unkeyworded dependencies (probably) for ${1:?}" >> "{{ report_file }}"
elif [[ ${eout} =~ Error:\ circular\ dependencies: ]]; then
echo " : circular dependencies (probably) for ${1:?}" >> "{{ report_file }}"
elif [[ ${eout} =~ Blocked\ Packages ]]; then
echo " : blocked packages (probably) for ${1:?}" >> "{{ report_file }}"
else
echo " failed for ${1:?}" >> "{{ report_file }}"
fi
local CP=${1#=}
local BUILDDIR=/var/tmp/portage/${CP}
local BUILDLOG=${BUILDDIR}/temp/build.log
if [[ -s ${BUILDLOG} ]]; then
mkdir -p {{ log_dir }}
local LOGNAME=$(mktemp -p {{ log_dir }} "${CP/\//_}_use_XXXXX")
cp "${BUILDLOG}" "${LOGNAME}"
echo " log has been saved as ${LOGNAME}" >> "{{ report_file }}"
TESTLOGS=($(find ${BUILDDIR}/work -iname '*test*log*'))
{% raw %}
if [[ ${#TESTLOGS[@]} -gt 0 ]]; then
tar cf ${LOGNAME}.tar ${TESTLOGS[@]}
echo " test-suite logs have been saved as ${LOGNAME}.tar" >> "{{ report_file }}"
fi
fi
{% endraw %}
}
tatt_test_pkg() {
local CP=${1#=}
CP=${CP/\//_}
if [[ ${2} == "--test" ]]; then
# Do a first pass to avoid circular dependencies
# --onlydeps should mean we're avoiding (too much) duplicate work
USE="minimal -doc" emerge --onlydeps -q1 --with-test-deps {{ emerge_opts }} "${1:?}"
if ! emerge --onlydeps -q1 --with-test-deps {{ emerge_opts }} "${1:?}"; then
echo "merging test dependencies of ${1} failed" >> "{{ report_file }}"
return 1
fi
printf "%s pkgdev_tatt_{{ job_name }}_test\n" "${1:?}"> "/etc/portage/package.env/pkgdev_tatt_{{ job_name }}/${CP}"
local TFEATURES="${FEATURES} test"
else
printf "%s pkgdev_tatt_{{ job_name }}_no_test\n" "${1:?}" > "/etc/portage/package.env/pkgdev_tatt_{{ job_name }}/${CP}"
local TFEATURES="${FEATURES}"
fi
{% for env in extra_env_files %}
printf "%s {{env}}\n" "${1}" >> "/etc/portage/package.env/pkgdev_tatt_{{ job_name }}/${CP}"
{% endfor %}
printf "%s %s\n" "${1:?}" "${TUSE}" > "/etc/portage/package.use/pkgdev_tatt_{{ job_name }}/${CP}"
# --usepkg-exclude needs the package name, so let's extract it
# from the atom we have
local name=$(portageq pquery "${1:?}" -n)
eout=$( emerge -1 --getbinpkg=n --usepkg-exclude="${name}" {{ emerge_opts }} "${1:?}" 2>&1 1>/dev/tty )
local RES=$?
rm -v -f /etc/portage/package.{env,use}/pkgdev_tatt_{{ job_name }}/${CP}
if [[ ${RES} == 0 ]] ; then
if [[ -n ${TFEATURES} ]]; then
echo -n "FEATURES='${TFEATURES}' " >> "{{ report_file }}"
fi
echo "USE='${TUSE}' succeeded for ${1:?}" >> "{{ report_file }}"
else
FEATURES="${TFEATURES}" tatt_pkg_error "${1:?}" "${eout}"
return 1
fi
}
if [[ ${1} == "--clean" ]]; then
cleanup
else
main
fi
|