-
Notifications
You must be signed in to change notification settings - Fork 8
/
mirror_site
executable file
·290 lines (260 loc) · 9.64 KB
/
mirror_site
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#!/bin/bash
# Eclipse search directories
ECLIPSE_DIRS="$HOME/eclipse $HOME ../ ../../ ../..//usr/lib/ /usr/share"
true ${DOWNLOAD_DIR:=/tmp/download}
# Local directory for the old-style update site mirror
true ${MIRROR_DIR_OLD:=/tmp/mirror-sites/}
# Local p2 repo
true ${MIRROR_DIR:=file://tmp/mirror-eclipse-p2/}
#------------------------------------------------------------
# find_eclipsehome
#
# This function checks ECLIPSE_HOME env variable and if it is
# not set, it searches an eclipse directory under ECLIPSE_DIRS,
# and set ECLIPSE_HOME env variable.
# ------------------------------------------------------------
find_eclipsehome()
{
if test ! "x$ECLIPSE_HOME" = "x" ; then
if test -d $ECLIPSE_HOME ; then
return 0
fi
echo "ECLIPSE_HOME $ECLIPSE_HOME does not exist."
fi
echo "Environment variable ECLIPSE_HOME is not set. Searching..."
for d in $ECLIPSE_DIRS ; do
tmp=`find -L $d -name .eclipseproduct`
if test "x$tmp" = "x" ; then
continue
fi
for e in $tmp ; do
edir=`dirname $e`
if test -f $edir/eclipse.ini && test -d $edir/plugins ; then
export ECLIPSE_HOME="$edir"
return 0
fi
done
done
echo "eclipse not found. Please install eclipse and set ECLIPSE_HOME."
exit 1
}
#------------------------------------------------------------
# mirror_site <site URL> <mirror dir>
#
# Mirrors an old-style update site (not a p2 repository)
# Can mirror multiple sites into one mirror. The sites are merged.
#
# $1: Source URL of the update site like you would enter it in Eclipse
# $2: Target directory to store mirror
#------------------------------------------------------------
function mirror_site()
{
java -jar $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_*.jar \
-application org.eclipse.update.core.standaloneUpdate \
-command mirror -from $1 -to $2
}
#------------------------------------------------------------
# convert_site <old mirror dir> <p2 repository dir>
#
# Converts are mirror of old-style update sites into a p2 repository.
# Usually called once for multiple mirror_site() calls.
# If called for an existing, non-empty local p2 repo, then the additional
# artifacts are merged into it.
#------------------------------------------------------------
function convert_site()
{
java -jar $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_*.jar \
-application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \
-metadataRepository $MIRROR_DIR \
-artifactRepository $MIRROR_DIR \
-source $MIRROR_DIR_OLD \
-append \
-publishArtifacts
}
#------------------------------------------------------------
# mirror_p2 <source URL> <mirror dir>
#
# Mirrors a p2 repository into a local directory.
# Can be called multiple times. All repos are merged into the local directory.
#
# $1: Source URL of the update site like you would enter it in Eclipse
# $2: Target directory to store mirror
#------------------------------------------------------------
function mirror_p2()
{
app_arti="org.eclipse.equinox.p2.artifact.repository.mirrorApplication"
app_meta="org.eclipse.equinox.p2.metadata.repository.mirrorApplication"
app_dire="org.eclipse.equinox.p2.director"
echo -n "Mirroring P2 Repo: $1..."
java -jar $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_*.jar \
-verbose \
-application $app_arti \
-source $1 -destination $2
java -jar $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_*.jar \
-verbose \
-application $app_meta\
-source $1 -destination $2
java -jar $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_*.jar \
-verbose \
-application $app_dire\
-source $1 -destination $2
echo "done."
}
mirror_p2_partial()
{
update_site=$1
shift
target_dir=$1
shift
ids=""
for id in $* ; do
ids="$ids
<iu id=\"$id\" />"
done
cat<<EOF > mirror.xml
<project name="Create Mirror" default="create-mirror" basedir=".">
<target name="create-mirror">
<p2.mirror source="$update_site">
<destination location="$target_dir" />$ids
</p2.mirror>
</target>
</project>
EOF
echo "Mirroring the following features."
echo "$*"
java -jar $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_* \
-application org.eclipse.ant.core.antRunner \
-verbose \
-buildfile mirror.xml
echo "Done"
}
#------------------------------------------------------------
# download_convert
#
# Downloads a zip file containing a eclipse plugin and adds this
# plugin to the local p2 repo. Note: The zip file must contain either
# a copy of the update site (e.g. site.xml) or at least a plugins/
# subdirectory so that it is recognized.
#
# $1: some unique symbolic name of the plugin. Needed, so that
# download_convert() can be called multiple times for different
# plugins without interferring each other.
#
# $2 - download URL, suitable for wget.
#------------------------------------------------------------
function download_convert()
{
if [ ! -e $DOWNLOAD_DIR ]; then
mkdir $DOWNLOAD_DIR
fi
mkdir $DOWNLOAD_DIR/$1
file="$DOWNLOAD_DIR/"`basename $2`
wget -O $file $2
unzip -d $DOWNLOAD_DIR/$1 $file
java -jar $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_*.jar \
-application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \
-metadataRepository $MIRROR_DIR \
-artifactRepository $MIRROR_DIR \
-source $DOWNLOAD_DIR/$1 \
-append \
-publishArtifacts
}
#------------------------------------------------------------
# download_convert_plugins
#
# Downloads a zip file containing a eclipse plugin and adds this
# plugin to the local p2 repo. Note: This time, the zip file contains
# directly the plugin and not a update site structure. Therefore a
# "plugins/" subdirectory is created.
#
# $1: some unique symbolic name of the plugin. Needed, so that
# download_convert() can be called multiple times for different
# plugins without interferring each other.
#
# $2: download URL, suitable for wget
#------------------------------------------------------------
function download_convert_plugins()
{
if [ ! -e $DOWNLOAD_DIR ]; then
mkdir $DOWNLOAD_DIR
fi
mkdir -p $DOWNLOAD_DIR/$1/plugins
file="$DOWNLOAD_DIR/"`basename $2`
wget -O $file $2
unzip -d $DOWNLOAD_DIR/$1/plugins $file
java -jar $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_*.jar \
-application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \
-metadataRepository $MIRROR_DIR \
-artifactRepository $MIRROR_DIR \
-source $DOWNLOAD_DIR/$1/ \
-append \
-publishArtifacts
}
#------------------------------------------------------------
# svn_site_
#
# Does an svn checkout of a subversion repository, which contains a ready to use
# update site. Then adds this update site to the local p2 repo.
#
# $1 - some unique symbolic name of the plugin. Needed, so that svn_site_checkout() can
# be called multiple times for different plugins without interferring each other.
# $2 - the svn repo url
#
function svn_site_checkout()
{
if [ ! -e $DOWNLOAD_DIR ]; then
mkdir $DOWNLOAD_DIR
fi
mkdir $DOWNLOAD_DIR/$1
svn checkout $2 $DOWNLOAD_DIR/$1
java -jar $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_*.jar \
-application \
org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \
-metadataRepository $MIRROR_DIR \
-artifactRepository $MIRROR_DIR \
-source $DOWNLOAD_DIR/$1 \
-append \
-publishArtifacts
}
#mirror_site "http://findbugs.cs.umd.edu/eclipse/"
#mirror_site "http://www.soyatec.com/update/juno/"
#mirror_site "http://www.jutils.com/eclipse-update/"
#mirror_site "http://andrei.gmxhome.de/eclipse/"
#mirror_site "http://download.aptana.com/studio3/plugin/install"
#atlassian doesn't work! This is missing: org.apache.commons.httpclient_3.1.0.v201012070820.jar
###mirror_site "http://update.atlassian.com/atlassian-eclipse-plugin/e3.6/"
#mirror_site "http://jautodoc.sourceforge.net/update/"
#mirror_site "http://www.junginger.biz/eclipse/"
#mirror_site "http://update.atlassian.com/eclipse/clover/"
#mirror_site "http://jadclipse.sourceforge.net/update/"
#mirror_site "http://pydev.org/updates/"
#convert_site
#mirror_p2 "http://download.eclipse.org/releases/juno"
#mirror_p2 "http://download.eclipse.org/mylyn/releases/juno"
#mirror_p2 "http://download.eclipse.org/eclipse/updates/4.2"
#mirror_p2 "http://download.eclipse.org/webtools/repository/juno"
#mirror_p2 "http://eclipse-cs.sourceforge.net/update"
#mirror_p2 "http://dist.springsource.com/release/TOOLS/update/e4.2"
#mirror_p2 "http://download.eclipse.org/technology/m2e/releases"
#mirror_p2 "http://update.eclemma.org/"
#mirror_p2 "http://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site/"
#mirror_p2 "http://download.eclipse.org/egit/updates"
#mirror_p2 "http://subclipse.tigris.org/update_1.8.x/"
#mirror_p2 "http://pluginbox.sourceforge.net/"
#mirror_p2 "http://download.jboss.org/jbosstools/updates/development/juno/"
#download_convert "rbe" "http://sourceforge.net/projects/eclipse-rbe/files/Eclipse%203.x/0.8.0/ResourceBundleEditor_v0.8.0.zip"
#download_convert_plugins "jutils" "http://sourceforge.net/projects/eclipse-jutils/files/eclipse-jutils/eclipse-jutils%20plugin%20v3.1/org.adarsh.jutils_3.1.0.zip"
#download_convert "json" "http://sourceforge.net/projects/eclipsejsonedit/files/eclipsejsonedit/Json%20Editor%20Plugin%200.9.4/JsonEditorPlugin-0.9.4.zip"
#svn_site_checkout "jenkins" "http://jenkins-eclipse-plugin.googlecode.com/svn/trunk/jenkins-update/"
#svn_site_checkout "grinderstone" "http://grinderstone.googlecode.com/svn/update/"
#------------------------------------------------------------
# main
#------------------------------------------------------------
find_eclipsehome
if test $# -eq 2 ; then
mirror_p2 $1 $2
exit 0
fi
if test $# -gt 2 ; then
mirror_p2 $*
fi