Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [pde-dev] site manifest merging

Hi Robin.

I was in a similar situation recently.  Unfortunately the situation
is a bit more complicated than simply copying the features and
plugins as produced through use of the Update Manager, as the
features and plugins may come with custom installers (used, for
example, in Mylyn to deal with old Mylar installs).

I hacked up a Bourne shell script (attached) to populate an update
site based on the features and plugins installed in an Eclipse
extension location.  It processes each of the features found there,
downloads the feature .jar, and then downloads each of the referenced
plugins.  It also produces a candidate site.xml based on what it
downloads.  The script depends on wget and xmlstarlet.

Hope it helps.

BTW: Unless I've misunderstood what you meant by `multiple feature
sets', the site.xml does support multiple features.

Brian.


On 2007.08.17 14:23:18 -0500, Friedrich, Robin K wrote:
> Hi guys,
> I work on a Linux platform isolated from the internet. I'm trying
> to set up an eclipse environment for a number of developers in our
> department. I'm
> downloading all the plugins of interest and I would like to set
> up an internal update site on my apache server to house them all.
> The idea of course is to
> provide a single site for users to install/update their plugins
> from. I would like to do this manually by expanding the zip files
> and editing some site
> manifest file but I'm finding that the site.xml file doesn't
> support the notion of multiple feature sets (at least I have failed
> to find documentation on
> how to do this). Can anyone point me to the how to for this
> situation (I can't be the only one wanting to do this)?
> TIA
> Robin Friedrich
>
>

> _______________________________________________
> pde-dev mailing list
> pde-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/pde-dev


-- 
  Brian de Alwis | Software Practices Lab | UBC | http://www.cs.ubc.ca/~bsd/
      "Amusement to an observing mind is study." - Benjamin Disraeli
#!/bin/sh
# Populates an update site to include the features and plugins installed
# at a given extension location.  Produces a candidate site.xml.
#
# Written by Brian de Alwis <bsd@xxxxxxxxx>.  Placed in the public domain.
# 
# Requires wget, xmlstarlet
#

error() {
    echo "error: $*" 1>&2
    exit 1
}

warn() {
    echo "warning: $*" 1>&2
}

extdir=.

usage()
{
    eval 1>&2
    echo "use: $0 [-d extdir] [-D overrideURL] [-s site.xml] update-site [features.xml ...]"
    echo
    echo "Populates an update site at <update-site> to match the features"
    echo "installed at <extdir>.  Produces a suitably configured site.xml"
    echo "as site-<update-site>.xml.  Can be restricted to specific features"
    echo "by providing locations of their feature.xml files."
    echo 
    echo "  -d   specify the extension location (default: $extdir)"
    echo "  -D   override any URLs with <overrideURL> (useful for features"
    echo "       that do not specify an update site)"
    echo "  -s   specify file for resulting site.xml (default: placed in"
    echo "       <update-site>/site-<update-site>.xml, with '/' -> '_')"
    echo
    echo "This script will download the requisite plugins too."
    exit 1
}

while getopts d:D:s: c; do
    case $c in
    d)  extdir=$OPTARG;;
    D)  overrideURL=`echo "$OPTARG" | sed 's;/*$;/;'`;;
    s)	sitexmlpath=$OPTARG;;
    \?)	usage;;
    esac
done
shift `expr $OPTIND - 1`

if [ $# -eq 0 ]; then
    usage
fi

updatedir="$1"; shift
if [ ! -d "${updatedir}" ]; then
    error "${updatedir}: update site does not exist!"
fi

if [ ! -d "${extdir}" ]; then
    error "${extdir}: extensions directory doesn't exist!"
fi
if [ ! -f "${extdir}/.eclipseextension" \
	-a ! -f "${extdir}/.eclipseproduct" ]; then
    if [ -d "${extdir}/eclipse" -a \( -f "${extdir}/.eclipseextension" \
	    -o -f "${extdir}/.eclipseproduct" \) ]; then
	exitdir="${extdir}/eclipse"
    else
	error "${extdir}: can't find the extension directory"
    fi
fi

extdir=`echo "${extdir}" | sed 's;/*$;;'`
# so extdir now points to .../eclipse, and under it should be 
# features/ and plugins/
if [ ! -d "${extdir}/features" -o ! -d "${extdir}/plugins" ]; then
    error "${extdir}: can't seem to find features/ and plugins/?"
fi
extdirtoken=`cd ${extdir}/..; pwd | tr '/' '_'`

sitexmlpath=${sitexmlpath:-"${updatedir}/site-${extdirtoken}.xml"}
if [ -f "${sitexmlpath}" ]; then
    error "${sitexmlpath}: already exists; remove and try again"
fi
if [ ! -d "${updatedir}/features" ]; then
    echo "creating ${updatedir}/features"
    mkdir "${updatedir}/features" || error
fi
if [ ! -d "${updatedir}/plugins" ]; then
    echo "creating ${updatedir}/plugins"
    mkdir "${updatedir}/plugins" || error
fi

####
#### verification done: now start
####
tmpdir=${TMP:-/tmp/gup.$$}
mkdir "${tmpdir}" || error "${tmpdir}: can't create temp directory"
trap "rm -rf ${tmpdir}" 0 1 2 3 15

debugfile=wget.log
rm -f $debugfile

# fetch a file, ensuring to translate it through the URL's archive
# redirections (as used by TPTP, for example)
fetchurl() {
    if [ $# -ne 3 ]; then
	echo "error: use: fetchurl url pathname destdir"
	exit 2
    fi
    othersitexmlpath=${tmpdir}/`echo "${1}" | tr '/' '_'`
    if [ ! -f "${othersitexml}" ]; then
	wget -o $debugfile -O "${othersitexmlpath}" "${1}site.xml" \
	    || (rm -f "${othersitexmlpath}"; error "cannot fetch $1/site.xml";\
		cat $debugfile)
    fi
    # check to see if the site.xml specifies a different URL
    url=`xml sel -t -m '/site' -v '@url' "${othersitexmlpath}"`
    if [ -z "$url" ]; then url="$1"; fi
    url=`echo $url | sed 's;/*$;/;'`
    translated=`xml sel -t -m "/site/archive[@path='$2']" -v '@url' "${othersitexmlpath}"`
    if [ -z "$translated" ]; then translated="$2"; fi
    if [ -f "${3}/${2}" ]; then
	echo "       (already exists: ${3}/${2})"
    else
	wget -o $debugfile -c -O "${3}/${2}" "${url}${translated}" \
	    || (rm -f "${3}/${2}"; warn "unable to fetch ${url}${translated}";\
		cat $debugfile)
    fi
}

echo '<category-def name="Enabling Features" label="Required Features" />' \
    >> "${sitexmlpath}"

# for each feature directory, find the update site, fetch the site.xml
# (if not already found), and then proceed to download the files
(if [ $# -gt 0 ]; then echo "$@" | tr ' ' '\012'; else find "${extdir}/features" -name feature.xml -follow; fi) \
| while read featurexmlpath; do
    url=`xml sel -t -m '/feature/url/update' -v '@url' "${featurexmlpath}"`
    url=`echo "${url}" | sed -e 's;/site.xml;;' -e 's;/*$;/;'`
    if [ -n "${overrideURL}" ]; then
	echo "   overriding derived URL: ${url}"
	url=${overrideURL}
    fi
    version=`xml sel -t -m '/feature' -v '@version' "${featurexmlpath}"`
    id=`xml sel -t -m '/feature' -v '@id' "${featurexmlpath}"`
    featurename="${id}_${version}"
    downloadname="features/${featurename}.jar"

    echo "===> downloading feature ${url}${downloadname}"
    echo "<feature url=\"${downloadname}\" id=\"${id}\" version=\"${version}\">" \
	>> "${sitexmlpath}"
    echo "  <category name=\"Enabling Features\" />" >> "${sitexmlpath}"
    echo "</feature>" >> "${sitexmlpath}"
    if [ "$url" = "/" ]; then
	warn "cannot find URL for feature ${featurename}"
	continue
    fi

    fetchurl "${url}" "${downloadname}" "${updatedir}"

    # use the feature.xml from the newly-downloaded feature .jar
    # as the feature.xml can be rewritten as part of an installer (as
    # per Mylyn/Mylar compatability stuff)
    unzip -p "${updatedir}/${downloadname}" feature.xml \
    | xml sel -T -t -m '/feature/plugin' -v '@id' -o '_' -v '@version' \
	-o '.jar' -n \
    | while read pluginfile; do
	downloadname="plugins/${pluginfile}"
	echo "***** downloading plugin ${url}${downloadname}"
	fetchurl "${url}" "${downloadname}" "${updatedir}"
    done

    # blank line for prettiness
    echo
done


Back to the top