blob: d8de2bcb7639a0705d1bff17db0efa629af7c715 [file] [log] [blame]
Stephan Herrmannff801a62016-11-01 15:01:00 +01001#!/bin/sh
2
Stephan Herrmann434a0842016-11-01 18:02:29 +01003# OPTIONAL VARIABLES TO BE SUPPLIED VIA ENV:
4# SIGN (unset or nosign)
5# PROMOTE (unset or true)
6
Stephan Herrmannff801a62016-11-01 15:01:00 +01007BASE=`pwd`
Stephan Herrmann434a0842016-11-01 18:02:29 +01008
9# ABSOLUTE PATHS:
10export STAGINGBASE=/opt/public/download-staging.priv/tools/objectteams
11export UPDATES_BASE=/home/data/httpd/download.eclipse.org/objectteams/updates
Stephan Herrmann2e927b02018-01-28 11:48:32 +010012export JAVA5=/shared/common/jdk1.5.0-latest
13export JAVA8=/shared/common/jdk1.8.0_x64-latest
Stephan Herrmann434a0842016-11-01 18:02:29 +010014
15# RELATIVE PATHS:
Stephan Herrmannff801a62016-11-01 15:01:00 +010016BUILD=${BASE}/releng/build-scripts/build
17METADATA=${BASE}/metadata
Stephan Herrmann434a0842016-11-01 18:02:29 +010018
Stephan Herrmannff801a62016-11-01 15:01:00 +010019export JAR_PROCESSOR_JAVA=java8
20
21# Find the master repository to build upon:
22if [ "$1" == "none" ]
23then
24 MASTER="none"
25 echo "Generating fresh new repository"
26else
27 MASTER=${UPDATES_BASE}/$1
28 if [ -r ${MASTER}/features ]
29 then
30 echo "Generating Repository based on ${MASTER}"
31 else
32 MASTER=${HOME}/shared/baseRepos/$1
33 if [ -r ${MASTER}/features ]
34 then
35 echo "Generating Repository based on ${MASTER}"
36 else
37 echo "No such repository ${MASTER}"
38 echo "Usage: $0 updateMasterRelativePath [ -nosign ] [ statsRepoId statsVersionId ]"
39 exit 1
40 fi
41 fi
42fi
43
44# Analyze the version number of the JDT feature as needed for patching content.xml later:
45JDTFEATURE=`ls -d ${BASE}/testrun/build-root/eclipse/features/org.eclipse.jdt_*`
46if echo $JDTFEATURE | grep "\.r"
47then
48 JDTVERSION="`echo ${JDTFEATURE} | cut -d '_' -f 2`_`echo ${JDTFEATURE} | cut -d '_' -f 3`"
49else
50 JDTVERSION=`echo ${JDTFEATURE} | cut -d '_' -f 2`
51fi
52JDTVERSIONA=`echo ${JDTVERSION} | cut -d '-' -f 1`
53JDTVERSIONB=`echo ${JDTVERSION} | cut -d '-' -f 2`
54echo "after first split: ${JDTVERSIONA} and ${JDTVERSIONB}"
55case ${JDTVERSIONB} in
56 ????)
57 #A=v20110813 B=0800
58 JDTVERSIONB2=`expr $JDTVERSIONB + 1`
59 JDTVERSIONB2=`printf "%04d" ${JDTVERSIONB2}`
60 JDTVERSION=${JDTVERSIONA}-${JDTVERSIONB}
61 JDTVERSIONNEXT=${JDTVERSIONA}-${JDTVERSIONB2}
62 ;;
63 *)
64 #A=3.8.0.v20110813 B=someunspeakablelonghashid
65 JDTVERSIONC1=`echo ${JDTVERSIONA} | cut -d 'v' -f 1`
66 JDTVERSIONC2=`echo ${JDTVERSIONA} | cut -d 'v' -f 2`
67 JDTVERSIONC3=`expr $JDTVERSIONC2 + 1`
68 JDTVERSION=${JDTVERSIONC1}v${JDTVERSIONC2}
69 JDTVERSIONNEXT=${JDTVERSIONC1}v${JDTVERSIONC3}
70 ;;
71esac
72# hardcode when unable to compute
73#JDTVERSION=${JDTVERSIONA}
74#JDTVERSIONNEXT=3.8.0.v20110728
75echo "JDT feature is ${JDTVERSION}"
76echo "Next ${JDTVERSIONNEXT}"
77if [ ! -r ${BASE}/testrun/build-root/eclipse/features/org.eclipse.jdt_${JDTVERSION} ]
78then
79 echo "JDT feature not correctly found in ${BASE}/testrun/build-root/eclipse/features"
80 exit 2
81fi
82OTDTVERSION=`cat ${BASE}/testrun/build-root/src/finalFeaturesVersions.properties|grep "objectteams.otdt="|cut -d '=' -f 2`
Stephan Herrmann491e4dd2016-11-01 17:01:44 +010083if [ "${OTDTVERSION}" == "" ]
84then
85 echo "finalFeaturesVersions.properties not found, maybe build hasn't run successfully?"
86 exit 3
87fi
Stephan Herrmannff801a62016-11-01 15:01:00 +010088echo "OTDTVERSION is $OTDTVERSION"
89
90# Configure for calling various p2 applications:
91LAUNCHER=`grep equinox.launcher_jar= ${BUILD}/run.properties | cut -d '=' -f 2`
92LAUNCHER_PATH=${BASE}/testrun/build-root/eclipse/plugins/${LAUNCHER}
93FABPUB=org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher
94CATPUB=org.eclipse.equinox.p2.publisher.CategoryPublisher
95JARPROCESSOR=`ls ${BASE}/testrun/build-root/eclipse/plugins/org.eclipse.equinox.p2.jarprocessor_*.jar`
96NAME="Object Teams"
97
98echo "LAUNCHER_PATH = ${LAUNCHER_PATH}"
99echo "NAME = ${NAME}"
100
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200101echo "====Step 0: condition jars ===="
Stephan Herrmann6f337832018-05-15 23:58:44 +0200102CONDITIONED=${BASE}/testrun/updateSiteRepack
103if [ ! -d ${CONDITIONED} ]
104then
105 mkdir ${CONDITIONED}
106else
107 /bin/rm -r ${CONDITIONED}/*
108fi
109
110for dir in features plugins
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200111do
Stephan Herrmann6f337832018-05-15 23:58:44 +0200112 find ${BASE}/testrun/updateSite/${dir} -type f -name \*.jar -exec \
113 ${JAVA8}/bin/java -jar ${JARPROCESSOR} -verbose -processAll -repack -outputDir ${CONDITIONED}/${dir} {} \;
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200114done
Stephan Herrmann0dc84312018-05-16 00:12:42 +0200115# not conditioned, but must not be skipped!
116cp ${BASE}/testrun/updateSite/plugins/org.eclipse.jdt.core_* ${CONDITIONED}/plugins/
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200117
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200118echo "====Step 1: request signing and zip===="
Stephan Herrmann6f337832018-05-15 23:58:44 +0200119cd ${CONDITIONED}
Stephan Herrmann023b4422018-05-16 00:01:44 +0200120JARS=`find . -type f -name \*.jar`
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200121OTDTJAR=${BASE}/testrun/otdt.jar
Stephan Herrmann30789152016-11-01 15:44:32 +0100122if [ "${SIGN}" == "nosign" ]
Stephan Herrmannff801a62016-11-01 15:01:00 +0100123then
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100124 /bin/rm ${OTDTJAR}
125 zip ${OTDTJAR} ${JARS}
Stephan Herrmannfd97f0e2016-11-01 16:01:11 +0100126 echo "SKIPPING SIGNING"
Stephan Herrmannff801a62016-11-01 15:01:00 +0100127else
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200128 SIGNED=${BASE}/testrun/updateSiteSigned
129 if [ ! -d ${SIGNED} ]
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100130 then
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200131 mkdir ${SIGNED}
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100132 else
Stephan Herrmann6f337832018-05-15 23:58:44 +0200133 /bin/rm -r ${SIGNED}/*
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100134 fi
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200135 for JAR in ${JARS}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200136 do
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200137 DIR=`dirname $JAR`
138 if [ ! -d ${SIGNED}/${DIR} ]
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200139 then
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200140 mkdir -p ${SIGNED}/${DIR}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200141 fi
142 curl -o ${SIGNED}/${JAR} -F file=@${JAR} http://build.eclipse.org:31338/sign
143 done
144 if [ -f ${OTDTJAR} ]
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100145 then
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100146 /bin/rm ${OTDTJAR}
147 fi
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200148 cd ${SIGNED}
149 zip ${OTDTJAR} ${JARS}
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100150 echo "Signing completed"
Stephan Herrmannff801a62016-11-01 15:01:00 +0100151fi
Stephan Herrmannff801a62016-11-01 15:01:00 +0100152
153
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200154echo "====Step 2: fill new repository===="
Stephan Herrmannff801a62016-11-01 15:01:00 +0100155if [ -r ${BASE}/stagingRepo ]
156then
157 /bin/rm -rf ${BASE}/stagingRepo
158fi
159mkdir ${BASE}/stagingRepo
160cd ${BASE}/stagingRepo
161if [ "$MASTER" != "none" ]
162then
163 mkdir features
164 (cd features; ln -s ${MASTER}/features/* .)
165 mkdir plugins
166 (cd plugins; ln -s ${MASTER}/plugins/* .)
167else
168 mkdir plugins
169 cp ${BASE}/testrun/updateSite/plugins/org.apache.bcel* plugins/
170fi
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100171unzip -n ${OTDTJAR}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200172#/bin/rm ${OTDTJAR}
Stephan Herrmannff801a62016-11-01 15:01:00 +0100173
174LOCATION=${BASE}/stagingRepo
175echo "LOCATION = ${LOCATION}"
176cd ${LOCATION}
177
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200178echo "====Step 3: pack jars (again) ===="
Stephan Herrmann70aac8e2018-05-16 00:12:42 +0200179for dir in ${LOCATION}/features ${LOCATION}/plugins
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200180do
181 find ${dir} -type f -name \*.jar -exec \
182 ${JAVA8}/bin/java -jar ${JARPROCESSOR} -verbose -pack -outputDir ${dir} {} \;
183done
184
Stephan Herrmannff801a62016-11-01 15:01:00 +0100185
186echo "====Step 4: generate metadata===="
187java -jar ${LAUNCHER_PATH} -consoleLog -application ${FABPUB} \
188 -source ${LOCATION} \
189 -metadataRepository file:${LOCATION} \
190 -artifactRepository file:${LOCATION} \
191 -metadataRepositoryName "${NAME} Updates" \
192 -artifactRepositoryName "${NAME} Artifacts" \
193 -reusePack200Files -publishArtifacts
194ls -ltr *\.*
195
196
197echo "====Step 5: patch content for feature inclusion version range===="
198mv content.xml content.xml-orig
199xsltproc -o content.xml --stringparam version ${JDTVERSION} \
200 --stringparam versionnext ${JDTVERSIONNEXT} \
201 ${BUILD}/patch-content-xml.xsl content.xml-orig
202ls -ltr *\.*
203
204echo "====Step 6: archive raw meta data===="
Stephan Herrmann434a0842016-11-01 18:02:29 +0100205mkdir -p ${METADATA}/$OTDTVERSION
Stephan Herrmannff801a62016-11-01 15:01:00 +0100206cp *.xml ${METADATA}/$OTDTVERSION
207ls -ltr ${METADATA}/$OTDTVERSION/*.xml
208
209echo "====Step 7: generate category===="
210CATEGORYARGS="-categoryDefinition file:${BASE}/testrun/build-root/src/features/org.eclipse.objectteams.otdt/category.xml"
211echo "CATEGORYARGS = ${CATEGORYARGS}"
212java -jar ${LAUNCHER_PATH} -consoleLog -application ${CATPUB} \
213 -source ${LOCATION} \
214 -metadataRepository file:${LOCATION} \
215 ${CATEGORYARGS}
216ls -ltr *\.*
217
218
219echo "====Step 8: add download stats capability===="
220XSLT_FILE=${BASE}/releng/build-scripts/bin/addDownloadStats.xsl
221
222if [ $# == 3 ]; then
223 mv artifacts.xml artifacts.xml.original
224 if grep p2.statsURI artifacts.xml.original ; then echo "p2.statsURI already defined: exiting"; exit 1; fi
225 xsltproc -o artifacts.xml --stringparam repo "http://download.eclipse.org/stats/objectteams/${2}" --stringparam version $3 $XSLT_FILE artifacts.xml.original
226fi
227
228echo "====Step 9: jar-up metadata===="
229jar cf content.jar content.xml
230jar cf artifacts.jar artifacts.xml
Stephan Herrmanncd701a02018-01-25 21:36:27 +0100231#/bin/rm *.xml*
Stephan Herrmannff801a62016-11-01 15:01:00 +0100232ls -ltr *\.*
233
234echo "====Step 10: cleanup: remove symbolic links===="
235find . -type l -exec /bin/rm {} \;
236
Stephan Herrmann0eeafef2017-03-21 23:35:39 +0100237if [ "${PROMOTE}" != "false" ]
Stephan Herrmann30789152016-11-01 15:44:32 +0100238then
Stephan Herrmann806942c2016-11-01 16:13:05 +0100239 BUILDID=`echo $OTDTVERSION | cut -d '.' -f 4`
Stephan Herrmann0eeafef2017-03-21 23:35:39 +0100240 if [ "${PROMOTE}" == "staging" ]
241 then
242 DEST=${UPDATES_BASE}/${2}/staging
243 /bin/rm -rf ${DEST}
244 else
245 DEST=${UPDATES_BASE}/${2}/${BUILDID}
246 fi
Stephan Herrmann806942c2016-11-01 16:13:05 +0100247 echo "====Step 11: promote to ${DEST}===="
Stephan Herrmann30789152016-11-01 15:44:32 +0100248 if [ -d ${UPDATES_BASE}/${2} ]
249 then
Stephan Herrmanne44829a2016-11-01 17:30:01 +0100250 mkdir ${DEST} && \
251 cp -pr ${UPDATES_BASE}/${1}/* ${DEST}/ && \
252 cp -pr * ${DEST}/ && \
Stephan Herrmann9853f0c2016-11-02 23:47:03 +0100253 chmod -R g+w ${DEST} && \
254 find ${DEST} -type d -exec /bin/ls -ld {} \;
255 ls -latr ${UPDATES_BASE}/${2}
Stephan Herrmann806942c2016-11-01 16:13:05 +0100256 else
Stephan Herrmann9853f0c2016-11-02 23:47:03 +0100257 echo "${UPDATES_BASE}/${2} not found or not a directory"
Stephan Herrmann30789152016-11-01 15:44:32 +0100258 fi
259fi
Stephan Herrmannff801a62016-11-01 15:01:00 +0100260echo "====DONE===="