blob: 870ddfb716a9e5d137e0580b8f0455a710f2f411 (
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
#!/bin/bash
set -e
source "${BUILD_SCRIPT_ROOT}"/helpers
setup-repo-vars
#Translate
# https://android-build.linaro.org/jenkins/job/doanac_build-script-generation/6/
# into
# http://snapshots.linaro.org/android/~doanac/build-script-generation/6/
PINNED_MANIFEST_URL=${BUILD_URL/http*jenkins\/job\//http://snapshots.linaro.org/android/~}
# change the dash in doanac_build... to doanac/build...
PINNED_MANIFEST_URL=${PINNED_MANIFEST_URL/_/\/}
if [ -n "$SOURCE_OVERLAY" ]; then
USAGE_SUM="'Usage: \$0 -m <manifest.xml> -o <overlay.tar> [ -t -d directory -l login ]'"
USAGE_OVERLAY="'\\n -m <manifest> If -t is not used, then using a browser with cookies you\\n must download the pinned manifest from:\\n $PINNED_MANIFEST_URL\\n -o The path to the vendor required overlay.\\n Can be downloaded from http://snapshots.linaro.org/android/binaries/$SOURCE_OVERLAY\\n'"
USAGE_OPTOVERLAY="m:o:"
USAGE_OPTHANDLER="o ) SOURCE_OVERLAY=\$OPTARG;; m ) MANIFEST=\$OPTARG;;"
else
USAGE_SUM="'Usage: \$0 [ -t -d directory -l login ]'"
fi
header()
{
cat <<EOF
#!/bin/bash
# Author+=amit.pundir@linaro.org
set -e
EXACT=1
DIR=android
ID=default-bot
usage()
{
echo $USAGE_SUM
echo -e $USAGE_OVERLAY
echo " -t Reproduce the build from the tip of the branch rather than doing"
echo " an exact replica build"
echo " -d <directory> The directory to download code and build from"
echo " Default: \${DIR}"
echo " -l <login-id> login-id to clone from linaro-private git repositories"
echo " If in doubt, kindly raise access request to rt@linaro.org"
echo " Default: \${ID}"
exit 1
}
while getopts "${USAGE_OPTOVERLAY}d:l:ht" optn; do
case \$optn in
$USAGE_OPTHANDLER
d ) DIR=\$OPTARG;;
l ) ID=\$OPTARG;;
t ) EXACT=0;;
h ) usage; exit 1;;
esac
done
UBUNTU=\`cat /etc/issue.net | cut -d' ' -f2\`
HOST_ARCH=\`uname -m\`
if [ \${HOST_ARCH} == "x86_64" ] ; then
PKGS='git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc uboot-mkimage openjdk-6-jdk openjdk-6-jre vim-common'
else
echo "ERROR: Only 64bit Host(Build) machines are supported at the moment."
exit 1
fi
if [ \${UBUNTU} == "12.10" ]; then
PKGS+=' lib32readline-gplv2-dev'
elif [ \${UBUNTU} == "12.04" ] ; then
PKGS+=' lib32readline-gplv2-dev'
elif [ \${UBUNTU} == "10.04" ] ; then
PKGS+=' ia32-libs lib32readline5-dev'
else
echo
echo "ERROR: Only Ubuntu 10.04, 12.04 and 12.10 versiona are supported."
exit 1
fi
echo "Checking and installing missing dependencies if any .. .."
sudo apt-get install \${PKGS}
MISSING=\`dpkg-query -W -f='\${Status}\n' \${PKGS} 2>&1 | grep 'No packages found matching' | cut -d' ' -f5\`
if [ -n "\$MISSING" ] ; then
echo "Missing required packages:"
for m in \$MISSING ; do
echo -n "\${m%?} "
done
echo
exit 1
fi
EOF
if [ -n "$SOURCE_OVERLAY" ]; then
cat <<EOF
if [ "a\$MANIFEST" == "a" -a \$EXACT -eq 1 ]; then
echo "ERROR: no pinned manifest provided. Please download from $PINNED_MANIFEST_URL. This must be done from a browser that accepts cookies."
exit 1
fi
if [ "a\$SOURCE_OVERLAY" == "a" ]; then
echo "ERROR: no source overlay provided. Please download from http://snapshots.linaro.org/android/binaries/$SOURCE_OVERLAY. This must be done from a browser that accepts cookies."
exit 1
fi
EOF
fi
cat <<EOF
if [ -d \${DIR} ] ; then
echo "Directory \${DIR} exists. Are you sure you want to use this? (y/n) "
read CONTINUE
[ \${CONTINUE} == y ] || exit 1
else
mkdir \${DIR}
fi
cd \${DIR}
EOF
}
jenkins_configs_method()
{
cat <<EOF
export MANIFEST_REPO=${MANIFEST_REPO}
export MANIFEST_BRANCH=${MANIFEST_BRANCH}
export MANIFEST_FILENAME=${MANIFEST_FILENAME}
export TARGET_PRODUCT=${TARGET_PRODUCT}
export TARGET_SIMULATOR=false
export BUILD_TINY_ANDROID=${BUILD_TINY_ANDROID}
export CPUS=\`grep -c processor /proc/cpuinfo\`
EOF
if [ -n "$TOOLCHAIN_URL" ] ; then
cat <<EOF
export TOOLCHAIN_URL=${TOOLCHAIN_URL}
export TARGET_TOOLS_PREFIX=android-toolchain-eabi/bin/arm-linux-androideabi-
EOF
else
cat <<EOF
export TARGET_TOOLS_PREFIX=prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi-
EOF
fi
}
git_configs_method()
{
cat <<EOF
export BUILD_CONFIG_REPO=${BUILD_CONFIG_REPO}
export BUILD_CONFIG_BRANCH=${BUILD_CONFIG_BRANCH}
export BUILD_CONFIG_FILENAME=${BUILD_CONFIG_FILENAME}
git clone "\$BUILD_CONFIG_REPO" configs_repo
git --git-dir=configs_repo/.git checkout "\$BUILD_CONFIG_BRANCH"
CONFIGURATION=\$(cat configs_repo/"\$BUILD_CONFIG_FILENAME")
set -a
eval \$CONFIGURATION
EOF
}
sync_commands()
{
if [ -n "$SOURCE_OVERLAY" ]; then
CP_CMD="cp \$MANIFEST .repo/manifest.xml"
else
CP_CMD="curl -k ${PINNED_MANIFEST_URL}/pinned-manifest.xml > .repo/manifest.xml"
fi
if [ "$REPO_GROUPS" != "all,-notdefault,-eclipse" ]; then
REPO_GROUPS_OPTION="-g $REPO_GROUPS"
else
REPO_GROUPS_OPTION=""
fi
cat <<EOF
# download the repo tool for android
curl "http://android.git.linaro.org/gitweb?p=tools/repo.git;a=blob_plain;f=repo;hb=refs/heads/stable" > repo
chmod +x repo
# download the android code
./repo init -u \${MANIFEST_REPO} -b \${MANIFEST_BRANCH} -m \${MANIFEST_FILENAME} ${REPO_MIRROR} $REPO_GROUPS_OPTION
if [ \${EXACT} -eq 1 ] ; then
rm .repo/manifest.xml
$CP_CMD
fi
# check for linaro private git repositories
PRI=\`grep -i "linaro-private" .repo/manifests/\${MANIFEST_FILENAME} | wc -l\`
if [ \${PRI} -gt 0 ] ; then
if [ "\${ID}" == "default-bot" ] ; then
echo "You must specify valid login/access-id to clone from linaro-private git repositories."
echo "Press "y" to continue (which may result in incomplete build), OR"
echo "Press "n" to enter login details, OR"
echo "Press "h" for help."
read NEXT
if [ \${NEXT} == n ] ; then
echo "Enter login/access-id:"
read ID
elif [ \${NEXT} == h ] ; then
usage
fi
fi
sed -i 's/\/\/.*-bot@/\/\/'"\${ID}"'@/' .repo/manifests/\${MANIFEST_FILENAME}
fi
./repo sync
EOF
if [ -n "$TOOLCHAIN_URL" ] ; then
cat <<EOF
# download the toolchain to build with
curl -k \${TOOLCHAIN_URL} > toolchain.tar.bz2
tar -jxf toolchain.tar.bz2
rm toolchain.tar.bz2
EOF
fi
if [ -n "$SOURCE_OVERLAY" ]; then
cat <<EOF
# extract the vendor's source overlay
tar -x -a -f "\$SOURCE_OVERLAY" -C .
EOF
fi
echo
}
build_commands()
{
cat <<EOF
# build the code
. build/envsetup.sh
make -j\${CPUS} boottarball systemtarball userdatatarball
EOF
}
{
header
if [ -n "$BUILD_CONFIG_REPO" ]; then
git_configs_method
else
jenkins_configs_method
fi
sync_commands
build_commands
} > linaro_android_build_cmds.sh
chmod +x linaro_android_build_cmds.sh
|