forked from CyanogenMod/hudson
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·143 lines (115 loc) · 2.89 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
#!/usr/bin/env bash
function check_result {
if [ "0" -ne "$?" ]
then
echo $1 step failed !
cat $WORKSPACE/archive/reposync.log
exit 1
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
rm -rf $WORKSPACE/archive
mkdir -p $WORKSPACE/archive
export BUILD_NO=$BUILD_NUMBER
unset BUILD_NUMBER
export PATH=~/bin:$PATH
REPO=$(which repo)
if [ -z "$REPO" ]; then
mkdir -p ~/bin
curl -s -S 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]
# Repo manifest
if [ -z "$REPO_MANIFEST" ]; then
REPO_MANIFEST=CyanogenMod
fi
cd $WORKSPACE
if [ ! -d "$REPO_BRANCH" ]
then
mkdir $REPO_BRANCH
if [ ! -z "$BOOTSTRAP" -a -d "$BOOTSTRAP" ]; then
echo Bootstrapping repo with: $BOOTSTRAP
cp -R $BOOTSTRAP/.repo $REPO_BRANCH
fi
cd $REPO_BRANCH
repo init -u git://github.com/$REPO_MANIFEST/android.git -b $REPO_BRANCH
else
cd $REPO_BRANCH
repo init -u git://github.com/$REPO_MANIFEST/android.git -b $REPO_BRANCH
fi
# make sure ccache is in PATH
export PATH="$PATH:/opt/local/bin/:$PWD/prebuilt/$(uname|awk '{print tolower($0)}')-x86/ccache"
if [ -f ~/.jenkins_profile ]
then
. ~/.jenkins_profile
fi
HUDSON_DIR=$WORKSPACE/hudson
cp $HUDSON_DIR/$REPO_BRANCH.xml $WORKSPACE/$REPO_BRANCH/.repo/local_manifest.xml
echo Syncing...
repo sync -j 1 -f 2>$WORKSPACE/archive/reposync.log
check_result repo sync failed.
echo Sync complete.
cd $WORKSPACE/$REPO_BRANCH
if [ -f $HUDSON_DIR/$REPO_BRANCH-setup.sh ]
then
$HUDSON_DIR/$REPO_BRANCH-setup.sh
fi
# colorization fix in Jenkins (override yellow color)
export BUILD_WITH_COLORS=0
export CL_PFX="\"\033[34m\""
export CL_INS="\"\033[32m\""
export CL_RST="\"\033[0m\""
export USE_CCACHE=1
cd $WORKSPACE/$REPO_BRANCH
echo "We are ready to build in $WORKSPACE/$REPO_BRANCH"
. build/envsetup.sh
lunch $LUNCH
check_result lunch failed.
export USE_CCACHE=1
UNAME=$(uname)
if [ "$RELEASE_TYPE" = "CM_NIGHTLY" ]
then
export CYANOGEN_NIGHTLY=true
export CM_NIGHTLY=true
elif [ "$RELEASE_TYPE" = "CM_SNAPSHOT" ]
then
export CM_SNAPSHOT=true
elif [ "$RELEASE_TYPE" = "CM_RELEASE" ]
then
export CYANOGEN_RELEASE=true
export CM_RELEASE=true
fi
if [ ! "$(ccache -s|grep -E 'max cache size'|awk '{print $4}')" = "5.0" ]
then
ccache -M 5G
fi
rm -f $OUT/*.zip*
make $CLEAN_TYPE
mka bacon
check_result Build failed.
# Files to keep
find $OUT/*.zip* | grep ota | xargs rm -f
cp $OUT/*.zip* $WORKSPACE/archive/
# archive the build.prop as well
cat $OUT/system/build.prop > $WORKSPACE/archive/build.prop