Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Stephan Herrmann | 434a084 | 2016-11-01 18:02:29 +0100 | [diff] [blame] | 3 | # OPTIONAL VARIABLES TO BE SUPPLIED VIA ENV: |
| 4 | # SIGN (unset or nosign) |
| 5 | # PROMOTE (unset or true) |
| 6 | |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 7 | BASE=`pwd` |
Stephan Herrmann | 434a084 | 2016-11-01 18:02:29 +0100 | [diff] [blame] | 8 | |
| 9 | # ABSOLUTE PATHS: |
| 10 | export STAGINGBASE=/opt/public/download-staging.priv/tools/objectteams |
| 11 | export UPDATES_BASE=/home/data/httpd/download.eclipse.org/objectteams/updates |
Stephan Herrmann | 2e927b0 | 2018-01-28 11:48:32 +0100 | [diff] [blame] | 12 | export JAVA5=/shared/common/jdk1.5.0-latest |
| 13 | export JAVA8=/shared/common/jdk1.8.0_x64-latest |
Stephan Herrmann | 434a084 | 2016-11-01 18:02:29 +0100 | [diff] [blame] | 14 | |
| 15 | # RELATIVE PATHS: |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 16 | BUILD=${BASE}/releng/build-scripts/build |
| 17 | METADATA=${BASE}/metadata |
Stephan Herrmann | 434a084 | 2016-11-01 18:02:29 +0100 | [diff] [blame] | 18 | |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 19 | export JAR_PROCESSOR_JAVA=java8 |
| 20 | |
| 21 | # Find the master repository to build upon: |
| 22 | if [ "$1" == "none" ] |
| 23 | then |
| 24 | MASTER="none" |
| 25 | echo "Generating fresh new repository" |
| 26 | else |
| 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 |
| 42 | fi |
| 43 | |
| 44 | # Analyze the version number of the JDT feature as needed for patching content.xml later: |
| 45 | JDTFEATURE=`ls -d ${BASE}/testrun/build-root/eclipse/features/org.eclipse.jdt_*` |
| 46 | if echo $JDTFEATURE | grep "\.r" |
| 47 | then |
| 48 | JDTVERSION="`echo ${JDTFEATURE} | cut -d '_' -f 2`_`echo ${JDTFEATURE} | cut -d '_' -f 3`" |
| 49 | else |
| 50 | JDTVERSION=`echo ${JDTFEATURE} | cut -d '_' -f 2` |
| 51 | fi |
| 52 | JDTVERSIONA=`echo ${JDTVERSION} | cut -d '-' -f 1` |
| 53 | JDTVERSIONB=`echo ${JDTVERSION} | cut -d '-' -f 2` |
| 54 | echo "after first split: ${JDTVERSIONA} and ${JDTVERSIONB}" |
| 55 | case ${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 | ;; |
| 71 | esac |
| 72 | # hardcode when unable to compute |
| 73 | #JDTVERSION=${JDTVERSIONA} |
| 74 | #JDTVERSIONNEXT=3.8.0.v20110728 |
| 75 | echo "JDT feature is ${JDTVERSION}" |
| 76 | echo "Next ${JDTVERSIONNEXT}" |
| 77 | if [ ! -r ${BASE}/testrun/build-root/eclipse/features/org.eclipse.jdt_${JDTVERSION} ] |
| 78 | then |
| 79 | echo "JDT feature not correctly found in ${BASE}/testrun/build-root/eclipse/features" |
| 80 | exit 2 |
| 81 | fi |
| 82 | OTDTVERSION=`cat ${BASE}/testrun/build-root/src/finalFeaturesVersions.properties|grep "objectteams.otdt="|cut -d '=' -f 2` |
Stephan Herrmann | 491e4dd | 2016-11-01 17:01:44 +0100 | [diff] [blame] | 83 | if [ "${OTDTVERSION}" == "" ] |
| 84 | then |
| 85 | echo "finalFeaturesVersions.properties not found, maybe build hasn't run successfully?" |
| 86 | exit 3 |
| 87 | fi |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 88 | echo "OTDTVERSION is $OTDTVERSION" |
| 89 | |
| 90 | # Configure for calling various p2 applications: |
| 91 | LAUNCHER=`grep equinox.launcher_jar= ${BUILD}/run.properties | cut -d '=' -f 2` |
| 92 | LAUNCHER_PATH=${BASE}/testrun/build-root/eclipse/plugins/${LAUNCHER} |
| 93 | FABPUB=org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher |
| 94 | CATPUB=org.eclipse.equinox.p2.publisher.CategoryPublisher |
| 95 | JARPROCESSOR=`ls ${BASE}/testrun/build-root/eclipse/plugins/org.eclipse.equinox.p2.jarprocessor_*.jar` |
| 96 | NAME="Object Teams" |
| 97 | |
| 98 | echo "LAUNCHER_PATH = ${LAUNCHER_PATH}" |
| 99 | echo "NAME = ${NAME}" |
| 100 | |
Stephan Herrmann | 48f5a9c | 2018-05-15 23:46:30 +0200 | [diff] [blame] | 101 | echo "====Step 0: condition jars ====" |
Stephan Herrmann | 6f33783 | 2018-05-15 23:58:44 +0200 | [diff] [blame] | 102 | CONDITIONED=${BASE}/testrun/updateSiteRepack |
| 103 | if [ ! -d ${CONDITIONED} ] |
| 104 | then |
| 105 | mkdir ${CONDITIONED} |
| 106 | else |
| 107 | /bin/rm -r ${CONDITIONED}/* |
| 108 | fi |
| 109 | |
| 110 | for dir in features plugins |
Stephan Herrmann | c80b417 | 2018-05-10 15:30:26 +0200 | [diff] [blame] | 111 | do |
Stephan Herrmann | 6f33783 | 2018-05-15 23:58:44 +0200 | [diff] [blame] | 112 | find ${BASE}/testrun/updateSite/${dir} -type f -name \*.jar -exec \ |
| 113 | ${JAVA8}/bin/java -jar ${JARPROCESSOR} -verbose -processAll -repack -outputDir ${CONDITIONED}/${dir} {} \; |
Stephan Herrmann | c80b417 | 2018-05-10 15:30:26 +0200 | [diff] [blame] | 114 | done |
Stephan Herrmann | 0dc8431 | 2018-05-16 00:12:42 +0200 | [diff] [blame] | 115 | # not conditioned, but must not be skipped! |
| 116 | cp ${BASE}/testrun/updateSite/plugins/org.eclipse.jdt.core_* ${CONDITIONED}/plugins/ |
Stephan Herrmann | c80b417 | 2018-05-10 15:30:26 +0200 | [diff] [blame] | 117 | |
Stephan Herrmann | 48f5a9c | 2018-05-15 23:46:30 +0200 | [diff] [blame] | 118 | echo "====Step 1: request signing and zip====" |
Stephan Herrmann | 6f33783 | 2018-05-15 23:58:44 +0200 | [diff] [blame] | 119 | cd ${CONDITIONED} |
Stephan Herrmann | 023b442 | 2018-05-16 00:01:44 +0200 | [diff] [blame] | 120 | JARS=`find . -type f -name \*.jar` |
Stephan Herrmann | 49d7a78 | 2018-05-10 15:09:51 +0200 | [diff] [blame] | 121 | OTDTJAR=${BASE}/testrun/otdt.jar |
Stephan Herrmann | 3078915 | 2016-11-01 15:44:32 +0100 | [diff] [blame] | 122 | if [ "${SIGN}" == "nosign" ] |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 123 | then |
Stephan Herrmann | b5d54e7 | 2016-11-01 15:59:09 +0100 | [diff] [blame] | 124 | /bin/rm ${OTDTJAR} |
| 125 | zip ${OTDTJAR} ${JARS} |
Stephan Herrmann | fd97f0e | 2016-11-01 16:01:11 +0100 | [diff] [blame] | 126 | echo "SKIPPING SIGNING" |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 127 | else |
Stephan Herrmann | 49d7a78 | 2018-05-10 15:09:51 +0200 | [diff] [blame] | 128 | SIGNED=${BASE}/testrun/updateSiteSigned |
| 129 | if [ ! -d ${SIGNED} ] |
Stephan Herrmann | 568b61a | 2017-11-15 00:00:57 +0100 | [diff] [blame] | 130 | then |
Stephan Herrmann | 49d7a78 | 2018-05-10 15:09:51 +0200 | [diff] [blame] | 131 | mkdir ${SIGNED} |
Stephan Herrmann | 568b61a | 2017-11-15 00:00:57 +0100 | [diff] [blame] | 132 | else |
Stephan Herrmann | 6f33783 | 2018-05-15 23:58:44 +0200 | [diff] [blame] | 133 | /bin/rm -r ${SIGNED}/* |
Stephan Herrmann | 568b61a | 2017-11-15 00:00:57 +0100 | [diff] [blame] | 134 | fi |
Stephan Herrmann | b3a79fe | 2018-05-10 15:15:30 +0200 | [diff] [blame] | 135 | for JAR in ${JARS} |
Stephan Herrmann | 49d7a78 | 2018-05-10 15:09:51 +0200 | [diff] [blame] | 136 | do |
Stephan Herrmann | b3a79fe | 2018-05-10 15:15:30 +0200 | [diff] [blame] | 137 | DIR=`dirname $JAR` |
| 138 | if [ ! -d ${SIGNED}/${DIR} ] |
Stephan Herrmann | 49d7a78 | 2018-05-10 15:09:51 +0200 | [diff] [blame] | 139 | then |
Stephan Herrmann | b3a79fe | 2018-05-10 15:15:30 +0200 | [diff] [blame] | 140 | mkdir -p ${SIGNED}/${DIR} |
Stephan Herrmann | 49d7a78 | 2018-05-10 15:09:51 +0200 | [diff] [blame] | 141 | fi |
| 142 | curl -o ${SIGNED}/${JAR} -F file=@${JAR} http://build.eclipse.org:31338/sign |
| 143 | done |
| 144 | if [ -f ${OTDTJAR} ] |
Stephan Herrmann | 568b61a | 2017-11-15 00:00:57 +0100 | [diff] [blame] | 145 | then |
Stephan Herrmann | 568b61a | 2017-11-15 00:00:57 +0100 | [diff] [blame] | 146 | /bin/rm ${OTDTJAR} |
| 147 | fi |
Stephan Herrmann | 49d7a78 | 2018-05-10 15:09:51 +0200 | [diff] [blame] | 148 | cd ${SIGNED} |
| 149 | zip ${OTDTJAR} ${JARS} |
Stephan Herrmann | b5d54e7 | 2016-11-01 15:59:09 +0100 | [diff] [blame] | 150 | echo "Signing completed" |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 151 | fi |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 152 | |
| 153 | |
Stephan Herrmann | 48f5a9c | 2018-05-15 23:46:30 +0200 | [diff] [blame] | 154 | echo "====Step 2: fill new repository====" |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 155 | if [ -r ${BASE}/stagingRepo ] |
| 156 | then |
| 157 | /bin/rm -rf ${BASE}/stagingRepo |
| 158 | fi |
| 159 | mkdir ${BASE}/stagingRepo |
| 160 | cd ${BASE}/stagingRepo |
| 161 | if [ "$MASTER" != "none" ] |
| 162 | then |
| 163 | mkdir features |
| 164 | (cd features; ln -s ${MASTER}/features/* .) |
| 165 | mkdir plugins |
| 166 | (cd plugins; ln -s ${MASTER}/plugins/* .) |
| 167 | else |
| 168 | mkdir plugins |
| 169 | cp ${BASE}/testrun/updateSite/plugins/org.apache.bcel* plugins/ |
| 170 | fi |
Stephan Herrmann | b5d54e7 | 2016-11-01 15:59:09 +0100 | [diff] [blame] | 171 | unzip -n ${OTDTJAR} |
Stephan Herrmann | 49d7a78 | 2018-05-10 15:09:51 +0200 | [diff] [blame] | 172 | #/bin/rm ${OTDTJAR} |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 173 | |
| 174 | LOCATION=${BASE}/stagingRepo |
| 175 | echo "LOCATION = ${LOCATION}" |
| 176 | cd ${LOCATION} |
| 177 | |
Stephan Herrmann | 48f5a9c | 2018-05-15 23:46:30 +0200 | [diff] [blame] | 178 | echo "====Step 3: pack jars (again) ====" |
Stephan Herrmann | 70aac8e | 2018-05-16 00:12:42 +0200 | [diff] [blame] | 179 | for dir in ${LOCATION}/features ${LOCATION}/plugins |
Stephan Herrmann | 48f5a9c | 2018-05-15 23:46:30 +0200 | [diff] [blame] | 180 | do |
| 181 | find ${dir} -type f -name \*.jar -exec \ |
| 182 | ${JAVA8}/bin/java -jar ${JARPROCESSOR} -verbose -pack -outputDir ${dir} {} \; |
| 183 | done |
| 184 | |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 185 | |
| 186 | echo "====Step 4: generate metadata====" |
| 187 | java -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 |
| 194 | ls -ltr *\.* |
| 195 | |
| 196 | |
| 197 | echo "====Step 5: patch content for feature inclusion version range====" |
| 198 | mv content.xml content.xml-orig |
| 199 | xsltproc -o content.xml --stringparam version ${JDTVERSION} \ |
| 200 | --stringparam versionnext ${JDTVERSIONNEXT} \ |
| 201 | ${BUILD}/patch-content-xml.xsl content.xml-orig |
| 202 | ls -ltr *\.* |
| 203 | |
| 204 | echo "====Step 6: archive raw meta data====" |
Stephan Herrmann | 434a084 | 2016-11-01 18:02:29 +0100 | [diff] [blame] | 205 | mkdir -p ${METADATA}/$OTDTVERSION |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 206 | cp *.xml ${METADATA}/$OTDTVERSION |
| 207 | ls -ltr ${METADATA}/$OTDTVERSION/*.xml |
| 208 | |
| 209 | echo "====Step 7: generate category====" |
| 210 | CATEGORYARGS="-categoryDefinition file:${BASE}/testrun/build-root/src/features/org.eclipse.objectteams.otdt/category.xml" |
| 211 | echo "CATEGORYARGS = ${CATEGORYARGS}" |
| 212 | java -jar ${LAUNCHER_PATH} -consoleLog -application ${CATPUB} \ |
| 213 | -source ${LOCATION} \ |
| 214 | -metadataRepository file:${LOCATION} \ |
| 215 | ${CATEGORYARGS} |
| 216 | ls -ltr *\.* |
| 217 | |
| 218 | |
| 219 | echo "====Step 8: add download stats capability====" |
| 220 | XSLT_FILE=${BASE}/releng/build-scripts/bin/addDownloadStats.xsl |
| 221 | |
| 222 | if [ $# == 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 |
| 226 | fi |
| 227 | |
| 228 | echo "====Step 9: jar-up metadata====" |
| 229 | jar cf content.jar content.xml |
| 230 | jar cf artifacts.jar artifacts.xml |
Stephan Herrmann | cd701a0 | 2018-01-25 21:36:27 +0100 | [diff] [blame] | 231 | #/bin/rm *.xml* |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 232 | ls -ltr *\.* |
| 233 | |
| 234 | echo "====Step 10: cleanup: remove symbolic links====" |
| 235 | find . -type l -exec /bin/rm {} \; |
| 236 | |
Stephan Herrmann | 0eeafef | 2017-03-21 23:35:39 +0100 | [diff] [blame] | 237 | if [ "${PROMOTE}" != "false" ] |
Stephan Herrmann | 3078915 | 2016-11-01 15:44:32 +0100 | [diff] [blame] | 238 | then |
Stephan Herrmann | 806942c | 2016-11-01 16:13:05 +0100 | [diff] [blame] | 239 | BUILDID=`echo $OTDTVERSION | cut -d '.' -f 4` |
Stephan Herrmann | 0eeafef | 2017-03-21 23:35:39 +0100 | [diff] [blame] | 240 | 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 Herrmann | 806942c | 2016-11-01 16:13:05 +0100 | [diff] [blame] | 247 | echo "====Step 11: promote to ${DEST}====" |
Stephan Herrmann | 3078915 | 2016-11-01 15:44:32 +0100 | [diff] [blame] | 248 | if [ -d ${UPDATES_BASE}/${2} ] |
| 249 | then |
Stephan Herrmann | e44829a | 2016-11-01 17:30:01 +0100 | [diff] [blame] | 250 | mkdir ${DEST} && \ |
| 251 | cp -pr ${UPDATES_BASE}/${1}/* ${DEST}/ && \ |
| 252 | cp -pr * ${DEST}/ && \ |
Stephan Herrmann | 9853f0c | 2016-11-02 23:47:03 +0100 | [diff] [blame] | 253 | chmod -R g+w ${DEST} && \ |
| 254 | find ${DEST} -type d -exec /bin/ls -ld {} \; |
| 255 | ls -latr ${UPDATES_BASE}/${2} |
Stephan Herrmann | 806942c | 2016-11-01 16:13:05 +0100 | [diff] [blame] | 256 | else |
Stephan Herrmann | 9853f0c | 2016-11-02 23:47:03 +0100 | [diff] [blame] | 257 | echo "${UPDATES_BASE}/${2} not found or not a directory" |
Stephan Herrmann | 3078915 | 2016-11-01 15:44:32 +0100 | [diff] [blame] | 258 | fi |
| 259 | fi |
Stephan Herrmann | ff801a6 | 2016-11-01 15:01:00 +0100 | [diff] [blame] | 260 | echo "====DONE====" |