User Tools

Site Tools


infrastructure:schroot-18.04-on-20.04

This is an old revision of the document!


Creating an 18.04 environment for melodic on a 20.04 system

From http://wiki.ros.org/ROS/Tutorials/InstallingIndigoInChroot

This setup is for installing an 18.04 environment on a 20.04 host system. If you want it the other way around (hosting an 18.04 system and creating a 20.04 environment) go back to this page instead.

Setup schroot env

Install debootstrap and schroot, which enable switching mounting points and environments on the fly.

sudo apt-get install debootstrap schroot

Describe the new environment to build (in this case its 18.04 bionic). Open a new conf file first.

sudo gedit /etc/schroot/chroot.d/bionic.conf

Now put the following settings into it.

[bionic]
description=ubuntu 18.04
type=directory
directory=/srv/chroot/bionic
users=cram ## put the username of your host-machine here
root-groups=root
root-users=root

Create the mounting point for the new environment.

sudo mkdir -p /srv/chroot/bionic

Initialize the new environment. This will install the base system of the desired OS.

sudo debootstrap --variant=buildd --arch=amd64 bionic /srv/chroot/bionic http://archive.ubuntu.com/ubuntu/

Use this to check for existing schroot environments on your machine.

schroot -l

Change the environment to the new root.

sudo schroot -c bionic

You are now logged in to the new environment as root and can start installing all the stuff you need, starting with sudo and git (and vim, why not). Install bash-completion to tab-complete apt packages.

apt install sudo vim git bash-completion
apt update
apt install lsb-release
apt clean all

This will leave the environment. On the next login you won't be root per default anymore.

exit
schroot -c bionic

Setting up ROS in the environment

Login to the schroot environment again. We're going to do a full ROS install in here. First get some general archives. Since it is an 18.04 bionic environment we are installing ROS melodic.

sudo sh -c 'echo "deb http://archive.ubuntu.com/ubuntu bionic universe" >> /etc/apt/sources.list'
sudo sh -c 'echo "deb http://archive.ubuntu.com/ubuntu bionic multiverse" >> /etc/apt/sources.list'
sudo sh -c 'echo "deb http://archive.ubuntu.com/ubuntu bionic restricted" >> /etc/apt/sources.list'

Now for the ROS install do everything you'd usually do to install ROS on your machine.

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl 
sudo apt install gnupg
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update
sudo apt install ros-melodic-desktop-full

ROS is now installed in the schroot environment. Now come some python packages for rosdep and build-scripts. For 18.04 stick to python 2.7 packages, which is the default on bionic systems.

sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo rosdep init
rosdep update

Additional

For a little bit more convenience, put the following in your host-machine's bash setup (.bashrc or .bash_profile, as I prefer). Streaming to /dev/null only prevents these calls to produce output. The conditional (== “bionic”) depends on the name of your environment, which was set in the file at the beginning of this page.

if [[ ${SCHROOT_CHROOT_NAME} == "bionic" ]]; then
  echo "Ubuntu 18.04"
  unset PYTHONPATH
  source /opt/ros/melodic/setup.bash > /dev/null
  eval `ssh-agent -s` > /dev/null
else
  echo "Ubuntu 20.04"
  source /opt/ros/noetic/setup.bash
fi

The following aliases make things a bit more convenient.

alias melodic='schroot -r -p -c melodic' # connects to the schroot session
alias start_melodic='schroot -b -p -c bionic -n melodic' # creates a persistent schroot session
alias stop_melodic='schroot -e -c melodic' # terminates the schroot session
infrastructure/schroot-18.04-on-20.04.1634551529.txt.gz · Last modified: 2021/10/18 10:05 by s_fuyedc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki