blob: 56094e4203c6dd39ec5097b380f9fec9cfaa401e (
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
136
137
138
139
140
141
142
143
144
145
146
147
|
# Set REPO_MIRROR to non-empty value to get around upstream downtimes
REPO_MIRROR="--repo-url=git://android.git.linaro.org/tools/repo.git"
setup-repo-vars () {
EABI="${EABI-arm-eabi}"
MANIFEST_REPO="${MANIFEST_REPO-git://android.git.kernel.org/platform/manifest.git}"
MANIFEST_BRANCH="${MANIFEST_BRANCH-master}"
MANIFEST_FILENAME="${MANIFEST_FILENAME-default.xml}"
if [ -n "$REPO_QUIET" ]; then
REPO_QUIET="--quiet"
fi
if [ -n "$REPO_SEED_URL" ]; then
# If we use seeded builds, use higher value of repo sync -j,
# as large share of repository content will be local and thus
# only disk i/o bound.
SYNC_JOBS=${SYNC_JOBS-8}
else
SYNC_JOBS=${SYNC_JOBS-3}
fi
}
repo-sync-from-mirror () {
setup-repo-vars
repo init $REPO_QUIET -u "${MANIFEST_REPO}" -b "${MANIFEST_BRANCH}" -m "${MANIFEST_FILENAME}" $REPO_MIRROR
# Save input manifest as build artifact for reference
mkdir -p out
cp .repo/manifest.xml out/source-manifest.xml
# Allow either specify hostname or pass $HUDSON_URL from Jenkins
mirror_host=`python -c 'import urlparse, sys; print urlparse.urlparse(sys.argv[1]).netloc if "/jenkins" in sys.argv[1] else sys.argv[1]' "$1"`
time python -c 'import xmlrpclib, sys; print xmlrpclib.ServerProxy(sys.argv[1]).mirror(open(".repo/manifest.xml").read())' "http://$mirror_host:8080" > .repo/mirror-manifest.xml
echo "Received modified manifest:"
cat .repo/mirror-manifest.xml
echo ----------------------------
cp .repo/mirror-manifest.xml .repo/manifest.xml
time repo sync $REPO_QUIET -j$SYNC_JOBS
# Restore source manifest temporarily to create pinned manifest
cp out/source-manifest.xml .repo/manifest.xml
repo manifest -r -o out/pinned-manifest.xml
cp .repo/mirror-manifest.xml .repo/manifest.xml
}
repo-sync-from-seed () {
setup-repo-vars
time curl --silent --show-error "$REPO_SEED_URL" | gzip -d -c | tar x
repo init $REPO_QUIET -u "${MANIFEST_REPO}" -b "${MANIFEST_BRANCH}" -m "${MANIFEST_FILENAME}" $REPO_MIRROR --reference=$PWD/$(basename $REPO_SEED_URL .tar.gz)
mkdir -p out
cp .repo/manifest.xml out/source-manifest.xml
time repo sync $REPO_QUIET -j$SYNC_JOBS
repo manifest -r -o out/pinned-manifest.xml
}
calc_make_jobs () {
if [ -z "$MAKE_JOBS" ]; then
cpuc=`cat /proc/cpuinfo | grep processor | wc -l`
MAKE_JOBS=$(($cpuc * 4))
fi
}
function get_url_basename {
echo "$1" | sed -e 's/^.*\/\([^/]*\)$/\1/'
}
function get_tarball_version {
# echo "$1" | sed -e 's/^.*-//' -e 's/\.tar.*$//'
echo "$1" | sed -r -e 's/\.tar.*$//' -e 's/^[a-z0-9]+-(.*)/\1/'
}
#echo `get_version gcc-linaro-4.5-2011.04-0.tar.bz2`
# linaro-4.5-2011.04-0
#echo `get_version binutils-2.20.1.tar.bz2`
# 2.20.1
#
# Download another builds's artifacts, as if they were
# produced by this build. Used for testing, trigger by BUILD_COPYCAT
# build config setting.
#
download_another_build () {
local baseurl
if ! echo "$1" | grep '://' >/dev/null; then
baseurl="http://snapshots.linaro.org/android/$1"
else
baseurl=$1
fi
local dir=out/target/product/$TARGET_PRODUCT
mkdir -p $dir
pushd $dir
wget -nv --no-check-certificate "$baseurl/target/product/$TARGET_PRODUCT/boot.tar.bz2"
wget -nv --no-check-certificate "$baseurl/target/product/$TARGET_PRODUCT/system.tar.bz2"
wget -nv --no-check-certificate "$baseurl/target/product/$TARGET_PRODUCT/userdata.tar.bz2"
popd
}
unpack_overlays () {
local ifs_save="$IFS"
IFS=";"
for p in $1; do
tarball="../snapshots.linaro.org/android/binaries/$p"
tar -x -a -f "$tarball" -C .
done
IFS="$ifs_save"
}
unpack_external_tarball () {
ext_tarball_dir=$BUILD_SCRIPT_ROOT/../../build/external_tarballs
# Always start clean
if [[ -d $ext_tarball_dir ]]; then
rm -rf $ext_tarball_dir
fi
mkdir -p $ext_tarball_dir
pushd $ext_tarball_dir
local ifs_save="$IFS"
IFS=";"
for p in $1; do
regex_is_http="^https?://"
regex_file=".*/(.*?)$"
if [[ $p =~ $regex_is_http ]]; then
# File is on a remote web server, wget it
wget -nv --no-check-certificate $p
fi
if [[ $p =~ $regex_file ]]; then
filename=${BASH_REMATCH[1]}
tar -x -a -f "$filename" -C $ext_tarball_dir
else
echo "Fatal Error: $p - file name can not be determined"
exit 1
fi
done
IFS="$ifs_save"
popd
}
# Error handler for infrastructure setup (vs compiple) errors
# Wrap infra-setup code in:
# trap infrastructure_error ERR
# trap - ERR
infrastructure_error () {
echo "Caught infrastructure error - finishing build with 'Not Built' status"
# Interpreted as NOT_BUILT by Shell Status plugin
exit 123
}
|