blob: 4116fa82690e74ba05a5caf06ed17db9fce68e29 (
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
|
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
[[ $(whoami) == "root" ]] || exit 1
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function ENV_SETUP() {
eselect news read --quiet all
eselect ruby set 1
if [[ ! -d /etc/portage/env/ ]]; then
mkdir /etc/portage/env/
fi
echo 'FEATURES="${FEATURES} test keepwork"' > /etc/portage/env/test
if [[ ! -d $SCRIPT_DIR/ci-logs/ ]]; then
mkdir "$SCRIPT_DIR/ci-logs"
fi
}
function SETUP () {
cp /var/lib/portage/world /var/lib/portage/world.original
echo "" > /etc/portage/package.accept_keywords
echo "=$PACKAGE doc" > /etc/portage/package.use
echo "=$PACKAGE test" > /etc/portage/package.env
if [[ -e /usr/portage/packages/$PACKAGE.tbz2 ]]; then
rm "/usr/portage/packages/$PACKAGE.tbz2"
fi
set +e
emerge --pretend --quiet "=$PACKAGE"
if [[ $? == 1 ]]; then
emerge --autounmask-write "=$PACKAGE"
etc-update --automode -5
fi
set -e
}
function EMERGE() {
set +e
timeout 1000 emerge --usepkg --buildpkg "=$PACKAGE"
LOG "$?"
set -e
}
function LOG() {
DATE=$(date +%s)
SHA1=$(sha1sum "/usr/portage/$CATEGORY/$NAME/$NAME-$VERSION.ebuild" | awk '{print $1}')
mkdir -p "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE"
emerge --info "=$PACKAGE" > "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE/emerge-info"
emerge -pqv "=$PACKAGE" > "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE/emerge-pqv"
cp "/var/tmp/portage/$PACKAGE/temp/build.log" "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE/build.log"
cp "/var/tmp/portage/$PACKAGE/temp/environment" "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE/environment"
gem list > "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE/gem-list"
if [[ $1 == 0 ]]; then
RESULT="\e[0;32mBUILD SUCCEEDED\e[0m"
echo "succeeded" > "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE/result"
elif [[ $1 == 1 ]]; then
RESULT="\e[0;31mBUILD FAILED\e[0m"
echo "failed" > "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE/result"
elif [[ $1 == 124 ]]; then
RESULT="\e[0;31mBUILD TIMED OUT\e[0m"
echo "timed out" > "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE/result"
else
RESULT="\e[0;31mBUILD UNKNOWN\e[0m"
echo "unknown" > "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE/result"
fi
chmod 755 -R "$SCRIPT_DIR/ci-logs/$SHA1/$TYPE/builds/$DATE"
}
function CLEANUP() {
mv /var/lib/portage/world.original /var/lib/portage/world
rm -r /var/tmp/portage/* || true
emerge --depclean --quiet
echo -e "$PACKAGE : $RESULT"
}
ENV_SETUP
PKG_ARR=($(qatom $1))
CATEGORY="${PKG_ARR[0]}"
NAME="${PKG_ARR[1]}"
if [[ ${PKG_ARR[3]:=foo} == "foo" ]]; then
VERSION="${PKG_ARR[2]}"
else
VERSION="${PKG_ARR[2]}-${PKG_ARR[3]}"
fi
if [[ $# -eq 1 ]]; then
TYPE="current_target"
PACKAGE=$1
SETUP
EMERGE
CLEANUP
elif [[ $# -eq 3 ]]; then
TYPE="next_target"
PACKAGE=$1
CURR_TARGET=$2
NEXT_TARGET=$3
SETUP
EMERGE
CLEANUP
fi
|