diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-10 03:49:30 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-10 03:49:30 +0200 |
commit | ede215cf93ba81c963ae62d665d0f32c9407551c (patch) | |
tree | 4a6dc80f259bccb8ff8b76d31e6cc8794bd97a2b /scripts/build.sh | |
download | eclipse-poky-kepler-daisy-140929.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'scripts/build.sh')
-rwxr-xr-x | scripts/build.sh | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..99acff7 --- /dev/null +++ b/scripts/build.sh | |||
@@ -0,0 +1,173 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | help () | ||
4 | { | ||
5 | echo "Build the Yocto Eclipse plugins" | ||
6 | echo "Usage: [GIT_URL=url_of_repo] [DOC_GIT=url_of_repo] $0 [OPTIONS] BRANCH_NAME RELEASE_NAME [TAG_NAME]"; | ||
7 | echo "" | ||
8 | echo "Options:" | ||
9 | echo "-h - display this help and exit" | ||
10 | echo "-l - use local git repository" | ||
11 | echo "BRANCH_NAME - git branch name to build upon" | ||
12 | echo "RELEAES_NAME - release name in the final output name" | ||
13 | echo "TAG_NAME - git tag name to build upon. defaults to HEAD if not set" | ||
14 | echo "GIT_URL - use this repo for the plugins. Defaults to git://git.pokylinux.org/eclipse-poky-juno.git if not set" | ||
15 | echo "DOC_GIT - use this repo for documentation. Defaults to git://git.pokylinux.org/yocto-docs.git if not set" | ||
16 | echo "" | ||
17 | echo "Example: $0 master r0 M1.1_rc1"; | ||
18 | exit 1; | ||
19 | } | ||
20 | |||
21 | fail () | ||
22 | { | ||
23 | local retval=$1 | ||
24 | shift $1 | ||
25 | echo "[Fail $retval]: $*" | ||
26 | echo "BUILD_TOP=${BUILD_TOP}" | ||
27 | cd ${TOP} | ||
28 | exit ${retval} | ||
29 | } | ||
30 | |||
31 | find_eclipse_base () | ||
32 | { | ||
33 | [ -d ${ECLIPSE_HOME}/plugins ] && ECLIPSE_BASE=${ECLIPSE_HOME} | ||
34 | } | ||
35 | |||
36 | find_launcher () | ||
37 | { | ||
38 | local list="`ls ${ECLIPSE_BASE}/plugins/org.eclipse.equinox.launcher_*.jar`" | ||
39 | for launcher in $list; do | ||
40 | [ -f $launcher ] && LAUNCHER=${launcher} | ||
41 | done | ||
42 | } | ||
43 | |||
44 | find_buildfile () | ||
45 | { | ||
46 | local list="`ls ${ECLIPSE_BASE}/plugins/org.eclipse.pde.build_*/scripts/build.xml`" | ||
47 | for buildfile in $list; do | ||
48 | [ -f $buildfile ] && BUILDFILE=${buildfile} | ||
49 | done | ||
50 | } | ||
51 | |||
52 | check_env () | ||
53 | { | ||
54 | find_eclipse_base | ||
55 | find_launcher | ||
56 | find_buildfile | ||
57 | |||
58 | local err=0 | ||
59 | [ "x${ECLIPSE_BASE}" = "x" -o "x${LAUNCHER}" = "x" -o "x${BUILDFILE}" = "x" ] && err=1 | ||
60 | if [ $err -eq 0 ]; then | ||
61 | [ ! -d ${ECLIPSE_BASE} ] && err=1 | ||
62 | [ ! -f ${LAUNCHER} ] && err=1 | ||
63 | [ ! -f ${BUILDFILE} ] && err=1 | ||
64 | fi | ||
65 | |||
66 | if [ $err -ne 0 ]; then | ||
67 | echo "Please set env variable ECLIPSE_HOME to the eclipse installation directory!" | ||
68 | exit 1 | ||
69 | fi | ||
70 | } | ||
71 | |||
72 | USE_LOCAL_GIT_REPO=0 | ||
73 | while getopts ":lh" opt; do | ||
74 | case $opt in | ||
75 | h) | ||
76 | help | ||
77 | ;; | ||
78 | l) | ||
79 | USE_LOCAL_GIT_REPO=1 | ||
80 | ;; | ||
81 | esac | ||
82 | done | ||
83 | shift $(($OPTIND - 1)) | ||
84 | |||
85 | |||
86 | if [ $# -ne 2 ] && [ $# -ne 3 ]; then | ||
87 | help | ||
88 | fi | ||
89 | |||
90 | #milestone | ||
91 | BRANCH=$1 | ||
92 | RELEASE=$2 | ||
93 | |||
94 | if [ "x" = "x${3}" ] | ||
95 | then | ||
96 | TAG="HEAD" | ||
97 | else | ||
98 | TAG=$3 | ||
99 | fi | ||
100 | |||
101 | TOP=`pwd` | ||
102 | |||
103 | check_env | ||
104 | |||
105 | #create tmp dir for build | ||
106 | DATE=`date +%Y%m%d%H%M` | ||
107 | BUILD_TOP=`echo ${BRANCH} | sed 's%/%-%'` | ||
108 | BUILD_TOP=${TOP}/${BUILD_TOP}_build_${DATE} | ||
109 | rm -rf ${BUILD_TOP} | ||
110 | mkdir ${BUILD_TOP} || fail $? "Create temporary build directory ${BUILD_TOP}" | ||
111 | BUILD_SRC=${BUILD_TOP}/src | ||
112 | BUILD_DIR=${BUILD_TOP}/build | ||
113 | mkdir ${BUILD_DIR} || fail $? "Create temporary build directory ${BUILD_DIR}" | ||
114 | |||
115 | |||
116 | #git clone | ||
117 | GIT_URL=${GIT_URL:-git://git.pokylinux.org/eclipse-poky-kepler.git} | ||
118 | if [ $USE_LOCAL_GIT_REPO -eq 1 ]; then | ||
119 | SCRIPT_DIR=`dirname $0` | ||
120 | GIT_DIR=`readlink -f ${SCRIPT_DIR}/..` | ||
121 | GIT_URL="file://${GIT_DIR}" | ||
122 | fi | ||
123 | |||
124 | GIT_DIR=${BUILD_SRC} | ||
125 | #mkdir ${GIT_DIR} | ||
126 | #cp -r features/ ${GIT_DIR} | ||
127 | #cp -r plugins/ ${GIT_DIR} | ||
128 | #cp -r tcf/ ${GIT_DIR} | ||
129 | git clone ${GIT_URL} ${GIT_DIR} || fail $? "git clone ${GIT_URL}" | ||
130 | cd ${GIT_DIR} | ||
131 | git checkout origin/${BRANCH} || fail $? "git checkout origin/${BRANCH}" | ||
132 | git checkout ${TAG} || fail $? "git checkout ${TAG}" | ||
133 | cd ${TOP} | ||
134 | |||
135 | # generate and add documentation | ||
136 | if [ "${TAG}" = "HEAD" ]; then | ||
137 | ${GIT_DIR}/scripts/generate-doc.sh ${BRANCH} ${GIT_DIR} | ||
138 | else | ||
139 | ${GIT_DIR}/scripts/generate-doc.sh -t ${TAG} ${GIT_DIR} | ||
140 | fi | ||
141 | |||
142 | #build | ||
143 | java -jar ${LAUNCHER} -application org.eclipse.ant.core.antRunner -buildfile ${BUILDFILE} -DbaseLocation=${ECLIPSE_BASE} -Dbuilder=${GIT_DIR}/features/org.yocto.bc.headless.build -DbuildDirectory=${BUILD_DIR} -DotherSrcDirectory=${GIT_DIR} -DbuildId=${RELEASE} || fail $? "normal build" | ||
144 | java -jar ${LAUNCHER} -application org.eclipse.ant.core.antRunner -buildfile ${BUILDFILE} -DbaseLocation=${ECLIPSE_BASE} -Dbuilder=${GIT_DIR}/features/org.yocto.doc.headless.build -DbuildDirectory=${BUILD_DIR} -DotherSrcDirectory=${GIT_DIR} -DbuildId=${RELEASE} || fail $? "normal build" | ||
145 | java -jar ${LAUNCHER} -application org.eclipse.ant.core.antRunner -buildfile ${BUILDFILE} -DbaseLocation=${ECLIPSE_BASE} -Dbuilder=${GIT_DIR}/features/org.yocto.sdk.headless.build -DbuildDirectory=${BUILD_DIR} -DotherSrcDirectory=${GIT_DIR} -DbuildId=${RELEASE} || fail $? "normal build" | ||
146 | |||
147 | if [ -f ${BUILD_DIR}/I.${RELEASE}/org.yocto.sdk-${RELEASE}.zip ] && | ||
148 | [ -f ${BUILD_DIR}/I.${RELEASE}/org.yocto.bc-${RELEASE}.zip ] && | ||
149 | [ -f ${BUILD_DIR}/I.${RELEASE}/org.yocto.doc-${RELEASE}.zip ]; then | ||
150 | cp -f ${BUILD_DIR}/I.${RELEASE}/org.yocto.bc-${RELEASE}.zip ./org.yocto.bc-${RELEASE}-${DATE}.zip | ||
151 | cp -f ${BUILD_DIR}/I.${RELEASE}/org.yocto.doc-${RELEASE}.zip ./org.yocto.doc-${RELEASE}-${DATE}.zip | ||
152 | cp -f ${BUILD_DIR}/I.${RELEASE}/org.yocto.sdk-${RELEASE}.zip ./org.yocto.sdk-${RELEASE}-${DATE}.zip | ||
153 | rm -rf ${BUILD_DIR} | ||
154 | else | ||
155 | fail 1 "Not finding normal build output" | ||
156 | fi | ||
157 | |||
158 | #build archive for update site | ||
159 | java -jar ${LAUNCHER} -application org.eclipse.ant.core.antRunner -buildfile ${BUILDFILE} -DbaseLocation=${ECLIPSE_BASE} -Dbuilder=${GIT_DIR}/features/org.yocto.bc.headless.build -DbuildDirectory=${BUILD_DIR} -DotherSrcDirectory=${GIT_DIR} -DbuildId=${RELEASE} -Dp2.gathering=true || fail $? "archive build" | ||
160 | java -jar ${LAUNCHER} -application org.eclipse.ant.core.antRunner -buildfile ${BUILDFILE} -DbaseLocation=${ECLIPSE_BASE} -Dbuilder=${GIT_DIR}/features/org.yocto.doc.headless.build -DbuildDirectory=${BUILD_DIR} -DotherSrcDirectory=${GIT_DIR} -DbuildId=${RELEASE} -Dp2.gathering=true || fail $? "archive build" | ||
161 | java -jar ${LAUNCHER} -application org.eclipse.ant.core.antRunner -buildfile ${BUILDFILE} -DbaseLocation=${ECLIPSE_BASE} -Dbuilder=${GIT_DIR}/features/org.yocto.sdk.headless.build -DbuildDirectory=${BUILD_DIR} -DotherSrcDirectory=${GIT_DIR} -DbuildId=${RELEASE} -Dp2.gathering=true || fail $? "archive build" | ||
162 | |||
163 | #clean up | ||
164 | if [ -f ${BUILD_DIR}/I.${RELEASE}/org.yocto.sdk-${RELEASE}-group.group.group.zip ] && | ||
165 | [ -f ${BUILD_DIR}/I.${RELEASE}/org.yocto.bc-${RELEASE}-group.group.group.zip ] && | ||
166 | [ -f ${BUILD_DIR}/I.${RELEASE}/org.yocto.doc-${RELEASE}-group.group.group.zip ]; then | ||
167 | cp -f ${BUILD_DIR}/I.${RELEASE}/org.yocto.sdk-${RELEASE}-group.group.group.zip ./org.yocto.sdk-${RELEASE}-${DATE}-archive.zip | ||
168 | rm -rf ${BUILD_TOP} | ||
169 | else | ||
170 | fail 1 "Not finding archive build output" | ||
171 | fi | ||
172 | |||
173 | exit 0 | ||