User Tools

Site Tools


infrastructure:schroot-18.04-on-20.04

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
infrastructure:schroot-18.04-on-20.04 [2021/10/18 09:57] – created s_fuyedcinfrastructure:schroot-18.04-on-20.04 [2021/10/20 11:58] (current) hassouna
Line 1: Line 1:
 +=====Creating an 18.04 environment with ROS melodic on a 20.04 system======
 +
 From http://wiki.ros.org/ROS/Tutorials/InstallingIndigoInChroot 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 [[infrastructure/schroot|this page instead]].+This setup is for installing an 18.04 environment with ROS melodic 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 [[infrastructure/schroot|this page instead]].
  
 ===Setup schroot env=== ===Setup schroot env===
Line 10: Line 12:
 </code> </code>
  
-Describe the new environment to build (in this case its 20.04 focal). Open a new conf file first.+Describe the new environment to build (in this case its 18.04 bionic). Open a new conf file first. Here gedit is used, feel free to use your favorite editor instead.
  
 <code> <code>
-sudo gedit /etc/schroot/chroot.d/focal.conf+sudo gedit /etc/schroot/chroot.d/bionic.conf
 </code> </code>
  
-Now put the following settings into it.+Now put the following settings into it. Don't forget to put the username of your host machine as users.
  
 <code> <code>
-[focal+[bionic
-description=ubuntu 20.04+description=ubuntu 18.04
 type=directory type=directory
-directory=/srv/chroot/focal +directory=/srv/chroot/bionic 
-users=cram ## put the username of your host-machine here+users=cram ## put the username of your host machine here
 root-groups=root root-groups=root
 root-users=root root-users=root
Line 31: Line 33:
  
 <code> <code>
-sudo mkdir -p /srv/chroot/focal+sudo mkdir -p /srv/chroot/bionic
 </code> </code>
  
 Initialize the new environment. This will install the base system of the desired OS. Initialize the new environment. This will install the base system of the desired OS.
 <code> <code>
-sudo debootstrap --variant=buildd --arch=amd64 focal /srv/chroot/focal http://archive.ubuntu.com/ubuntu/+sudo debootstrap --variant=buildd --arch=amd64 bionic /srv/chroot/bionic http://archive.ubuntu.com/ubuntu/
 </code> </code>
  
Line 47: Line 49:
 Change the environment to the new root. Change the environment to the new root.
 <code> <code>
-sudo schroot -c focal+sudo schroot -c bionic
 </code> </code>
  
Line 62: Line 64:
 <code> <code>
 exit exit
-schroot -c focal+schroot -c bionic
 </code> </code>
  
 ===Setting up ROS in the environment=== ===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. Again, remember to change 'noetic' and 'focal' to 'melodic' and 'bionic' if you created a 18.04 environment instead of 20.04.+Login to the schroot environment again. We're going to do a full ROS install in here. First get some general archives.
  
 <code> <code>
-sudo sh -c 'echo "deb http://archive.ubuntu.com/ubuntu focal universe" >> /etc/apt/sources.list' +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 focal multiverse" >> /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 focal restricted" >> /etc/apt/sources.list'+sudo sh -c 'echo "deb http://archive.ubuntu.com/ubuntu bionic restricted" >> /etc/apt/sources.list'
 </code> </code>
  
-Now for the ROS install do everything you'd usually do to install ROS on your machine. +Now for the ROS install do everything you'd usually do to install ROS on your machine. Since it is an 18.04 bionic environment we are installing ROS melodic.
  
 <code> <code>
Line 83: Line 85:
 curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
 sudo apt update sudo apt update
-sudo apt install ros-noetic-desktop-full+sudo apt install ros-melodic-desktop-full
 </code> </code>
  
-ROS is now installed in the schroot environment. Now come some python packages for rosdep and build-scripts. For 18.04 stick to the python 2.7 packages like 'python-rosdep' instead of python3-*.+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.
  
 <code> <code>
-sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential+sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
 sudo rosdep init sudo rosdep init
 rosdep update rosdep update
Line 95: Line 97:
  
  
-===Additional===+===Final touches===
  
-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 (== "focal") depends on the name of your environment, which was set in the file at the beginning of this page. Choose "bionic" if the environment was set up for 18.04 bionic.+For a little bit more convenience, put the following in your host-machine's bash setup (.bashrc in the home directory). Streaming to /dev/null only prevents these calls from producing output. The conditional (== "bionic") depends on the name of your environment, which was set in the file at the beginning of this page. The PYTHONPATH needs to be reset because focal and bionic use different default versions of python. Also, the ssh-agent needs a restart when the environment changes
  
 <code> <code>
-if [[ ${SCHROOT_CHROOT_NAME} == "focal" ]]; then +if [[ ${SCHROOT_CHROOT_NAME} == "bionic" ]]; then 
-  echo "Ubuntu 20.04" +  echo "Ubuntu 18.04" 
-  unset PYTHONPATH  +  unset PYTHONPATH 
-  source /opt/ros/noetic/setup.bash > /dev/null+  source /opt/ros/melodic/setup.bash > /dev/null
   eval `ssh-agent -s` > /dev/null   eval `ssh-agent -s` > /dev/null
 else else
-  echo "Ubuntu 18.04" +  echo "Ubuntu 20.04" 
-  source /opt/ros/melodic/setup.bash+  source /opt/ros/noetic/setup.bash
 fi fi
 </code> </code>
  
  
-The following aliases make things bit more convenient.+The following aliases allow you to create persistent schroot session, which you can connect to easily.
  
 <code> <code>
-alias noetic='schroot -r -p -c noetic' # connects to the schroot session +alias melodic='schroot -r -p -c melodic' # connects to the schroot session 
-alias start_noetic='schroot -b -p -c focal -n noetic' # creates a persistent schroot session +alias start_melodic='schroot -b -p -c bionic -n melodic' # creates a persistent schroot session 
-alias stop_noetic='schroot -e -c noetic' # terminates the schroot session+alias stop_melodic='schroot -e -c melodic' # terminates the schroot session
 </code> </code>
 +
 +If the following message appears when calling 'start_melodic', a session already exists.
 +<code>
 +Failed to lock chroot: /var/lib/schroot/session/melodic: Failed to write session file: File exists
 +</code>
 +
 +Congratulations, you can now connect to the 18.04 environment from your 20.04 machine. Run packages for melodic while in your 18.04 environment, and those for noetic on your host machine. 
infrastructure/schroot-18.04-on-20.04.1634551058.txt.gz · Last modified: 2021/10/18 09:57 by s_fuyedc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki