blob: b40cd7352e37117eb8d412b4254ae68c153a3ff1 [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 Herrmann040b4e02021-03-05 00:25:26 +010010TARGET_HOST=genie.objectteams@projects-storage.eclipse.org
11TARGET_BASEDIR=/home/data/httpd/download.eclipse.org/objectteams/updates
12TARGET_HTTPS="https://download.eclipse.org/objectteams/updates"
13export UPDATES_BASE=${TARGET_HOST}:${TARGET_BASEDIR}
Stephan Herrmann21972f62021-03-04 19:29:10 +010014export JAVA8=/opt/tools/java/oracle/jdk-8/latest/bin/java
15export JAVA11=/opt/tools/java/openjdk/jdk-11/latest/bin/java
Stephan Herrmann434a0842016-11-01 18:02:29 +010016
17# RELATIVE PATHS:
Stephan Herrmannff801a62016-11-01 15:01:00 +010018BUILD=${BASE}/releng/build-scripts/build
19METADATA=${BASE}/metadata
Stephan Herrmann434a0842016-11-01 18:02:29 +010020
Stephan Herrmannff801a62016-11-01 15:01:00 +010021# Find the master repository to build upon:
22if [ "$1" == "none" ]
23then
24 MASTER="none"
25 echo "Generating fresh new repository"
26else
Stephan Herrmann040b4e02021-03-05 00:25:26 +010027 echo "Using a previous repo is broken in this script"
28 exit 1
Stephan Herrmannff801a62016-11-01 15:01:00 +010029 MASTER=${UPDATES_BASE}/$1
30 if [ -r ${MASTER}/features ]
31 then
32 echo "Generating Repository based on ${MASTER}"
33 else
34 MASTER=${HOME}/shared/baseRepos/$1
35 if [ -r ${MASTER}/features ]
36 then
37 echo "Generating Repository based on ${MASTER}"
38 else
39 echo "No such repository ${MASTER}"
Stephan Herrmann040b4e02021-03-05 00:25:26 +010040 echo "Usage: $0 updateMasterRelativePath [ statsRepoId statsVersionId ]"
Stephan Herrmannff801a62016-11-01 15:01:00 +010041 exit 1
42 fi
43 fi
44fi
45
46# Analyze the version number of the JDT feature as needed for patching content.xml later:
47JDTFEATURE=`ls -d ${BASE}/testrun/build-root/eclipse/features/org.eclipse.jdt_*`
48if echo $JDTFEATURE | grep "\.r"
49then
50 JDTVERSION="`echo ${JDTFEATURE} | cut -d '_' -f 2`_`echo ${JDTFEATURE} | cut -d '_' -f 3`"
51else
52 JDTVERSION=`echo ${JDTFEATURE} | cut -d '_' -f 2`
53fi
54JDTVERSIONA=`echo ${JDTVERSION} | cut -d '-' -f 1`
55JDTVERSIONB=`echo ${JDTVERSION} | cut -d '-' -f 2`
56echo "after first split: ${JDTVERSIONA} and ${JDTVERSIONB}"
57case ${JDTVERSIONB} in
58 ????)
59 #A=v20110813 B=0800
60 JDTVERSIONB2=`expr $JDTVERSIONB + 1`
61 JDTVERSIONB2=`printf "%04d" ${JDTVERSIONB2}`
62 JDTVERSION=${JDTVERSIONA}-${JDTVERSIONB}
63 JDTVERSIONNEXT=${JDTVERSIONA}-${JDTVERSIONB2}
64 ;;
65 *)
66 #A=3.8.0.v20110813 B=someunspeakablelonghashid
67 JDTVERSIONC1=`echo ${JDTVERSIONA} | cut -d 'v' -f 1`
68 JDTVERSIONC2=`echo ${JDTVERSIONA} | cut -d 'v' -f 2`
69 JDTVERSIONC3=`expr $JDTVERSIONC2 + 1`
Stephan Herrmann040b4e02021-03-05 00:25:26 +010070 JDTVERSIONC3=`printf "%04d" ${JDTVERSIONC3}`
Stephan Herrmannff801a62016-11-01 15:01:00 +010071 JDTVERSION=${JDTVERSIONC1}v${JDTVERSIONC2}
72 JDTVERSIONNEXT=${JDTVERSIONC1}v${JDTVERSIONC3}
73 ;;
74esac
75# hardcode when unable to compute
Stephan Herrmann21972f62021-03-04 19:29:10 +010076#JDTVERSION=3.18.700.v20210224-1800
77#JDTVERSIONNEXT=3.18.700.v20210224-1801
Stephan Herrmannff801a62016-11-01 15:01:00 +010078echo "JDT feature is ${JDTVERSION}"
79echo "Next ${JDTVERSIONNEXT}"
80if [ ! -r ${BASE}/testrun/build-root/eclipse/features/org.eclipse.jdt_${JDTVERSION} ]
81then
82 echo "JDT feature not correctly found in ${BASE}/testrun/build-root/eclipse/features"
83 exit 2
84fi
85OTDTVERSION=`cat ${BASE}/testrun/build-root/src/finalFeaturesVersions.properties|grep "objectteams.otdt="|cut -d '=' -f 2`
Stephan Herrmann491e4dd2016-11-01 17:01:44 +010086if [ "${OTDTVERSION}" == "" ]
87then
88 echo "finalFeaturesVersions.properties not found, maybe build hasn't run successfully?"
89 exit 3
90fi
Stephan Herrmannff801a62016-11-01 15:01:00 +010091echo "OTDTVERSION is $OTDTVERSION"
92
93# Configure for calling various p2 applications:
94LAUNCHER=`grep equinox.launcher_jar= ${BUILD}/run.properties | cut -d '=' -f 2`
95LAUNCHER_PATH=${BASE}/testrun/build-root/eclipse/plugins/${LAUNCHER}
96FABPUB=org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher
97CATPUB=org.eclipse.equinox.p2.publisher.CategoryPublisher
98JARPROCESSOR=`ls ${BASE}/testrun/build-root/eclipse/plugins/org.eclipse.equinox.p2.jarprocessor_*.jar`
99NAME="Object Teams"
100
101echo "LAUNCHER_PATH = ${LAUNCHER_PATH}"
102echo "NAME = ${NAME}"
103
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200104echo "====Step 0: condition jars ===="
Stephan Herrmann6f337832018-05-15 23:58:44 +0200105CONDITIONED=${BASE}/testrun/updateSiteRepack
106if [ ! -d ${CONDITIONED} ]
107then
108 mkdir ${CONDITIONED}
109else
110 /bin/rm -r ${CONDITIONED}/*
111fi
112
Stephan Herrmann38e35fb2022-05-24 15:37:48 +0200113ls /opt/tools/java/openjdk/jdk-11
Stephan Herrmann107540a2022-05-24 15:20:37 +0200114${JAVA11} --version
Stephan Herrmann38e35fb2022-05-24 15:37:48 +0200115ls -l ${JARPROCESSOR}
Stephan Herrmann69185852022-05-24 15:06:38 +0200116
Stephan Herrmann6f337832018-05-15 23:58:44 +0200117for dir in features plugins
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200118do
Stephan Herrmann040b4e02021-03-05 00:25:26 +0100119 # add "-verbose" to the second line if needed:
Stephan Herrmann69185852022-05-24 15:06:38 +0200120 find ${BASE}/testrun/updateSite/${dir} -type f -name \*.jar -print -exec \
121 ${JAVA11} -jar ${JARPROCESSOR} -processAll -repack -verbose -outputDir ${CONDITIONED}/${dir} {} \;
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200122done
Stephan Herrmann69185852022-05-24 15:06:38 +0200123
124ls -R ${CONDITIONED}
125
Stephan Herrmann0dc84312018-05-16 00:12:42 +0200126# not conditioned, but must not be skipped!
127cp ${BASE}/testrun/updateSite/plugins/org.eclipse.jdt.core_* ${CONDITIONED}/plugins/
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200128
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200129echo "====Step 1: request signing and zip===="
Stephan Herrmann6f337832018-05-15 23:58:44 +0200130cd ${CONDITIONED}
Stephan Herrmann023b4422018-05-16 00:01:44 +0200131JARS=`find . -type f -name \*.jar`
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200132OTDTJAR=${BASE}/testrun/otdt.jar
Stephan Herrmann30789152016-11-01 15:44:32 +0100133if [ "${SIGN}" == "nosign" ]
Stephan Herrmannff801a62016-11-01 15:01:00 +0100134then
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100135 /bin/rm ${OTDTJAR}
136 zip ${OTDTJAR} ${JARS}
Stephan Herrmannfd97f0e2016-11-01 16:01:11 +0100137 echo "SKIPPING SIGNING"
Stephan Herrmannff801a62016-11-01 15:01:00 +0100138else
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200139 SIGNED=${BASE}/testrun/updateSiteSigned
140 if [ ! -d ${SIGNED} ]
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100141 then
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200142 mkdir ${SIGNED}
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100143 else
Stephan Herrmann6f337832018-05-15 23:58:44 +0200144 /bin/rm -r ${SIGNED}/*
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100145 fi
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200146 for JAR in ${JARS}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200147 do
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200148 DIR=`dirname $JAR`
149 if [ ! -d ${SIGNED}/${DIR} ]
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200150 then
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200151 mkdir -p ${SIGNED}/${DIR}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200152 fi
Stephan Herrmann0f6d49e2021-09-18 14:52:25 +0200153 curl -o ${SIGNED}/${JAR} -F file=@${JAR} https://cbi.eclipse.org/jarsigner/sign
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200154 done
155 if [ -f ${OTDTJAR} ]
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100156 then
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100157 /bin/rm ${OTDTJAR}
158 fi
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200159 cd ${SIGNED}
160 zip ${OTDTJAR} ${JARS}
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100161 echo "Signing completed"
Stephan Herrmannff801a62016-11-01 15:01:00 +0100162fi
Stephan Herrmannff801a62016-11-01 15:01:00 +0100163
164
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200165echo "====Step 2: fill new repository===="
Stephan Herrmannff801a62016-11-01 15:01:00 +0100166if [ -r ${BASE}/stagingRepo ]
167then
168 /bin/rm -rf ${BASE}/stagingRepo
169fi
170mkdir ${BASE}/stagingRepo
171cd ${BASE}/stagingRepo
172if [ "$MASTER" != "none" ]
173then
174 mkdir features
175 (cd features; ln -s ${MASTER}/features/* .)
176 mkdir plugins
177 (cd plugins; ln -s ${MASTER}/plugins/* .)
178else
179 mkdir plugins
180 cp ${BASE}/testrun/updateSite/plugins/org.apache.bcel* plugins/
181fi
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100182unzip -n ${OTDTJAR}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200183#/bin/rm ${OTDTJAR}
Stephan Herrmannff801a62016-11-01 15:01:00 +0100184
185LOCATION=${BASE}/stagingRepo
186echo "LOCATION = ${LOCATION}"
187cd ${LOCATION}
188
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200189echo "====Step 3: pack jars (again) ===="
Stephan Herrmann70aac8e2018-05-16 00:12:42 +0200190for dir in ${LOCATION}/features ${LOCATION}/plugins
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200191do
Stephan Herrmann040b4e02021-03-05 00:25:26 +0100192 # add "-verbose" to the second line if needed:
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200193 find ${dir} -type f -name \*.jar -exec \
Stephan Herrmann38da53d2021-05-06 21:49:27 +0200194 ${JAVA11} -jar ${JARPROCESSOR} -pack -outputDir ${dir} {} \;
Stephan Herrmann48f5a9c2018-05-15 23:46:30 +0200195done
196
Stephan Herrmannff801a62016-11-01 15:01:00 +0100197
198echo "====Step 4: generate metadata===="
Stephan Herrmann5a728462020-12-06 11:49:56 +0100199${JAVA11} -jar ${LAUNCHER_PATH} -consoleLog -application ${FABPUB} \
Stephan Herrmannff801a62016-11-01 15:01:00 +0100200 -source ${LOCATION} \
201 -metadataRepository file:${LOCATION} \
202 -artifactRepository file:${LOCATION} \
203 -metadataRepositoryName "${NAME} Updates" \
204 -artifactRepositoryName "${NAME} Artifacts" \
205 -reusePack200Files -publishArtifacts
206ls -ltr *\.*
207
208
209echo "====Step 5: patch content for feature inclusion version range===="
210mv content.xml content.xml-orig
211xsltproc -o content.xml --stringparam version ${JDTVERSION} \
212 --stringparam versionnext ${JDTVERSIONNEXT} \
213 ${BUILD}/patch-content-xml.xsl content.xml-orig
214ls -ltr *\.*
215
216echo "====Step 6: archive raw meta data===="
Stephan Herrmann434a0842016-11-01 18:02:29 +0100217mkdir -p ${METADATA}/$OTDTVERSION
Stephan Herrmannff801a62016-11-01 15:01:00 +0100218cp *.xml ${METADATA}/$OTDTVERSION
219ls -ltr ${METADATA}/$OTDTVERSION/*.xml
220
221echo "====Step 7: generate category===="
222CATEGORYARGS="-categoryDefinition file:${BASE}/testrun/build-root/src/features/org.eclipse.objectteams.otdt/category.xml"
223echo "CATEGORYARGS = ${CATEGORYARGS}"
Stephan Herrmann5a728462020-12-06 11:49:56 +0100224${JAVA11} -jar ${LAUNCHER_PATH} -consoleLog -application ${CATPUB} \
Stephan Herrmannff801a62016-11-01 15:01:00 +0100225 -source ${LOCATION} \
226 -metadataRepository file:${LOCATION} \
227 ${CATEGORYARGS}
228ls -ltr *\.*
229
230
231echo "====Step 8: add download stats capability===="
232XSLT_FILE=${BASE}/releng/build-scripts/bin/addDownloadStats.xsl
233
234if [ $# == 3 ]; then
235 mv artifacts.xml artifacts.xml.original
236 if grep p2.statsURI artifacts.xml.original ; then echo "p2.statsURI already defined: exiting"; exit 1; fi
237 xsltproc -o artifacts.xml --stringparam repo "http://download.eclipse.org/stats/objectteams/${2}" --stringparam version $3 $XSLT_FILE artifacts.xml.original
238fi
239
240echo "====Step 9: jar-up metadata===="
241jar cf content.jar content.xml
242jar cf artifacts.jar artifacts.xml
Stephan Herrmanncd701a02018-01-25 21:36:27 +0100243#/bin/rm *.xml*
Stephan Herrmannff801a62016-11-01 15:01:00 +0100244ls -ltr *\.*
245
246echo "====Step 10: cleanup: remove symbolic links===="
247find . -type l -exec /bin/rm {} \;
248
Stephan Herrmann0eeafef2017-03-21 23:35:39 +0100249if [ "${PROMOTE}" != "false" ]
Stephan Herrmann30789152016-11-01 15:44:32 +0100250then
Stephan Herrmannae580b92018-06-08 22:31:20 +0200251 if [ "${PROMOTE}" != "" ]
Stephan Herrmann0eeafef2017-03-21 23:35:39 +0100252 then
Stephan Herrmann040b4e02021-03-05 00:25:26 +0100253 DEST_REL=${2}/${PROMOTE}
Stephan Herrmannae580b92018-06-08 22:31:20 +0200254 else
Stephan Herrmann040b4e02021-03-05 00:25:26 +0100255 BUILDID=`echo $OTDTVERSION | cut -d '.' -f 4`
256 if [ "${BUILDID}" != "" ]
257 then
258 DEST_REL=${2}/${BUILDID}
259 else
260 echo "Unrecognized OT version: $OTDTVERSION"
261 exit 1
262 fi
Stephan Herrmannae580b92018-06-08 22:31:20 +0200263 fi
Stephan Herrmann0f6d49e2021-09-18 14:52:25 +0200264 echo "====Step 11: promote to ${TARGET_HOST}:${TARGET_BASEDIR}/${DEST_REL}===="
Stephan Herrmann040b4e02021-03-05 00:25:26 +0100265 # FIXME mkdir ${DEST}
266 # if [ "${MASTER}" != "none" ]
267 # then
268 # FIXME
269 # cp -pr ${MASTER}/* ${DEST}/
270 # fi
271 ssh ${TARGET_HOST} "/bin/rm -r ${TARGET_BASEDIR}/${DEST_REL} || true"
Stephan Herrmann5456aff2021-08-20 00:21:35 +0200272 scp -r `pwd` ${TARGET_HOST}:${TARGET_BASEDIR}/${DEST_REL}
Stephan Herrmann040b4e02021-03-05 00:25:26 +0100273 echo "Installed to ${TARGET_HTTPS}/${DEST_REL}"
Stephan Herrmann30789152016-11-01 15:44:32 +0100274fi
Stephan Herrmannff801a62016-11-01 15:01:00 +0100275echo "====DONE===="