Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 2af3ac95ab6ed580bd0695a98b988c7d6efdcbe1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash

#--------------------------------------------------------------------------------
# Copyright (c) 2012 CEA LIST.
#
#    
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#    Nicolas Bros (Mia-Software)
#--------------------------------------------------------------------------------

set -o errexit
set -o nounset

DROPS_DIR=/home/data/httpd/download.eclipse.org/modeling/mdt/papyrus/downloads/drops
ARCHIVE_DIR=/home/data/httpd/archive.eclipse.org/modeling/mdt/papyrus/downloads/drops
ARCHIVE_INDEX=/home/data/httpd/archive.eclipse.org/modeling/mdt/papyrus/downloads/index.html
UPDATE_SITES_DIR=/home/data/httpd/download.eclipse.org/modeling/mdt/papyrus/updates
ZIP_PREFIX="Papyrus-Update-incubation"
PROMOTE_FUNCTIONS_SH=/opt/public/modeling/mdt/papyrus/promoteFunctions.sh
ADD_TO_COMPOSITE_SH=/opt/public/modeling/mdt/papyrus/addToComposite.sh

SVN_DIRECTORIES_TO_TAG[0]="file:///svnroot/modeling/org.eclipse.mdt.papyrus"

# constants required by promoteFunctions.sh
export ADD_DOWNLOAD_STATS=/opt/public/modeling/mdt/papyrus/addDownloadStats.sh

# include promote functions
source "$PROMOTE_FUNCTIONS_SH"

# ============================== USER PARAMETERS ==============================

echo "-------------------- user parameters --------------------"
mainBuildNumber=""
extrasBuildNumber=""
testsBuildNumber=""
version=""
updateSite=""
sure=""

echo "mainBuildNumber (the number of the \"papyrus-0.9-maintenance-nightly\" Hudson build from which to publish the main Papyrus plug-ins): "
while [[ ! "$mainBuildNumber" =~ ^[0-9]+$ || "$mainBuildNumber" < 1 ]]; do
	echo -n "? "
	read mainBuildNumber
done

echo "extrasBuildNumber (the number of the \"papyrus-0.9-maintenance-extra-nightly\" Hudson build from which to publish the extra Papyrus plug-ins, or 0 to not publish): "
while [[ ! "$extrasBuildNumber" =~ ^[0-9]+$ || "$extrasBuildNumber" < 0 ]]; do
	echo -n "? "
	read extrasBuildNumber
done

echo "testsBuildNumber (the number of the \"papyrus-0.9-maintenance-nightly-tests\" Hudson build from which to publish the test results, or 0 to not publish): "
while [[ ! "$testsBuildNumber" =~ ^[0-9]+$ || "$testsBuildNumber" < 0 ]]; do
	echo -n "? "
	read testsBuildNumber
done

echo "version (e.g. \"0.9.0\"): "
while [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; do
	echo -n "? "
	read version
done

echo "updateSite (e.g. \"nightly/juno\", \"milestones/0.9/M5\", \"releases/indigo/0.8.1\") : "
while [[ ! "$updateSite" =~ ^(tmpTest|releases/(indigo|juno|kepler)/[0-9]+\.[0-9]\.[0-9]|milestones/[0-9]+\.[0-9]+/(M[1-7]|RC[1-9]|SR[1-9]_RC[1-9])|nightly/(indigo|juno|kepler))$ ]]; do
	echo -n "? "
	read updateSite
done

updateSiteDir="$UPDATE_SITES_DIR/$updateSite"

deleteUpdateSite=""
if [ -e "$updateSiteDir" ]; then
	echo "The update site already exists: $updateSiteDir"
	echo "Do you want to delete it (yes|no)?"
	while [[ ! "$deleteUpdateSite" =~ ^(yes|no)$ ]]; do
		echo -n "? "
		read deleteUpdateSite
	done
	if [ "$deleteUpdateSite" != "yes" ]; then echo "Canceled."; exit 1; fi
	rm -rf "$updateSiteDir"
fi


echo "Are you sure you want to publish with these parameters (yes|no)?"
while [[ ! "$sure" =~ ^(yes|no)$ ]]; do
	echo -n "? "
	read sure
done

if [ "$sure" != "yes" ]; then echo "Canceled."; exit 1; fi

# from now on, display executed commands
set -x

dirBefore=$(pwd)
echo "[$DATE] creating working dir"
workingDir=$(mktemp -d)
cd "$workingDir"

# ============================== PUBLISH MAIN ==============================
nfsURL="/shared/jobs/papyrus-0.9-maintenance-nightly/builds/$mainBuildNumber/archive/"
hudsonURL="https://hudson.eclipse.org/hudson/job/papyrus-0.9-maintenance-nightly/$mainBuildNumber/artifact/"
zipName="Papyrus-Main.zip"
updateZipPrefix="Papyrus-Update-incubation"
getZip "$zipName" "$nfsURL" "$hudsonURL"

mkdir -p "$updateSiteDir"

buildsDir="$DROPS_DIR/$version"
echo "publishing build (version='$version') to the builds directory '$buildsDir'..."
unzip -o "$zipName" -d "$buildsDir"

foldersInZip=$(unzip -t "$zipName" | egrep "testing: *[^/]*/ +OK" | sed 's%^ *testing: *\([^/]*\)/ *OK$%\1%')
[ $(echo "$foldersInZip" | wc -l) == 1 ] || { echo "one directory expected in zip"; exit 1; }
folderName="$foldersInZip"

updateSiteZipName=$(basename $(ls -1 "$buildsDir/$folderName/${updateZipPrefix}"*.zip))
unzip -o "$buildsDir/$folderName/${updateSiteZipName}" -d "$updateSiteDir/main"

# create the composite update site
cat > "$updateSiteDir/compositeArtifacts.xml" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<repository name="Papyrus" type="org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository" version="1.0.0">
  <properties size="1">
    <property name="p2.timestamp" value="$(date +%s000)"/>
  </properties>
  <children size="2">
    <child location="main"/>
    <child location="extra"/>
  </children>
</repository>
EOF

cat > "$updateSiteDir/compositeContent.xml" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<repository name="Papyrus" type="org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository" version="1.0.0">
  <properties size="1">
    <property name="p2.timestamp" value="$(date +%s000)"/>
  </properties>
  <children size="2">
    <child location="main"/>
    <child location="extra"/>
  </children>
</repository>
EOF

$ADD_DOWNLOAD_STATS "$updateSiteDir/main" "main"

# ============================== PUBLISH EXTRAS ==============================
if [[ "$extrasBuildNumber" != "0" ]]; then
	nfsURL="/shared/jobs/papyrus-0.9-maintenance-extra-nightly/builds/$extrasBuildNumber/archive/"
	hudsonURL="https://hudson.eclipse.org/hudson/job/papyrus-0.9-maintenance-extra-nightly/$extrasBuildNumber/artifact/"
	zipName="Papyrus-Extra.zip"
	updateZipName="Papyrus-Extra-Update.zip"
	getZip "$zipName" "$nfsURL" "$hudsonURL"
	# unzips under an "extra" folder under the main build's folder
	unzip -o "$zipName" -d "$buildsDir/$folderName"
	unzip -o "$buildsDir/$folderName/extra/$updateZipName" -d "$updateSiteDir/extra"
	
	$ADD_DOWNLOAD_STATS "$updateSiteDir/extra" "extra"
fi

# ============================== PUBLISH TESTS ==============================
if [[ "$testsBuildNumber" != "0" ]]; then
	nfsURL="/shared/jobs/papyrus-0.9-maintenance-nightly-tests/builds/$testsBuildNumber/archive/"
	hudsonURL="https://hudson.eclipse.org/hudson/job/papyrus-0.9-maintenance-nightly-tests/$testsBuildNumber/artifact/"
	zipName="Papyrus-TestResults.zip"
	getZip "$zipName" "$nfsURL" "$hudsonURL"
	# unzips under a "testresults" folder under the main build's folder 
	unzip -o "$zipName" -d "$buildsDir/$folderName"
fi


setAccessRights "$buildsDir/$folderName"
setAccessRights "$updateSiteDir"

echo "publishing done."

Back to the top