2008-03-31 18:45:06 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2008-07-29 13:40:46 +00:00
|
|
|
# args: [-f <feature>] [-d <dependencies (outside SDK)>] [-a <additional build args>] [-j <JVM args>] [-v] [-D] [-o <Orbit dependencies>]
|
2008-03-31 18:45:06 +00:00
|
|
|
|
|
|
|
function usage {
|
|
|
|
cat << _EOF_
|
|
|
|
usage: $0 [<options>]
|
|
|
|
|
|
|
|
Use PDE Build to build Eclipse features
|
|
|
|
|
|
|
|
Optional arguments:
|
|
|
|
-h Show this help message
|
|
|
|
-f Feature ID to build
|
|
|
|
-d Plugin dependencies in addition to Eclipse SDK
|
|
|
|
(space-separated, names on which to glob features and plugins)
|
|
|
|
-a Additional build arguments (ex. -DjavacSource=1.5)
|
|
|
|
-j VM arguments (ex. -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar)
|
|
|
|
-v Be verbose
|
|
|
|
-D Debug platform itself (passes -consolelog -debug to Eclipse)
|
2008-10-17 19:49:13 +00:00
|
|
|
-o Directory containing Orbit-style dependencies
|
2008-12-15 17:32:26 +00:00
|
|
|
-z Comma-delimited list of dependency zips (not for use during RPM build)
|
2008-03-31 18:45:06 +00:00
|
|
|
_EOF_
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyPlatform {
|
|
|
|
# This seems silly but I was running into issues with empty strings
|
|
|
|
# counting as arguments to copy-platform -- overholt, 2008-03
|
2008-07-29 13:40:46 +00:00
|
|
|
if [ -z "$dependencies" ]; then
|
2008-03-31 18:45:06 +00:00
|
|
|
if [ $verbose -eq 1 ]; then
|
|
|
|
echo "/bin/sh -x $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse"
|
|
|
|
/bin/sh -x $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse
|
|
|
|
else
|
|
|
|
echo "/bin/sh $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse"
|
|
|
|
/bin/sh $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ $verbose -eq 1 ]; then
|
|
|
|
echo "/bin/sh -x $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse $dependencies"
|
|
|
|
/bin/sh -x $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse $dependencies
|
|
|
|
else
|
|
|
|
echo "/bin/sh $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse $dependencies"
|
|
|
|
/bin/sh $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse $dependencies
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function findFeatureId {
|
|
|
|
# We can determine the feature ID if we have only one
|
|
|
|
numFeatures=$(find $sourceDir -name feature.xml | wc -l)
|
|
|
|
if [ $numFeatures -ne 1 ]; then
|
|
|
|
#echo "# features found = $numFeatures"
|
|
|
|
echo "Cannot determine feature ID. Please specify with -f."
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
featureXml=$(find $sourceDir -name feature.xml)
|
|
|
|
|
|
|
|
# Taken from Ben Konrath's package-build
|
|
|
|
# make an ant build files to extract the id from the feature.xml
|
|
|
|
buildFile=$buildDir/findFeatureForRPM-tmp-build.xml
|
|
|
|
|
|
|
|
echo "<project default=\"main\">
|
|
|
|
<target name=\"main\">
|
|
|
|
<xmlproperty file=\"$featureXml\" collapseAttributes=\"true\"/>
|
|
|
|
<fail unless=\"feature.id\" message=\"feature.id not set\"/>
|
|
|
|
<echo message=\"\${feature.id}\" />
|
|
|
|
</target>
|
|
|
|
</project>" > $buildFile
|
|
|
|
|
|
|
|
featureId=$(ant -Dbasedir=$sourceDir -f $buildFile 2>&1 | grep echo | cut --delimiter=' ' -f 7)
|
|
|
|
rm $buildFile
|
|
|
|
}
|
|
|
|
|
2008-08-06 18:24:30 +00:00
|
|
|
function findFeatureNameAndVersion {
|
|
|
|
featureXml=$(find $sourceDir -name feature.xml | while read f; do grep -l id=\"$featureId\" $f; done)
|
|
|
|
|
|
|
|
buildFile=$buildDir/findFeatureForRPM-tmp-build.xml
|
|
|
|
|
|
|
|
echo "<project default=\"main\">
|
|
|
|
<target name=\"main\">
|
|
|
|
<xmlproperty file=\"$featureXml\" collapseAttributes=\"true\"/>
|
|
|
|
<fail unless=\"feature.id\" message=\"feature.id not set\"/>
|
|
|
|
<echo message=\"\${feature.label}\" />
|
|
|
|
</target>
|
|
|
|
</project>" > $buildFile
|
|
|
|
|
|
|
|
featureName=$(ant -Dbasedir=$sourceDir -f $buildFile 2>&1 | grep echo | sed "s/.*\[echo\]\ //")
|
|
|
|
rm $buildFile
|
|
|
|
|
|
|
|
echo "<project default=\"main\">
|
|
|
|
<target name=\"main\">
|
|
|
|
<xmlproperty file=\"$featureXml\" collapseAttributes=\"true\"/>
|
|
|
|
<fail unless=\"feature.id\" message=\"feature.id not set\"/>
|
|
|
|
<echo message=\"\${feature.version}\" />
|
|
|
|
</target>
|
|
|
|
</project>" > $buildFile
|
|
|
|
|
|
|
|
featureVersion=$(ant -Dbasedir=$sourceDir -f $buildFile 2>&1 | grep echo | sed "s/.*\[echo\]\ //")
|
|
|
|
rm $buildFile
|
|
|
|
}
|
2008-03-31 18:45:06 +00:00
|
|
|
sourceDir=$PWD
|
|
|
|
buildDir=$PWD/build
|
|
|
|
SDK=$buildDir/SDK
|
|
|
|
homeDir=$buildDir/home
|
2008-07-29 13:40:46 +00:00
|
|
|
datadir=`rpm --eval "%{_libdir}"`
|
2008-08-12 18:53:34 +00:00
|
|
|
pdeBuildDir=$datadir/eclipse/dropins/sdk/plugins/org.eclipse.pde.build_@PDEBUILDVERSION@
|
2008-03-31 18:45:06 +00:00
|
|
|
|
|
|
|
featureId=
|
|
|
|
dependencies=
|
|
|
|
additionalArgs=
|
|
|
|
vmArgs=
|
|
|
|
verbose=0
|
|
|
|
dryRun=0
|
|
|
|
debugPlatform=0
|
2008-07-29 13:40:46 +00:00
|
|
|
orbitDepsDir=
|
2008-08-27 20:12:35 +00:00
|
|
|
p2Generate=
|
|
|
|
testing=false
|
2008-12-15 17:32:26 +00:00
|
|
|
zipDeps=
|
2008-03-31 18:45:06 +00:00
|
|
|
|
|
|
|
# See above. r = dry run (used for testing)
|
2008-12-15 17:32:26 +00:00
|
|
|
while getopts “hf:d:z:a:j:tvrDo:” OPTION
|
2008-03-31 18:45:06 +00:00
|
|
|
do
|
|
|
|
case $OPTION in
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
f)
|
|
|
|
featureId=$OPTARG
|
|
|
|
;;
|
|
|
|
d)
|
|
|
|
dependencies=$OPTARG
|
|
|
|
;;
|
|
|
|
a)
|
|
|
|
additionalArgs=$OPTARG
|
|
|
|
;;
|
|
|
|
j)
|
|
|
|
vmArgs=$OPTARG
|
|
|
|
;;
|
2008-08-27 20:12:35 +00:00
|
|
|
t)
|
|
|
|
testing=true
|
|
|
|
;;
|
2008-03-31 18:45:06 +00:00
|
|
|
v)
|
|
|
|
verbose=1
|
|
|
|
;;
|
|
|
|
r)
|
|
|
|
dryRun=1
|
|
|
|
;;
|
|
|
|
D)
|
|
|
|
debugPlatform=1
|
|
|
|
;;
|
2008-07-29 13:40:46 +00:00
|
|
|
o)
|
|
|
|
orbitDepsDir=$OPTARG
|
|
|
|
;;
|
2008-12-15 17:32:26 +00:00
|
|
|
z)
|
|
|
|
zipDeps=$OPTARG
|
|
|
|
;;
|
2008-03-31 18:45:06 +00:00
|
|
|
?)
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "mkdir -p $buildDir"
|
|
|
|
if [ $dryRun -ne 1 ]; then
|
|
|
|
mkdir -p $buildDir
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Eclipse may try to write to the building user's home directory so we create a
|
|
|
|
# temporary one for use by the build.
|
|
|
|
echo "mkdir -p $homeDir"
|
|
|
|
if [ $dryRun -ne 1 ]; then
|
|
|
|
mkdir -p $homeDir
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $featureId ]; then
|
|
|
|
findFeatureId
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $featureId ]; then
|
|
|
|
echo "Cannot determine feature ID. Please specify with -f."
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-08-06 18:24:30 +00:00
|
|
|
findFeatureNameAndVersion
|
|
|
|
|
2008-03-31 18:45:06 +00:00
|
|
|
echo "Building feature = $featureId."
|
|
|
|
|
|
|
|
if [ -z "$dependencies" ]; then
|
|
|
|
if [ $verbose -eq 1 ]; then
|
|
|
|
echo "Assuming no dependencies except Eclipse SDK."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Symlink the SDK and dependencies for build
|
|
|
|
if [ -z "$dependencies" ]; then
|
|
|
|
echo "Symlinking SDK into $SDK directory."
|
|
|
|
else
|
|
|
|
echo "Symlinking SDK and \"$dependencies\" into $SDK directory."
|
|
|
|
fi
|
|
|
|
if [ $dryRun -ne 1 ]; then
|
|
|
|
copyPlatform
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $debugPlatform -eq 1 ]; then
|
|
|
|
debugPlatformArgs="-debug -consolelog"
|
|
|
|
fi
|
|
|
|
|
2008-10-17 19:49:13 +00:00
|
|
|
if [ "x$orbitDepsDir" != "x" ]; then
|
|
|
|
orbitDeps="-DorbitDepsDir=\"$orbitDepsDir\""
|
2008-08-27 20:12:35 +00:00
|
|
|
fi
|
|
|
|
|
2008-12-15 17:32:26 +00:00
|
|
|
if [ "x$zipDeps" != "x" ]; then
|
|
|
|
OLD_IFS="$IFS"
|
|
|
|
IFS=","
|
|
|
|
zipDepsArray=($zipDeps)
|
|
|
|
IFS="$OLD_IFS"
|
|
|
|
numZips=${#zipDepsArray[@]}
|
|
|
|
for (( i=0; i< $numZips; i++ )); do
|
|
|
|
thisZip=${zipDepsArray[$i]}
|
|
|
|
thisFile=$(basename $thisZip)
|
|
|
|
thisURL=$(echo $thisZip | sed s/$thisFile//)
|
|
|
|
if [ ! -e $thisFile ]; then
|
|
|
|
wget -q $thisZip
|
|
|
|
fi
|
|
|
|
mkdir -p tmp
|
|
|
|
unzip -q -o $thisFile -d tmp
|
|
|
|
cp -raf tmp/eclipse/features/* $SDK/features
|
|
|
|
cp -raf tmp/eclipse/plugins/* $SDK/plugins
|
|
|
|
rm -rf tmp
|
|
|
|
thisZip=
|
|
|
|
thisFile=
|
|
|
|
thisURL=
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2008-03-31 18:45:06 +00:00
|
|
|
echo "Starting build:"
|
|
|
|
|
2008-10-17 19:49:13 +00:00
|
|
|
if [ $testing != true ]; then
|
|
|
|
java -cp $SDK/startup.jar \
|
2008-03-31 18:45:06 +00:00
|
|
|
org.eclipse.core.launcher.Main \
|
|
|
|
-application org.eclipse.ant.core.antRunner \
|
|
|
|
$debugPlatformArgs \
|
|
|
|
-Dtype=feature \
|
|
|
|
-Did=$featureId \
|
|
|
|
-DbaseLocation=$SDK \
|
|
|
|
-DsourceDirectory=$sourceDir \
|
|
|
|
-DbuildDirectory=$buildDir \
|
2008-08-12 18:53:34 +00:00
|
|
|
-Dbuilder=$datadir/eclipse/dropins/sdk/plugins/org.eclipse.pde.build_@PDEBUILDVERSION@/templates/package-build \
|
2008-10-17 19:49:13 +00:00
|
|
|
$orbitDeps \
|
2008-08-27 20:12:35 +00:00
|
|
|
-Dtesting="$testing" \
|
2008-10-17 19:49:13 +00:00
|
|
|
-Dp2.root.name="$featureName" \
|
|
|
|
-Dp2.root.version="$featureVersion" \
|
|
|
|
-Dgenerate.p2.metadata=true \
|
|
|
|
-Dp2.metadata.repo=file:$buildDir/repo \
|
|
|
|
-Dp2.artifact.repo=file:$buildDir/repo \
|
|
|
|
-Dp2.flavor=tooling \
|
|
|
|
-Dp2.publish.artifacts=true \
|
2008-03-31 18:45:06 +00:00
|
|
|
$additionalArgs \
|
|
|
|
-f $pdeBuildDir/scripts/build.xml \
|
|
|
|
-vmargs \
|
|
|
|
-Duser.home=$homeDir \
|
|
|
|
$vmArgs
|
2008-08-06 18:24:30 +00:00
|
|
|
|
2008-08-27 20:12:35 +00:00
|
|
|
# Add content.xml into zip
|
|
|
|
pushd $buildDir/rpmBuild
|
|
|
|
unzip $featureId.zip
|
|
|
|
rm $featureId.zip
|
|
|
|
cp -p ../repo/content.xml eclipse
|
|
|
|
zip -r $featureId.zip eclipse
|
|
|
|
rm -rf eclipse
|
|
|
|
popd
|
2008-10-17 19:49:13 +00:00
|
|
|
else
|
|
|
|
java -cp $SDK/startup.jar \
|
|
|
|
org.eclipse.core.launcher.Main \
|
|
|
|
-application org.eclipse.ant.core.antRunner \
|
|
|
|
$debugPlatformArgs \
|
|
|
|
-Dtype=feature \
|
|
|
|
-Did=$featureId \
|
|
|
|
-DbaseLocation=$SDK \
|
|
|
|
-DsourceDirectory=$sourceDir \
|
|
|
|
-DbuildDirectory=$buildDir \
|
|
|
|
-Dbuilder=$datadir/eclipse/dropins/sdk/plugins/org.eclipse.pde.build_@PDEBUILDVERSION@/templates/package-build \
|
|
|
|
$orbitDeps \
|
|
|
|
-Dtesting="$testing" \
|
|
|
|
$additionalArgs \
|
|
|
|
-f $pdeBuildDir/scripts/build.xml \
|
|
|
|
-vmargs \
|
|
|
|
-Duser.home=$homeDir \
|
|
|
|
$vmArgs
|
|
|
|
fi
|