forked from brandon15811/hudson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·206 lines (169 loc) · 4.3 KB
/
build.sh
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
#!/usr/bin/env bash
function check_result {
if [ "0" -ne "$?" ]
then
echo $1
exit 1
fi
}
if [ -z "$HOME" ]
then
echo HOME not in environment, guessing...
export HOME=$(awk -F: -v v="$USER" '{if ($1==v) print $6}' /etc/passwd)
fi
if [ -z "$WORKSPACE" ]
then
echo WORKSPACE not specified
exit 1
fi
if [ -z "$CLEAN_TYPE" ]
then
echo CLEAN_TYPE not specified
exit 1
fi
if [ -z "$REPO_BRANCH" ]
then
echo REPO_BRANCH not specified
exit 1
fi
if [ -z "$LUNCH" ]
then
echo LUNCH not specified
exit 1
fi
if [ -z "$RELEASE_TYPE" ]
then
echo RELEASE_TYPE not specified
exit 1
fi
if [ -z "$SYNC_PROTO" ]
then
SYNC_PROTO=http
fi
# colorization fix in Jenkins
export CL_PFX="\"\033[34m\""
export CL_INS="\"\033[32m\""
export CL_RST="\"\033[0m\""
cd $WORKSPACE
rm -rf archive
mkdir -p archive
export BUILD_NO=$BUILD_NUMBER
unset BUILD_NUMBER
export CM_EXTRAVERSION=$BUILD_NO
export PATH=/mnt/bin:~/bin:$PATH
export USE_CCACHE=1
export CCACHE_NLEVELS=4
export BUILD_WITH_COLORS=0
export CM_FAST_BUILD=1
REPO=$(which repo)
if [ -z "$REPO" ]
then
mkdir -p ~/bin
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
fi
# git config --global user.name $(whoami)@$NODE_NAME
# git config --global user.email [email protected]
# make sure ccache is in PATH
if [ "$REPO_BRANCH" == "jellybean" ]
then
export PATH="$PATH:/opt/local/bin/:$PWD/prebuilts/misc/$(uname|awk '{print tolower($0)}')-x86/ccache"
export CCACHE_DIR=$WORKSPACE/../.jb_ccache
else
export PATH="$PATH:/opt/local/bin/:$PWD/prebuilt/$(uname|awk '{print tolower($0)}')-x86/ccache"
export CCACHE_DIR=$WORKSPACE/../.ics_ccache
fi
if [ -f ~/.jenkins_profile ]
then
. ~/.jenkins_profile
fi
echo Core Manifest:
cat .repo/manifests/default.xml
echo Local Manifest:
cat .repo/local_manifest.xml
echo "About to do $WORKSPACE/hudson/$REPO_BRANCH-setup.sh"
cd $WORKSPACE/$REPO_BRANCH
if [ -f $WORKSPACE/hudson/$REPO_BRANCH-setup.sh ]
then
echo "Doing $WORKSPACE/hudson/$REPO_BRANCH-setup.sh"
$WORKSPACE/hudson/$REPO_BRANCH-setup.sh $WORKSPACE $REPO_BRANCH
fi
cd $WORKSPACE/$REPO_BRANCH
echo "We are ready to build in $WORKSPACE/$REPO_BRANCH"
. build/envsetup.sh
lunch $LUNCH
check_result "lunch failed."
# save manifest used for build (saving revisions as current HEAD)
repo manifest -o $WORKSPACE/archive/manifest.xml -r
rm -f $OUT/cm-*.zip*
UNAME=$(uname)
if [ "$RELEASE_TYPE" = "CM_NIGHTLY" ]
then
if [ "$REPO_BRANCH" = "gingerbread" ]
then
export CYANOGEN_NIGHTLY=true
else
export CM_NIGHTLY=true
fi
elif [ "$RELEASE_TYPE" = "CM_EXPERIMENTAL" ]
then
export CM_EXPERIMENTAL=true
elif [ "$RELEASE_TYPE" = "CM_RELEASE" ]
then
if [ "$REPO_BRANCH" = "gingerbread" ]
then
export CYANOGEN_RELEASE=true
else
export CM_RELEASE=true
fi
fi
if [ ! -z "$CM_EXTRAVERSION" ]
then
export CM_EXPERIMENTAL=true
fi
if [ ! -z "$GERRIT_CHANGES" ]
then
export CM_EXPERIMENTAL=true
IS_HTTP=$(echo $GERRIT_CHANGES | grep http)
if [ -z "$IS_HTTP" ]
then
python $WORKSPACE/hudson/repopick.py $GERRIT_CHANGES
check_result "gerrit picks failed."
else
python $WORKSPACE/hudson/repopick.py $(curl $GERRIT_CHANGES)
check_result "gerrit picks failed."
fi
fi
if [ ! "$(ccache -s|grep -E 'max cache size'|awk '{print $4}')" = "20.0" ]
then
ccache -M 20G
fi
WORKSPACE=$WORKSPACE LUNCH=$LUNCH sh $WORKSPACE/hudson/changes/buildlog.sh 2>&1
rm -f $OUT/*.zip*
make $CLEAN_TYPE
time mka bacon recoveryzip recoveryimage
check_result "Build failed."
echo "Files in $OUT"
echo "############################################"
ls -l $OUT
echo "############################################"
# Files to keep
find $OUT/*.zip* | grep ota | xargs rm -f
cp $OUT/cm-*.zip* $WORKSPACE/archive
if [ -f $OUT/utilties/update.zip ]
then
cp $OUT/utilties/update.zip $WORKSPACE/archive/recovery.zip
fi
if [ -f $OUT/recovery.img ]
then
cp $OUT/recovery.img $WORKSPACE/archive
fi
# archive the build.prop as well
ZIP=$(ls $WORKSPACE/archive/cm-*.zip)
unzip -p $ZIP system/build.prop > $WORKSPACE/archive/build.prop
#archive file size for CMUpdater
ls -nl $WORKSPACE/archive/cm-*.zip | awk '{print $5}' > $(ls $WORKSPACE/archive/cm-*.zip).size
chmod -R ugo+r $WORKSPACE/archive
# CORE: save manifest used for build (saving revisions as current HEAD)
rm -f .repo/local_manifest.xml
repo manifest -o $WORKSPACE/archive/core.xml -r