blob: 63bbd96f1b32251b3ac8d4bb18110f253b46b447 (
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
|
#!/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 "$?" "$PACKAGE"
set -e
}
function LOG() {
DATE=$(date +%s)
mkdir -p "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE"
emerge --info "=$PACKAGE" > "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE/emerge-info"
emerge -pqv "=$PACKAGE" > "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE/emerge-pqv"
cp "/var/tmp/portage/$PACKAGE/temp/build.log" "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE/build.log"
cp "/var/tmp/portage/$PACKAGE/temp/environment" "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE/environment"
gem list > "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE/gem-list"
if [[ $1 == 0 ]]; then
RESULT="\e[0;32mBUILD SUCCEEDED\e[0m"
touch "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE/succeeded"
elif [[ $1 == 1 ]]; then
RESULT="\e[0;31mBUILD FAILED\e[0m"
touch "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE/failed"
elif [[ $1 == 124 ]]; then
RESULT="\e[0;31mBUILD TIMED OUT\e[0m"
touch "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE/timedout"
else
RESULT="\e[0;31mBUILD UNKNOWN\e[0m"
touch "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE/unknown"
fi
chmod 755 -R "$SCRIPT_DIR/ci-logs/$PACKAGE/$DATE"
}
function CLEANUP() {
mv /var/lib/portage/world.original /var/lib/portage/world
emerge --depclean --quiet
rm -r /var/tmp/portage/* || true
}
ENV_SETUP
PACKAGES=("$@")
for PACKAGE in "${PACKAGES[@]}"; do
SETUP $PACKAGE
EMERGE $PACKAGE
CLEANUP
echo -e "$PACKAGE : $RESULT"
done
|