Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

LinuxPackaging

Packing Eclipse for Linux Distributions

This page is intended to show how to package Eclipse for Linux distributions. It's a work in progress though.

General Info

These notes attempt to provide some help to those troubleshooting/maintaining these eclipse packages. They are extracted from a readme that was included with the specfile and Ant build file below.

General Troubleshooting

To start, if you are having trouble with any of these packages, try starting eclipse with the -clean option. You can also try running with -consoleLog to see error messages. See the link below about command line options for more info. Also see the wiki link below about dropins and debugging to get more debugging output.

Overview of build and installation (and p2 director and dropins folder)

In general the eclipse-platform package is our base install and other packages are installed as plugins into the dropins folder. This means that packages require eclispe-platform >= 3.4 because 3.4 is the earlierest version with p2 which is what added support for the dropins folder

To understand why things are built and installed as they are, you should read the links in the links section below especially those regarding the dropins folder and the the director application. Also, see the #eclipse IRC logs for September 2012 for conversations regarding directory, p2, mirroring, and dropins.

In short the director application is the command line interface to p2 which is the Eclipse provisioning platform that handles installation. The dropins folder allows for dropping plugins and features into a folder that p2 watches and will automatically install from. Most plugins only provide p2 repos though (sometimes as a zip), which are typically not suitable for simply dropping in. So, the best solution is to actually install the plugins and then basically take the difference of the features and plugins folder between the base install and the target installation folder to create your dropins directory. So this is what we do. We use the directory application for installing the plugins from the command line; see the link in the links section for more info.

In some cases, plugins may provide an archive suitable for simply extracting to the dropins folder (see pydev subpackage for an example). Ideally, simply extracting will be enough. In some cases, you may have to manually remove (as part of the build or install scriptlet) plugins or features that you don't want or that are not targeted to linux,gtk,x86_64.

It should be noted that we do not build Eclipse ourselves (as Fedora does) because this would be fairly difficult especially when using the newest Eclipse versions on older versions of RHEL.

Lastly, be aware that though this is the recommended approach, it is new and not well tested it seems. The majority of Eclipse users it seems simply install plugins using the P2 GUI. The exception are those on Linux, on which users typically use a package manager, but many distros have not switched over to dropins yet and are still using old hacks. The point is that, there should be no surprise if there are still bugs on occasion, in particular with updating. When in doubt, it might be worth trying a fresh install of all packages (erase, remove anything leftover, and then install new ones)

Downloading/getting binaries (and mirroring)

Only in the case of the platform can you download a tarball that can simply be extracted. In all other cases you either need an dropins archive or a p2 repo archive; both are typically zip files and often only one or the other is provided. I recommend to use the dropins folder if it is provided. Your second choice should be a p2 repo archive published by the package/plugin maintainers.

Some groups only provide an online p2 repo though and no binary archives. In this case - as a last resort - you can mirror the desired features from the p2 repo and create your own archive. See the links below about mirroring for more info on this. The m2e subpackage is a case where this was necessary as an example. Mirroring may also be useful if working with a p2 repo archive that is missing many dependencies as is the case with m2e. In this case simultaneously mirroring from both the plugin p2 repo and the release repo (e.g. the juno p2 repo) will often be the best way forward.

Versioning

Note that we have explicitly assigned versions to each package rather than using the global version inserted by the Makefile. In some cases it is unclear what version should be assigned, but we have used the following convention:

* Packages/plugins that come from the main Eclipse project download page are assigned the
  version number for that release of Eclipse.
* Plugins downloaded from anywhere else are assigned the version given to them there
* In cases where the version is unclear (like when mirroring), we use the version of the
  feature that is being installed.

Known Issues (TODO)

* If there is a bug when using p2 director (or any of the Eclipse command line tools), there
  will be a pop up error; there seems to be no way to disable this.
* For various reasons, things may be left in /opt/eclipse even after removing all packages.
  This could either be configuration data (from running as root as is done to initialize
  during post) or a directory used by other eclipse packages like the dropins folder that
  the rpm utility wasn't smart enough to remove.

Links

* Eclipse command line options: http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.user/tasks/running_eclipse.htm?cp=0_3_0
* Eclipse Director application: http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/guide/p2_director.html?cp=2_0_20_2
* Mirroring Eclipse repositories using command line: http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/guide/p2_mirror.html?cp=2_0_20_3_0
* Mirroring Eclipse repositories using Ant: http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/guide/p2_repositorytasks.htm?cp=2_0_20_3_3
* Eclipse dropins folder: http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/reference/misc/p2_dropins_format.html?cp=2_1_3_22
* Wiki on dropins folder (and debbugind): http://wiki.eclipse.org/Equinox_p2_Getting_Started#Dropins

Spec file for RHEL 5.5

This spec works on RHEL 5.5. The general concept or model should work for other distros as well.

# Macros
%define _topdir /home/foo/src
%define _tmppath /home/foo/src/tmp
%define _buildroot /home/foo/src/tmp/eclipse-4.2-buildroot
 
# Common rpm macros across all projects
%define __echo  /bin/echo
%define __ls    /bin/ls
 
# Override certain rpmbuild settings
%define __os_install_post %{nil}	# do not automatically run compress and strip scripts during post install
 
Name: eclipse
Version: 4.2
Release: 1
Group: (none)
License: EPL 1.0
Packager: (none)
Vendor: (none)
BuildRoot: %{_buildroot}
 
Summary: Eclipse IDE for C/C++ Developers
 
Source0: http://www.gtlib.gatech.edu/pub/eclipse/eclipse/downloads/drops4/R-4.2-201206081400/eclipse-platform-4.2-linux-gtk-x86_64.tar.gz 
Source1: http://www.gtlib.gatech.edu/pub/eclipse/eclipse/downloads/drops4/R-4.2-201206081400/org.eclipse.jdt-4.2.zip
Source2: http://www.gtlib.gatech.edu/pub/eclipse/tools/cdt/releases/juno/r/cdt-master-8.1.0.zip
# http://sourceforge.net/projects/pydev/files/pydev/PyDev%202.6.0/PyDev%202.6.0.zip
# Have to remove space and replace with hyphen or rpmbuild complains
Source3: PyDev-2.6.0.zip
Source4: http://sourceforge.net/projects/shelled/files/shelled/ShellEd%202.0.2/net.sourceforge.shelled-site-2.0.2.zip
Source5: http://www.gtlib.gatech.edu/pub/eclipse/technology/dltk/downloads/drops/R4.0/R-4.0-201206120903/dltk-core-R-4.0-201206120903.zip
# This source is created by running "make update-m2e-repo" from the eclipse directory; see the Makefile target and ant_build.xml for more info.
Source6: org.eclipse.m2e.feature.feature.group_1.1.0.20120530-0009_downloaded-20120913-1336.zip
Source7: http://www.gtlib.gatech.edu/pub/eclipse/linuxtools/linuxtools-1.1.zip
 
# alias macros for sources and give protocals
%define _platform_source %{SOURCE0}
%define _jdt_source %{SOURCE1}
%define _cdt_source %{SOURCE2}
%define _pydev_source %{SOURCE3}
%define _shelled_source %{SOURCE4}
%define _dltk_source %{SOURCE5}
%define _m2e_source %{SOURCE6}
%define _linuxtools_source %{SOURCE7}
 
# macros
%define _prefix             /opt
%define _eclipse_dropins    %{_prefix}/eclipse/dropins
%define _eclipse_profile    PlatformProfile
 
# Macro for installing plugins into dropins folder using diff 
# between install version and base version.
# parameters:
#   1: name
#   2: base eclipse install folder
#   3: eclipse install folder where plugin is installed
%define plugin_install_to_dropins() \
# parameters \
name="%1" \
eclipse_base="%2" \
eclipse_plugin="%3" \
# create dropins directory \
%{__mkdir} -p ${RPM_BUILD_ROOT}%{_eclipse_dropins}/$name/features \
%{__mkdir} -p ${RPM_BUILD_ROOT}%{_eclipse_dropins}/$name/plugins \
# copy features from plugin install folder not in base install to dropins \
for f in $(%{__ls} $eclipse_plugin/features) ; do \
    if [ ! -e $eclipse_base/features/$f ]; then \
        %{__cp} -r $eclipse_plugin/features/$f ${RPM_BUILD_ROOT}%{_eclipse_dropins}/$name/features; \
    fi \
done \
# copy plugins from plugin install folder not in base install to dropins \
for f in $(%{__ls} $eclipse_plugin/plugins) ; do \
    if [ ! -e $eclipse_base/plugins/$f ]; then \
        %{__cp} -r $eclipse_plugin/plugins/$f ${RPM_BUILD_ROOT}%{_eclipse_dropins}/$name/plugins; \
    fi \
done
 
%description
An IDE for C/C++ developers with Mylyn integration.
 
%clean
%{__rm} -rf ${RPM_BUILD_DIR}/%{name}-%{version}
%{__rm} -rf ${RPM_BUILD_ROOT}
 
%package platform
Summary: The Eclipse Platform Runtime Binary
Version: 4.2
Group: %{_group}
 
%description platform
Contains only the Eclipse Platform with user documentation and no source 
and no programmer documentation. The Java development tools and Plug-in 
Development Environment are NOT included.
 
%package jdt
Summary: The Eclipse JDT Runtime Binary
Version: 4.2
Group: %{_group}
Requires: eclipse-platform >= 3.4
 
%description jdt
Contains the Java development tools bundles only, with user documentation 
and no source and no programmer documentation. The Eclipse platform and Plug-in 
development environment are NOT included.
 
%package cdt
Summary: The Eclipse CDT IDE.
Version: 8.1.0
Group: %{_group}
Requires: eclipse-platform >= 3.4
 
%description cdt
An IDE for C/C++ developers with Mylyn integration.
 
%package pydev
Summary: Eclipse Python IDE
Group: %{_group}
Version: 2.6.0
Requires: eclipse-platform >= 3.4
 
%description pydev
PyDev is a Python IDE for Eclipse, which may be used in 
Python, Jython and IronPython development.
 
%package shelled
Summary: Eclipse Shell Script Editor
Group: %{_group}
Version: 2.0.2
Requires: eclipse-platform >= 3.4
 
%description shelled
ShellEd is a shell script editor for Eclipse. The benefits of 
this plugin are the integration of man page information for 
content assist/hover help and the ability to run your project's 
shell scripts without leaving Eclipse.
 
%package m2e
Summary: Eclipse Maven Integration
Group: %{_group}
Version: 1.1.0
Requires: eclipse-platform >= 3.4
Requires: eclipse-jdt
 
%description m2e
Apache Maven support in the Eclipse IDE, making it easier to edit 
Maven's pom.xml, run a build from the IDE and much more. For Java 
developers, the very tight integration with JDT greatly simplifies 
the consumption of Java artifacts either being hosted on open 
source repositories such as Maven Central, or in your in-house 
Maven repository.
 
%package linuxtools
Summary: Eclipse Linux Tools
Group: %{_group}
Version: 1.1
Requires: eclipse-platform >= 3.4
Requires: eclipse-cdt
Requires: eclipse-jdt
 
%description linuxtools
The Linux Tools project aims to bring a full-featured C and C++ IDE
to Linux developers. It builds on the source editing and debugging 
features of the CDT and integrate popular native development tools 
such as Valgrind, OProfile, RPM, SystemTap, GCov, GProf, LTTng, etc.
This package only includes the RPM, GCov, Manpage, and Valgrind
features.
 
%prep
# This essentially creates the base copy of the Eclipse Platform install
%setup -T -q -c -a0
 
%build
# Director Options Overview:
#   * -noSplash: this stops the splash screen from showing up
#   * -data workspace: this will create a temporary workspace in the current directory to avoid clobbering the user workspace 
#   * -application org.eclipse.equinox.p2.director: this specifies that we're using the p2 director
#   * -repository 'jar:file:%{_jdt_source}!/': this specifies the source, we're using; just copy the weird syntax for zip files, use http or file protocol for other repos
#   * -installIU org.eclipse.jdt.feature.group: use -list option to find the names of these if youd on't know it
#   * -profile %{_eclipse_profile}: this has to match the profile of the base install or you'll end up having two installs which is weird
#   * -profileProperties org.eclipse.update.install.features=true: this is so that the feature will show up as installed, but shouldn't affect functionality
#   * -destination $(pwd)/eclipse_jdt: has to be absolute and points to the target installation folder
#   * -consoleLog: use this for troubleshooting
 
# install jdt into copy of base install
%{__cp} -r eclipse eclipse_jdt
./eclipse/eclipse                                                   \
    -noSplash                                                       \
    -data workspace                                                 \
    -application org.eclipse.equinox.p2.director                    \
    -repository 'jar:file:%{_jdt_source}!/'                         \
    -installIU org.eclipse.jdt.feature.group                        \
    -profile %{_eclipse_profile}                                    \
    -profileProperties org.eclipse.update.install.features=true     \
    -destination $(pwd)/eclipse_jdt
 
# install cdt into copy of base install
# NOTE: you have to specify the autotools feature separately becuase
# it's not included in the overall CDT feature.
%{__cp} -r eclipse eclipse_cdt
./eclipse/eclipse                                                   \
    -noSplash                                                       \
    -data workspace                                                 \
    -application org.eclipse.equinox.p2.director                    \
    -repository 'jar:file:%{_cdt_source}!/'                         \
    -installIU org.eclipse.cdt.feature.group                        \
    -installIU org.eclipse.cdt.autotools.feature.group              \
    -profile %{_eclipse_profile}                                    \
    -profileProperties org.eclipse.update.install.features=true     \
    -destination $(pwd)/eclipse_cdt
 
# install shelled into copy of base install
%{__cp} -r eclipse eclipse_shelled
./eclipse/eclipse                                                   \
    -noSplash                                                       \
    -data workspace                                                 \
    -application org.eclipse.equinox.p2.director                    \
    -repository 'jar:file:%{_shelled_source}!/'                     \
    -repository 'jar:file:%{_dltk_source}!/'                        \
    -installIU net.sourceforge.shelled.feature.group                \
    -profile %{_eclipse_profile}                                    \
    -profileProperties org.eclipse.update.install.features=true     \
    -destination $(pwd)/eclipse_shelled
 
# install m2e into copy of jdt install
%{__cp} -r eclipse_jdt eclipse_m2e
./eclipse/eclipse                                                   \
    -noSplash                                                       \
    -data workspace                                                 \
    -application org.eclipse.equinox.p2.director                    \
    -repository 'jar:file:%{_m2e_source}!/'                         \
    -installIU org.eclipse.m2e.feature.feature.group                \
    -profile %{_eclipse_profile}                                    \
    -profileProperties org.eclipse.update.install.features=true     \
    -destination $(pwd)/eclipse_m2e
 
# install jdt into copy of cdt install to use as linuxtools base
%{__cp} -r eclipse_cdt eclipse_cdt_jdt
./eclipse/eclipse                                                   \
    -noSplash                                                       \
    -data workspace                                                 \
    -application org.eclipse.equinox.p2.director                    \
    -repository 'jar:file:%{_jdt_source}!/'                         \
    -installIU org.eclipse.jdt.feature.group                        \
    -profile %{_eclipse_profile}                                    \
    -profileProperties org.eclipse.update.install.features=true     \
    -destination $(pwd)/eclipse_cdt_jdt
 
# install linuxtools into copy of install with cdt and jdt
# NOTE: we only install a subset of the features because many of the
# other features require additional deps and we don't need/use them.
%{__cp} -r eclipse_cdt_jdt eclipse_linuxtools
./eclipse/eclipse                                                   \
    -noSplash                                                       \
    -data workspace                                                 \
    -application org.eclipse.equinox.p2.director                    \
    -repository 'jar:file:%{_linuxtools_source}!/archive/releng/org.eclipse.linuxtools.releng-site/target/repository/' \
    -installIU org.eclipse.linuxtools.rpm.feature.group             \
    -installIU org.eclipse.linuxtools.gcov.feature.group            \
    -installIU org.eclipse.linuxtools.man.feature.group             \
    -installIU org.eclipse.linuxtools.valgrind.feature.group        \
    -profile %{_eclipse_profile}                                    \
    -profileProperties org.eclipse.update.install.features=true     \
    -destination $(pwd)/eclipse_linuxtools
 
%install
# create install directory
%{__rm} -rf ${RPM_BUILD_ROOT}
%{__mkdir} -p ${RPM_BUILD_ROOT}%{_prefix}
 
# install platform
%{__tar} zxf %{_platform_source} -C ${RPM_BUILD_ROOT}%{_prefix}
%{__mkdir_p} ${RPM_BUILD_ROOT}/usr/share/applications
 
# Increase default memory pool
/bin/sed -i 's/-Xmx384m/-Xmx1024m/' ${RPM_BUILD_ROOT}%{_prefix}/eclipse/eclipse.ini
 
# create desktop icon
%{__cat} >> ${RPM_BUILD_ROOT}/usr/share/applications/eclipse.desktop <<EOF
[Desktop Entry]
Name=Eclipse
Name[en_US]=Eclipse
Exec=/opt/eclipse/eclipse
Icon=/eclipse/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=Development
Version=%{version}
Encoding=UTF-8
Comment[en_US]=Eclipse
Comment=Launch Eclipse
GenericName[en_US]=Eclipse
EOF
 
# install plugins to dropins
%plugin_install_to_dropins jdt eclipse eclipse_jdt
%plugin_install_to_dropins cdt eclipse eclipse_cdt
%plugin_install_to_dropins shelled eclipse eclipse_shelled
%plugin_install_to_dropins m2e eclipse_jdt eclipse_m2e
%plugin_install_to_dropins linuxtools eclipse_cdt_jdt eclipse_linuxtools
 
# install pydev
PYDEV_INSTALL_DIR="${RPM_BUILD_ROOT}%{_eclipse_dropins}/pydev"
%{__mkdir} -p ${PYDEV_INSTALL_DIR}
%{__unzip} -q %{_pydev_source} -d ${PYDEV_INSTALL_DIR}
%{__chmod} -R go+r ${PYDEV_INSTALL_DIR}
# Remove the django templates feature because it requires some other deps and we don't need it
%{__rm} -rf ${PYDEV_INSTALL_DIR}/features/org.python.pydev.django_templates.feature_2.6.0.2012062818
%{__rm} -rf ${PYDEV_INSTALL_DIR}/plugins/org.python.pydev.django_templates_2.6.0.2012062818
 
# Run eclipse with -intialize option after each install.
# This is overkill if you're installing everything at once, but is minimal
# and needed if installing packages at different times.
#
# This will improve the startup time significantly for users.
# Note though that the dropins folders will still be scanned
# one for each user (and thereafter whenever there is a change)
# to create a timestamp file, but that is fairly quick. 
%post platform -p '%{_prefix}/eclipse/eclipse -initialize'
%post jdt -p '%{_prefix}/eclipse/eclipse -initialize'
%post cdt -p '%{_prefix}/eclipse/eclipse -initialize'
%post pydev -p '%{_prefix}/eclipse/eclipse -initialize'
%post shelled -p '%{_prefix}/eclipse/eclipse -initialize'
%post m2e -p '%{_prefix}/eclipse/eclipse -initialize'
%post linuxtools -p '%{_prefix}/eclipse/eclipse -initialize'
 
%files platform
%defattr(-,root,root)
%dir %{_prefix}/eclipse
%{_prefix}/eclipse/about_files
%{_prefix}/eclipse/about.html
%{_prefix}/eclipse/artifacts.xml
%{_prefix}/eclipse/configuration
%dir %{_prefix}/eclipse/dropins
%{_prefix}/eclipse/eclipse
%{_prefix}/eclipse/eclipse.ini
%{_prefix}/eclipse/epl-v10.html
%{_prefix}/eclipse/features
%{_prefix}/eclipse/icon.xpm
%{_prefix}/eclipse/libcairo-swt.so
%{_prefix}/eclipse/notice.html
%{_prefix}/eclipse/p2
%{_prefix}/eclipse/plugins
%{_prefix}/eclipse/readme
%{_prefix}/eclipse/.eclipseproduct
/usr/share/applications/eclipse.desktop
 
%files jdt
%defattr(-,root,root)
%{_eclipse_dropins}/jdt/
 
%files cdt
%defattr(-,root,root)
%{_eclipse_dropins}/cdt/
 
%files pydev
%defattr(-,root,root)
%{_eclipse_dropins}/pydev/
 
%files shelled
%defattr(-,root,root)
%{_eclipse_dropins}/shelled/
 
%files m2e
%defattr(-,root,root)
%{_eclipse_dropins}/m2e/
 
%files linuxtools
%defattr(-,root,root)
%{_eclipse_dropins}/linuxtools/

Ant file for mirroring

In some cases, no binary archives are provided. In those cases, mirroring the http p2 repo is an alternative. Here is an example Ant file to do that:

<!-- usage:
    ./eclipse/eclipse -nosplash -application org.eclipse.ant.core.antRunner -consolelog -f ant_build.xml
-->
<project name="mirrors" default="mirror-m2e">
	<!-- directories -->
    <property name="localRepos" value="${user.dir}/mirrors" />
    <property name="m2eLocalRepo" value="${localRepos}/m2e" />
 
	<!-- update sites -->
    <property name="releaseUpdateSite" value="http://download.eclipse.org/releases/juno/" /> 
    <property name="m2eUpdateSite" value="http://download.eclipse.org/technology/m2e/releases" />
 
	<!-- installable units -->
	<property name="m2eIU" value="org.eclipse.m2e.feature.feature.group" />
 
	<!-- versions -->
	<property name="m2eVersion" value="1.1.0.20120530-0009" />
 
	<!-- other settings -->
	<property name="timestamp" value="1.1.0.20120530-0009" />	
 
	<target name="mirror-m2e">
		<tstamp />
        <echo message="Mirror ${m2eIU} to ${m2eLocalRepo}" />
        <p2.mirror destination="file:${m2eLocalRepo}" ignoreErrors="false" verbose="true" raw="true">
            <source location="${m2eUpdateSite}" />
            <source location="${releaseUpdateSite}" />
            <slicingOptions includeOptional="false" includeNonGreedy="false" latestVersionOnly="true" platformFilter="linux,gtk,x86_64" />
            <iu id="${m2eIU}" version="${m2eVersion}" />
        </p2.mirror>
        <zip destfile="${user.dir}/${m2eIU}_${m2eVersion}_downloaded-${DSTAMP}-${TSTAMP}.zip" basedir="${m2eLocalRepo}" />
    </target>
 
</project>

Back to the top