blob: b11d1b4753e136abf92285791404180a727716f4 [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 Herrmannc80b4172018-05-10 15:30:26 +0200101echo "====Step 1: pack jars ===="
102for dir in ${BASE}/testrun/updateSite/features ${BASE}/testrun/updateSite/plugins
103do
104 find ${dir} -type f -name \*.jar -exec \
105 ${JAVA8}/bin/java -jar ${JARPROCESSOR} -verbose -pack -outputDir ${dir} {} \;
106done
107
108echo "====Step 2: request signing and zip===="
Stephan Herrmannff801a62016-11-01 15:01:00 +0100109cd ${BASE}/testrun/updateSite
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200110JARS=`find . -type f -name \*.jar -o -name \*.jar.pack.gz`
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200111OTDTJAR=${BASE}/testrun/otdt.jar
Stephan Herrmann30789152016-11-01 15:44:32 +0100112if [ "${SIGN}" == "nosign" ]
Stephan Herrmannff801a62016-11-01 15:01:00 +0100113then
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100114 /bin/rm ${OTDTJAR}
115 zip ${OTDTJAR} ${JARS}
Stephan Herrmannfd97f0e2016-11-01 16:01:11 +0100116 echo "SKIPPING SIGNING"
Stephan Herrmannff801a62016-11-01 15:01:00 +0100117else
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200118 SIGNED=${BASE}/testrun/updateSiteSigned
119 if [ ! -d ${SIGNED} ]
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100120 then
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200121 mkdir ${SIGNED}
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100122 else
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200123 /bin/rm -rf ${SIGNED}/*
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100124 fi
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200125 for JAR in ${JARS}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200126 do
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200127 DIR=`dirname $JAR`
128 if [ ! -d ${SIGNED}/${DIR} ]
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200129 then
Stephan Herrmannb3a79fe2018-05-10 15:15:30 +0200130 mkdir -p ${SIGNED}/${DIR}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200131 fi
132 curl -o ${SIGNED}/${JAR} -F file=@${JAR} http://build.eclipse.org:31338/sign
133 done
134 if [ -f ${OTDTJAR} ]
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100135 then
Stephan Herrmann568b61a2017-11-15 00:00:57 +0100136 /bin/rm ${OTDTJAR}
137 fi
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200138 cd ${SIGNED}
139 zip ${OTDTJAR} ${JARS}
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100140 echo "Signing completed"
Stephan Herrmannff801a62016-11-01 15:01:00 +0100141fi
Stephan Herrmannff801a62016-11-01 15:01:00 +0100142
143
Stephan Herrmannc80b4172018-05-10 15:30:26 +0200144echo "====Step 3: fill new repository===="
Stephan Herrmannff801a62016-11-01 15:01:00 +0100145if [ -r ${BASE}/stagingRepo ]
146then
147 /bin/rm -rf ${BASE}/stagingRepo
148fi
149mkdir ${BASE}/stagingRepo
150cd ${BASE}/stagingRepo
151if [ "$MASTER" != "none" ]
152then
153 mkdir features
154 (cd features; ln -s ${MASTER}/features/* .)
155 mkdir plugins
156 (cd plugins; ln -s ${MASTER}/plugins/* .)
157else
158 mkdir plugins
159 cp ${BASE}/testrun/updateSite/plugins/org.apache.bcel* plugins/
160fi
Stephan Herrmannb5d54e72016-11-01 15:59:09 +0100161unzip -n ${OTDTJAR}
Stephan Herrmann49d7a782018-05-10 15:09:51 +0200162#/bin/rm ${OTDTJAR}
Stephan Herrmannff801a62016-11-01 15:01:00 +0100163
164LOCATION=${BASE}/stagingRepo
165echo "LOCATION = ${LOCATION}"
166cd ${LOCATION}
167
Stephan Herrmannff801a62016-11-01 15:01:00 +0100168
169echo "====Step 4: generate metadata===="
170java -jar ${LAUNCHER_PATH} -consoleLog -application ${FABPUB} \
171 -source ${LOCATION} \
172 -metadataRepository file:${LOCATION} \
173 -artifactRepository file:${LOCATION} \
174 -metadataRepositoryName "${NAME} Updates" \
175 -artifactRepositoryName "${NAME} Artifacts" \
176 -reusePack200Files -publishArtifacts
177ls -ltr *\.*
178
179
180echo "====Step 5: patch content for feature inclusion version range===="
181mv content.xml content.xml-orig
182xsltproc -o content.xml --stringparam version ${JDTVERSION} \
183 --stringparam versionnext ${JDTVERSIONNEXT} \
184 ${BUILD}/patch-content-xml.xsl content.xml-orig
185ls -ltr *\.*
186
187echo "====Step 6: archive raw meta data===="
Stephan Herrmann434a0842016-11-01 18:02:29 +0100188mkdir -p ${METADATA}/$OTDTVERSION
Stephan Herrmannff801a62016-11-01 15:01:00 +0100189cp *.xml ${METADATA}/$OTDTVERSION
190ls -ltr ${METADATA}/$OTDTVERSION/*.xml
191
192echo "====Step 7: generate category===="
193CATEGORYARGS="-categoryDefinition file:${BASE}/testrun/build-root/src/features/org.eclipse.objectteams.otdt/category.xml"
194echo "CATEGORYARGS = ${CATEGORYARGS}"
195java -jar ${LAUNCHER_PATH} -consoleLog -application ${CATPUB} \
196 -source ${LOCATION} \
197 -metadataRepository file:${LOCATION} \
198 ${CATEGORYARGS}
199ls -ltr *\.*
200
201
202echo "====Step 8: add download stats capability===="
203XSLT_FILE=${BASE}/releng/build-scripts/bin/addDownloadStats.xsl
204
205if [ $# == 3 ]; then
206 mv artifacts.xml artifacts.xml.original
207 if grep p2.statsURI artifacts.xml.original ; then echo "p2.statsURI already defined: exiting"; exit 1; fi
208 xsltproc -o artifacts.xml --stringparam repo "http://download.eclipse.org/stats/objectteams/${2}" --stringparam version $3 $XSLT_FILE artifacts.xml.original
209fi
210
211echo "====Step 9: jar-up metadata===="
212jar cf content.jar content.xml
213jar cf artifacts.jar artifacts.xml
Stephan Herrmanncd701a02018-01-25 21:36:27 +0100214#/bin/rm *.xml*
Stephan Herrmannff801a62016-11-01 15:01:00 +0100215ls -ltr *\.*
216
217echo "====Step 10: cleanup: remove symbolic links===="
218find . -type l -exec /bin/rm {} \;
219
Stephan Herrmann0eeafef2017-03-21 23:35:39 +0100220if [ "${PROMOTE}" != "false" ]
Stephan Herrmann30789152016-11-01 15:44:32 +0100221then
Stephan Herrmann806942c2016-11-01 16:13:05 +0100222 BUILDID=`echo $OTDTVERSION | cut -d '.' -f 4`
Stephan Herrmann0eeafef2017-03-21 23:35:39 +0100223 if [ "${PROMOTE}" == "staging" ]
224 then
225 DEST=${UPDATES_BASE}/${2}/staging
226 /bin/rm -rf ${DEST}
227 else
228 DEST=${UPDATES_BASE}/${2}/${BUILDID}
229 fi
Stephan Herrmann806942c2016-11-01 16:13:05 +0100230 echo "====Step 11: promote to ${DEST}===="
Stephan Herrmann30789152016-11-01 15:44:32 +0100231 if [ -d ${UPDATES_BASE}/${2} ]
232 then
Stephan Herrmanne44829a2016-11-01 17:30:01 +0100233 mkdir ${DEST} && \
234 cp -pr ${UPDATES_BASE}/${1}/* ${DEST}/ && \
235 cp -pr * ${DEST}/ && \
Stephan Herrmann9853f0c2016-11-02 23:47:03 +0100236 chmod -R g+w ${DEST} && \
237 find ${DEST} -type d -exec /bin/ls -ld {} \;
238 ls -latr ${UPDATES_BASE}/${2}
Stephan Herrmann806942c2016-11-01 16:13:05 +0100239 else
Stephan Herrmann9853f0c2016-11-02 23:47:03 +0100240 echo "${UPDATES_BASE}/${2} not found or not a directory"
Stephan Herrmann30789152016-11-01 15:44:32 +0100241 fi
242fi
Stephan Herrmannff801a62016-11-01 15:01:00 +0100243echo "====DONE===="