Skip to content

Instantly share code, notes, and snippets.

@chutsu
Last active August 29, 2025 21:32
Show Gist options
  • Save chutsu/59a51a2a1954f0c6bafb06a3e4056282 to your computer and use it in GitHub Desktop.
Save chutsu/59a51a2a1954f0c6bafb06a3e4056282 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# Settings
USER_HOME=$(eval echo "~$SUDO_USER")
CHROOT_DIR=${USER_HOME}/bootstrap
UBUNTU_VERSION="focal"
ROS_VERSION="noetic"
# Script dependencies
apt-get update -q
apt-get install -q debootstrap wget curl lsb-release
# Bootstrap Ubuntu base installation
mkdir -p ${CHROOT_DIR}
if [ ! -f "${CHROOT_DIR}/bin/bash" ]; then
debootstrap $UBUNTU_VERSION $CHROOT_DIR http://archive.ubuntu.com/ubuntu
fi
# Setup APT sources
cat > ${CHROOT_DIR}/etc/apt/sources.list <<EOF
deb http://archive.ubuntu.com/ubuntu $UBUNTU_VERSION main universe restricted multiverse
deb http://archive.ubuntu.com/ubuntu $UBUNTU_VERSION-updates main universe restricted multiverse
deb http://archive.ubuntu.com/ubuntu $UBUNTU_VERSION-security main universe restricted multiverse
deb http://packages.ros.org/ros/ubuntu $UBUNTU_VERSION main
EOF
# Install ROS
cat << 'EOF' | chroot $CHROOT_DIR /bin/bash
export DEBIAN_FRONTEND=noninteractive
apt-get install -yqq curl
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -
apt-get install -yqq ros-noetic-ros-base
exit
EOF
~

Chroot Jail - Ubuntu 20.04 + ROS Noetic

sudo bash bootstrap.bash     # creates a chroot jail at $HOME/bootstrap
sudo chroot $HOME/bootstrap  # Type exit to exit the chroot jail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment