blob: d1c30a2e7cdc8fd2788f3803b3b1afa89ebb3327 [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)
Stephan Herrmannae580b92018-06-08 22:31:20 +02005# PROMOTE (unset or false or target directory)
Stephan Herrmann434a0842016-11-01 18:02:29 +01006
Stephan Herrmannff801a62016-11-01 15:01:00 +01007BASE=`pwd`
Stephan Herrmann434a0842016-11-01 18:02:29 +01008
9# ABSOLUTE PATHS:
Stephan Herrmann434a0842016-11-01 18:02:29 +010010export UPDATES_BASE=/home/data/httpd/download.eclipse.org/objectteams/updates
Stephan Herrmann2e927b02018-01-28 11:48:32 +010011export JAVA8=/shared/common/jdk1.8.0_x64-latest
Stephan Herrmann434a0842016-11-01 18:02:29 +010012
13# RELATIVE PATHS:
Stephan Herrmannff801a62016-11-01 15:01:00 +010014BUILD=${BASE}/releng/build-scripts/build
15METADATA=${BASE}/metadata
Stephan Herrmann434a0842016-11-01 18:02:29 +010016
Stephan Herrmannff801a62016-11-01 15:01:00 +010017# Find the master repository to build upon:
18if [ "$1" == "none" ]
19then
20 MASTER="none"
21 echo "Generating fresh new repository"
22else
23 MASTER=${UPDATES_BASE}/$1
24 if [ -r ${MASTER}/features ]
25 then
26 echo "Generating Repository based on ${MASTER}"
27 else
28 MASTER=${HOME}/shared/baseRepos/$1
29 if [ -r ${MASTER}/features ]
30 then
31 echo "Generating Repository based on ${MASTER}"
32 else
33 echo "No such repository ${MASTER}"
34 echo "Usage: $0 updateMasterRelativePath [ -nosign ] [ statsRepoId statsVersionId ]"
35 exit 1
36 fi
37 fi
38fi
39
40# Analyze the version number of the JDT feature as needed for patching content.xml later:
41JDTFEATURE=`ls -d ${BASE}/testrun/build-root/eclipse/features/org.eclipse.jdt_*`
42if echo $JDTFEATURE | grep "\.r"
43then
44 JDTVERSION="`echo ${JDTFEATURE} | cut -d '_' -f 2`_`echo ${JDTFEATURE} | cut -d '_' -f 3`"
45else
46 JDTVERSION=`echo ${JDTFEATURE} | cut -d '_' -f 2`
47fi
48JDTVERSIONA=`echo ${JDTVERSION} | cut -d '-' -f 1`
49JDTVERSIONB=`echo ${JDTVERSION} | cut -d '-' -f 2`
50echo "after first split: ${JDTVERSIONA} and ${JDTVERSIONB}"
51case ${JDTVERSIONB} in
52 ????)
53 #A=v20110813 B=0800
54 JDTVERSIONB2=`expr $JDTVERSIONB + 1`
55 JDTVERSIONB2=`printf "%04d" ${JDTVERSIONB2}`
56 JDTVERSION=${JDTVERSIONA}-${JDTVERSIONB}
57 JDTVERSIONNEXT=${JDTVERSIONA}-${JDTVERSIONB2}
58 ;;
59 *)
60 #A=3.8.0.v20110813 B=someunspeakablelonghashid
61 JDTVERSIONC1=`echo ${JDTVERSIONA} | cut -d 'v' -f 1`
62 JDTVERSIONC2=`echo ${JDTVERSIONA} | cut -d 'v' -f 2`
63 JDTVERSIONC3=`expr $JDTVERSIONC2 + 1`
64 JDTVERSION=${JDTVERSIONC1}v${JDTVERSIONC2}
65 JDTVERSIONNEXT=${JDTVERSIONC1}v${JDTVERSIONC3}
66 ;;
67esac
68# hardcode when unable to compute
69#JDTVERSION=${JDTVERSIONA}
70#JDTVERSIONNEXT=3.8.0.v20110728
71echo "JDT feature is ${JDTVERSION}"
72echo "Next ${JDTVERSIONNEXT}"
73if [ ! -r ${BASE}/testrun/build-root/eclipse/features/org.eclipse.jdt_${JDTVERSION} ]
74then
75 echo "JDT feature not correctly found in ${BASE}/testrun/build-root/eclipse/features"
76 exit 2
77fi
78OTDTVERSION=`cat ${BASE}/testrun/build-root/src/finalFeaturesVersions.properties|grep "objectteams.otdt="|cut -d '=' -f 2`
Stephan Herrmann491e4dd2016-11-01 17:01:44 +010079if [ "${OTDTVERSION}" == "" ]
80then
81 echo "finalFeaturesVersions.properties not found, maybe build hasn't run successfully?"
82 exit 3
83fi
Stephan Herrmannff801a62016-11-01 15:01:00 +010084echo "OTDTVERSION is $OTDTVERSION"
85
86# Configure for calling various p2 applications:
87LAUNCHER=`grep equinox.launcher_jar= ${BUILD}/run.properties | cut -d '=' -f 2`
88LAUNCHER_PATH=${BASE}/testrun/build-root/eclipse/plugins/${LAUNCHER}
89FABPUB=org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher
90CATPUB=org.eclipse.equinox.p2.publisher.CategoryPublisher
91JARPROCESSOR=`ls ${BASE}/testrun/build-root/eclipse/plugins/org.eclipse.equinox.p2.jarprocessor_*.jar`
92NAME="Object Teams"
93
94echo "LAUNCHER_PATH = ${LAUNCHER_PATH}"
95echo "NAME = ${NAME}"
96
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +020097echo "====Step 0: condition jars ===="
Stephan Herrmann6f337832018-05-15 23:58:44 +020098CONDITIONED=${BASE}/testrun/updateSiteRepack
99if [ ! -d ${CONDITIONED} ]
100then
101 mkdir ${CONDITIONED}
102else
103 /bin/rm -r ${CONDITIONED}/*
104fi
105
106for dir in features plugins
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200107do
Stephan Herrmann6f337832018-05-15 23:58:44 +0200108 find ${BASE}/testrun/updateSite/${dir} -type f -name \*.jar -exec \
109 ${JAVA8}/bin/java -jar ${JARPROCESSOR} -verbose -processAll -repack -outputDir ${CONDITIONED}/${dir} {} \;
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200110done
Stephan Herrmann0dc84312018-05-16 00:12:42 +0200111# not conditioned, but must not be skipped!
112cp ${BASE}/testrun/updateSite/plugins/org.eclipse.jdt.core_* ${CONDITIONED}/plugins/
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200113
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200114echo "====Step 1: request signing and zip===="
Stephan Herrmann6f337832018-05-15 23:58:44 +0200115cd ${CONDITIONED}
Stephan Herrmann023b4422018-05-16 00:01:44 +0200116JARS=`find . -type f -name \*.jar`
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200117OTDTJAR=${BASE}/testrun/otdt.jar
Stephan Herrmann30789152016-11-01 15:44:32 +0100118if [ "${SIGN}" == "nosign" ]
Stephan Herrmannff801a62016-11-01 15:01:00 +0100119then
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100120 /bin/rm ${OTDTJAR}
121 zip ${OTDTJAR} ${JARS}
Stephan Herrmannfd97f0e2016-11-01 16:01:11 +0100122 echo "SKIPPING SIGNING"
Stephan Herrmannff801a62016-11-01 15:01:00 +0100123else
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200124 SIGNED=${BASE}/testrun/updateSiteSigned
125 if [ ! -d ${SIGNED} ]
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100126 then
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200127 mkdir ${SIGNED}
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100128 else
Stephan Herrmann6f337832018-05-15 23:58:44 +0200129 /bin/rm -r ${SIGNED}/*
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100130 fi
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200131 for JAR in ${JARS}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200132 do
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200133 DIR=`dirname $JAR`
134 if [ ! -d ${SIGNED}/${DIR} ]
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200135 then
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200136 mkdir -p ${SIGNED}/${DIR}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200137 fi
138 curl -o ${SIGNED}/${JAR} -F file=@${JAR} http://build.eclipse.org:31338/sign
139 done
140 if [ -f ${OTDTJAR} ]
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100141 then
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100142 /bin/rm ${OTDTJAR}
143 fi
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200144 cd ${SIGNED}
145 zip ${OTDTJAR} ${JARS}
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100146 echo "Signing completed"
Stephan Herrmannff801a62016-11-01 15:01:00 +0100147fi
Stephan Herrmannff801a62016-11-01 15:01:00 +0100148
149
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200150echo "====Step 2: fill new repository===="
Stephan Herrmannff801a62016-11-01 15:01:00 +0100151if [ -r ${BASE}/stagingRepo ]
152then
153 /bin/rm -rf ${BASE}/stagingRepo
154fi
155mkdir ${BASE}/stagingRepo
156cd ${BASE}/stagingRepo
157if [ "$MASTER" != "none" ]
158then
159 mkdir features
160 (cd features; ln -s ${MASTER}/features/* .)
161 mkdir plugins
162 (cd plugins; ln -s ${MASTER}/plugins/* .)
163else
164 mkdir plugins
165 cp ${BASE}/testrun/updateSite/plugins/org.apache.bcel* plugins/
166fi
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100167unzip -n ${OTDTJAR}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200168#/bin/rm ${OTDTJAR}
Stephan Herrmannff801a62016-11-01 15:01:00 +0100169
170LOCATION=${BASE}/stagingRepo
171echo "LOCATION = ${LOCATION}"
172cd ${LOCATION}
173
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200174echo "====Step 3: pack jars (again) ===="
Stephan Herrmann70aac8e2018-05-16 00:12:42 +0200175for dir in ${LOCATION}/features ${LOCATION}/plugins
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200176do
177 find ${dir} -type f -name \*.jar -exec \
178 ${JAVA8}/bin/java -jar ${JARPROCESSOR} -verbose -pack -outputDir ${dir} {} \;
179done
180
Stephan Herrmannff801a62016-11-01 15:01:00 +0100181
182echo "====Step 4: generate metadata===="
183java -jar ${LAUNCHER_PATH} -consoleLog -application ${FABPUB} \
184 -source ${LOCATION} \
185 -metadataRepository file:${LOCATION} \
186 -artifactRepository file:${LOCATION} \
187 -metadataRepositoryName "${NAME} Updates" \
188 -artifactRepositoryName "${NAME} Artifacts" \
189 -reusePack200Files -publishArtifacts
190ls -ltr *\.*
191
192
193echo "====Step 5: patch content for feature inclusion version range===="
194mv content.xml content.xml-orig
195xsltproc -o content.xml --stringparam version ${JDTVERSION} \
196 --stringparam versionnext ${JDTVERSIONNEXT} \
197 ${BUILD}/patch-content-xml.xsl content.xml-orig
198ls -ltr *\.*
199
200echo "====Step 6: archive raw meta data===="
Stephan Herrmann434a0842016-11-01 18:02:29 +0100201mkdir -p ${METADATA}/$OTDTVERSION
Stephan Herrmannff801a62016-11-01 15:01:00 +0100202cp *.xml ${METADATA}/$OTDTVERSION
203ls -ltr ${METADATA}/$OTDTVERSION/*.xml
204
205echo "====Step 7: generate category===="
206CATEGORYARGS="-categoryDefinition file:${BASE}/testrun/build-root/src/features/org.eclipse.objectteams.otdt/category.xml"
207echo "CATEGORYARGS = ${CATEGORYARGS}"
208java -jar ${LAUNCHER_PATH} -consoleLog -application ${CATPUB} \
209 -source ${LOCATION} \
210 -metadataRepository file:${LOCATION} \
211 ${CATEGORYARGS}
212ls -ltr *\.*
213
214
215echo "====Step 8: add download stats capability===="
216XSLT_FILE=${BASE}/releng/build-scripts/bin/addDownloadStats.xsl
217
218if [ $# == 3 ]; then
219 mv artifacts.xml artifacts.xml.original
220 if grep p2.statsURI artifacts.xml.original ; then echo "p2.statsURI already defined: exiting"; exit 1; fi
221 xsltproc -o artifacts.xml --stringparam repo "http://download.eclipse.org/stats/objectteams/${2}" --stringparam version $3 $XSLT_FILE artifacts.xml.original
222fi
223
224echo "====Step 9: jar-up metadata===="
225jar cf content.jar content.xml
226jar cf artifacts.jar artifacts.xml
Stephan Herrmanncd701a02018-01-25 21:36:27 +0100227#/bin/rm *.xml*
Stephan Herrmannff801a62016-11-01 15:01:00 +0100228ls -ltr *\.*
229
230echo "====Step 10: cleanup: remove symbolic links===="
231find . -type l -exec /bin/rm {} \;
232
Stephan Herrmann0eeafef2017-03-21 23:35:39 +0100233if [ "${PROMOTE}" != "false" ]
Stephan Herrmann30789152016-11-01 15:44:32 +0100234then
Stephan Herrmann806942c2016-11-01 16:13:05 +0100235 BUILDID=`echo $OTDTVERSION | cut -d '.' -f 4`
Stephan Herrmannae580b92018-06-08 22:31:20 +0200236 if [ "${PROMOTE}" != "" ]
Stephan Herrmann0eeafef2017-03-21 23:35:39 +0100237 then
Stephan Herrmannae580b92018-06-08 22:31:20 +0200238 DEST=${UPDATES_BASE}/${2}/${PROMOTE}
239 /bin/rm -rf ${DEST}
240 else
241 DEST=${UPDATES_BASE}/${2}/${BUILDID}
242 fi
Stephan Herrmann806942c2016-11-01 16:13:05 +0100243 echo "====Step 11: promote to ${DEST}===="
Stephan Herrmann30789152016-11-01 15:44:32 +0100244 if [ -d ${UPDATES_BASE}/${2} ]
245 then
Stephan Herrmanne44829a2016-11-01 17:30:01 +0100246 mkdir ${DEST} && \
247 cp -pr ${UPDATES_BASE}/${1}/* ${DEST}/ && \
248 cp -pr * ${DEST}/ && \
Stephan Herrmann9853f0c2016-11-02 23:47:03 +0100249 chmod -R g+w ${DEST} && \
250 find ${DEST} -type d -exec /bin/ls -ld {} \;
251 ls -latr ${UPDATES_BASE}/${2}
Stephan Herrmann806942c2016-11-01 16:13:05 +0100252 else
Stephan Herrmann9853f0c2016-11-02 23:47:03 +0100253 echo "${UPDATES_BASE}/${2} not found or not a directory"
Stephan Herrmann30789152016-11-01 15:44:32 +0100254 fi
255fi
Stephan Herrmannff801a62016-11-01 15:01:00 +0100256echo "====DONE===="