= Installation Instructions for Jade in Arch Linux =
This page describes how to install Jade in Arch Linux. 

<<TOC(3)>>

== Method 1: Using the AUR Packages ==

=== Installing an AUR helper ===

First, install '''[[https://wiki.archlinux.org/index.php/Makepkg#Usage|base-devel]]''' that contains everything needed by '''makepkg''' to compile packages on Arch Linux:
{{{
pacman -S base-devel
}}}

The current most straightforward way to install ROS Jade is using the AUR packages that start with ros-jade. Using a helper such as [[https://wiki.archlinux.org/index.php/yaourt|yaourt]] or [[https://github.com/keenerd/packer/wiki|packer]], it is possible to install all packages related to ROS Jade and let the [[https://wiki.archlinux.org/index.php/Arch_Build_System|Arch Build System]] take care of all the dependencies involved.

To install yaourt, you can add the '''archlinuxfr''' repository to '''/etc/pacman.conf''':

{{{
[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch
}}}

Then, simply run:

{{{
pacman -Sy yaourt
}}}

Or if you decide to go for packer:

{{{
pacman -Sy packer
}}}

=== Preliminary configuration ===

Some settings will make the installation process faster:

 * Set [[https://wiki.archlinux.org/index.php/makepkg#MAKEFLAGS|MAKEFLAGS]] in '''/etc/makepkg.conf''' to the number of threads you want to use when compiling. If you want to use the maximum of threads for your system, use the value given by {{{nproc}}}. For instance, if you have 4 cores, use {{{MAKEFLAGS="-j4"}}}. If you want to be able to use your computer while installing ROS without much of a performance hit, you may want to lower this value.

You should also make sure that '''[core]''', '''[extra]''' and possibly '''[community]''' are enabled in your '''/etc/pacman.conf''', since some dependencies are part of these official repositories.

=== Python version ===

[[https://www.archlinux.org/news/python-is-now-python-3/|Arch Linux uses Python 3]] as its default version, and starting with Indigo, Python 3 is now [[http://wiki.ros.org/indigo/Migration#Python_3_support|supported]] in ROS. However, since several non-core packages have not been fixed for Python 3 yet, we still rely on Python 2.

Since Python 3 is not fully compatible with Python 2, some extra options have to be provided to '''catkin_make''' and/or '''cmake''' to make sure that the proper Python executable, headers and libraries are used.

=== Installing AUR Packages ===

In the following simple examples I will be using yaourt, however, it is trivial to replace it with packer. In order to see what packages are avaible, simply use:

{{{
yaourt ros-jade
}}}
Or view the list of packages [[https://aur.archlinux.org/packages/?O=0&C=0&SeB=n&K=ros-jade&outdated=&SB=n&SO=a&PP=50&do_Search=Go|online]]. It is then possible to install a specific subset of the packages (or all of them, using a string like 1-112).

In order to avoid all of the prompts when installing a large number of packages, the use of the following flag may be applied (be warned that you will NOT be prompted for confirmation on any of the packages, only for your password)

{{{
yaourt --noconfirm ros-jade-desktop
}}}
Using this method, you will be asked only once for the password, and all following packages will be installed without asking the using to edit any PKGBUILD or confirm a package installation. Be warned that should a failure occur in one of the builds, you will not be able to edit a PKBUILD. You can, however, attempt to install that specific package alone and then restart the build process without having to reinstall every package. For instance, should the package [[https://aur.archlinux.org/packages/ros-jade-actionlib-msgs|ros-jade-actionlib-msgs]] fail, you can check it separately with the following procedure:

{{{
yaourt -S ros-jade-actionlib-msgs
}}}
Depending on where it fails, different actions are possible. To restart the building process without rebuilding all of the packages, a simple

{{{
yaourt --noconfirm --needed ros-jade-desktop
}}}
and selecting the packages you want to install will suffice. Once this is done, you will have a complete ROS Jade installation in /opt/ros/jade, and you can proceed to follow the [[http://www.ros.org/wiki/ROS/Tutorials/|ROS Tutorials]] online. Note, however, that a few extra steps need to be taken:

First, install rosdep with

{{{
yaourt -S python2-rosdep
}}}
Then, initialize rosdep with

{{{
sudo rosdep init
rosdep update
}}}
Some users could experience problems with the last command. In this case, remove the '''python2-rosdep''' package and install '''python2-pip'''. Therefore, '''rosdep''' could be installed using '''pip2'''. In the following, these steps are summarized:
{{{
yaourt -Rsc python2-rosdep
yaourt -S python2-pip
sudo pip2 install -U rosdep
}}}
Therefore, init and update rosdep:
{{{
sudo rosdep init
rosdep update
}}}

=== User configuration ===

Finally, when initializing a catkin workspace, as specified in the [[http://www.ros.org/wiki/catkin/Tutorials/create_a_workspace|tutorial pages]], instead of issuing the command:

{{{
catkin_make
}}}

some Python 2 flags will need to be added, as in:

{{{
catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python2 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so
}}}

This step will not be necessary when installing every package, but if an error occurs mentioning a version of Python 3, then it will be needed in order to specify the right version.

To make things easier, you should create a shell function that sets everything ROS-related, and run that function when you want to use some shells for ROS. For instance, you can add something like this in your '''~/.bashrc''':

{{{
# ROS
jade() {
  source /opt/ros/jade/setup.bash
  export PYTHONPATH=/opt/ros/jade/lib/python2.7/site-packages:$PYTHONPATH
  export PKG_CONFIG_PATH="/opt/ros/jade/lib/pkgconfig:$PKG_CONFIG_PATH"
  # Optionally, you can set:
  #export ROS_PACKAGE_PATH=/path/to/your/package/path:$ROS_PACKAGE_PATH

  # Useful aliases
  alias catkin_make="catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python2 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so"

  # If you use Gazebo:
  #source /usr/share/gazebo/setup.sh
}
}}}

Then, in a shell:

{{{
$ jade
$ roscore
}}}

=== Adding New AUR Packages ===
If you want to help packaging for Arch Linux, you can use `import_catkin_packages.py` available in `arch-ros-stacks`. You can fork [[https://github.com/bchretien/arch-ros-stacks|arch-ros-stacks]] and contribute by following the instructions in the [[https://github.com/bchretien/arch-ros-stacks/blob/master/README.md|README]].

If you do push your packages to the AUR, other Arch Linux users will be able to install your package by simply typing:

{{{
yaourt ros-jade-package-name
}}}

Note that you can also create PKGBUILDs manually (just copy another package's PKGBUILD and adapt it), but the automatic process is probably the safest option, since it gets the latest release version, the adequate dependencies, the short description etc.

== Community ==
If you would like to contribute to packaging ROS on Arch, check [[https://github.com/bchretien/arch-ros-stacks|arch-ros-stacks]] on GitHub (as explained in [[#Adding_New_AUR_Packages|#1.2]]), or even [https://wiki.archlinux.org/index.php/Talk:Ros].